descend method

bool descend()

Descends to the first child of the current node.

This is deliberately separate from advance. Native Tree-sitter only descends into a subtree when the subtree overlaps the parser position or when the subtree itself is not reusable but may contain reusable descendants.

Implementation

bool descend() {
  final node = _current;
  if (node == null || node.children.isEmpty || _stack.isEmpty) {
    return false;
  }
  final frame = _stack.last;
  if (!identical(frame.node, node)) return false;
  final child = _pushNextChild(frame);
  _stack.add(child.$2);
  _current = child.$1;
  return true;
}