visit<T extends OrgNode> method

bool visit<T extends OrgNode>(
  1. bool visitor(
    1. T
    )
)

Walk AST with visitor. Specify a type T to only visit nodes of that type. The visitor function must return true to continue iterating, or false to stop.

Implementation

bool visit<T extends OrgNode>(bool Function(T) visitor) {
  final self = this;
  if (self is T) {
    if (!visitor.call(self)) {
      return false;
    }
  }
  final children = this.children;
  if (children != null) {
    for (final child in children) {
      if (!child.visit<T>(visitor)) {
        return false;
      }
    }
  }
  return true;
}