enclosingOfType<T extends AstNode> method
T?
enclosingOfType<T extends AstNode>()
Finds the first element in selfAndParents of the type T
.
Returns null
if there's no node of type T
surrounding this ast node.
Implementation
T? enclosingOfType<T extends AstNode>() {
for (final element in selfAndParents) {
if (element is T) {
return element;
}
}
return null;
}