root property

  1. @override
AstNode root
override

Return the node at the root of this node's AST structure.

Note that this method's performance is linear with respect to the depth of the node in the AST structure (O(depth)).

Implementation

@override
AstNode get root {
  AstNode root = this;
  var rootParent = parent;
  while (rootParent != null) {
    root = rootParent;
    rootParent = root.parent;
  }
  return root;
}