public class Node
extends java.lang.Object
implements java.io.Serializable
Type | Property and Description |
---|---|
boolean |
isShorthand
Gets the value of the property shorthandProperty.
|
Modifier and Type | Class and Description |
---|---|
static class |
Node.AncestorIterable
Iterator to go up the ancestor tree.
|
static class |
Node.SideEffectFlags
A helper class for getting and setting the side-effect flags.
|
static class |
Node.TypeDeclarationNode
Represents a node in the type declaration AST.
|
Modifier and Type | Field and Description |
---|---|
static byte |
ACCESS_MODIFIER |
static byte |
ADDED_BLOCK |
static byte |
ANALYZED_DURING_GTI |
static byte |
ARROW_FN |
static byte |
ASYNC_FN |
static byte |
CHANGE_TIME |
static int |
COLUMN_BITS
COLUMN_BITS represents how many of the lower-order bits of
sourcePosition are reserved for storing the column number.
|
static int |
COLUMN_MASK
COLUMN_MASK stores a value where bits storing the column number
are set, and bits storing the line are not set.
|
static byte |
COMPUTED_PROP_GETTER |
static byte |
COMPUTED_PROP_METHOD |
static byte |
COMPUTED_PROP_SETTER |
static byte |
COMPUTED_PROP_VARIABLE |
static byte |
CONSTANT_PROPERTY_DEF |
static byte |
CONSTRUCT_SIGNATURE |
static byte |
DECLARED_TYPE_EXPR |
static byte |
DELETED |
static byte |
DIRECT_EVAL |
static byte |
DIRECTIVES |
static byte |
ES6_MODULE |
static byte |
EXPORT_ALL_FROM |
static byte |
EXPORT_DEFAULT |
static byte |
FEATURE_SET |
static int |
FLAG_ARGUMENTS_UNMODIFIED |
static int |
FLAG_GLOBAL_STATE_UNMODIFIED |
static int |
FLAG_LOCAL_RESULTS |
static int |
FLAG_NO_THROWS |
static int |
FLAG_THIS_UNMODIFIED |
static byte |
FREE_CALL |
static byte |
GENERATOR_FN |
static byte |
GENERATOR_MARKER |
static byte |
GENERATOR_SAFE |
static byte |
GENERIC_TYPE_LIST |
static byte |
GOOG_MODULE |
static byte |
GOOG_MODULE_REQUIRE |
static byte |
IMPLEMENTS |
static byte |
INCRDECR_PROP |
static byte |
INFERRED_FUNCTION |
static byte |
INPUT_ID |
static byte |
IS_CONSTANT_NAME |
static byte |
IS_CONSTANT_VAR |
static byte |
IS_ES6_CLASS |
static byte |
IS_MODULE_NAME |
static byte |
IS_NAMESPACE |
static byte |
IS_SHORTHAND_PROPERTY |
static byte |
IS_UNUSED_PARAMETER |
static byte |
JSDOC_INFO_PROP |
static int |
MAX_COLUMN_NUMBER
MAX_COLUMN_NUMBER represents the maximum column number that can
be represented.
|
static byte |
MODULE_ALIAS |
static byte |
MODULE_EXPORT |
static int |
NO_SIDE_EFFECTS |
static byte |
NON_INDEXABLE |
static byte |
OPT_ARG_NAME |
static byte |
OPT_ES6_TYPED |
static byte |
ORIGINALNAME_PROP |
protected Node |
parent |
static byte |
PARSE_RESULTS |
static byte |
QUOTED_PROP |
static byte |
RAW_STRING_VALUE |
static byte |
REFLECTED_OBJECT |
static byte |
SIDE_EFFECT_FLAGS |
static int |
SIDE_EFFECTS_ALL |
static int |
SIDE_EFFECTS_FLAGS_MASK |
static byte |
SLASH_V |
static byte |
STATIC_MEMBER |
static byte |
STATIC_SOURCE_FILE |
static byte |
SYNTHETIC_BLOCK_PROP |
static byte |
TRANSPILED |
static byte |
TYPE_BEFORE_CAST |
static byte |
VAR_ARGS_NAME |
static byte |
WAS_PREVIOUSLY_PROVIDED |
static byte |
YIELD_ALL |
Constructor and 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) |
Modifier and Type | Method and Description |
---|---|
void |
addChildAfter(Node newChild,
Node node)
Add 'newChild' after 'node'.
|
void |
addChildBefore(Node newChild,
Node node)
Add 'child' before 'node'.
|
void |
addChildrenAfter(Node children,
Node node)
Add all children after 'node'.
|
void |
addChildrenToBack(Node children) |
void |
addChildrenToFront(Node children)
Add all children to the front of this node.
|
void |
addChildToBack(Node child) |
void |
addChildToFront(Node child) |
void |
appendStringTree(java.lang.Appendable appendable) |
java.lang.String |
checkTreeEquals(Node actual)
Checks if the subtree under this node is the same as another subtree.
|
java.lang.String |
checkTreeEqualsIncludingJsDoc(Node actual)
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.
|
Node |
cloneNode() |
protected Node |
cloneNode(boolean cloneTypeExprs) |
Node |
clonePropsFrom(Node other)
Clone the properties from the provided node without copying
the property object.
|
Node |
cloneTree() |
Node |
cloneTree(boolean cloneTypeExprs) |
Node |
detach()
Removes this node from its parent.
|
void |
detachChildren()
Removes all children from this node and isolates the children from each
other.
|
Node |
detachFromParent()
Removes this node from its parent.
|
protected static int |
extractCharno(int lineCharNo)
Extracts the character number and character number from a merged line
char number (see
mergeLineCharNo(int, int) ). |
protected static int |
extractLineno(int lineCharNo)
Extracts the line number and character number from a merged line char
number (see
mergeLineCharNo(int, int) ). |
Node |
getAncestor(int level)
Gets the ancestor node relative to this.
|
Node.AncestorIterable |
getAncestors()
Iterates all of the node's ancestors excluding itself.
|
boolean |
getBooleanProp(byte propType) |
int |
getChangeTime()
Returns the time of the last change for this node
|
int |
getCharno() |
Node |
getChildAtIndex(int i)
Gets the ith child, note that this is O(N) where N is the number of children.
|
Node |
getChildBefore(Node child) |
int |
getChildCount() |
java.lang.String |
getCookedString()
Can only be called when getType() == Token.TEMPLATELIT_STRING
|
Node.TypeDeclarationNode |
getDeclaredTypeExpression()
Returns the syntactical type specified on this node.
|
java.util.Set<java.lang.String> |
getDirectives()
Returns the set of ES5 directives for this node.
|
double |
getDouble()
Can only be called when getType() == TokenStream.NUMBER
|
int |
getExistingIntProp(byte propType) |
Node |
getFirstChild() |
Node |
getFirstFirstChild()
Get the first child of the first child.
|
Node |
getGrandparent() |
int |
getIndexOfChild(Node child)
Gets the index of a child, note that this is O(N) where N is the number of children.
|
InputId |
getInputId() |
int |
getIntProp(byte propType)
Returns the integer value for the property, or 0 if the property
is not defined.
|
JSDocInfo |
getJSDocInfo()
Get the
JSDocInfo attached to this node. |
JSType |
getJSType()
Returns the compiled inferred type on this node.
|
JSType |
getJSTypeBeforeCast()
Returns the type of this node before casting.
|
Node |
getLastChild() |
int |
getLength() |
int |
getLineno() |
Node |
getNext() |
Node |
getOnlyChild() |
java.lang.String |
getOriginalName()
The original name of this node, if the node has been renamed.
|
java.lang.String |
getOriginalQualifiedName()
This function takes a set of GETPROP nodes and produces a string that is each property
separated by dots.
|
Node |
getParent() |
Node |
getPrevious() |
java.lang.Object |
getProp(byte propType) |
java.lang.String |
getQualifiedName()
This function takes a set of GETPROP nodes and produces a string that is each property
separated by dots.
|
java.lang.String |
getRawString()
Can only be called when getType() == Token.TEMPLATELIT_STRING
|
Node |
getSecondChild() |
int |
getSideEffectFlags()
Returns the side effects flags for this node.
|
java.lang.String |
getSourceFileName() |
int |
getSourceOffset() |
int |
getSourcePosition() |
StaticSourceFile |
getStaticSourceFile()
Returns the source file associated with this input.
|
java.lang.String |
getString()
Can only be called when node has String context.
|
Token |
getToken() |
boolean |
hasChild(Node child) |
boolean |
hasChildren() |
boolean |
hasMoreThanOneChild()
Check for more than one child more efficiently than by iterating over all
the children as is done with Node.getChildCount().
|
boolean |
hasOneChild()
Check for one child more efficiently than by iterating over all the
children as is done with Node.getChildCount().
|
boolean |
hasProps() |
boolean |
hasTwoChildren()
Check for two children more efficiently than
getChildCount() == 2 |
boolean |
hasXChildren(int x)
Check for has exactly the number of specified children.
|
boolean |
hasZeroOrOneChild()
Check for zero or one child more efficiently than by iterating over all the
children as is done with Node.getChildCount().
|
boolean |
isAdd()
AST type check methods
|
boolean |
isAddedBlock()
Returns whether this is an added block that should not be considered
a real source block.
|
boolean |
isAnd() |
boolean |
isArrayLit() |
boolean |
isArrayPattern() |
boolean |
isArrowFunction()
Returns whether this node is a arrow function node.
|
boolean |
isAssign() |
boolean |
isAssignAdd() |
boolean |
isAsyncFunction()
Returns whether this is an async function node.
|
boolean |
isAsyncGeneratorFunction()
Returns whether this is an async generator function node.
|
boolean |
isAwait() |
boolean |
isBlock() |
boolean |
isBreak() |
boolean |
isCall() |
boolean |
isCallSignature() |
boolean |
isCase() |
boolean |
isCast() |
boolean |
isCatch() |
boolean |
isClass() |
boolean |
isClassMembers() |
boolean |
isComma() |
boolean |
isComputedProp() |
boolean |
isConst() |
boolean |
isContinue() |
boolean |
isDebugger() |
boolean |
isDec() |
boolean |
isDefaultCase() |
boolean |
isDefaultValue() |
boolean |
isDeleted() |
boolean |
isDelProp() |
boolean |
isDescendantOf(Node node) |
boolean |
isDestructuringLhs() |
boolean |
isDestructuringPattern() |
boolean |
isDo() |
boolean |
isEmpty() |
boolean |
isEquivalentTo(Node node)
Returns true if this node is equivalent semantically to another
|
boolean |
isEquivalentTo(Node node,
boolean compareType,
boolean recurse,
boolean jsDoc,
boolean sideEffect) |
boolean |
isEquivalentToShallow(Node node)
Checks equivalence without going into child nodes
|
boolean |
isEquivalentToTyped(Node node)
Returns true if this node is equivalent semantically to another and the types are equivalent.
|
boolean |
isEquivalentWithSideEffectsTo(Node node)
Returns true if this node is equivalent semantically to another including side effects.
|
boolean |
isEquivalentWithSideEffectsToShallow(Node node)
Returns true if this node is equivalent semantically to another including side effects.
|
boolean |
isEs6Class()
Returns true if this is or ever was a CLASS node (i.e.
|
boolean |
isExport() |
boolean |
isExportSpec() |
boolean |
isExportSpecs() |
boolean |
isExprResult() |
boolean |
isFalse() |
boolean |
isFirstChildOf(Node possibleParent) |
boolean |
isForAwaitOf() |
boolean |
isForIn() |
boolean |
isForOf() |
boolean |
isFromExterns() |
boolean |
isFunction() |
boolean |
isGeneratorFunction()
Returns whether this node is a generator function node.
|
boolean |
isGeneratorMarker()
Returns whether this node was marked as containing YIELD nodes.
|
boolean |
isGeneratorSafe()
Used when translating ES6 generators.
|
boolean |
isGetElem() |
boolean |
isGetProp() |
boolean |
isGetterDef() |
boolean |
isHook() |
boolean |
isIf() |
boolean |
isImport() |
boolean |
isImportSpec() |
boolean |
isImportSpecs() |
boolean |
isImportStar() |
boolean |
isIn() |
boolean |
isInc() |
boolean |
isIndexable()
Whether this node should be indexed by static analysis / code indexing tools.
|
boolean |
isIndexSignature() |
boolean |
isInstanceOf() |
boolean |
isInterfaceMembers() |
boolean |
isLabel() |
boolean |
isLabelName() |
boolean |
isLet() |
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).
|
boolean |
isMemberFunctionDef() |
boolean |
isMemberVariableDef() |
boolean |
isModuleBody() |
boolean |
isName() |
boolean |
isNE() |
boolean |
isNew() |
boolean |
isNormalBlock() |
boolean |
isNoSideEffectsCall()
Returns true if this node is a function or constructor call that
has no side effects.
|
boolean |
isNot() |
boolean |
isNull() |
boolean |
isNumber() |
boolean |
isObjectLit() |
boolean |
isObjectPattern() |
boolean |
isOnlyChildOf(Node possibleParent) |
boolean |
isOnlyModifiesArgumentsCall() |
boolean |
isOnlyModifiesThisCall() |
boolean |
isOptionalArg()
Returns whether this node is an optional argument node.
|
boolean |
isOptionalEs6Typed()
Returns whether this node is an optional node in the ES6 Typed syntax.
|
boolean |
isOr() |
boolean |
isParamList() |
boolean |
isQualifiedName()
Returns whether a node corresponds to a simple or a qualified name, such as
x or a.b.c or this.a . |
boolean |
isQuotedString()
This should only be called for STRING nodes children of OBJECTLIT.
|
boolean |
isRecordType() |
boolean |
isRegExp() |
boolean |
isRest() |
boolean |
isReturn() |
boolean |
isRoot() |
boolean |
isScript() |
boolean |
isSecondChildOf(Node possibleParent) |
boolean |
isSetterDef() |
boolean |
isShorthandProperty()
Gets the value of the property shorthandProperty.
|
boolean |
isSpread() |
boolean |
isStaticMember()
Returns whether this node is a static member node.
|
boolean |
isString() |
boolean |
isStringKey() |
boolean |
isSub() |
boolean |
isSuper() |
boolean |
isSwitch() |
boolean |
isSyntheticBlock()
Returns whether this is a synthetic block that should not be considered
a real source block.
|
boolean |
isTaggedTemplateLit() |
boolean |
isTemplateLit() |
boolean |
isTemplateLitString() |
boolean |
isTemplateLitSub() |
boolean |
isThis() |
boolean |
isThrow() |
boolean |
isTrue() |
boolean |
isTry() |
boolean |
isTypeOf() |
boolean |
isUnscopedQualifiedName()
Returns whether a node corresponds to a simple or a qualified name without
a "this" reference, such as
a.b.c , but not this.a
. |
boolean |
isUnusedParameter() |
boolean |
isValidAssignmentTarget() |
boolean |
isVanillaFor() |
boolean |
isVar() |
boolean |
isVarArgs()
Returns whether this node is a variable length argument node.
|
boolean |
isVoid() |
boolean |
isWhile() |
boolean |
isWith() |
boolean |
isYield() |
boolean |
isYieldAll()
Returns whether this node is a generator node.
|
void |
makeNonIndexable() |
void |
makeNonIndexableRecursive() |
boolean |
matchesQualifiedName(Node n)
Returns whether a node matches a simple or a qualified name, such as
x or
a.b.c or this.a . |
boolean |
matchesQualifiedName(java.lang.String name)
Returns whether a node matches a simple or a qualified name, such as
x or a.b.c or this.a . |
boolean |
mayMutateArguments()
Returns true if this is a new/call that may mutate its arguments.
|
boolean |
mayMutateGlobalStateOrThrow()
Returns true if this is a new/call that may mutate global state or throw.
|
protected static int |
mergeLineCharNo(int lineno,
int charno)
Merges the line number and character number in one integer.
|
static Node |
newNumber(double number) |
static Node |
newNumber(double number,
int lineno,
int charno) |
static Node |
newString(java.lang.String str) |
static Node |
newString(java.lang.String str,
int lineno,
int charno) |
static Node |
newString(Token token,
java.lang.String str) |
static Node |
newString(Token token,
java.lang.String str,
int lineno,
int charno) |
static Node |
newTemplateLitString(java.lang.String cooked,
java.lang.String raw) |
void |
putBooleanProp(byte propType,
boolean value) |
void |
putIntProp(byte propType,
int value) |
void |
putProp(byte propType,
java.lang.Object value) |
void |
removeChild(Node child)
Detach a child from its parent and siblings.
|
Node |
removeChildAfter(Node prev) |
Node |
removeChildren() |
Node |
removeFirstChild()
Removes the first child of Node.
|
Node |
removeFirstOrChildAfter(Node prev)
Remove the child after the given child, or the first child if given null.
|
void |
removeProp(byte propType) |
void |
replaceChild(Node child,
Node newChild)
Detaches child from Node and replaces it with newChild.
|
void |
replaceChildAfter(Node prevChild,
Node newChild) |
void |
replaceFirstOrChildAfter(Node prev,
Node newChild)
Detaches the child after the given child, or the first child if prev is null.
|
void |
replaceWith(Node newNode)
Detaches Node and replaces it with newNode.
|
void |
setChangeTime(int time)
This node was last changed at
time |
void |
setCharno(int charno) |
void |
setDeclaredTypeExpression(Node.TypeDeclarationNode typeExpression)
Sets the syntactical type specified on this node.
|
void |
setDeleted(boolean deleted) |
void |
setDirectives(java.util.Set<java.lang.String> val)
Sets the ES5 directives on this node.
|
void |
setDouble(double value)
Can only be called when getType() == Token.NUMBER
|
void |
setGeneratorMarker(boolean isGeneratorMarker)
Sets whether this node subtree contains YIELD nodes.
|
void |
setGeneratorSafe(boolean isGeneratorSafe) |
void |
setInputId(InputId inputId) |
void |
setIsAddedBlock(boolean val)
Sets whether this is an added block that should not be considered
a real source block.
|
void |
setIsArrowFunction(boolean isArrow)
Sets whether this node is a arrow function node.
|
void |
setIsAsyncFunction(boolean isAsync)
Sets whether this node is an async function node.
|
void |
setIsGeneratorFunction(boolean isGenerator)
Sets whether this node is a generator node.
|
void |
setIsSyntheticBlock(boolean val)
Sets whether this is a synthetic block that should not be considered
a real source block.
|
Node |
setJSDocInfo(JSDocInfo info)
Sets the
JSDocInfo attached to this node. |
Node |
setJSType(JSType jstype) |
void |
setJSTypeBeforeCast(JSType type)
Sets the type of this node before casting.
|
void |
setLength(int length) |
void |
setLineno(int lineno) |
void |
setOptionalArg(boolean optionalArg)
Sets whether this node is an optional argument node.
|
void |
setOriginalName(java.lang.String originalName) |
void |
setQuotedString()
This should only be called for STRING nodes children of OBJECTLIT.
|
void |
setShorthandProperty(boolean shorthand)
Sets the isShorthandProperty annotation.
|
void |
setSideEffectFlags(int flags)
Marks this function or constructor call's side effect flags.
|
void |
setSideEffectFlags(Node.SideEffectFlags flags) |
void |
setSourceEncodedPosition(int sourcePosition) |
void |
setSourceEncodedPositionForTree(int sourcePosition) |
void |
setSourceFileForTesting(java.lang.String name)
Sets the source file to a non-extern file of the given name.
|
void |
setStaticMember(boolean isStatic)
Sets whether this node is a static member node.
|
void |
setStaticSourceFile(StaticSourceFile file) |
void |
setStaticSourceFileFrom(Node other) |
void |
setString(java.lang.String value)
Can only be called for a Token.STRING or Token.NAME.
|
void |
setToken(Token token) |
void |
setUnusedParameter(boolean unused) |
void |
setVarArgs(boolean varArgs)
Sets whether this node is a variable length argument node.
|
void |
setYieldAll(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.
|
Node |
srcref(Node other) |
Node |
srcrefTree(Node other) |
java.lang.String |
toString() |
java.lang.String |
toString(boolean printSource,
boolean printAnnotations,
boolean printType) |
java.lang.String |
toStringTree() |
Node |
useSourceInfoFrom(Node other)
Overwrite all the source information in this node with
that of
other . |
Node |
useSourceInfoFromForTree(Node other)
Overwrite all the source information in this node and its subtree with
that of
other . |
Node |
useSourceInfoIfMissingFrom(Node other)
Overwrite all the source information in this node with
that of
other iff the source info is missing. |
Node |
useSourceInfoIfMissingFromForTree(Node other)
Overwrite all the source information in this node and its subtree with
that of
other iff the source info is missing. |
public final boolean isShorthandProperty
public static final byte JSDOC_INFO_PROP
public static final byte VAR_ARGS_NAME
public static final byte INCRDECR_PROP
public static final byte QUOTED_PROP
public static final byte OPT_ARG_NAME
public static final byte SYNTHETIC_BLOCK_PROP
public static final byte ADDED_BLOCK
public static final byte ORIGINALNAME_PROP
public static final byte SIDE_EFFECT_FLAGS
public static final byte IS_CONSTANT_NAME
public static final byte IS_NAMESPACE
public static final byte DIRECTIVES
public static final byte DIRECT_EVAL
public static final byte FREE_CALL
public static final byte STATIC_SOURCE_FILE
public static final byte INPUT_ID
public static final byte SLASH_V
public static final byte INFERRED_FUNCTION
public static final byte CHANGE_TIME
public static final byte REFLECTED_OBJECT
public static final byte STATIC_MEMBER
public static final byte GENERATOR_FN
public static final byte ARROW_FN
public static final byte ASYNC_FN
public static final byte YIELD_ALL
public static final byte EXPORT_DEFAULT
public static final byte EXPORT_ALL_FROM
public static final byte IS_CONSTANT_VAR
public static final byte GENERATOR_MARKER
public static final byte GENERATOR_SAFE
public static final byte RAW_STRING_VALUE
public static final byte COMPUTED_PROP_METHOD
public static final byte COMPUTED_PROP_GETTER
public static final byte COMPUTED_PROP_SETTER
public static final byte COMPUTED_PROP_VARIABLE
public static final byte ANALYZED_DURING_GTI
public static final byte CONSTANT_PROPERTY_DEF
public static final byte DECLARED_TYPE_EXPR
public static final byte TYPE_BEFORE_CAST
public static final byte OPT_ES6_TYPED
public static final byte GENERIC_TYPE_LIST
public static final byte IMPLEMENTS
public static final byte CONSTRUCT_SIGNATURE
public static final byte ACCESS_MODIFIER
public static final byte NON_INDEXABLE
public static final byte PARSE_RESULTS
public static final byte GOOG_MODULE
public static final byte GOOG_MODULE_REQUIRE
public static final byte FEATURE_SET
public static final byte IS_MODULE_NAME
public static final byte WAS_PREVIOUSLY_PROVIDED
public static final byte IS_ES6_CLASS
public static final byte TRANSPILED
public static final byte DELETED
public static final byte MODULE_ALIAS
public static final byte IS_UNUSED_PARAMETER
public static final byte MODULE_EXPORT
public static final byte IS_SHORTHAND_PROPERTY
public static final byte ES6_MODULE
public static final int COLUMN_BITS
public static final int MAX_COLUMN_NUMBER
public static final int COLUMN_MASK
@Nullable protected transient Node parent
public static final int FLAG_GLOBAL_STATE_UNMODIFIED
public static final int FLAG_THIS_UNMODIFIED
public static final int FLAG_ARGUMENTS_UNMODIFIED
public static final int FLAG_NO_THROWS
public static final int FLAG_LOCAL_RESULTS
public static final int SIDE_EFFECTS_FLAGS_MASK
public static final int SIDE_EFFECTS_ALL
public static final int NO_SIDE_EFFECTS
public Node(Token nodeType)
public Node(Token nodeType, int lineno, int charno)
public static Node newNumber(double number)
public static Node newNumber(double number, int lineno, int charno)
public static Node newString(java.lang.String str)
public static Node newString(java.lang.String str, int lineno, int charno)
public static Node newTemplateLitString(java.lang.String cooked, java.lang.String raw)
public final Token getToken()
public final void setToken(Token token)
public final boolean hasChildren()
public final Node getOnlyChild()
@Nullable public final Node getFirstChild()
@Nullable public final Node getFirstFirstChild()
@Nullable public final Node getSecondChild()
@Nullable public final Node getLastChild()
@Nullable public final Node getNext()
@Nullable public final Node getPrevious()
public final Node getChildAtIndex(int i)
i
- The indexpublic final int getIndexOfChild(Node child)
child
- The childpublic final void addChildToFront(Node child)
public final void addChildToBack(Node child)
public final void addChildrenToFront(@Nullable Node children)
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.public final void addChildrenToBack(Node children)
public final void addChildBefore(Node newChild, Node node)
public final void addChildAfter(Node newChild, @Nullable Node node)
public final void addChildrenAfter(@Nullable Node children, @Nullable Node node)
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.public final void removeChild(Node child)
public final void replaceWith(Node newNode)
public final void replaceChild(Node child, Node newChild)
public final void replaceFirstOrChildAfter(@Nullable Node prev, Node newChild)
public final Node clonePropsFrom(Node other)
other
- The node to clone properties from.public final boolean hasProps()
public final void removeProp(byte propType)
@Nullable public final java.lang.Object getProp(byte propType)
public final boolean getBooleanProp(byte propType)
public final int getIntProp(byte propType)
public final int getExistingIntProp(byte propType)
public final void putProp(byte propType, @Nullable java.lang.Object value)
public final void putBooleanProp(byte propType, boolean value)
public final void putIntProp(byte propType, int value)
public final void setDeclaredTypeExpression(Node.TypeDeclarationNode typeExpression)
typeExpression
- @Nullable public final Node.TypeDeclarationNode getDeclaredTypeExpression()
getJSType()
which returns the compiler-inferred type.public final void setJSTypeBeforeCast(JSType type)
@Nullable public final JSType getJSTypeBeforeCast()
public double getDouble()
public void setDouble(double value)
value
- value to set.public java.lang.String getString()
public void setString(java.lang.String value)
value
- the value to set.public java.lang.String getRawString()
@Nullable public java.lang.String getCookedString()
public final java.lang.String toString()
toString
in class java.lang.Object
public final java.lang.String toString(boolean printSource, boolean printAnnotations, boolean printType)
@CheckReturnValue public final java.lang.String toStringTree()
public final void appendStringTree(java.lang.Appendable appendable) throws java.io.IOException
java.io.IOException
public final void setStaticSourceFileFrom(Node other)
public final void setStaticSourceFile(@Nullable StaticSourceFile file)
public final void setSourceFileForTesting(java.lang.String name)
@Nullable public java.lang.String getSourceFileName()
@Nullable public StaticSourceFile getStaticSourceFile()
public void setInputId(InputId inputId)
inputId
- @Nullable public InputId getInputId()
@Nullable public java.lang.String getOriginalName()
public void setOriginalName(java.lang.String originalName)
public final boolean isIndexable()
public final void makeNonIndexable()
public final void makeNonIndexableRecursive()
public final boolean isFromExterns()
public final int getLength()
public final void setLength(int length)
public final int getLineno()
public final int getCharno()
public int getSourceOffset()
public final int getSourcePosition()
public final void setLineno(int lineno)
public final void setCharno(int charno)
public final void setSourceEncodedPosition(int sourcePosition)
public final void setSourceEncodedPositionForTree(int sourcePosition)
protected static int mergeLineCharNo(int lineno, int charno)
212-1
it is
adjusted to 212-1
.protected static int extractLineno(int lineCharNo)
mergeLineCharNo(int, int)
).protected static int extractCharno(int lineCharNo)
mergeLineCharNo(int, int)
).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()) { ...
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()) { ...
@Nullable public final Node getParent()
@Nullable public final Node getGrandparent()
@Nullable public final Node getAncestor(int level)
level
- 0 = this, 1 = the parent, etc.public final boolean isDescendantOf(Node node)
node
or a descendant of node
.public final boolean isOnlyChildOf(Node possibleParent)
public final boolean isFirstChildOf(Node possibleParent)
public final boolean isSecondChildOf(Node possibleParent)
public final Node.AncestorIterable getAncestors()
public final boolean hasOneChild()
public final boolean hasTwoChildren()
getChildCount() == 2
public final boolean hasZeroOrOneChild()
public final boolean hasMoreThanOneChild()
public final boolean hasXChildren(int x)
public final int getChildCount()
public final boolean hasChild(Node child)
@Nullable public final java.lang.String checkTreeEquals(Node actual)
this
as the
"expected" node and actual
as the "actual" node.@Nullable public final java.lang.String checkTreeEqualsIncludingJsDoc(Node actual)
this
as the "expected" node and actual
as the "actual" node.Object.equals(Object)
public final boolean isEquivalentToShallow(Node node)
public final boolean isEquivalentWithSideEffectsTo(Node node)
public final boolean isEquivalentWithSideEffectsToShallow(Node node)
public final boolean isEquivalentToTyped(Node node)
public final boolean isEquivalentTo(Node node)
public boolean isEquivalentTo(Node node, boolean compareType, boolean recurse, boolean jsDoc, boolean sideEffect)
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.@Nullable public final java.lang.String getQualifiedName()
@Nullable public final java.lang.String getOriginalQualifiedName()
public final boolean isQualifiedName()
x
or a.b.c
or this.a
.public final boolean matchesQualifiedName(java.lang.String name)
x
or a.b.c
or this.a
.public final boolean matchesQualifiedName(Node n)
x
or
a.b.c
or this.a
.public final boolean isUnscopedQualifiedName()
a.b.c
, but not this.a
.public final boolean isValidAssignmentTarget()
public final Node detachFromParent()
public final Node detach()
@Nullable public final Node removeFirstChild()
@Nullable public final Node removeChildren()
public final void detachChildren()
public final Node removeFirstOrChildAfter(@Nullable Node prev)
@CheckReturnValue public final Node cloneNode()
@CheckReturnValue protected Node cloneNode(boolean cloneTypeExprs)
@CheckReturnValue public final Node cloneTree()
@CheckReturnValue public final Node cloneTree(boolean cloneTypeExprs)
public final Node useSourceInfoFrom(Node other)
other
.public final Node useSourceInfoFromForTree(Node other)
other
.public final Node useSourceInfoIfMissingFrom(Node other)
other
iff the source info is missing.public final Node useSourceInfoIfMissingFromForTree(Node other)
other
iff the source info is missing.@Nullable public final JSType getJSType()
getDeclaredTypeExpression()
which returns the syntactically specified type.@Nullable public final JSDocInfo getJSDocInfo()
JSDocInfo
attached to this node.null
if no JSDoc is attached to this nodepublic final Node setJSDocInfo(JSDocInfo info)
JSDocInfo
attached to this node.public final void setChangeTime(int time)
time
public final int getChangeTime()
public final void setDeleted(boolean deleted)
public final boolean isDeleted()
public final void setUnusedParameter(boolean unused)
public final boolean isUnusedParameter()
public final void setShorthandProperty(boolean shorthand)
public final boolean isShorthandProperty()
public final void setVarArgs(boolean varArgs)
Token.NAME
nodes
used to define a Token.FUNCTION
's argument list.public final boolean isVarArgs()
Token.NAME
nodes
used to define a Token.FUNCTION
's argument list.public final void setOptionalArg(boolean optionalArg)
Token.NAME
nodes
used to define a Token.FUNCTION
's argument list.public final boolean isOptionalArg()
Token.NAME
nodes
used to define a Token.FUNCTION
's argument list.public final boolean isOptionalEs6Typed()
public final void setIsSyntheticBlock(boolean val)
public final boolean isSyntheticBlock()
public final void setDirectives(java.util.Set<java.lang.String> val)
@Nullable public final java.util.Set<java.lang.String> getDirectives()
public final void setIsAddedBlock(boolean val)
public final boolean isAddedBlock()
public final void setStaticMember(boolean isStatic)
Token.GETTER_DEF
,
Token.SETTER_DEF
or Token.MEMBER_FUNCTION_DEF
nodes contained
within Token.CLASS
.public final boolean isStaticMember()
Token.GETTER_DEF
,
Token.SETTER_DEF
or Token.MEMBER_FUNCTION_DEF
nodes contained
within Token.CLASS
.public final void setIsGeneratorFunction(boolean isGenerator)
Token.FUNCTION
or
Token.MEMBER_FUNCTION_DEF
nodes.public final boolean isGeneratorFunction()
public final void setGeneratorMarker(boolean isGeneratorMarker)
It's used in the translation of generators.
public final boolean isGeneratorMarker()
It's used in the translation of generators.
public final void setGeneratorSafe(boolean isGeneratorSafe)
isGeneratorSafe()
public final boolean isGeneratorSafe()
public final void setIsArrowFunction(boolean isArrow)
Token.FUNCTION
public final boolean isArrowFunction()
public void setIsAsyncFunction(boolean isAsync)
Token.FUNCTION
public final boolean isAsyncFunction()
public final boolean isAsyncGeneratorFunction()
public final void setYieldAll(boolean isGenerator)
Token.FUNCTION
or
Token.MEMBER_FUNCTION_DEF
nodes.public final boolean isYieldAll()
Token.FUNCTION
or
Token.MEMBER_FUNCTION_DEF
nodes.public final boolean isEs6Class()
public final void setSideEffectFlags(int flags)
Token.CALL
and
Token.NEW
nodes.public final void setSideEffectFlags(Node.SideEffectFlags flags)
public final int getSideEffectFlags()
public final boolean isOnlyModifiesThisCall()
public final boolean isOnlyModifiesArgumentsCall()
public final boolean isNoSideEffectsCall()
public final boolean isLocalResultCall()
public final boolean mayMutateArguments()
public final boolean mayMutateGlobalStateOrThrow()
public boolean isQuotedString()
public void setQuotedString()
public final boolean isAdd()
public final boolean isSub()
public final boolean isAnd()
public final boolean isArrayLit()
public final boolean isArrayPattern()
public final boolean isAssign()
public final boolean isAssignAdd()
public final boolean isNormalBlock()
public final boolean isBlock()
public final boolean isRoot()
public final boolean isAwait()
public final boolean isBreak()
public final boolean isCall()
public final boolean isCase()
public final boolean isCast()
public final boolean isCatch()
public final boolean isClass()
public final boolean isClassMembers()
public final boolean isComma()
public final boolean isComputedProp()
public final boolean isContinue()
public final boolean isConst()
public final boolean isDebugger()
public final boolean isDec()
public final boolean isDefaultCase()
public final boolean isDefaultValue()
public final boolean isDelProp()
public final boolean isDestructuringLhs()
public final boolean isDestructuringPattern()
public final boolean isDo()
public final boolean isEmpty()
public final boolean isExport()
public final boolean isExportSpec()
public final boolean isExportSpecs()
public final boolean isExprResult()
public final boolean isFalse()
public final boolean isVanillaFor()
public final boolean isForIn()
public final boolean isForOf()
public final boolean isForAwaitOf()
public final boolean isFunction()
public final boolean isGetterDef()
public final boolean isGetElem()
public final boolean isGetProp()
public final boolean isHook()
public final boolean isIf()
public final boolean isImport()
public final boolean isImportStar()
public final boolean isImportSpec()
public final boolean isImportSpecs()
public final boolean isIn()
public final boolean isInc()
public final boolean isInstanceOf()
public final boolean isInterfaceMembers()
public final boolean isRecordType()
public final boolean isCallSignature()
public final boolean isIndexSignature()
public final boolean isLabel()
public final boolean isLabelName()
public final boolean isLet()
public final boolean isMemberFunctionDef()
public final boolean isMemberVariableDef()
public final boolean isModuleBody()
public final boolean isName()
public final boolean isNE()
public final boolean isNew()
public final boolean isNot()
public final boolean isNull()
public final boolean isNumber()
public final boolean isObjectLit()
public final boolean isObjectPattern()
public final boolean isOr()
public final boolean isParamList()
public final boolean isRegExp()
public final boolean isRest()
public final boolean isReturn()
public final boolean isScript()
public final boolean isSetterDef()
public final boolean isSpread()
public final boolean isString()
public final boolean isStringKey()
public final boolean isSuper()
public final boolean isSwitch()
public final boolean isTaggedTemplateLit()
public final boolean isTemplateLit()
public final boolean isTemplateLitString()
public final boolean isTemplateLitSub()
public final boolean isThis()
public final boolean isThrow()
public final boolean isTrue()
public final boolean isTry()
public final boolean isTypeOf()
public final boolean isVar()
public final boolean isVoid()
public final boolean isWhile()
public final boolean isWith()
public final boolean isYield()
Copyright © 2009-2018 Google. All Rights Reserved.