thisOrAncestorOfType<E extends Element> method
Returns either this element or the most immediate ancestor of this element
that has the given type, or null
if there is no such element.
Implementation
@override
E? thisOrAncestorOfType<E extends Element>() {
Element element = this;
while (element is! E) {
var ancestor = element.enclosingElement;
if (ancestor == null) return null;
element = ancestor;
}
return element;
}