insertMatch method

void insertMatch(
  1. SourceTree tree,
  2. Match match,
  3. int index
)

Implementation

void insertMatch(SourceTree tree, Match match, int index) {
  SourceNode? root = findElement(children, (child) => child.accessor == match.paths[0][index]);

  if (root == null) {
    children.add(root = tree.makeNode(
      this,
        match.paths[0][index],  // step
      match.paths[0].length - 1 == index ? match : null));
  }

  if (match.paths[0].length > index + 1) {
    root.insertMatch(tree, match, index + 1);
  }
}