Walking

Tree-walking functions enable efficient traversal of the syntax tree with the help of a stateful cursor object.

tsc-make-cursor node-or-tree
Create a new cursor on a node. The cursor cannot move out of this node. If called on a tree, the cursor is created on the tree’s root node.
tsc-goto-parent cursor
tsc-goto-first-child cursor
tsc-goto-next-sibling cursor
Attempt to move the cursor to the parent node, the first child node, or the next sibling node. This function returns t if the move was successful, nil if the move is invalid.
tsc-goto-first-child-for-position cursor pos
Attempt to move the cursor to the first child node that extends beyond the given position. This function returns the index of the child node found, nil otherwise.
tsc-reset-cursor cursor node
Re-initialize the cursor to start on a different node.
tsc-current-node cursor
Get the node that the cursor is currently on.
tsc-current-field cursor
Get the field name (as a keyword) associated with the current node.