The number of children this node has
Array of all child nodes
The number of descendants this node has, including itself
The byte offset where this node ends
The position where this node ends in terms of rows and columns
The first child of this node
The first named child of this node
This node's type as a numeric id as it appears in the grammar, ignoring aliases
This node's symbol name as it appears in the grammar, ignoring aliases
Whether this node has been edited
Whether this node represents a syntax error or contains any syntax errors within it
A 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.
Whether this node represents a syntax error. Syntax errors represent parts of the code that could not be incorporated into a valid syntax tree.
Whether this node is extra. Extra nodes represent things like comments, which are not required by the grammar but can appear anywhere.
Whether this node is missing. Missing nodes are inserted by the parser in order to recover from certain kinds of syntax errors.
Whether this node is named. Named nodes correspond to named rules in the grammar, whereas anonymous nodes correspond to string literals in the grammar.
The last child of this node
The last child of this node
The number of named children this node has.
Array of all named child nodes
This node's next named sibling
The parse state that follows this node
This node's next sibling
This node's immediate parent. For iterating over ancestors, prefer using childWithDescendant
The parse state of this node
This node's previous named sibling
This node's previous sibling
The byte offset where this node starts
The position where this node starts in terms of rows and columns
The text content for this node from the source code
The syntax tree that contains this node
This node's type as a string
This 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 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
Create a new TreeCursor starting from this node.
A new cursor positioned at this node
The syntax tree that contains this node