findNodesAtPosition method

List<SyntaxNode> findNodesAtPosition(
  1. int position
)

Implementation

List<SyntaxNode> findNodesAtPosition(int position) {
  var curr = root;
  final res = <SyntaxNode>[];
  while (true) {
    res.add(curr);
    final next = curr.children.firstWhereOrNull((child) => child == null
        ? false
        : child.range.start <= position && child.range.end >= position);
    if (next == null) break;
    curr = next;
  }
  return res;
}