Class ClassElement
java.lang.Object
com.oracle.js.parser.ir.Node
com.oracle.js.parser.ir.PropertyNode
com.oracle.js.parser.ir.ClassElement
- All Implemented Interfaces:
Cloneable
IR representation for class elements.
-
Field Summary
Fields inherited from class PropertyNode
computed, getter, isAnonymousFunctionDefinition, isStatic, key, setter, value -
Method Summary
Modifier and TypeMethodDescriptionaccept(NodeVisitor<? extends LexicalContext> visitor) Provides a means to navigate the IR.<R> Raccept(TranslatorNodeVisitor<? extends LexicalContext, R> visitor) Provides a means to navigate the IR.static ClassElementcreateAccessor(long token, int finish, Expression key, FunctionNode get, FunctionNode set, List<Expression> decorators, boolean isPrivate, boolean isStatic, boolean hasComputedKey) Create an Accessor (i.e., get/set) element.static ClassElementcreateAutoAccessor(long token, int finish, Expression key, FunctionNode initializer, List<Expression> classElementDecorators, boolean isStatic, boolean hasComputedKey, boolean anonymousFunctionDefinition) Create an auto-accessor class element.static ClassElementcreateDefaultConstructor(long token, int finish, Expression key, Expression value) Create the class default constructor.static ClassElementcreateField(long token, int finish, Expression key, Expression initialize, List<Expression> decorators, boolean isStatic, boolean hasComputedKey, boolean anonymousFunctionDefinition) Create a class field element.static ClassElementcreateMethod(long token, int finish, Expression key, Expression value, List<Expression> decorators, boolean isStatic, boolean hasComputedKey) Create a Method class element.static ClassElementcreateStaticInitializer(long token, int finish, FunctionNode functionNode) Create a static initializer element.booleanbooleanbooleanbooleanReturns true if the class element is one of: field, auto accessor.booleanbooleanisMethod()booleanReturns true if the class element is one of: method, getter, setter, auto accessor.booleanbooleanisStatic()setDecorators(List<Expression> decorators) setGetter(FunctionNode get) Set the getter of this property, null if nonesetKey(Expression key) setSetter(FunctionNode set) Set the setter for this property, null if nonesetValue(Expression value) Set the value of this propertyvoidtoString(StringBuilder sb, boolean printType) Print logic that decides whether to show the optimistic type or not - for example it should not be printed after just parse, when it hasn't been computed, or has been set to a trivially provable valueMethods inherited from class PropertyNode
getGetter, getKey, getKeyName, getKeyNameTS, getPrivateName, getPrivateNameTS, getSetter, getValue, isAnonymousFunctionDefinition, isComputed, isCoverInitializedName, isProto, isRestMethods inherited from class Node
clone, equals, getFinish, getSourceOrder, getStart, getToken, hashCode, isAssignment, isLoop, isTokenType, tokenType, toString, toString
-
Method Details
-
createMethod
public static ClassElement createMethod(long token, int finish, Expression key, Expression value, List<Expression> decorators, boolean isStatic, boolean hasComputedKey) Create a Method class element.- Parameters:
token- token.finish- finish.key- The name of the method.value- The value of the method.decorators- The decorators of the method. Optional.isStatic- static method.hasComputedKey- has computed key.- Returns:
- A ClassElement node representing a method.
-
createAccessor
public static ClassElement createAccessor(long token, int finish, Expression key, FunctionNode get, FunctionNode set, List<Expression> decorators, boolean isPrivate, boolean isStatic, boolean hasComputedKey) Create an Accessor (i.e., get/set) element.- Parameters:
token- token.finish- finish.key- The name of the accessor.get- The getter of the accessor. Optional.set- The setter of the accessor. Optional.decorators- The decorators of the accessor. Optional.isPrivate- private accessor.isStatic- static accessor.hasComputedKey- has computed key.- Returns:
- A ClassElement node representing an accessor (getter, setter).
-
createField
public static ClassElement createField(long token, int finish, Expression key, Expression initialize, List<Expression> decorators, boolean isStatic, boolean hasComputedKey, boolean anonymousFunctionDefinition) Create a class field element.- Parameters:
token- token.finish- finish.key- The name of the field.initialize- The initialization value of the field. Optional.decorators- The decorators of the field. Optional.isStatic- static field,hasComputedKey- has computed key.anonymousFunctionDefinition- is anonymous function definition.- Returns:
- A ClassElement node representing a field.
-
createDefaultConstructor
public static ClassElement createDefaultConstructor(long token, int finish, Expression key, Expression value) Create the class default constructor.- Parameters:
token- token.finish- finish.key- class name.value- value.- Returns:
- A ClassElement node representing a default constructor.
-
createStaticInitializer
public static ClassElement createStaticInitializer(long token, int finish, FunctionNode functionNode) Create a static initializer element.- Parameters:
token- token.finish- finish.functionNode- function node.- Returns:
- A ClassElement node representing a static initializer.
-
createAutoAccessor
public static ClassElement createAutoAccessor(long token, int finish, Expression key, FunctionNode initializer, List<Expression> classElementDecorators, boolean isStatic, boolean hasComputedKey, boolean anonymousFunctionDefinition) Create an auto-accessor class element.- Parameters:
token- token.finish- finish.key- key name.initializer- initializer body.classElementDecorators- decorators.isStatic- is static.hasComputedKey- has computed key.anonymousFunctionDefinition- is anonymous function definition.- Returns:
- A ClassElement node representing an auto-accessor.
-
accept
Description copied from class:NodeProvides a means to navigate the IR.- Overrides:
acceptin classPropertyNode- Parameters:
visitor- Node visitor.- Returns:
- node the node or its replacement after visitation, null if no further visitations are required
-
accept
Description copied from class:NodeProvides a means to navigate the IR.- Overrides:
acceptin classPropertyNode- Parameters:
visitor- Node visitor.- Returns:
- node the node or its replacement after visitation, null if no further visitations are required
-
getDecorators
-
setDecorators
-
setGetter
Description copied from class:PropertyNodeSet the getter of this property, null if none- Overrides:
setGetterin classPropertyNode- Parameters:
get- getter- Returns:
- same node or new node if state changed
-
setKey
-
setSetter
Description copied from class:PropertyNodeSet the setter for this property, null if none- Overrides:
setSetterin classPropertyNode- Parameters:
set- setter- Returns:
- same node or new node if state changed
-
setValue
Description copied from class:PropertyNodeSet the value of this property- Overrides:
setValuein classPropertyNode- Parameters:
value- new value- Returns:
- same node or new node if state changed
-
isAccessor
public boolean isAccessor()- Overrides:
isAccessorin classPropertyNode
-
isAutoAccessor
public boolean isAutoAccessor() -
isClassField
public boolean isClassField()- Overrides:
isClassFieldin classPropertyNode
-
isClassFieldOrAutoAccessor
public boolean isClassFieldOrAutoAccessor()Returns true if the class element is one of: field, auto accessor. -
isClassStaticBlock
public boolean isClassStaticBlock()- Overrides:
isClassStaticBlockin classPropertyNode
-
isMethod
public boolean isMethod() -
isMethodOrAccessor
public boolean isMethodOrAccessor()Returns true if the class element is one of: method, getter, setter, auto accessor. -
isPrivate
public boolean isPrivate()- Overrides:
isPrivatein classPropertyNode
-
isStatic
public boolean isStatic()- Overrides:
isStaticin classPropertyNode
-
toString
Description copied from class:NodePrint logic that decides whether to show the optimistic type or not - for example it should not be printed after just parse, when it hasn't been computed, or has been set to a trivially provable value- Overrides:
toStringin classPropertyNode- Parameters:
sb- string builderprintType- print type?
-