getDescendants static method

List<ParseTree> getDescendants(
  1. ParseTree t
)

Get all descendents; includes t itself.

@since 4.5.1

Implementation

static List<ParseTree> getDescendants(ParseTree t) {
  final nodes = <ParseTree>[];
  nodes.add(t);

  final n = t.childCount;
  for (var i = 0; i < n; i++) {
    nodes.addAll(getDescendants(t.getChild(i)!));
  }
  return nodes;
}