Package com.google.javascript.rhino
Class Node
- java.lang.Object
-
- com.google.javascript.rhino.Node
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable
public class Node extends java.lang.Object implements java.lang.Cloneable, 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.classNode.FileLevelJsDocBuilderAn inner class that provides back-door access to the license property of the JSDocInfo property for this node.static classNode.SideEffectFlagsA helper class for getting and setting the side-effect flags.
-
Field Summary
Fields Modifier and Type Field Description static 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 intDECR_FLAGstatic intDIRECT_EVALstatic intDIRECTIVESstatic intEMPTY_BLOCKstatic intFLAG_ARGUMENTS_UNMODIFIEDstatic intFLAG_GLOBAL_STATE_UNMODIFIEDstatic intFLAG_LOCAL_RESULTSstatic intFLAG_NO_THROWSstatic intFLAG_THIS_UNMODIFIEDstatic intFREE_CALLstatic intINCRDECR_PROPstatic intINFERRED_FUNCTIONstatic intINPUT_IDstatic intIS_CONSTANT_NAMEstatic intIS_DISPATCHERstatic intIS_NAMESPACEstatic intJSDOC_INFO_PROPstatic intLAST_PROPstatic intLENGTHstatic intMAX_COLUMN_NUMBERMAX_COLUMN_NUMBER represents the maximum column number that can be represented.static intNO_SIDE_EFFECTSstatic intOPT_ARG_NAMEstatic intORIGINALNAME_PROPstatic intPOST_FLAGstatic intQUOTED_PROPstatic intSIDE_EFFECT_FLAGSstatic intSIDE_EFFECTS_ALLstatic intSIDE_EFFECTS_FLAGS_MASKstatic intSLASH_Vstatic intSTATIC_SOURCE_FILEstatic intSYNTHETIC_BLOCK_PROPstatic intVAR_ARGS_NAME
-
Constructor Summary
Constructors Constructor Description Node(int nodeType)Node(int nodeType, int lineno, int charno)Node(int nodeType, Node child)Node(int nodeType, Node[] children)Node(int nodeType, Node[] children, int lineno, int charno)Node(int nodeType, Node child, int lineno, int charno)Node(int nodeType, Node left, Node right)Node(int nodeType, Node left, Node right, int lineno, int charno)Node(int nodeType, Node left, Node mid, Node right)Node(int nodeType, Node left, Node mid, Node right, int lineno, int charno)Node(int nodeType, Node left, Node mid, Node mid2, Node right)Node(int nodeType, Node left, Node mid, Node mid2, Node right, int lineno, int charno)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddChildAfter(Node newChild, Node node)Add 'child' 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)voidaddChildToBack(Node child)voidaddChildToFront(Node child)voidaddSuppression(java.lang.String warning)Adds a warning to be suppressed.voidappendStringTree(java.lang.Appendable appendable)java.lang.StringcheckTreeEquals(Node node2)Checks if the subtree under this node is the same as another subtree.java.lang.Iterable<Node>children()Return an iterable object that iterates over this node's children.NodecloneNode()NodeclonePropsFrom(Node other)Clone the properties from the provided node without copying the property object.NodecloneTree()NodecopyInformationFrom(Node other)Copies source file and name information from the other node given to the current node.NodecopyInformationFromForTree(Node other)Copies source file and name information from the other node to the entire tree rooted at this node.voiddetachChildren()Removes all children from this node and isolates the children from each other.NodedetachFromParent()Removes this node from its parent.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.booleangetBooleanProp(int propType)intgetCharno()NodegetChildAtIndex(int i)NodegetChildBefore(Node child)intgetChildCount()java.util.Set<java.lang.String>getDirectives()Returns the set of ES5 directives for this node.doublegetDouble()Can only be called when getType() == TokenStream.NUMBERintgetExistingIntProp(int propType)NodegetFirstChild()intgetIndexOfChild(Node child)InputIdgetInputId()intgetIntProp(int propType)Returns the integer value for the property, or 0 if the property is not defined.Node.FileLevelJsDocBuildergetJsDocBuilderForNode()JSDocInfogetJSDocInfo()Get theJSDocInfoattached to this node.JSTypegetJSType()NodegetLastChild()NodegetLastSibling()intgetLength()intgetLineno()NodegetNext()NodegetParent()java.lang.ObjectgetProp(int propType)java.lang.StringgetQualifiedName()This function takes a set of GETPROP nodes and produces a string that is each property separated by dots.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.intgetType()booleanhasChild(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().booleanisAdd()AST type check methodsbooleanisAnd()booleanisArrayLit()booleanisAssign()booleanisAssignAdd()booleanisBlock()booleanisBreak()booleanisCall()booleanisCase()booleanisCast()booleanisCatch()booleanisComma()booleanisContinue()booleanisDebugger()booleanisDec()booleanisDefaultCase()booleanisDelProp()booleanisDo()booleanisEmpty()booleanisEquivalentTo(Node node)Returns true if this node is equivalent semantically to anotherbooleanisEquivalentToTyped(Node node)Returns true if this node is equivalent semantically to another and the types are equivalent.booleanisExprResult()booleanisFalse()booleanisFor()booleanisFromExterns()booleanisFunction()booleanisGetElem()booleanisGetProp()booleanisGetterDef()booleanisHook()booleanisIf()booleanisIn()booleanisInc()booleanisInstanceOf()booleanisLabel()booleanisLabelName()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).booleanisName()booleanisNE()booleanisNew()booleanisNoSideEffectsCall()Returns true if this node is a function or constructor call that has no side effects.booleanisNot()booleanisNull()booleanisNumber()booleanisObjectLit()booleanisOnlyModifiesThisCall()booleanisOptionalArg()Returns whether this node is an optional argument node.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.booleanisRegExp()booleanisReturn()booleanisScript()booleanisSetterDef()booleanisString()booleanisStringKey()booleanisSwitch()booleanisSyntheticBlock()Returns whether this is a synthetic block that should not be considered a real source block.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.booleanisVar()booleanisVarArgs()Returns whether this node is a variable length argument node.booleanisVoid()booleanisWhile()booleanisWith()protected static intmergeLineCharNo(int lineno, int charno)Merges the line number and character number in one integer.static NodenewNumber(double number)static NodenewNumber(double number, int lineno, int charno)static NodenewString(int type, java.lang.String str)static NodenewString(int type, java.lang.String str, int lineno, int charno)static NodenewString(java.lang.String str)static NodenewString(java.lang.String str, int lineno, int charno)voidputBooleanProp(int propType, boolean value)voidputIntProp(int propType, int value)voidputProp(int 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.voidremoveProp(int propType)voidreplaceChild(Node child, Node newChild)Detaches child from Node and replaces it with newChild.voidreplaceChildAfter(Node prevChild, Node newChild)voidsetCharno(int charno)voidsetDirectives(java.util.Set<java.lang.String> val)Sets the ES5 directives on this node.voidsetDouble(double value)Can only be called when getType() == Token.NUMBERvoidsetInputId(InputId inputId)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.voidsetJSType(JSType jsType)voidsetLength(int length)voidsetLineno(int lineno)voidsetOptionalArg(boolean optionalArg)Sets whether this node is an optional argument node.voidsetQuotedString()This should only be called for STRING nodes children of OBJECTLIT.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.voidsetStaticSourceFile(StaticSourceFile file)voidsetString(java.lang.String value)Can only be called for a Token.STRING or Token.NAME.voidsetType(int type)voidsetVarArgs(boolean varArgs)Sets whether this node is a variable length argument node.voidsetWasEmptyNode(boolean val)Sets whether this is a synthetic block that should not be considered a real source block.java.lang.Iterable<Node>siblings()Return an iterable object that iterates over this node's siblings.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.booleanwasEmptyNode()Returns whether this is a synthetic block that should not be considered a real source block.
-
-
-
Field Detail
-
JSDOC_INFO_PROP
public static final int JSDOC_INFO_PROP
- See Also:
- Constant Field Values
-
VAR_ARGS_NAME
public static final int VAR_ARGS_NAME
- See Also:
- Constant Field Values
-
INCRDECR_PROP
public static final int INCRDECR_PROP
- See Also:
- Constant Field Values
-
QUOTED_PROP
public static final int QUOTED_PROP
- See Also:
- Constant Field Values
-
OPT_ARG_NAME
public static final int OPT_ARG_NAME
- See Also:
- Constant Field Values
-
SYNTHETIC_BLOCK_PROP
public static final int SYNTHETIC_BLOCK_PROP
- See Also:
- Constant Field Values
-
EMPTY_BLOCK
public static final int EMPTY_BLOCK
- See Also:
- Constant Field Values
-
ORIGINALNAME_PROP
public static final int ORIGINALNAME_PROP
- See Also:
- Constant Field Values
-
SIDE_EFFECT_FLAGS
public static final int SIDE_EFFECT_FLAGS
- See Also:
- Constant Field Values
-
IS_CONSTANT_NAME
public static final int IS_CONSTANT_NAME
- See Also:
- Constant Field Values
-
IS_NAMESPACE
public static final int IS_NAMESPACE
- See Also:
- Constant Field Values
-
IS_DISPATCHER
public static final int IS_DISPATCHER
- See Also:
- Constant Field Values
-
DIRECTIVES
public static final int DIRECTIVES
- See Also:
- Constant Field Values
-
DIRECT_EVAL
public static final int DIRECT_EVAL
- See Also:
- Constant Field Values
-
FREE_CALL
public static final int FREE_CALL
- See Also:
- Constant Field Values
-
STATIC_SOURCE_FILE
public static final int STATIC_SOURCE_FILE
- See Also:
- Constant Field Values
-
LENGTH
public static final int LENGTH
- See Also:
- Constant Field Values
-
INPUT_ID
public static final int INPUT_ID
- See Also:
- Constant Field Values
-
SLASH_V
public static final int SLASH_V
- See Also:
- Constant Field Values
-
INFERRED_FUNCTION
public static final int INFERRED_FUNCTION
- See Also:
- Constant Field Values
-
LAST_PROP
public static final int LAST_PROP
- See Also:
- Constant Field Values
-
DECR_FLAG
public static final int DECR_FLAG
- See Also:
- Constant Field Values
-
POST_FLAG
public static final int POST_FLAG
- See Also:
- Constant Field Values
-
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
-
FLAG_GLOBAL_STATE_UNMODIFIED
public static final int FLAG_GLOBAL_STATE_UNMODIFIED
- See Also:
- Constant Field Values
-
FLAG_THIS_UNMODIFIED
public static final int FLAG_THIS_UNMODIFIED
- See Also:
- Constant Field Values
-
FLAG_ARGUMENTS_UNMODIFIED
public static final int FLAG_ARGUMENTS_UNMODIFIED
- See Also:
- Constant Field Values
-
FLAG_NO_THROWS
public static final int FLAG_NO_THROWS
- See Also:
- Constant Field Values
-
FLAG_LOCAL_RESULTS
public static final int FLAG_LOCAL_RESULTS
- See Also:
- Constant Field Values
-
SIDE_EFFECTS_FLAGS_MASK
public static final int SIDE_EFFECTS_FLAGS_MASK
- See Also:
- Constant Field Values
-
SIDE_EFFECTS_ALL
public static final int SIDE_EFFECTS_ALL
- See Also:
- Constant Field Values
-
NO_SIDE_EFFECTS
public static final int NO_SIDE_EFFECTS
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Node
public Node(int nodeType)
-
Node
public Node(int nodeType, Node child)
-
Node
public Node(int nodeType, int lineno, int charno)
-
Node
public Node(int nodeType, Node child, int lineno, int charno)
-
Node
public Node(int nodeType, Node[] children, int lineno, int charno)
-
Node
public Node(int nodeType, Node[] children)
-
-
Method Detail
-
newNumber
public static Node newNumber(double number)
-
newNumber
public static Node newNumber(double number, int lineno, int charno)
-
newString
public static Node newString(java.lang.String str)
-
newString
public static Node newString(int type, java.lang.String str)
-
newString
public static Node newString(java.lang.String str, int lineno, int charno)
-
newString
public static Node newString(int type, java.lang.String str, int lineno, int charno)
-
getType
public int getType()
-
setType
public void setType(int type)
-
hasChildren
public boolean hasChildren()
-
getFirstChild
public Node getFirstChild()
-
getLastChild
public Node getLastChild()
-
getNext
public Node getNext()
-
getChildAtIndex
public Node getChildAtIndex(int i)
-
getIndexOfChild
public int getIndexOfChild(Node child)
-
getLastSibling
public Node getLastSibling()
-
addChildToFront
public void addChildToFront(Node child)
-
addChildToBack
public void addChildToBack(Node child)
-
addChildrenToFront
public void addChildrenToFront(Node children)
-
addChildrenToBack
public void addChildrenToBack(Node children)
-
addChildrenAfter
public void addChildrenAfter(Node children, Node node)
Add all children after 'node'.
-
removeChild
public void removeChild(Node child)
Detach a child from its parent and siblings.
-
replaceChild
public void replaceChild(Node child, Node newChild)
Detaches child from Node and replaces it with newChild.
-
clonePropsFrom
public 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.
-
removeProp
public void removeProp(int propType)
-
getProp
public java.lang.Object getProp(int propType)
-
getBooleanProp
public boolean getBooleanProp(int propType)
-
getIntProp
public int getIntProp(int propType)
Returns the integer value for the property, or 0 if the property is not defined.
-
getExistingIntProp
public int getExistingIntProp(int propType)
-
putProp
public void putProp(int propType, java.lang.Object value)
-
putBooleanProp
public void putBooleanProp(int propType, boolean value)
-
putIntProp
public void putIntProp(int propType, int value)
-
getDouble
public double getDouble() throws java.lang.UnsupportedOperationExceptionCan only be called when getType() == TokenStream.NUMBER- Throws:
java.lang.UnsupportedOperationException
-
setDouble
public void setDouble(double value) throws java.lang.UnsupportedOperationExceptionCan only be called when getType() == Token.NUMBER- Parameters:
value- value to set.- Throws:
java.lang.UnsupportedOperationException
-
getString
public java.lang.String getString() throws java.lang.UnsupportedOperationExceptionCan only be called when node has String context.- Throws:
java.lang.UnsupportedOperationException
-
setString
public void setString(java.lang.String value) throws java.lang.UnsupportedOperationExceptionCan only be called for a Token.STRING or Token.NAME.- Parameters:
value- the value to set.- Throws:
java.lang.UnsupportedOperationException
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
toString
public java.lang.String toString(boolean printSource, boolean printAnnotations, boolean printType)
-
toStringTree
public java.lang.String toStringTree()
-
appendStringTree
public void appendStringTree(java.lang.Appendable appendable) throws java.io.IOException- Throws:
java.io.IOException
-
setStaticSourceFile
public void setStaticSourceFile(StaticSourceFile file)
-
setSourceFileForTesting
public void setSourceFileForTesting(java.lang.String name)
Sets the source file to a non-extern file of the given name.
-
getSourceFileName
public java.lang.String getSourceFileName()
-
getStaticSourceFile
public StaticSourceFile getStaticSourceFile()
Returns the source file associated with this input. May be null
-
setInputId
public void setInputId(InputId inputId)
- Parameters:
inputId-
-
getInputId
public InputId getInputId()
- Returns:
- The Id of the CompilerInput associated with this Node.
-
isFromExterns
public boolean isFromExterns()
-
getLength
public int getLength()
-
setLength
public void setLength(int length)
-
getLineno
public int getLineno()
-
getCharno
public int getCharno()
-
getSourceOffset
public int getSourceOffset()
-
getSourcePosition
public int getSourcePosition()
-
setLineno
public void setLineno(int lineno)
-
setCharno
public void setCharno(int charno)
-
setSourceEncodedPosition
public void setSourceEncodedPosition(int sourcePosition)
-
setSourceEncodedPositionForTree
public 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 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 siblings, one can write
Node n = ...; for (Node child : n.children()) { ...
-
siblings
public java.lang.Iterable<Node> siblings()
Return an iterable object that iterates over this node's siblings. The iterator does not support the optional operation
Iterator.remove().To iterate over a node's siblings, one can write
Node n = ...; for (Node sibling : n.siblings()) { ...
-
getParent
public Node getParent()
-
getAncestor
public Node getAncestor(int level)
Gets the ancestor node relative to this.- Parameters:
level- 0 = this, 1 = the parent, etc.
-
getAncestors
public Node.AncestorIterable getAncestors()
Iterates all of the node's ancestors excluding itself.
-
hasOneChild
public 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.
-
hasMoreThanOneChild
public 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.
-
getChildCount
public int getChildCount()
-
hasChild
public boolean hasChild(Node child)
-
checkTreeEquals
public java.lang.String checkTreeEquals(Node node2)
Checks if the subtree under this node is the same as another subtree. Returns null if it's equal, or a message describing the differences.
-
isEquivalentTo
public boolean isEquivalentTo(Node node)
Returns true if this node is equivalent semantically to another
-
isEquivalentToTyped
public boolean isEquivalentToTyped(Node node)
Returns true if this node is equivalent semantically to another and the types are equivalent.
-
getQualifiedName
public 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.
-
isQualifiedName
public boolean isQualifiedName()
Returns whether a node corresponds to a simple or a qualified name, such asxora.b.corthis.a.
-
isUnscopedQualifiedName
public 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.
-
detachFromParent
public Node detachFromParent()
Removes this node from its parent. Equivalent to: node.getParent().removeChild();
-
removeFirstChild
public Node removeFirstChild()
Removes the first child of Node. Equivalent to: node.removeChild(node.getFirstChild());- Returns:
- The removed Node.
-
removeChildren
public Node removeChildren()
- Returns:
- A Node that is the head of the list of children.
-
detachChildren
public void detachChildren()
Removes all children from this node and isolates the children from each other.
-
cloneNode
public Node cloneNode()
- Returns:
- A detached clone of the Node, specifically excluding its children.
-
cloneTree
public Node cloneTree()
- Returns:
- A detached clone of the Node and all its children.
-
copyInformationFrom
public Node copyInformationFrom(Node other)
Copies source file and name information from the other node given to the current node. Used for maintaining debug information across node append and remove operations.- Returns:
- this
-
copyInformationFromForTree
public Node copyInformationFromForTree(Node other)
Copies source file and name information from the other node to the entire tree rooted at this node.- Returns:
- this
-
useSourceInfoFrom
public Node useSourceInfoFrom(Node other)
Overwrite all the source information in this node with that ofother.
-
useSourceInfoFromForTree
public Node useSourceInfoFromForTree(Node other)
Overwrite all the source information in this node and its subtree with that ofother.
-
useSourceInfoIfMissingFrom
public Node useSourceInfoIfMissingFrom(Node other)
Overwrite all the source information in this node with that ofotheriff the source info is missing.
-
useSourceInfoIfMissingFromForTree
public Node useSourceInfoIfMissingFromForTree(Node other)
Overwrite all the source information in this node and its subtree with that ofotheriff the source info is missing.
-
getJSType
public JSType getJSType()
-
setJSType
public void setJSType(JSType jsType)
-
getJsDocBuilderForNode
public Node.FileLevelJsDocBuilder getJsDocBuilderForNode()
-
getJSDocInfo
public JSDocInfo getJSDocInfo()
Get theJSDocInfoattached to this node.- Returns:
- the information or
nullif no JSDoc is attached to this node
-
setVarArgs
public void setVarArgs(boolean varArgs)
Sets whether this node is a variable length argument node. This method is meaningful only onToken.NAMEnodes used to define aToken.FUNCTION's argument list.
-
isVarArgs
public boolean isVarArgs()
Returns whether this node is a variable length argument node. This method's return value is meaningful only onToken.NAMEnodes used to define aToken.FUNCTION's argument list.
-
setOptionalArg
public void setOptionalArg(boolean optionalArg)
Sets whether this node is an optional argument node. This method is meaningful only onToken.NAMEnodes used to define aToken.FUNCTION's argument list.
-
isOptionalArg
public boolean isOptionalArg()
Returns whether this node is an optional argument node. This method's return value is meaningful only onToken.NAMEnodes used to define aToken.FUNCTION's argument list.
-
setIsSyntheticBlock
public void setIsSyntheticBlock(boolean val)
Sets whether this is a synthetic block that should not be considered a real source block.
-
isSyntheticBlock
public boolean isSyntheticBlock()
Returns whether this is a synthetic block that should not be considered a real source block.
-
setDirectives
public void setDirectives(java.util.Set<java.lang.String> val)
Sets the ES5 directives on this node.
-
getDirectives
public java.util.Set<java.lang.String> getDirectives()
Returns the set of ES5 directives for this node.
-
addSuppression
public void addSuppression(java.lang.String warning)
Adds a warning to be suppressed. This is indistinguishable from having a@suppresstag in the code.
-
setWasEmptyNode
public void setWasEmptyNode(boolean val)
Sets whether this is a synthetic block that should not be considered a real source block.
-
wasEmptyNode
public boolean wasEmptyNode()
Returns whether this is a synthetic block that should not be considered a real source block.
-
setSideEffectFlags
public void setSideEffectFlags(int flags)
Marks this function or constructor call's side effect flags. This property is only meaningful forToken.CALLandToken.NEWnodes.
-
setSideEffectFlags
public void setSideEffectFlags(Node.SideEffectFlags flags)
-
getSideEffectFlags
public int getSideEffectFlags()
Returns the side effects flags for this node.
-
isOnlyModifiesThisCall
public boolean isOnlyModifiesThisCall()
- Returns:
- Whether the only side-effect is "modifies this"
-
isNoSideEffectsCall
public boolean isNoSideEffectsCall()
Returns true if this node is a function or constructor call that has no side effects.
-
isLocalResultCall
public 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).
-
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 boolean isAdd()
AST type check methods
-
isAnd
public boolean isAnd()
-
isArrayLit
public boolean isArrayLit()
-
isAssign
public boolean isAssign()
-
isAssignAdd
public boolean isAssignAdd()
-
isBlock
public boolean isBlock()
-
isBreak
public boolean isBreak()
-
isCall
public boolean isCall()
-
isCase
public boolean isCase()
-
isCast
public boolean isCast()
-
isCatch
public boolean isCatch()
-
isComma
public boolean isComma()
-
isContinue
public boolean isContinue()
-
isDebugger
public boolean isDebugger()
-
isDec
public boolean isDec()
-
isDefaultCase
public boolean isDefaultCase()
-
isDelProp
public boolean isDelProp()
-
isDo
public boolean isDo()
-
isEmpty
public boolean isEmpty()
-
isExprResult
public boolean isExprResult()
-
isFalse
public boolean isFalse()
-
isFor
public boolean isFor()
-
isFunction
public boolean isFunction()
-
isGetterDef
public boolean isGetterDef()
-
isGetElem
public boolean isGetElem()
-
isGetProp
public boolean isGetProp()
-
isHook
public boolean isHook()
-
isIf
public boolean isIf()
-
isIn
public boolean isIn()
-
isInc
public boolean isInc()
-
isInstanceOf
public boolean isInstanceOf()
-
isLabel
public boolean isLabel()
-
isLabelName
public boolean isLabelName()
-
isName
public boolean isName()
-
isNE
public boolean isNE()
-
isNew
public boolean isNew()
-
isNot
public boolean isNot()
-
isNull
public boolean isNull()
-
isNumber
public boolean isNumber()
-
isObjectLit
public boolean isObjectLit()
-
isOr
public boolean isOr()
-
isParamList
public boolean isParamList()
-
isRegExp
public boolean isRegExp()
-
isReturn
public boolean isReturn()
-
isScript
public boolean isScript()
-
isSetterDef
public boolean isSetterDef()
-
isString
public boolean isString()
-
isStringKey
public boolean isStringKey()
-
isSwitch
public boolean isSwitch()
-
isThis
public boolean isThis()
-
isThrow
public boolean isThrow()
-
isTrue
public boolean isTrue()
-
isTry
public boolean isTry()
-
isTypeOf
public boolean isTypeOf()
-
isVar
public boolean isVar()
-
isVoid
public boolean isVoid()
-
isWhile
public boolean isWhile()
-
isWith
public boolean isWith()
-
-