AstNode
Base class for AST node types. The AST represents the physical source code, which makes it useful for IDEs and pretty-printers; the parser must not rewrite the tree when producing it.
The hierarchy sits on top of the older Node class, which was designed for code generation and keeps its children in a weakly typed linked list. AstNode is a strongly typed facade over that list with named accessors, plus position, length and parent.
All offset fields in subclasses are relative to the parent. During parsing the positions are absolute; adding a node to its parent rewrites them to be relative, so by the time a visitor sees the tree all offsets are relative.
Inheritors
Types
Properties
The absolute document position, computed by adding this node's relative position to the relative positions of all its parents.
The innermost enclosing function, or null. The search begins with the parent.
Comments on the same line as the statement, for example the trailing comment in if (x == 2) // note.
The node type, e.g. Token.NAME.
Functions
A debugging representation of the parse tree starting at this node. Each line reads abs-pos name position length [identifier].
Checks that every return usage in a function body is consistent with strict mode. See the END_* flags for what the analysis reports.
Constructs an indentation string of indent steps.
Recursively unlabel every TARGET or YIELD node in the tree. Used only for inlining finally blocks where jsr instructions used to be.
Makes this node's position relative to a parent. The current position is assumed to be absolute and is decremented by parentPosition.
Visits this node and its children in an arbitrary order.