thisOrAncestorMatching<E extends AstNode> method
Return either this node or the most immediate ancestor of this node for
which the predicate
returns true
, or null
if there is no such node.
Implementation
@override
E? thisOrAncestorMatching<E extends AstNode>(
bool Function(AstNode) predicate,
) {
AstNode? node = this;
while (node != null && !predicate(node)) {
node = node.parent;
}
return node as E?;
}