ReadonlychildThe number of children this node has
ReadonlychildrenArray of all child nodes
ReadonlydescendantThe number of descendants this node has, including itself
ReadonlyendThe byte offset where this node ends
ReadonlyendThe position where this node ends in terms of rows and columns
ReadonlyfieldsThe names of extra fields available in the subclass, if any.
ReadonlyfirstThe first child of this node
ReadonlyfirstThe first named child of this node
ReadonlygrammarThis node's type as a numeric id as it appears in the grammar, ignoring aliases
ReadonlygrammarThis node's symbol name as it appears in the grammar, ignoring aliases
ReadonlyhasWhether this node has been edited
ReadonlyhasWhether this node represents a syntax error or contains any syntax errors within it
ReadonlyidA unique numeric identifier for this node. Within a given syntax tree, no two nodes have the same id. If a new tree is created based on an older tree and reuses a node, that node will have the same id in both trees.
ReadonlyisWhether this node represents a syntax error. Syntax errors represent parts of the code that could not be incorporated into a valid syntax tree.
ReadonlyisWhether this node is extra. Extra nodes represent things like comments, which are not required by the grammar but can appear anywhere.
ReadonlyisWhether this node is missing. Missing nodes are inserted by the parser in order to recover from certain kinds of syntax errors.
ReadonlyisWhether this node is named. Named nodes correspond to named rules in the grammar, whereas anonymous nodes correspond to string literals in the grammar.
ReadonlylastThe last child of this node
ReadonlylastThe last child of this node
ReadonlynamedThe number of named children this node has.
ReadonlynamedArray of all named child nodes
ReadonlynextThis node's next named sibling
ReadonlynextThe parse state that follows this node
ReadonlynextThis node's next sibling
ReadonlyparentThis node's immediate parent. For iterating over ancestors, prefer using childWithDescendant
ReadonlyparseThe parse state of this node
ReadonlypreviousThis node's previous named sibling
ReadonlypreviousThis node's previous sibling
ReadonlystartThe byte offset where this node starts
ReadonlystartThe position where this node starts in terms of rows and columns
ReadonlytextThe text content for this node from the source code
ReadonlytreeThe syntax tree that contains this node
ReadonlytypeThis node's type as a string
ReadonlytypeThis node's type as a numeric id
Get the node's child at the given index, where zero represents the first child.
Note: While fairly fast, this method's cost is technically log(i). For iterating over many children, prefer using the children array.
Zero-based index of the child to retrieve
The child node, or null if none exists at the given index
Get this node's child with the given numerical field id.
Field IDs can be obtained from field names using the parser's language object.
The field ID to search for
The child node, or null if no child has the given field ID
Get the first child with the given field name.
For fields that may have multiple children, use childrenForFieldName instead.
The field name to search for
The child node, or null if no child has the given field name
Get all children that have the given field ID
The field ID to search for
Array of child nodes with the given field ID
Get all children that have the given field name
The field name to search for
Array of child nodes with the given field name
Get the immediate child that contains the given descendant node. Note that this can return the descendant itself if it is an immediate child.
The descendant node to find the parent of
The child containing the descendant, or null if not found
Find the closest ancestor of the current node that matches the given type(s).
Starting from the node's parent, walks up the tree until it finds a node whose type matches any of the given types.
A string or array of strings representing the node types to search for
The closest matching ancestor node, or null if none found
Get the smallest node within this node that spans the given byte offset.
The byte offset to search for
The smallest node spanning the offset
Get the smallest node within this node that spans the given byte range.
The starting byte offset
The ending byte offset
The smallest node spanning the range
Get the smallest node within this node that spans the given position. When only one position is provided, it's used as both start and end.
The point to search for
The smallest node spanning the position
Get the smallest node within this node that spans the given position range.
The smallest node spanning the range
Get all descendants of this node that have the given type(s)
Array of descendant nodes matching the given types
Get the field name of the child at the given index
Zero-based index of the child
The field name, or null if the child has no field name
Get the field name of the named child at the given index
Zero-based index of the named child
The field name, or null if the named child has no field name
Get the node's first child that extends beyond the given byte offset
The byte offset to search from
The first child extending beyond the offset, or null if none found
Get the node's first named child that extends beyond the given byte offset
The byte offset to search from
The first named child extending beyond the offset, or null if none found
Get this node's named child at the given index.
Note: While fairly fast, this method's cost is technically log(i). For iterating over many children, prefer using the namedChildren array.
Zero-based index of the named child to retrieve
The named child node, or null if none exists at the given index
Get the smallest named node within this node that spans the given byte offset.
The byte offset to search for
The smallest named node spanning the offset
Get the smallest named node within this node that spans the given byte range.
The starting byte offset
The ending byte offset
The smallest named node spanning the range
Get the smallest named node within this node that spans the given position. When only one position is provided, it's used as both start and end.
The point to search for
The smallest named node spanning the position
Get the smallest named node within this node that spans the given position range.
The smallest named node spanning the range
Convert this node to its JSON representation
Convert this node to its string representation
Create a new TreeCursor starting from this node.
A new cursor positioned at this node
The syntax tree that contains this node