Class Node
- java.lang.Object
-
- com.google.javascript.rhino.Node
-
- All Implemented Interfaces:
java.io.Serializable
- Direct Known Subclasses:
Node.TypeDeclarationNode
public class Node extends java.lang.Object implements java.io.SerializableThis class implements the root of the intermediate representation.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classNode.AncestorIterableIterator to go up the ancestor tree.static classNode.SideEffectFlagsA helper class for getting and setting invocation side-effect flags.static classNode.TypeDeclarationNodeRepresents a node in the type declaration AST.
-
Field Summary
Fields Modifier and Type Field Description static com.google.javascript.rhino.Node.PropACCESS_MODIFIERstatic intCOLUMN_BITSCOLUMN_BITS represents how many of the lower-order bits of sourcePosition are reserved for storing the column number.static intCOLUMN_MASKCOLUMN_MASK stores a value where bits storing the column number are set, and bits storing the line are not set.static com.google.javascript.rhino.Node.PropCOMPUTED_PROP_GETTERstatic com.google.javascript.rhino.Node.PropCOMPUTED_PROP_METHODstatic com.google.javascript.rhino.Node.PropCOMPUTED_PROP_SETTERstatic com.google.javascript.rhino.Node.PropCOMPUTED_PROP_VARIABLEstatic com.google.javascript.rhino.Node.PropCONSTRUCT_SIGNATUREstatic com.google.javascript.rhino.Node.PropDIRECT_EVALstatic com.google.javascript.rhino.Node.PropES6_MODULEstatic com.google.javascript.rhino.Node.PropEXPORT_ALL_FROMstatic com.google.javascript.rhino.Node.PropEXPORT_DEFAULTstatic com.google.javascript.rhino.Node.PropFEATURE_SETstatic com.google.javascript.rhino.Node.PropFREE_CALLstatic com.google.javascript.rhino.Node.PropGENERATOR_FNstatic com.google.javascript.rhino.Node.PropGENERIC_TYPE_LISTstatic com.google.javascript.rhino.Node.PropGOOG_MODULEstatic com.google.javascript.rhino.Node.PropIMPLEMENTSstatic com.google.javascript.rhino.Node.PropINCRDECR_PROPstatic com.google.javascript.rhino.Node.PropIS_CONSTANT_NAMEstatic com.google.javascript.rhino.Node.PropIS_NAMESPACEstatic com.google.javascript.rhino.Node.PropIS_SHORTHAND_PROPERTYstatic com.google.javascript.rhino.Node.PropJSDOC_INFO_PROPstatic intMAX_COLUMN_NUMBERMAX_COLUMN_NUMBER represents the maximum column number that can be represented.static com.google.javascript.rhino.Node.PropMODULE_ALIASstatic com.google.javascript.rhino.Node.PropMODULE_EXPORTstatic com.google.javascript.rhino.Node.PropOPT_ES6_TYPEDstatic com.google.javascript.rhino.Node.PropORIGINALNAME_PROPprotected Nodeparentstatic com.google.javascript.rhino.Node.PropPARSE_RESULTSstatic com.google.javascript.rhino.Node.PropQUOTED_PROPstatic com.google.javascript.rhino.Node.PropREFLECTED_OBJECTstatic com.google.javascript.rhino.Node.PropSLASH_Vstatic com.google.javascript.rhino.Node.PropSTATIC_MEMBERstatic com.google.javascript.rhino.Node.PropTRANSPILEDstatic com.google.javascript.rhino.Node.PropWAS_PREVIOUSLY_PROVIDEDstatic com.google.javascript.rhino.Node.PropYIELD_ALL
-
Constructor Summary
Constructors Constructor Description Node(Token nodeType)Node(Token nodeType, int lineno, int charno)Node(Token nodeType, Node child)Node(Token nodeType, Node child, int lineno, int charno)Node(Token nodeType, Node left, Node right)Node(Token nodeType, Node left, Node mid, Node right)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddChildAfter(Node newChild, Node node)Add 'newChild' after 'node'.voidaddChildBefore(Node newChild, Node node)Add 'child' before 'node'.voidaddChildrenAfter(Node children, Node node)Add all children after 'node'.voidaddChildrenToBack(Node children)voidaddChildrenToFront(Node children)Add all children to the front of this node.voidaddChildToBack(Node child)voidaddChildToFront(Node child)voidappendStringTree(java.lang.Appendable appendable)java.lang.Iterable<Node>children()Return an iterable object that iterates over this node's children.NodecloneNode()protected NodecloneNode(boolean cloneTypeExprs)NodeclonePropsFrom(Node other)Clone the properties from the provided node without copying the property object.NodecloneTree()NodecloneTree(boolean cloneTypeExprs)Nodedetach()Removes this node from its parent.voiddetachChildren()Removes all children from this node and isolates the children from each other.NodedetachFromParent()Deprecated.usedetach()instead.protected static intextractCharno(int lineCharNo)Extracts the character number and character number from a merged line char number (seemergeLineCharNo(int, int)).protected static intextractLineno(int lineCharNo)Extracts the line number and character number from a merged line char number (seemergeLineCharNo(int, int)).NodegetAncestor(int level)Gets the ancestor node relative to this.Node.AncestorIterablegetAncestors()Iterates all of the node's ancestors excluding itself.java.math.BigIntegergetBigInt()Can only be called whengetType() == TokenStream.BIGINTbooleangetBooleanProp(com.google.javascript.rhino.Node.Prop propType)intgetChangeTime()Returns the time of the last change for this nodeintgetCharno()NodegetChildAtIndex(int i)Gets the ith child, note that this is O(N) where N is the number of children.NodegetChildBefore(Node child)intgetChildCount()ColorgetColor()Returns the compiled inferred type on this node.java.lang.StringgetCookedString()Can only be called whengetType() == Token.TEMPLATELIT_STRINGNode.TypeDeclarationNodegetDeclaredTypeExpression()Returns the syntactical type specified on this node.java.lang.StringgetDefineName()Returns any goog.define'd name corresponding to this NAME or GETPROP node.java.util.Set<java.lang.String>getDirectives()Returns the set of ES5 directives for this node.doublegetDouble()Can only be called whengetType() == TokenStream.NUMBERintgetExistingIntProp(com.google.javascript.rhino.Node.Prop propType)NodegetFirstChild()NodegetFirstFirstChild()Get the first child of the first child.NodegetGrandparent()intgetIndexOfChild(Node child)Gets the index of a child, note that this is O(N) where N is the number of children.InputIdgetInputId()intgetIntProp(com.google.javascript.rhino.Node.Prop propType)Returns the integer value for the property, or 0 if the property is not defined.booleangetIsParenthesized()Check whether node was inside parentheses.JSDocInfogetJSDocInfo()Get theJSDocInfoattached to this node.JSTypegetJSType()Returns the compiled inferred type on this node.JSTypegetJSTypeBeforeCast()Returns the type of this node before casting.JSTypegetJSTypeRequired()Returns the compiled inferred type on this node, or throws an NPE if there isn't one.NodegetLastChild()intgetLength()intgetLineno()java.lang.StringgetLocation()NodegetNext()NonJSDocCommentgetNonJSDocComment()java.lang.StringgetNonJSDocCommentString()Get the NonJSDoc comment string attached to this node.NodegetOnlyChild()java.lang.StringgetOriginalName()The original name of this node, if the node has been renamed.java.lang.StringgetOriginalQualifiedName()This function takes a set of GETPROP nodes and produces a string that is each property separated by dots.NodegetParent()NodegetPrevious()java.lang.ObjectgetProp(com.google.javascript.rhino.Node.Prop propType)java.lang.StringgetQualifiedName()This function takes a set of GETPROP nodes and produces a string that is each property separated by dots.QualifiedNamegetQualifiedNameObject()java.lang.StringgetRawString()Can only be called whengetType() == Token.TEMPLATELIT_STRINGNodegetSecondChild()intgetSideEffectFlags()Returns the side effects flags for this node.java.lang.StringgetSourceFileName()intgetSourceOffset()intgetSourcePosition()StaticSourceFilegetStaticSourceFile()Returns the source file associated with this input.java.lang.StringgetString()Can only be called when node has String context.TokengetToken()JSTypegetTypedefTypeProp()If this node represents a typedef declaration, the associated JSTypebooleanhasChild(Node child)booleanhasChildren()booleanhasMoreThanOneChild()Check for more than one child more efficiently than by iterating over all the children as is done with Node.getChildCount().booleanhasOneChild()Check for one child more efficiently than by iterating over all the children as is done with Node.getChildCount().booleanhasProps()booleanhasTrailingComma()Returns true if there was a trailing comma in the orginal codebooleanhasTwoChildren()Check for two children more efficiently thangetChildCount() == 2booleanhasXChildren(int x)Check for has exactly the number of specified children.booleanhasZeroOrOneChild()Check for zero or one child more efficiently than by iterating over all the children as is done with Node.getChildCount().booleanisAdd()AST type check methodsbooleanisAddedBlock()Returns whether this is an added block that should not be considered a real source block.booleanisAnd()booleanisArrayLit()booleanisArrayPattern()booleanisArrowFunction()Returns whether this node is a arrow function node.booleanisAssign()booleanisAssignAdd()booleanisAssignExponent()booleanisAsyncFunction()Returns whether this is an async function node.booleanisAsyncGeneratorFunction()Returns whether this is an async generator function node.booleanisAwait()booleanisBigInt()booleanisBlock()booleanisBreak()booleanisCall()booleanisCallSignature()booleanisCase()booleanisCast()booleanisCatch()booleanisClass()booleanisClassMembers()booleanisComma()booleanisComputedProp()booleanisConst()booleanisContinue()booleanisDebugger()booleanisDec()booleanisDeclaredConstantVar()Returns whether this variable is declared as a constant.booleanisDefaultCase()booleanisDefaultValue()booleanisDeleted()booleanisDelProp()booleanisDescendantOf(Node node)booleanisDestructuringLhs()booleanisDestructuringPattern()booleanisDo()booleanisEmpty()booleanisEquivalentTo(Node node)Returns true if this node is equivalent semantically to anotherbooleanisEquivalentTo(Node node, boolean compareType, boolean recurse, boolean jsDoc, boolean sideEffect)booleanisEquivalentToShallow(Node node)Checks equivalence without going into child nodesbooleanisEquivalentToTyped(Node node)Returns true if this node is equivalent semantically to another and the types are equivalent.booleanisEquivalentWithSideEffectsTo(Node node)Returns true if this node is equivalent semantically to another including side effects.booleanisEquivalentWithSideEffectsToShallow(Node node)Returns true if this node is equivalent semantically to another including side effects.booleanisExponent()booleanisExport()booleanisExportSpec()booleanisExportSpecs()booleanisExprResult()booleanisFalse()booleanisFirstChildOf(Node possibleParent)booleanisForAwaitOf()booleanisForIn()booleanisForOf()booleanisFromExterns()booleanisFunction()booleanisGeneratorFunction()Returns whether this node is a generator function node.booleanisGeneratorMarker()Returns whether this node was marked as containing YIELD nodes.booleanisGeneratorSafe()Used when translating ES6 generators.booleanisGetElem()booleanisGetProp()booleanisGetterDef()booleanisHook()booleanisIf()booleanisImport()booleanisImportMeta()booleanisImportSpec()booleanisImportSpecs()booleanisImportStar()booleanisIn()booleanisInc()booleanisIndexable()Whether this node should be indexed by static analysis / code indexing tools.booleanisIndexSignature()booleanisInferredConstantVar()Returns whether this variable is inferred to be constant.booleanisInstanceOf()booleanisInterfaceMembers()booleanisLabel()booleanisLabelName()booleanisLet()booleanisLocalResultCall()Returns true if this node is a function or constructor call that returns a primitive or a local object (an object that has no other references).booleanisMemberFunctionDef()booleanisMemberVariableDef()booleanisModuleBody()booleanisName()booleanisNE()booleanisNew()booleanisNormalBlock()booleanisNoSideEffectsCall()Returns true if this node is a function or constructor call that has no side effects.booleanisNot()booleanisNull()booleanisNullishCoalesce()booleanisNumber()booleanisObjectLit()booleanisObjectPattern()booleanisObjectRest()booleanisOnlyChildOf(Node possibleParent)booleanisOnlyModifiesArgumentsCall()booleanisOnlyModifiesThisCall()booleanisOptChainCall()booleanisOptChainGetElem()booleanisOptChainGetProp()booleanisOptionalChainStart()Returns whether this node is an optional chaining node.booleanisOptionalEs6Typed()Returns whether this node is an optional node in the ES6 Typed syntax.booleanisOr()booleanisParamList()booleanisQualifiedName()Returns whether a node corresponds to a simple or a qualified name, such asxora.b.corthis.a.booleanisQuotedString()This should only be called for STRING nodes children of OBJECTLIT.booleanisRecordType()booleanisRegExp()booleanisRest()booleanisReturn()booleanisRoot()booleanisScript()booleanisSecondChildOf(Node possibleParent)booleanisSetterDef()booleanisShorthandProperty()Whether this {x:x} property was originally parsed as {x}.booleanisSpread()booleanisStaticMember()Returns whether this node is a static member node.booleanisString()booleanisStringKey()booleanisSub()booleanisSuper()booleanisSwitch()booleanisSyntheticBlock()Returns whether this is a synthetic block that should not be considered a real source block.booleanisTaggedTemplateLit()booleanisTemplateLit()booleanisTemplateLitString()booleanisTemplateLitSub()booleanisThis()booleanisThrow()booleanisTrue()booleanisTry()booleanisTypeOf()booleanisUnscopedQualifiedName()Returns whether a node corresponds to a simple or a qualified name without a "this" reference, such asa.b.c, but notthis.a.booleanisUnusedParameter()booleanisValidAssignmentTarget()booleanisVanillaFor()booleanisVar()booleanisVoid()booleanisWhile()booleanisWith()booleanisYield()booleanisYieldAll()Returns whether this node is a generator node.voidmakeNonIndexable()voidmakeNonIndexableRecursive()booleanmatchesName(Node n)Check that if two NAME node match, returns false if either node is not a NAME node.booleanmatchesName(java.lang.String name)Returns whether a node matches a simple name, such asx, returns false if this is not a NAME node.booleanmatchesQualifiedName(Node n)Returns whether a node matches a simple or a qualified name, such asxora.b.corthis.a.booleanmatchesQualifiedName(java.lang.String name)Returns whether a node matches a simple or a qualified name, such asxora.b.corthis.a.booleanmayMutateArguments()Returns true if this is a new/call that may mutate its arguments.booleanmayMutateGlobalStateOrThrow()Returns true if this is a new/call that may mutate global state or throw.protected static intmergeLineCharNo(int lineno, int charno)Merges the line number and character number in one integer.static NodenewBigInt(java.math.BigInteger bigint)static NodenewNumber(double number)static NodenewNumber(double number, int lineno, int charno)static NodenewString(Token token, java.lang.String str)static NodenewString(Token token, java.lang.String str, int lineno, int charno)static NodenewString(java.lang.String str)static NodenewString(java.lang.String str, int lineno, int charno)static NodenewTemplateLitString(java.lang.String cooked, java.lang.String raw)voidputBooleanProp(com.google.javascript.rhino.Node.Prop propType, boolean value)voidputIntProp(com.google.javascript.rhino.Node.Prop propType, int value)voidputProp(com.google.javascript.rhino.Node.Prop propType, java.lang.Object value)voidremoveChild(Node child)Detach a child from its parent and siblings.NoderemoveChildAfter(Node prev)NoderemoveChildren()NoderemoveFirstChild()Removes the first child of Node.NoderemoveFirstOrChildAfter(Node prev)Remove the child after the given child, or the first child if given null.voidremoveProp(com.google.javascript.rhino.Node.Prop propType)voidreplaceChild(Node child, Node newChild)Detaches child from Node and replaces it with newChild.voidreplaceChildAfter(Node prevChild, Node newChild)voidreplaceFirstOrChildAfter(Node prev, Node newChild)Detaches the child after the given child, or the first child if prev is null.voidreplaceWith(Node newNode)Detaches Node and replaces it with newNode.voidsetBigInt(java.math.BigInteger value)Can only be called whengetType() == Token.BIGINTvoidsetChangeTime(int time)This node was last changed attimevoidsetCharno(int charno)NodesetColor(Color jstype)voidsetDeclaredConstantVar(boolean value)Sets this variable to be a declared constant.voidsetDeclaredTypeExpression(Node.TypeDeclarationNode typeExpression)Sets the syntactical type specified on this node.voidsetDefineName(java.lang.String name)Sets the goog.define name for a NAME or GETPROP node.voidsetDeleted(boolean deleted)voidsetDirectives(java.util.Set<java.lang.String> val)Sets the ES5 directives on this node.voidsetDouble(double value)Can only be called whengetType() == Token.NUMBERvoidsetGeneratorMarker(boolean isGeneratorMarker)Sets whether this node subtree contains YIELD nodes.voidsetGeneratorSafe(boolean isGeneratorSafe)voidsetInferredConstantVar(boolean value)Sets this variable to be an inferred constant.voidsetInputId(InputId inputId)voidsetIsAddedBlock(boolean val)Sets whether this is an added block that should not be considered a real source block.voidsetIsArrowFunction(boolean isArrow)Sets whether this node is a arrow function node.voidsetIsAsyncFunction(boolean isAsync)Sets whether this node is an async function node.voidsetIsGeneratorFunction(boolean isGenerator)Sets whether this node is a generator node.voidsetIsOptionalChainStart(boolean isOptionalChainStart)Sets whether this node is the start of an optional chain.voidsetIsParenthesized(boolean b)Sets whether this node is inside parentheses.voidsetIsSyntheticBlock(boolean val)Sets whether this is a synthetic block that should not be considered a real source block.NodesetJSDocInfo(JSDocInfo info)Sets theJSDocInfoattached to this node.NodesetJSType(JSType jstype)voidsetJSTypeBeforeCast(JSType type)Sets the type of this node before casting.voidsetLength(int length)voidsetLengthForTree(int length)Useful to set length of a transpiled node tree to map back to the length of original node.voidsetLineno(int lineno)NodesetNonJSDocComment(NonJSDocComment comment)Sets the NonJSDoc comment attached to this node.voidsetOriginalName(java.lang.String originalName)voidsetQuotedString()This should only be called for STRING nodes children of OBJECTLIT.voidsetShorthandProperty(boolean shorthand)Sets the isShorthandProperty annotation.voidsetSideEffectFlags(int flags)Marks this function or constructor call's side effect flags.voidsetSideEffectFlags(Node.SideEffectFlags flags)voidsetSourceEncodedPosition(int sourcePosition)voidsetSourceEncodedPositionForTree(int sourcePosition)voidsetSourceFileForTesting(java.lang.String name)Sets the source file to a non-extern file of the given name.voidsetStaticMember(boolean isStatic)Sets whether this node is a static member node.NodesetStaticSourceFile(StaticSourceFile file)voidsetStaticSourceFileFrom(Node other)voidsetString(java.lang.String value)Can only be called for a Token.STRING or Token.NAME.voidsetToken(Token token)voidsetTrailingComma(boolean hasTrailingComma)Indicates that there was a trailing comma in this listvoidsetTypedefTypeProp(JSType type)If this node represents a typedef declaration, the associated JSTypevoidsetUnusedParameter(boolean unused)voidsetYieldAll(boolean isGenerator)Sets whether this node is a generator node.java.lang.Iterable<Node>siblings()Return an iterable object that iterates over this node's siblings, including this Node but not any siblings that are before this one.Nodesrcref(Node other)NodesrcrefTree(Node other)java.lang.StringtoString()java.lang.StringtoString(boolean printSource, boolean printAnnotations, boolean printType)java.lang.StringtoStringTree()NodeuseSourceInfoFrom(Node other)Overwrite all the source information in this node with that ofother.NodeuseSourceInfoFromForTree(Node other)Overwrite all the source information in this node and its subtree with that ofother.NodeuseSourceInfoIfMissingFrom(Node other)Overwrite all the source information in this node with that ofotheriff the source info is missing.NodeuseSourceInfoIfMissingFromForTree(Node other)Overwrite all the source information in this node and its subtree with that ofotheriff the source info is missing.
-
-
-
Field Detail
-
JSDOC_INFO_PROP
public static final com.google.javascript.rhino.Node.Prop JSDOC_INFO_PROP
-
INCRDECR_PROP
public static final com.google.javascript.rhino.Node.Prop INCRDECR_PROP
-
QUOTED_PROP
public static final com.google.javascript.rhino.Node.Prop QUOTED_PROP
-
ORIGINALNAME_PROP
public static final com.google.javascript.rhino.Node.Prop ORIGINALNAME_PROP
-
IS_CONSTANT_NAME
public static final com.google.javascript.rhino.Node.Prop IS_CONSTANT_NAME
-
IS_NAMESPACE
public static final com.google.javascript.rhino.Node.Prop IS_NAMESPACE
-
DIRECT_EVAL
public static final com.google.javascript.rhino.Node.Prop DIRECT_EVAL
-
FREE_CALL
public static final com.google.javascript.rhino.Node.Prop FREE_CALL
-
SLASH_V
public static final com.google.javascript.rhino.Node.Prop SLASH_V
-
REFLECTED_OBJECT
public static final com.google.javascript.rhino.Node.Prop REFLECTED_OBJECT
-
STATIC_MEMBER
public static final com.google.javascript.rhino.Node.Prop STATIC_MEMBER
-
GENERATOR_FN
public static final com.google.javascript.rhino.Node.Prop GENERATOR_FN
-
YIELD_ALL
public static final com.google.javascript.rhino.Node.Prop YIELD_ALL
-
EXPORT_DEFAULT
public static final com.google.javascript.rhino.Node.Prop EXPORT_DEFAULT
-
EXPORT_ALL_FROM
public static final com.google.javascript.rhino.Node.Prop EXPORT_ALL_FROM
-
COMPUTED_PROP_METHOD
public static final com.google.javascript.rhino.Node.Prop COMPUTED_PROP_METHOD
-
COMPUTED_PROP_GETTER
public static final com.google.javascript.rhino.Node.Prop COMPUTED_PROP_GETTER
-
COMPUTED_PROP_SETTER
public static final com.google.javascript.rhino.Node.Prop COMPUTED_PROP_SETTER
-
COMPUTED_PROP_VARIABLE
public static final com.google.javascript.rhino.Node.Prop COMPUTED_PROP_VARIABLE
-
OPT_ES6_TYPED
public static final com.google.javascript.rhino.Node.Prop OPT_ES6_TYPED
-
GENERIC_TYPE_LIST
public static final com.google.javascript.rhino.Node.Prop GENERIC_TYPE_LIST
-
IMPLEMENTS
public static final com.google.javascript.rhino.Node.Prop IMPLEMENTS
-
CONSTRUCT_SIGNATURE
public static final com.google.javascript.rhino.Node.Prop CONSTRUCT_SIGNATURE
-
ACCESS_MODIFIER
public static final com.google.javascript.rhino.Node.Prop ACCESS_MODIFIER
-
PARSE_RESULTS
public static final com.google.javascript.rhino.Node.Prop PARSE_RESULTS
-
GOOG_MODULE
public static final com.google.javascript.rhino.Node.Prop GOOG_MODULE
-
FEATURE_SET
public static final com.google.javascript.rhino.Node.Prop FEATURE_SET
-
WAS_PREVIOUSLY_PROVIDED
public static final com.google.javascript.rhino.Node.Prop WAS_PREVIOUSLY_PROVIDED
-
TRANSPILED
public static final com.google.javascript.rhino.Node.Prop TRANSPILED
-
MODULE_ALIAS
public static final com.google.javascript.rhino.Node.Prop MODULE_ALIAS
-
MODULE_EXPORT
public static final com.google.javascript.rhino.Node.Prop MODULE_EXPORT
-
IS_SHORTHAND_PROPERTY
public static final com.google.javascript.rhino.Node.Prop IS_SHORTHAND_PROPERTY
-
ES6_MODULE
public static final com.google.javascript.rhino.Node.Prop ES6_MODULE
-
COLUMN_BITS
public static final int COLUMN_BITS
COLUMN_BITS represents how many of the lower-order bits of sourcePosition are reserved for storing the column number. Bits above these store the line number. This gives us decent position information for everything except files already passed through a minimizer, where lines might be longer than 4096 characters.- See Also:
- Constant Field Values
-
MAX_COLUMN_NUMBER
public static final int MAX_COLUMN_NUMBER
MAX_COLUMN_NUMBER represents the maximum column number that can be represented. JSCompiler's modifications to Rhino cause all tokens located beyond the maximum column to MAX_COLUMN_NUMBER.- See Also:
- Constant Field Values
-
COLUMN_MASK
public static final int COLUMN_MASK
COLUMN_MASK stores a value where bits storing the column number are set, and bits storing the line are not set. It's handy for separating column number from line number.- See Also:
- Constant Field Values
-
parent
@Nullable protected transient Node parent
-
-
Method Detail
-
getNonJSDocCommentString
public final java.lang.String getNonJSDocCommentString()
Get the NonJSDoc comment string attached to this node.- Returns:
- the information or empty string if no nonJSDoc is attached to this node
-
getNonJSDocComment
public final NonJSDocComment getNonJSDocComment()
-
setNonJSDocComment
public final Node setNonJSDocComment(NonJSDocComment comment)
Sets the NonJSDoc comment attached to this node.
-
setIsParenthesized
public final void setIsParenthesized(boolean b)
Sets whether this node is inside parentheses.
-
getIsParenthesized
public final boolean getIsParenthesized()
Check whether node was inside parentheses.
-
newNumber
public static Node newNumber(double number)
-
newNumber
public static Node newNumber(double number, int lineno, int charno)
-
newBigInt
public static Node newBigInt(java.math.BigInteger bigint)
-
newString
public static Node newString(java.lang.String str)
-
newString
public static Node newString(java.lang.String str, int lineno, int charno)
-
newTemplateLitString
public static Node newTemplateLitString(java.lang.String cooked, java.lang.String raw)
-
getToken
public final Token getToken()
-
setToken
public final void setToken(Token token)
-
hasChildren
public final boolean hasChildren()
-
getOnlyChild
public final Node getOnlyChild()
-
getFirstChild
@Nullable public final Node getFirstChild()
-
getFirstFirstChild
@Nullable public final Node getFirstFirstChild()
Get the first child of the first child. This method assumes that the first child exists.- Returns:
- The first child of the first child.
-
getSecondChild
@Nullable public final Node getSecondChild()
-
getLastChild
@Nullable public final Node getLastChild()
-
getNext
@Nullable public final Node getNext()
-
getPrevious
@Nullable public final Node getPrevious()
-
getChildAtIndex
public final Node getChildAtIndex(int i)
Gets the ith child, note that this is O(N) where N is the number of children.- Parameters:
i- The index- Returns:
- The ith child
-
getIndexOfChild
public final int getIndexOfChild(Node child)
Gets the index of a child, note that this is O(N) where N is the number of children.- Parameters:
child- The child- Returns:
- The index of the child
-
addChildToFront
public final void addChildToFront(Node child)
-
addChildToBack
public final void addChildToBack(Node child)
-
addChildrenToFront
public final void addChildrenToFront(@Nullable Node children)Add all children to the front of this node.- Parameters:
children- first of a list of sibling nodes who have no parent. NOTE: Usually you would get this argument from a removeChildren() call. A single detached node will not work because its sibling pointers will not be correctly initialized.
-
addChildrenToBack
public final void addChildrenToBack(Node children)
-
addChildBefore
public final void addChildBefore(Node newChild, Node node)
Add 'child' before 'node'.
-
addChildAfter
public final void addChildAfter(Node newChild, @Nullable Node node)
Add 'newChild' after 'node'. If 'node' is null, add it to the front of this node.
-
addChildrenAfter
public final void addChildrenAfter(@Nullable Node children, @Nullable Node node)Add all children after 'node'. If 'node' is null, add them to the front of this node.- Parameters:
children- first of a list of sibling nodes who have no parent. NOTE: Usually you would get this argument from a removeChildren() call. A single detached node will not work because its sibling pointers will not be correctly initialized.
-
removeChild
public final void removeChild(Node child)
Detach a child from its parent and siblings.
-
replaceWith
public final void replaceWith(Node newNode)
Detaches Node and replaces it with newNode.
-
replaceChild
public final void replaceChild(Node child, Node newChild)
Detaches child from Node and replaces it with newChild.
-
replaceFirstOrChildAfter
public final void replaceFirstOrChildAfter(@Nullable Node prev, Node newChild)Detaches the child after the given child, or the first child if prev is null.
-
clonePropsFrom
public final Node clonePropsFrom(Node other)
Clone the properties from the provided node without copying the property object. The receiving node may not have any existing properties.- Parameters:
other- The node to clone properties from.- Returns:
- this node.
-
hasProps
public final boolean hasProps()
-
removeProp
public final void removeProp(com.google.javascript.rhino.Node.Prop propType)
-
getProp
@Nullable public final java.lang.Object getProp(com.google.javascript.rhino.Node.Prop propType)
-
getBooleanProp
public final boolean getBooleanProp(com.google.javascript.rhino.Node.Prop propType)
-
getIntProp
public final int getIntProp(com.google.javascript.rhino.Node.Prop propType)
Returns the integer value for the property, or 0 if the property is not defined.
-
getExistingIntProp
public final int getExistingIntProp(com.google.javascript.rhino.Node.Prop propType)
-
putProp
public final void putProp(com.google.javascript.rhino.Node.Prop propType, @Nullable java.lang.Object value)
-
putBooleanProp
public final void putBooleanProp(com.google.javascript.rhino.Node.Prop propType, boolean value)
-
putIntProp
public final void putIntProp(com.google.javascript.rhino.Node.Prop propType, int value)
-
setDeclaredTypeExpression
public final void setDeclaredTypeExpression(Node.TypeDeclarationNode typeExpression)
Sets the syntactical type specified on this node.- Parameters:
typeExpression-
-
getDeclaredTypeExpression
@Nullable public final Node.TypeDeclarationNode getDeclaredTypeExpression()
Returns the syntactical type specified on this node. Not to be confused withgetJSType()which returns the compiler-inferred type.
-
setJSTypeBeforeCast
public final void setJSTypeBeforeCast(JSType type)
Sets the type of this node before casting.
-
getJSTypeBeforeCast
@Nullable public final JSType getJSTypeBeforeCast()
Returns the type of this node before casting. This annotation will only exist on the first child of a CAST node after type checking.
-
getDouble
public double getDouble()
Can only be called whengetType() == TokenStream.NUMBER
-
setDouble
public void setDouble(double value)
Can only be called whengetType() == Token.NUMBER- Parameters:
value- value to set.
-
getBigInt
public java.math.BigInteger getBigInt()
Can only be called whengetType() == TokenStream.BIGINT
-
setBigInt
public void setBigInt(java.math.BigInteger value)
Can only be called whengetType() == Token.BIGINT- Parameters:
value- value to set.
-
getString
public java.lang.String getString()
Can only be called when node has String context.
-
setString
public void setString(java.lang.String value)
Can only be called for a Token.STRING or Token.NAME.- Parameters:
value- the value to set.
-
getRawString
public java.lang.String getRawString()
Can only be called whengetType() == Token.TEMPLATELIT_STRING
-
getCookedString
@Nullable public java.lang.String getCookedString()
Can only be called whengetType() == Token.TEMPLATELIT_STRING
-
toString
public final java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
toString
public final java.lang.String toString(boolean printSource, boolean printAnnotations, boolean printType)
-
toStringTree
@CheckReturnValue public final java.lang.String toStringTree()
-
appendStringTree
public final void appendStringTree(java.lang.Appendable appendable) throws java.io.IOException- Throws:
java.io.IOException
-
setStaticSourceFileFrom
public final void setStaticSourceFileFrom(Node other)
-
setStaticSourceFile
public final Node setStaticSourceFile(@Nullable StaticSourceFile file)
-
setSourceFileForTesting
public final void setSourceFileForTesting(java.lang.String name)
Sets the source file to a non-extern file of the given name.
-
getSourceFileName
@Nullable public java.lang.String getSourceFileName()
-
getStaticSourceFile
@Nullable public StaticSourceFile getStaticSourceFile()
Returns the source file associated with this input.
-
setInputId
public void setInputId(InputId inputId)
- Parameters:
inputId-
-
getInputId
@Nullable public InputId getInputId()
- Returns:
- The Id of the CompilerInput associated with this Node.
-
getOriginalName
@Nullable public java.lang.String getOriginalName()
The original name of this node, if the node has been renamed.
-
setOriginalName
public void setOriginalName(java.lang.String originalName)
-
isIndexable
public final boolean isIndexable()
Whether this node should be indexed by static analysis / code indexing tools.
-
makeNonIndexable
public final void makeNonIndexable()
-
makeNonIndexableRecursive
public final void makeNonIndexableRecursive()
-
isFromExterns
public final boolean isFromExterns()
-
getLength
public final int getLength()
-
setLength
public final void setLength(int length)
-
setLengthForTree
public final void setLengthForTree(int length)
Useful to set length of a transpiled node tree to map back to the length of original node.
-
getLineno
public final int getLineno()
-
getCharno
public final int getCharno()
-
getLocation
public final java.lang.String getLocation()
-
getSourceOffset
public int getSourceOffset()
-
getSourcePosition
public final int getSourcePosition()
-
setLineno
public final void setLineno(int lineno)
-
setCharno
public final void setCharno(int charno)
-
setSourceEncodedPosition
public final void setSourceEncodedPosition(int sourcePosition)
-
setSourceEncodedPositionForTree
public final void setSourceEncodedPositionForTree(int sourcePosition)
-
mergeLineCharNo
protected static int mergeLineCharNo(int lineno, int charno)Merges the line number and character number in one integer. The Character number takes the first 12 bits and the line number takes the rest. If the character number is greater than212-1it is adjusted to212-1.
-
extractLineno
protected static int extractLineno(int lineCharNo)
Extracts the line number and character number from a merged line char number (seemergeLineCharNo(int, int)).
-
extractCharno
protected static int extractCharno(int lineCharNo)
Extracts the character number and character number from a merged line char number (seemergeLineCharNo(int, int)).
-
children
public final java.lang.Iterable<Node> children()
Return an iterable object that iterates over this node's children. The iterator does not support the optional operation
Iterator.remove().To iterate over a node's children, one can write
Node n = ...; for (Node child : n.children()) { ...
-
siblings
public final java.lang.Iterable<Node> siblings()
Return an iterable object that iterates over this node's siblings, including this Node but not any siblings that are before this one.
The iterator does not support the optional operation
Iterator.remove().To iterate over a node's siblings including itself, one can write
Node n = ...; for (Node sibling : n.siblings()) { ...
-
getParent
@Nullable public final Node getParent()
-
getGrandparent
@Nullable public final Node getGrandparent()
-
getAncestor
@Nullable public final Node getAncestor(int level)
Gets the ancestor node relative to this.- Parameters:
level- 0 = this, 1 = the parent, etc.
-
isDescendantOf
public final boolean isDescendantOf(Node node)
- Returns:
- True if this Node is
nodeor a descendant ofnode.
-
isOnlyChildOf
public final boolean isOnlyChildOf(Node possibleParent)
-
isFirstChildOf
public final boolean isFirstChildOf(Node possibleParent)
-
isSecondChildOf
public final boolean isSecondChildOf(Node possibleParent)
-
getAncestors
public final Node.AncestorIterable getAncestors()
Iterates all of the node's ancestors excluding itself.
-
hasOneChild
public final boolean hasOneChild()
Check for one child more efficiently than by iterating over all the children as is done with Node.getChildCount().- Returns:
- Whether the node has exactly one child.
-
hasTwoChildren
public final boolean hasTwoChildren()
Check for two children more efficiently thangetChildCount() == 2- Returns:
- Whether the node has exactly two children.
-
hasZeroOrOneChild
public final boolean hasZeroOrOneChild()
Check for zero or one child more efficiently than by iterating over all the children as is done with Node.getChildCount().- Returns:
- Whether the node has no children or exactly one child.
-
hasMoreThanOneChild
public final boolean hasMoreThanOneChild()
Check for more than one child more efficiently than by iterating over all the children as is done with Node.getChildCount().- Returns:
- Whether the node more than one child.
-
hasXChildren
public final boolean hasXChildren(int x)
Check for has exactly the number of specified children.- Returns:
- Whether the node has exactly the number of children specified.
-
getChildCount
public final int getChildCount()
-
hasChild
public final boolean hasChild(Node child)
-
isEquivalentToShallow
public final boolean isEquivalentToShallow(Node node)
Checks equivalence without going into child nodes
-
isEquivalentWithSideEffectsTo
public final boolean isEquivalentWithSideEffectsTo(Node node)
Returns true if this node is equivalent semantically to another including side effects.
-
isEquivalentWithSideEffectsToShallow
public final boolean isEquivalentWithSideEffectsToShallow(Node node)
Returns true if this node is equivalent semantically to another including side effects.
-
isEquivalentToTyped
public final boolean isEquivalentToTyped(Node node)
Returns true if this node is equivalent semantically to another and the types are equivalent.
-
isEquivalentTo
public final boolean isEquivalentTo(Node node)
Returns true if this node is equivalent semantically to another
-
isEquivalentTo
public boolean isEquivalentTo(Node node, boolean compareType, boolean recurse, boolean jsDoc, boolean sideEffect)
- Parameters:
compareType- Whether to compare the JSTypes of the nodes.recurse- Whether to compare the children of the current node. If not, only the count of the children are compared.jsDoc- Whether to check that the JsDoc of the nodes are equivalent.sideEffect- Whether to check that the side-effect flags of the nodes are equivalent.- Returns:
- Whether this node is equivalent semantically to the provided node.
-
getQualifiedName
@Nullable public final java.lang.String getQualifiedName()
This function takes a set of GETPROP nodes and produces a string that is each property separated by dots. If the node ultimately under the left sub-tree is not a simple name, this is not a valid qualified name.- Returns:
- a null if this is not a qualified name, or a dot-separated string of the name and properties.
-
getQualifiedNameObject
@Nullable public final QualifiedName getQualifiedNameObject()
-
getOriginalQualifiedName
@Nullable public final java.lang.String getOriginalQualifiedName()
This function takes a set of GETPROP nodes and produces a string that is each property separated by dots. If the node ultimately under the left sub-tree is not a simple name, this is not a valid qualified name. This method returns the original name of each segment rather than the renamed version.- Returns:
- a null if this is not a qualified name, or a dot-separated string of the name and properties.
-
isQualifiedName
public final boolean isQualifiedName()
Returns whether a node corresponds to a simple or a qualified name, such asxora.b.corthis.a.
-
matchesName
public final boolean matchesName(java.lang.String name)
Returns whether a node matches a simple name, such asx, returns false if this is not a NAME node.
-
matchesName
public final boolean matchesName(Node n)
Check that if two NAME node match, returns false if either node is not a NAME node. As a empty string is not considered a valid Name (it is an AST placeholder), empty strings are never considered to be matches.
-
matchesQualifiedName
public final boolean matchesQualifiedName(java.lang.String name)
Returns whether a node matches a simple or a qualified name, such asxora.b.corthis.a.
-
matchesQualifiedName
public final boolean matchesQualifiedName(Node n)
Returns whether a node matches a simple or a qualified name, such asxora.b.corthis.a.
-
isUnscopedQualifiedName
public final boolean isUnscopedQualifiedName()
Returns whether a node corresponds to a simple or a qualified name without a "this" reference, such asa.b.c, but notthis.a.
-
isValidAssignmentTarget
public final boolean isValidAssignmentTarget()
-
detachFromParent
@Deprecated public final Node detachFromParent()
Deprecated.usedetach()instead. The behavior is equivalent.Removes this node from its parent.
-
detach
public final Node detach()
Removes this node from its parent. Equivalent to: node.getParent().removeChild();
-
removeFirstChild
@Nullable public final Node removeFirstChild()
Removes the first child of Node. Equivalent to: node.removeChild(node.getFirstChild());- Returns:
- The removed Node.
-
removeChildren
@Nullable public final Node removeChildren()
- Returns:
- A Node that is the head of the list of children.
-
detachChildren
public final void detachChildren()
Removes all children from this node and isolates the children from each other.
-
removeFirstOrChildAfter
public final Node removeFirstOrChildAfter(@Nullable Node prev)
Remove the child after the given child, or the first child if given null.
-
cloneNode
@CheckReturnValue public final Node cloneNode()
- Returns:
- A detached clone of the Node, specifically excluding its children.
-
cloneNode
@CheckReturnValue protected Node cloneNode(boolean cloneTypeExprs)
- Returns:
- A detached clone of the Node, specifically excluding its children.
-
cloneTree
@CheckReturnValue public final Node cloneTree()
- Returns:
- A detached clone of the Node and all its children.
-
cloneTree
@CheckReturnValue public final Node cloneTree(boolean cloneTypeExprs)
-
useSourceInfoFrom
public final Node useSourceInfoFrom(Node other)
Overwrite all the source information in this node with that ofother.
-
useSourceInfoFromForTree
public final Node useSourceInfoFromForTree(Node other)
Overwrite all the source information in this node and its subtree with that ofother.
-
useSourceInfoIfMissingFrom
public final Node useSourceInfoIfMissingFrom(Node other)
Overwrite all the source information in this node with that ofotheriff the source info is missing.
-
useSourceInfoIfMissingFromForTree
public final Node useSourceInfoIfMissingFromForTree(Node other)
Overwrite all the source information in this node and its subtree with that ofotheriff the source info is missing.
-
getJSType
@Nullable public final JSType getJSType()
Returns the compiled inferred type on this node. Not to be confused withgetDeclaredTypeExpression()which returns the syntactically specified type.
-
getJSTypeRequired
public final JSType getJSTypeRequired()
Returns the compiled inferred type on this node, or throws an NPE if there isn't one.
-
getColor
@Nullable public final Color getColor()
Returns the compiled inferred type on this node. Not to be confused withgetDeclaredTypeExpression()which returns the syntactically specified type.
-
getJSDocInfo
@Nullable public final JSDocInfo getJSDocInfo()
Get theJSDocInfoattached to this node.- Returns:
- the information or
nullif no JSDoc is attached to this node
-
setJSDocInfo
public final Node setJSDocInfo(JSDocInfo info)
Sets theJSDocInfoattached to this node.
-
setChangeTime
public final void setChangeTime(int time)
This node was last changed attime
-
getChangeTime
public final int getChangeTime()
Returns the time of the last change for this node
-
setDeleted
public final void setDeleted(boolean deleted)
-
isDeleted
public final boolean isDeleted()
-
setTypedefTypeProp
public final void setTypedefTypeProp(JSType type)
If this node represents a typedef declaration, the associated JSType
-
getTypedefTypeProp
public final JSType getTypedefTypeProp()
If this node represents a typedef declaration, the associated JSType
-
setUnusedParameter
public final void setUnusedParameter(boolean unused)
- Parameters:
unused- Whether a parameter was function to be unused. Set by RemoveUnusedVars
-
isUnusedParameter
public final boolean isUnusedParameter()
- Returns:
- Whether a parameter was function to be unused. Set by RemoveUnusedVars
-
setShorthandProperty
public final void setShorthandProperty(boolean shorthand)
Sets the isShorthandProperty annotation.
-
isShorthandProperty
public final boolean isShorthandProperty()
Whether this {x:x} property was originally parsed as {x}.
-
isOptionalEs6Typed
public final boolean isOptionalEs6Typed()
Returns whether this node is an optional node in the ES6 Typed syntax.
-
setIsSyntheticBlock
public final void setIsSyntheticBlock(boolean val)
Sets whether this is a synthetic block that should not be considered a real source block.
-
isSyntheticBlock
public final boolean isSyntheticBlock()
Returns whether this is a synthetic block that should not be considered a real source block.
-
setDirectives
public final void setDirectives(java.util.Set<java.lang.String> val)
Sets the ES5 directives on this node.
-
getDirectives
@Nullable public final java.util.Set<java.lang.String> getDirectives()
Returns the set of ES5 directives for this node.
-
setIsAddedBlock
public final void setIsAddedBlock(boolean val)
Sets whether this is an added block that should not be considered a real source block. Eg: In "if (true) x;", the "x;" is put under an added block in the AST.
-
isAddedBlock
public final boolean isAddedBlock()
Returns whether this is an added block that should not be considered a real source block.
-
setStaticMember
public final void setStaticMember(boolean isStatic)
Sets whether this node is a static member node. This method is meaningful only onToken.GETTER_DEF,Token.SETTER_DEForToken.MEMBER_FUNCTION_DEFnodes contained withinToken.CLASS.
-
isStaticMember
public final boolean isStaticMember()
Returns whether this node is a static member node. This method is meaningful only onToken.GETTER_DEF,Token.SETTER_DEForToken.MEMBER_FUNCTION_DEFnodes contained withinToken.CLASS.
-
setIsGeneratorFunction
public final void setIsGeneratorFunction(boolean isGenerator)
Sets whether this node is a generator node. This method is meaningful only onToken.FUNCTIONorToken.MEMBER_FUNCTION_DEFnodes.
-
isGeneratorFunction
public final boolean isGeneratorFunction()
Returns whether this node is a generator function node.
-
setGeneratorMarker
public final void setGeneratorMarker(boolean isGeneratorMarker)
Sets whether this node subtree contains YIELD nodes.It's used in the translation of generators.
-
isGeneratorMarker
public final boolean isGeneratorMarker()
Returns whether this node was marked as containing YIELD nodes.It's used in the translation of generators.
-
setGeneratorSafe
public final void setGeneratorSafe(boolean isGeneratorSafe)
- See Also:
isGeneratorSafe()
-
isGeneratorSafe
public final boolean isGeneratorSafe()
Used when translating ES6 generators. If this returns true, this Node was generated by the compiler, and it is safe to copy this node to the transpiled output with no further changes.
-
setIsOptionalChainStart
public final void setIsOptionalChainStart(boolean isOptionalChainStart)
Sets whether this node is the start of an optional chain. This method is meaningful only onToken.OPTCHAIN_GETELEM,Token.OPTCHAIN_GETPROP,Token.OPTCHAIN_CALL
-
isOptionalChainStart
public final boolean isOptionalChainStart()
Returns whether this node is an optional chaining node.
-
setIsArrowFunction
public final void setIsArrowFunction(boolean isArrow)
Sets whether this node is a arrow function node. This method is meaningful only onToken.FUNCTION
-
isArrowFunction
public final boolean isArrowFunction()
Returns whether this node is a arrow function node.
-
setIsAsyncFunction
public void setIsAsyncFunction(boolean isAsync)
Sets whether this node is an async function node. This method is meaningful only onToken.FUNCTION
-
isAsyncFunction
public final boolean isAsyncFunction()
Returns whether this is an async function node.
-
isAsyncGeneratorFunction
public final boolean isAsyncGeneratorFunction()
Returns whether this is an async generator function node.
-
setYieldAll
public final void setYieldAll(boolean isGenerator)
Sets whether this node is a generator node. This method is meaningful only onToken.FUNCTIONorToken.MEMBER_FUNCTION_DEFnodes.
-
isYieldAll
public final boolean isYieldAll()
Returns whether this node is a generator node. This method is meaningful only onToken.FUNCTIONorToken.MEMBER_FUNCTION_DEFnodes.
-
getDefineName
public final java.lang.String getDefineName()
Returns any goog.define'd name corresponding to this NAME or GETPROP node.
-
setDefineName
public final void setDefineName(java.lang.String name)
Sets the goog.define name for a NAME or GETPROP node.
-
setTrailingComma
public final void setTrailingComma(boolean hasTrailingComma)
Indicates that there was a trailing comma in this list
-
hasTrailingComma
public final boolean hasTrailingComma()
Returns true if there was a trailing comma in the orginal code
-
setSideEffectFlags
public final void setSideEffectFlags(int flags)
Marks this function or constructor call's side effect flags. This property is only meaningful forToken.CALLandToken.NEWnodes.
-
setSideEffectFlags
public final void setSideEffectFlags(Node.SideEffectFlags flags)
-
getSideEffectFlags
public final int getSideEffectFlags()
Returns the side effects flags for this node.
-
isOnlyModifiesThisCall
public final boolean isOnlyModifiesThisCall()
- Returns:
- Whether the only side-effect is "modifies this"
-
isOnlyModifiesArgumentsCall
public final boolean isOnlyModifiesArgumentsCall()
- Returns:
- Whether the only side-effect is "modifies arguments"
-
isNoSideEffectsCall
public final boolean isNoSideEffectsCall()
Returns true if this node is a function or constructor call that has no side effects.
-
isLocalResultCall
public final boolean isLocalResultCall()
Returns true if this node is a function or constructor call that returns a primitive or a local object (an object that has no other references).
-
mayMutateArguments
public final boolean mayMutateArguments()
Returns true if this is a new/call that may mutate its arguments.
-
mayMutateGlobalStateOrThrow
public final boolean mayMutateGlobalStateOrThrow()
Returns true if this is a new/call that may mutate global state or throw.
-
isDeclaredConstantVar
public final boolean isDeclaredConstantVar()
Returns whether this variable is declared as a constant.The compiler considers a variable to be declared if:
- it is declared with the
constkeyword, or - It is declared with a jsdoc
@constannotation, or - The current coding convention considers it to be a constant.
Only valid to call on a name node.
- it is declared with the
-
setDeclaredConstantVar
public final void setDeclaredConstantVar(boolean value)
Sets this variable to be a declared constant.See
isDeclaredConstantVar()for the rules.
-
isInferredConstantVar
public final boolean isInferredConstantVar()
Returns whether this variable is inferred to be constant.The compiler infers a variable to be a constant if:
- It is assigned at its declaration site, and
- It is never reassigned during its lifetime, and
- It is not defined by an extern.
Only valid to call on a name node.
-
setInferredConstantVar
public final void setInferredConstantVar(boolean value)
Sets this variable to be an inferred constant. *See
isInferredConstantVar()for the rules.
-
isQuotedString
public boolean isQuotedString()
This should only be called for STRING nodes children of OBJECTLIT.
-
setQuotedString
public void setQuotedString()
This should only be called for STRING nodes children of OBJECTLIT.
-
isAdd
public final boolean isAdd()
AST type check methods
-
isSub
public final boolean isSub()
-
isAnd
public final boolean isAnd()
-
isArrayLit
public final boolean isArrayLit()
-
isArrayPattern
public final boolean isArrayPattern()
-
isAssign
public final boolean isAssign()
-
isAssignAdd
public final boolean isAssignAdd()
-
isNormalBlock
public final boolean isNormalBlock()
-
isBlock
public final boolean isBlock()
-
isRoot
public final boolean isRoot()
-
isAwait
public final boolean isAwait()
-
isBigInt
public final boolean isBigInt()
-
isBreak
public final boolean isBreak()
-
isCall
public final boolean isCall()
-
isCase
public final boolean isCase()
-
isCast
public final boolean isCast()
-
isCatch
public final boolean isCatch()
-
isClass
public final boolean isClass()
-
isClassMembers
public final boolean isClassMembers()
-
isComma
public final boolean isComma()
-
isComputedProp
public final boolean isComputedProp()
-
isContinue
public final boolean isContinue()
-
isConst
public final boolean isConst()
-
isDebugger
public final boolean isDebugger()
-
isDec
public final boolean isDec()
-
isDefaultCase
public final boolean isDefaultCase()
-
isDefaultValue
public final boolean isDefaultValue()
-
isDelProp
public final boolean isDelProp()
-
isDestructuringLhs
public final boolean isDestructuringLhs()
-
isDestructuringPattern
public final boolean isDestructuringPattern()
-
isDo
public final boolean isDo()
-
isEmpty
public final boolean isEmpty()
-
isExponent
public final boolean isExponent()
-
isAssignExponent
public final boolean isAssignExponent()
-
isExport
public final boolean isExport()
-
isExportSpec
public final boolean isExportSpec()
-
isExportSpecs
public final boolean isExportSpecs()
-
isExprResult
public final boolean isExprResult()
-
isFalse
public final boolean isFalse()
-
isVanillaFor
public final boolean isVanillaFor()
-
isForIn
public final boolean isForIn()
-
isForOf
public final boolean isForOf()
-
isForAwaitOf
public final boolean isForAwaitOf()
-
isFunction
public final boolean isFunction()
-
isGetterDef
public final boolean isGetterDef()
-
isGetElem
public final boolean isGetElem()
-
isGetProp
public final boolean isGetProp()
-
isHook
public final boolean isHook()
-
isIf
public final boolean isIf()
-
isImport
public final boolean isImport()
-
isImportMeta
public final boolean isImportMeta()
-
isImportStar
public final boolean isImportStar()
-
isImportSpec
public final boolean isImportSpec()
-
isImportSpecs
public final boolean isImportSpecs()
-
isIn
public final boolean isIn()
-
isInc
public final boolean isInc()
-
isInstanceOf
public final boolean isInstanceOf()
-
isInterfaceMembers
public final boolean isInterfaceMembers()
-
isRecordType
public final boolean isRecordType()
-
isCallSignature
public final boolean isCallSignature()
-
isIndexSignature
public final boolean isIndexSignature()
-
isLabel
public final boolean isLabel()
-
isLabelName
public final boolean isLabelName()
-
isLet
public final boolean isLet()
-
isMemberFunctionDef
public final boolean isMemberFunctionDef()
-
isMemberVariableDef
public final boolean isMemberVariableDef()
-
isModuleBody
public final boolean isModuleBody()
-
isName
public final boolean isName()
-
isNE
public final boolean isNE()
-
isNew
public final boolean isNew()
-
isNot
public final boolean isNot()
-
isNull
public final boolean isNull()
-
isNullishCoalesce
public final boolean isNullishCoalesce()
-
isNumber
public final boolean isNumber()
-
isObjectLit
public final boolean isObjectLit()
-
isObjectPattern
public final boolean isObjectPattern()
-
isOptChainCall
public final boolean isOptChainCall()
-
isOptChainGetElem
public final boolean isOptChainGetElem()
-
isOptChainGetProp
public final boolean isOptChainGetProp()
-
isOr
public final boolean isOr()
-
isParamList
public final boolean isParamList()
-
isRegExp
public final boolean isRegExp()
-
isRest
public final boolean isRest()
-
isObjectRest
public final boolean isObjectRest()
-
isReturn
public final boolean isReturn()
-
isScript
public final boolean isScript()
-
isSetterDef
public final boolean isSetterDef()
-
isSpread
public final boolean isSpread()
-
isString
public final boolean isString()
-
isStringKey
public final boolean isStringKey()
-
isSuper
public final boolean isSuper()
-
isSwitch
public final boolean isSwitch()
-
isTaggedTemplateLit
public final boolean isTaggedTemplateLit()
-
isTemplateLit
public final boolean isTemplateLit()
-
isTemplateLitString
public final boolean isTemplateLitString()
-
isTemplateLitSub
public final boolean isTemplateLitSub()
-
isThis
public final boolean isThis()
-
isThrow
public final boolean isThrow()
-
isTrue
public final boolean isTrue()
-
isTry
public final boolean isTry()
-
isTypeOf
public final boolean isTypeOf()
-
isVar
public final boolean isVar()
-
isVoid
public final boolean isVoid()
-
isWhile
public final boolean isWhile()
-
isWith
public final boolean isWith()
-
isYield
public final boolean isYield()
-
-