enclosingElement2 property
The element that either physically or logically encloses this element.
Returns null
if this element is a library because libraries are the
top-level elements in the model.
Implementation
@override
Element2? get enclosingElement2 {
var candidate = _enclosingElement3;
if (candidate is CompilationUnitElementImpl ||
candidate is AugmentableElement) {
throw UnsupportedError('Cannot get an enclosingElement2 for a fragment');
}
return candidate as Element2?;
}