Deprecate 'Element.enclosingElement3', use 'enclosingElement'.

Change-Id: I6f4fd7e8c0f071bde10cb5e57ed6195ae517e575
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/261221
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
Konstantin Shcheglov 2022-09-26 23:58:14 +00:00 committed by Commit Queue
parent 83eec5f26f
commit 745d0ff64a
121 changed files with 571 additions and 430 deletions

View file

@ -65,7 +65,7 @@ class CanRenameResponse {
void _analyzePossibleConflicts(
ConstructorElement element, RefactoringStatus result, String newName) {
var parentClass = element.enclosingElement3;
var parentClass = element.enclosingElement;
// Check if the "newName" is the name of the enclosing class.
if (parentClass.name == newName) {
result.addError('The constructor should not have the same name '
@ -254,8 +254,8 @@ class CheckNameResponse {
var stateName = flutterState.newName;
var match = await canRename._fileResolver.findReferences2(stateClass);
var sourcePath = stateClass.source.fullName;
var location = stateClass.enclosingElement3.lineInfo
.getLocation(stateClass.nameOffset);
var location =
stateClass.enclosingElement.lineInfo.getLocation(stateClass.nameOffset);
CiderSearchMatch ciderMatch;
var searchInfo =
CiderSearchInfo(location, stateClass.nameLength, MatchKind.DECLARATION);
@ -297,7 +297,7 @@ class CheckNameResponse {
Future<CiderReplaceMatch?> _replaceSyntheticConstructor() async {
var element = canRename.refactoringElement.element;
var interfaceElement = element.enclosingElement3;
var interfaceElement = element.enclosingElement;
var fileResolver = canRename._fileResolver;
var libraryPath = interfaceElement!.library!.source.fullName;
@ -382,7 +382,7 @@ class CiderRenameComputer {
}
bool _canRenameElement(Element element) {
var enclosingElement = element.enclosingElement3;
var enclosingElement = element.enclosingElement;
if (element is ConstructorElement) {
return true;
}

View file

@ -104,7 +104,7 @@ class CallHierarchyItem {
codeRange = _codeRangeForElement(element),
file = element.source!.fullName,
kind = CallHierarchyKind.forElement(element) {
final enclosingElement = element.enclosingElement3;
final enclosingElement = element.enclosingElement;
final container =
enclosingElement != null ? _getContainer(enclosingElement) : null;
containerName = container != null ? _getDisplayName(container) : null;

View file

@ -83,7 +83,7 @@ class ColorComputer {
final constructor = expression.constructorName;
final staticElement = constructor.staticElement;
final classElement = staticElement?.enclosingElement3;
final classElement = staticElement?.enclosingElement;
final className = classElement?.name;
final constructorName = constructor.name?.name;
final constructorArgs = expression.argumentList.arguments

View file

@ -305,7 +305,7 @@ class DartUnitHighlightsComputer {
var parent = node.parent;
var isInvocation = parent is MethodInvocation && parent.methodName == node;
HighlightRegionType type;
var isTopLevel = element.enclosingElement3 is CompilationUnitElement;
var isTopLevel = element.enclosingElement is CompilationUnitElement;
if (node.inDeclarationContext()) {
type = isTopLevel
? HighlightRegionType.TOP_LEVEL_FUNCTION_DECLARATION
@ -334,7 +334,7 @@ class DartUnitHighlightsComputer {
return false;
}
// getter or setter
var isTopLevel = element.enclosingElement3 is CompilationUnitElement;
var isTopLevel = element.enclosingElement is CompilationUnitElement;
HighlightRegionType type;
if (element.isGetter) {
if (isTopLevel) {

View file

@ -95,7 +95,7 @@ class DartUnitHoverComputer {
hover.elementKind = element.kind.displayName;
hover.isDeprecated = element.hasDeprecated;
// not local element
if (element.enclosingElement3 is! ExecutableElement) {
if (element.enclosingElement is! ExecutableElement) {
// containing class
var containingClass =
element.thisOrAncestorOfType<InterfaceElement>();
@ -184,7 +184,7 @@ class DartUnitHoverComputer {
element = element.field;
}
if (element is ParameterElement) {
element = element.enclosingElement3;
element = element.enclosingElement;
}
if (element == null) {
// This can happen when the code is invalid, such as having a field formal
@ -229,9 +229,9 @@ class DartUnitHoverComputer {
var result =
dartdocInfo.processDartdoc(rawDoc, includeSummary: includeSummary);
var documentedElementClass = documentedElement.enclosingElement3;
var documentedElementClass = documentedElement.enclosingElement;
if (documentedElementClass != null &&
documentedElementClass != element.enclosingElement3) {
documentedElementClass != element.enclosingElement) {
var documentedClass = documentedElementClass.displayName;
result.full = '${result.full}\n\nCopied from `$documentedClass`.';
}

View file

@ -528,7 +528,7 @@ class _FunctionBodyOutlinesVisitor extends RecursiveAstVisitor<void> {
/// Return `true` if the given [element] is a top-level member of the test
/// package.
bool _isInsideTestPackage(engine.FunctionElement element) {
var parent = element.enclosingElement3;
var parent = element.enclosingElement;
return parent is engine.CompilationUnitElement &&
parent.source.fullName.endsWith('test.dart');
}

View file

@ -11,7 +11,7 @@ import 'package:analyzer/dart/element/element.dart';
/// Return the elements that the given [element] overrides.
OverriddenElements findOverriddenElements(Element element) {
if (element.enclosingElement3 is InterfaceElement) {
if (element.enclosingElement is InterfaceElement) {
return _OverriddenElementsFinder(element).find();
}
return OverriddenElements(element, <Element>[], <Element>[]);
@ -111,7 +111,7 @@ class _OverriddenElementsFinder {
final Set<InterfaceElement> _visited = {};
factory _OverriddenElementsFinder(Element seed) {
var class_ = seed.enclosingElement3 as InterfaceElement;
var class_ = seed.enclosingElement as InterfaceElement;
var library = class_.library;
var name = seed.displayName;
List<ElementKind> kinds;

View file

@ -82,7 +82,7 @@ class _Visitor extends UnifyingAstVisitor<void> {
!_isConstructorDeclarationReturnType(node)) {
var nodeElement = node.writeOrReadElement;
if (nodeElement != null &&
nodeElement.enclosingElement3 is CompilationUnitElement) {
nodeElement.enclosingElement is CompilationUnitElement) {
var nodeLibrary = nodeElement.library;
var path = nodeLibrary?.definingCompilationUnit.source.fullName;
if (path == null) {

View file

@ -225,7 +225,7 @@ Location newLocation_fromUnit(
OverriddenMember newOverriddenMember_fromEngine(engine.Element member,
{required bool withNullability}) {
var element = convertElement(member, withNullability: withNullability);
var className = member.enclosingElement3!.displayName;
var className = member.enclosingElement!.displayName;
return OverriddenMember(element, className);
}
@ -272,7 +272,7 @@ List<Element> _computePath(engine.Element element) {
var path = <Element>[];
if (element is engine.PrefixElement) {
element = element.enclosingElement3.definingCompilationUnit;
element = element.enclosingElement.definingCompilationUnit;
}
var withNullability = element.library?.isNonNullableByDefault ?? false;
@ -287,7 +287,7 @@ engine.CompilationUnitElement _getUnitElement(engine.Element element) {
return element;
}
var enclosingElement = element.enclosingElement3;
var enclosingElement = element.enclosingElement;
if (enclosingElement is engine.LibraryElement) {
element = enclosingElement;
}

View file

@ -73,6 +73,6 @@ class ElementReferencesComputer {
if (element is ConstructorElement) {
return false;
}
return element.enclosingElement3 is InterfaceElement;
return element.enclosingElement is InterfaceElement;
}
}

View file

@ -35,10 +35,10 @@ class TypeHierarchyComputer {
Element? element = _pivotElement;
if (_pivotElement is FieldElement) {
_pivotFieldFinal = (_pivotElement as FieldElement).isFinal;
element = _pivotElement.enclosingElement3;
element = _pivotElement.enclosingElement;
}
if (_pivotElement is ExecutableElement) {
element = _pivotElement.enclosingElement3;
element = _pivotElement.enclosingElement;
}
if (element is InterfaceElement) {
_pivotClass = element;

View file

@ -77,7 +77,7 @@ class LibraryElementSuggestionBuilder extends GeneralizingElementVisitor {
if (element.isOperator) {
return;
}
if (element.enclosingElement3 is! CompilationUnitElement) {
if (element.enclosingElement is! CompilationUnitElement) {
return;
}
var returnType = element.returnType;
@ -108,7 +108,7 @@ class LibraryElementSuggestionBuilder extends GeneralizingElementVisitor {
void visitPropertyAccessorElement(PropertyAccessorElement element) {
if (opType.includeReturnValueSuggestions ||
(opType.includeAnnotationSuggestions && element.variable.isConst)) {
var parent = element.enclosingElement3;
var parent = element.enclosingElement;
if (parent is InterfaceElement || parent is ExtensionElement) {
builder.suggestAccessor(element, inheritanceDistance: 0.0);
} else {

View file

@ -263,7 +263,7 @@ class _LocalVisitor extends LocalDeclarationVisitor {
.thisOrAncestorOfType<ClassDeclaration>();
var enclosingElement = enclosingClass?.declaredElement;
if (enclosingElement != null) {
var enclosingElement = field.enclosingElement3;
var enclosingElement = field.enclosingElement;
if (enclosingElement is InterfaceElement) {
inheritanceDistance = request.featureComputer
.inheritanceDistanceFeature(enclosingElement, enclosingElement);
@ -342,7 +342,7 @@ class _LocalVisitor extends LocalDeclarationVisitor {
var enclosingClass = request.target.containingNode
.thisOrAncestorOfType<ClassDeclaration>();
if (enclosingClass != null) {
var enclosingElement = element?.enclosingElement3;
var enclosingElement = element?.enclosingElement;
if (enclosingElement is InterfaceElement) {
inheritanceDistance = request.featureComputer
.inheritanceDistanceFeature(

View file

@ -24,7 +24,7 @@ class RedirectingContributor extends DartCompletionContributor {
var containingConstructor =
parent.thisOrAncestorOfType<ConstructorDeclaration>();
var constructorElement = containingConstructor?.declaredElement;
var classElement = constructorElement?.enclosingElement3;
var classElement = constructorElement?.enclosingElement;
if (classElement != null) {
for (var constructor in classElement.constructors) {
if (constructor != constructorElement) {
@ -52,7 +52,7 @@ class RedirectingContributor extends DartCompletionContributor {
var containingConstructor =
parent.thisOrAncestorOfType<ConstructorDeclaration>();
var constructorElement = containingConstructor?.declaredElement;
var classElement = constructorElement?.enclosingElement3;
var classElement = constructorElement?.enclosingElement;
var libraryElement = request.libraryElement;
if (classElement == null) {
return;

View file

@ -394,7 +394,7 @@ class SuggestionBuilder {
// If the class name is already in the text, then we don't support
// prepending a prefix.
assert(!hasClassName || prefix == null);
var enclosingClass = constructor.enclosingElement3;
var enclosingClass = constructor.enclosingElement;
var className = enclosingClass.name;
if (className.isEmpty) {
return;
@ -442,10 +442,10 @@ class SuggestionBuilder {
} else if (element is ExtensionElement) {
suggestExtension(element, kind: kind);
} else if (element is FunctionElement &&
element.enclosingElement3 is CompilationUnitElement) {
element.enclosingElement is CompilationUnitElement) {
suggestTopLevelFunction(element, kind: kind);
} else if (element is PropertyAccessorElement &&
element.enclosingElement3 is CompilationUnitElement) {
element.enclosingElement is CompilationUnitElement) {
suggestTopLevelPropertyAccessor(element);
} else if (element is TypeAliasElement) {
suggestTypeAlias(element);
@ -458,7 +458,7 @@ class SuggestionBuilder {
/// referenced using a prefix, then the [prefix] should be provided.
void suggestEnumConstant(FieldElement constant, {String? prefix}) {
var constantName = constant.name;
var enumElement = constant.enclosingElement3;
var enumElement = constant.enclosingElement;
var enumName = enumElement.name;
var completion = '$enumName.$constantName';
var relevance =
@ -706,7 +706,7 @@ class SuggestionBuilder {
inheritanceDistance: inheritanceDistance,
);
var enclosingElement = method.enclosingElement3;
var enclosingElement = method.enclosingElement;
if (method.name == 'setState' &&
enclosingElement is ClassElement &&
flutter.isExactState(enclosingElement)) {
@ -778,10 +778,10 @@ class SuggestionBuilder {
// Optionally add Flutter child widget details.
// todo (pq): revisit this special casing; likely it can be generalized away
var element = parameter.enclosingElement3;
var element = parameter.enclosingElement;
// If appendColon is false, default values should never be appended.
if (element is ConstructorElement && appendColon) {
if (Flutter.instance.isWidget(element.enclosingElement3)) {
if (Flutter.instance.isWidget(element.enclosingElement)) {
var codeStyleOptions = request
.analysisSession.analysisContext.analysisOptions.codeStyleOptions;
// Don't bother with nullability. It won't affect default list values.
@ -1082,9 +1082,9 @@ class SuggestionBuilder {
void suggestTopLevelPropertyAccessor(PropertyAccessorElement accessor,
{String? prefix}) {
assert(
accessor.enclosingElement3 is CompilationUnitElement,
accessor.enclosingElement is CompilationUnitElement,
'Enclosing element of ${accessor.runtimeType} is '
'${accessor.enclosingElement3.runtimeType}.');
'${accessor.enclosingElement.runtimeType}.');
if (accessor.isSynthetic) {
// Avoid visiting a field twice. All fields induce a getter, but only
// non-final fields induce a setter, so we don't add a suggestion for a
@ -1134,7 +1134,7 @@ class SuggestionBuilder {
/// referenced using a prefix, then the [prefix] should be provided.
void suggestTopLevelVariable(TopLevelVariableElement variable,
{String? prefix}) {
assert(variable.enclosingElement3 is CompilationUnitElement);
assert(variable.enclosingElement is CompilationUnitElement);
var relevance =
_computeTopLevelRelevance(variable, elementType: variable.type);
_addBuilder(
@ -1367,7 +1367,7 @@ class SuggestionBuilder {
withNullability: _isNonNullableByDefault,
);
var enclosingElement = element.enclosingElement3;
var enclosingElement = element.enclosingElement;
String? declaringType;
if (enclosingElement is InterfaceElement) {
@ -1426,7 +1426,7 @@ class SuggestionBuilder {
/// The enclosing element must be either a class, or extension; otherwise
/// we either fail with assertion, or return `null`.
String? _enclosingClassOrExtensionName(Element element) {
var enclosing = element.enclosingElement3;
var enclosing = element.enclosingElement;
if (enclosing is InterfaceElement) {
return enclosing.name;
} else if (enclosing is ExtensionElement) {

View file

@ -60,7 +60,7 @@ class AddLate extends CorrectionProducer {
getter.isSynthetic &&
!getter.variable.isSynthetic &&
getter.variable.setter == null &&
getter.enclosingElement3 is InterfaceElement) {
getter.enclosingElement is InterfaceElement) {
var declarationResult =
await sessionHelper.getElementDeclaration(getter.variable);
if (declarationResult == null) {

View file

@ -43,7 +43,7 @@ class ChangeToStaticAccess extends CorrectionProducer {
}
final target_final = target;
var declaringElement = invokedElement.enclosingElement3;
var declaringElement = invokedElement.enclosingElement;
if (declaringElement is InterfaceElement) {
_className = declaringElement.name;

View file

@ -76,7 +76,7 @@ class _BaseVisitor extends RecursiveAstVisitor<void> {
var constructorElement = node.constructorName.staticElement;
return constructorElement != null &&
!constructorElement.isFactory &&
constructorElement.enclosingElement3 == classElement;
constructorElement.enclosingElement == classElement;
}
}
@ -567,7 +567,7 @@ class _EnumDescription {
initializer.constructorName.staticElement;
if (constructorElement != null &&
!constructorElement.isFactory &&
constructorElement.enclosingElement3 == classElement) {
constructorElement.enclosingElement == classElement) {
var fieldValue = fieldElement.computeConstantValue();
if (fieldValue != null) {
if (fieldList.variables.length != 1) {

View file

@ -97,7 +97,7 @@ class _SuperclassReferenceFinder extends RecursiveAstVisitor<void> {
void _addElement(Element? element) {
if (element is ExecutableElement) {
var enclosingElement = element.enclosingElement3;
var enclosingElement = element.enclosingElement;
if (enclosingElement is ClassElement) {
referencedClasses.add(enclosingElement);
}

View file

@ -46,7 +46,7 @@ class ConvertIntoFinalField extends CorrectionProducer {
if (element == null) {
return;
}
var enclosing = element.enclosingElement3;
var enclosing = element.enclosingElement;
if (enclosing is InterfaceElement) {
if (enclosing.getSetter(element.name) != null) {
return;

View file

@ -43,7 +43,7 @@ class ConvertIntoIsNotEmpty extends CorrectionProducer {
return;
}
// should have "isNotEmpty"
var propertyTarget = propertyElement.enclosingElement3;
var propertyTarget = propertyElement.enclosingElement;
if (propertyTarget == null ||
getChildren(propertyTarget, 'isNotEmpty').isEmpty) {
return;

View file

@ -42,7 +42,7 @@ class ConvertMapFromIterableToForLiteral extends CorrectionProducer {
var element = creation.constructorName.staticElement;
if (element == null ||
element.name != 'fromIterable' ||
element.enclosingElement3 != typeProvider.mapElement) {
element.enclosingElement != typeProvider.mapElement) {
return;
}
//

View file

@ -164,7 +164,7 @@ class CreateConstructor extends CorrectionProducer {
}
// prepare target ClassDeclaration
var targetElement = constructorElement.enclosingElement3;
var targetElement = constructorElement.enclosingElement;
var targetResult = await sessionHelper.getElementDeclaration(targetElement);
if (targetResult == null) {
return;

View file

@ -313,7 +313,7 @@ class _ReplacementEditBuilder extends RecursiveAstVisitor<void> {
}
var element = node.staticElement;
if (element is ExecutableElement &&
element.enclosingElement3 == widgetClassElement &&
element.enclosingElement == widgetClassElement &&
!elementsToMove.contains(element)) {
var offset = node.offset - linesRange.offset;
var qualifier =

View file

@ -316,7 +316,7 @@ class _ReplacementEditBuilder extends RecursiveAstVisitor<void> {
}
var element = node.staticElement;
if (element is ExecutableElement &&
element.enclosingElement3 == widgetClassElement &&
element.enclosingElement == widgetClassElement &&
!elementsToMove.contains(element)) {
var parent = node.parent;
if (parent is PrefixedIdentifier) {
@ -359,7 +359,7 @@ class _StatelessVerifier extends RecursiveAstVisitor<void> {
void visitMethodInvocation(MethodInvocation node) {
var methodElement = node.methodName.staticElement?.declaration;
if (methodElement is ClassMemberElement) {
var classElement = methodElement.enclosingElement3;
var classElement = methodElement.enclosingElement;
if (classElement is ClassElement &&
Flutter.instance.isExactState(classElement) &&
!FlutterConvertToStatelessWidget._isDefaultOverride(

View file

@ -45,7 +45,7 @@ class MakeFieldNotFinal extends CorrectionProducer {
}
// It must be a field declaration.
if (getter.enclosingElement3 is! ClassElement) {
if (getter.enclosingElement is! ClassElement) {
return;
}

View file

@ -40,7 +40,7 @@ class QualifyReference extends CorrectionProducer {
return;
}
var enclosingElement = memberElement.enclosingElement3;
var enclosingElement = memberElement.enclosingElement;
if (enclosingElement == null ||
enclosingElement.library != libraryElement) {
// TODO(brianwilkerson) Support qualifying references to members defined

View file

@ -28,7 +28,7 @@ class ShadowField extends CorrectionProducer {
return;
}
if (!accessor.isGetter || accessor.enclosingElement3 is! InterfaceElement) {
if (!accessor.isGetter || accessor.enclosingElement is! InterfaceElement) {
// TODO(brianwilkerson) Should we also require that the getter be synthetic?
return;
}

View file

@ -208,7 +208,7 @@ class _MatcherBuilder {
);
}
} else if (parent is SuperConstructorInvocation) {
var superclassName = parent.staticElement?.enclosingElement3.name;
var superclassName = parent.staticElement?.enclosingElement.name;
if (superclassName != null) {
_addMatcher(
components: [parent.constructorName?.name ?? '', superclassName],
@ -509,7 +509,7 @@ class _MatcherBuilder {
}
}
if (element != null) {
var enclosingElement = element.enclosingElement3;
var enclosingElement = element.enclosingElement;
if (enclosingElement is InterfaceElement) {
return [identifier.name, enclosingElement.name];
} else if (enclosingElement is ExtensionElement) {

View file

@ -122,7 +122,7 @@ extension on MethodDeclaration {
ExecutableElement? overriddenElement() {
var element = declaredElement;
if (element != null) {
var enclosingElement = element.enclosingElement3;
var enclosingElement = element.enclosingElement;
if (enclosingElement is InterfaceElement) {
var name = Name(enclosingElement.library.source.uri, element.name);
return InheritanceManager3().getInherited2(enclosingElement, name);

View file

@ -42,7 +42,7 @@ LibraryImportElement? _getImportElement(
String prefix,
Element element,
Map<LibraryImportElement, Set<Element>> importElementsMap) {
if (element.enclosingElement3 is! CompilationUnitElement) {
if (element.enclosingElement is! CompilationUnitElement) {
return null;
}
var usedLibrary = element.library;

View file

@ -226,7 +226,7 @@ String getElementKindName(Element element) {
String getElementQualifiedName(Element element) {
var kind = element.kind;
if (kind == ElementKind.FIELD || kind == ElementKind.METHOD) {
return '${element.enclosingElement3!.displayName}.${element.displayName}';
return '${element.enclosingElement!.displayName}.${element.displayName}';
} else if (kind == ElementKind.LIBRARY) {
// Libraries may not have names, so use a path relative to the context root.
final session = element.session!;
@ -1434,7 +1434,7 @@ class CorrectionUtils {
/// Checks if [element] is visible in [targetExecutableElement] or
/// [targetClassElement].
bool _isTypeParameterVisible(TypeParameterElement element) {
var enclosing = element.enclosingElement3;
var enclosing = element.enclosingElement;
return identical(enclosing, targetExecutableElement) ||
identical(enclosing, targetClassElement);
}

View file

@ -467,7 +467,7 @@ class _EdgeInsetsProperty {
var constructor = propertyExpression.constructorName.staticElement;
if (flutter != null &&
constructor != null &&
constructor.enclosingElement3 == classEdgeInsets) {
constructor.enclosingElement == classEdgeInsets) {
var arguments = propertyExpression.argumentList.arguments;
var constructorName = constructor.name;
if (constructorName == 'all') {

View file

@ -278,7 +278,7 @@ class _WidgetDescriptionComputer {
constructorElement ??= classDescription?.constructor;
if (constructorElement == null) return;
var classElement = constructorElement.enclosingElement3;
var classElement = constructorElement.enclosingElement;
if (!elementsBeingProcessed.add(classElement)) return;
var existingNamed = <String>{};
@ -520,7 +520,7 @@ class _WidgetDescriptionComputer {
}
protocol.FlutterWidgetPropertyValueEnumItem _toEnumItem(FieldElement field) {
var interfaceElement = field.enclosingElement3 as InterfaceElement;
var interfaceElement = field.enclosingElement as InterfaceElement;
var libraryUriStr = '${interfaceElement.library.source.uri}';
var documentation = getFieldDocumentation(field);
@ -546,7 +546,7 @@ class _WidgetDescriptionComputer {
if (element is PropertyAccessorElement && element.isGetter) {
var field = element.variable;
if (field is FieldElement && field.isStatic) {
var enclosingClass = field.enclosingElement3 as InterfaceElement;
var enclosingClass = field.enclosingElement as InterfaceElement;
if (field.isEnumConstant ||
_flutter.isExactAlignment(enclosingClass) ||
_flutter.isExactAlignmentDirectional(enclosingClass)) {

View file

@ -28,7 +28,7 @@ const int _notFound = -1;
/// name of the constructor, unless the constructor is a named constructor in
/// which '<class-name>.<constructor-name>' is returned.
String _computeConstructorElementName(ConstructorElement element) {
var name = element.enclosingElement3.name;
var name = element.enclosingElement.name;
var constructorName = element.name;
if (constructorName.isNotEmpty) {
name = '$name.$constructorName';
@ -725,7 +725,7 @@ class KytheDartVisitor extends GeneralizingAstVisitor<void> with OutputUtils {
// We can't call _handleRefEdge as the anchor node has already been
// written out.
var enclosingEltVName = _vNameFromElement(
constructorElement.enclosingElement3, schema.RECORD_KIND);
constructorElement.enclosingElement, schema.RECORD_KIND);
var anchorVName =
_vNameAnchor(constructorName.offset, constructorName.end);
addEdge(anchorVName, schema.REF_EDGE, enclosingEltVName);
@ -1416,7 +1416,7 @@ class SignatureElementVisitor extends GeneralizingElementVisitor<StringBuffer> {
@override
StringBuffer visitElement(Element element) {
assert(element is! MultiplyInheritedExecutableElement);
var enclosingElt = element.enclosingElement3!;
var enclosingElt = element.enclosingElement!;
var buffer = enclosingElt.accept(this)!;
if (buffer.isNotEmpty) {
buffer.write('#');
@ -1448,7 +1448,7 @@ class SignatureElementVisitor extends GeneralizingElementVisitor<StringBuffer> {
// It is legal to have a named constructor with the same name as a type
// parameter. So we distinguish them by using '.' between the class (or
// typedef) name and the type parameter name.
return element.enclosingElement3!.accept(this)!
return element.enclosingElement!.accept(this)!
..write('.')
..write(element.name);
}

View file

@ -46,15 +46,15 @@ class ConvertGetterToMethodRefactoringImpl extends RefactoringImpl
Future<SourceChange> createChange() async {
change = SourceChange(refactoringName);
// function
if (element.enclosingElement3 is CompilationUnitElement) {
if (element.enclosingElement is CompilationUnitElement) {
await _updateElementDeclaration(element);
await _updateElementReferences(element);
}
// method
var field = element.variable;
if (field is FieldElement &&
(field.enclosingElement3 is InterfaceElement ||
field.enclosingElement3 is ExtensionElement)) {
(field.enclosingElement is InterfaceElement ||
field.enclosingElement is ExtensionElement)) {
var elements = await getHierarchyMembers(searchEngine, field);
await Future.forEach(elements, (ClassMemberElement member) async {
if (member is FieldElement) {

View file

@ -72,7 +72,7 @@ class ConvertMethodToGetterRefactoringImpl extends RefactoringImpl
RefactoringStatus _checkElement() {
// check Element type
if (element is FunctionElement) {
if (element.enclosingElement3 is! CompilationUnitElement) {
if (element.enclosingElement is! CompilationUnitElement) {
return RefactoringStatus.fatal(
'Only top-level functions can be converted to getters.');
}

View file

@ -38,7 +38,7 @@ bool isLocalElement(Element? element) {
return element is LocalVariableElement ||
element is ParameterElement ||
element is FunctionElement &&
element.enclosingElement3 is! CompilationUnitElement;
element.enclosingElement is! CompilationUnitElement;
}
Element? _getLocalElement(SimpleIdentifier node) {

View file

@ -669,7 +669,7 @@ class _ParametersCollector extends RecursiveAstVisitor<void> {
enclosingClass,
...enclosingClass.allSupertypes.map((t) => t.element2)
];
return enclosingClasses.contains(element.enclosingElement3);
return enclosingClasses.contains(element.enclosingElement);
}
return false;
}

View file

@ -213,7 +213,7 @@ class InlineMethodRefactoringImpl extends RefactoringImpl
@override
String? get className {
var interfaceElement = _methodElement?.enclosingElement3;
var interfaceElement = _methodElement?.enclosingElement;
if (interfaceElement is InterfaceElement) {
return interfaceElement.displayName;
}
@ -835,13 +835,13 @@ class _VariablesVisitor extends GeneralizingAstVisitor<void> {
} else {
return;
}
if (element.enclosingElement3 is! InterfaceElement) {
if (element.enclosingElement is! InterfaceElement) {
return;
}
// record the implicit static or instance reference
var offset = node.offset;
if (element.isStatic) {
var className = element.enclosingElement3.displayName;
var className = element.enclosingElement.displayName;
result.addImplicitClassNameOffset(className, offset);
} else {
result.addImplicitThisOffset(offset);

View file

@ -417,7 +417,7 @@ abstract class RenameRefactoring implements Refactoring {
if (element is PropertyAccessorElement) {
element = element.variable;
}
var enclosingElement = element.enclosingElement3;
var enclosingElement = element.enclosingElement;
if (enclosingElement is CompilationUnitElement) {
return RenameUnitMemberRefactoringImpl(
workspace, sessionHelper, resolvedUnit, element);

View file

@ -96,7 +96,7 @@ class RenameClassMemberRefactoringImpl extends RenameRefactoringImpl {
} else {
processor.addDeclarationEdit(renameElement);
if (!newName.startsWith('_')) {
var interfaceElement = renameElement.enclosingElement3;
var interfaceElement = renameElement.enclosingElement;
if (interfaceElement is InterfaceElement) {
for (var constructor in interfaceElement.constructors) {
for (var parameter in constructor.parameters) {
@ -230,7 +230,7 @@ class _BaseClassMemberValidator {
var declarations = await searchEngine.searchMemberDeclarations(name);
for (var declaration in declarations) {
var nameElement = getSyntheticAccessorVariable(declaration.element);
var nameClass = nameElement.enclosingElement3;
var nameClass = nameElement.enclosingElement;
// the renamed Element shadows a member of a superclass
if (superClasses.contains(nameClass)) {
result.addError(
@ -366,7 +366,7 @@ class _RenameClassMemberValidator extends _BaseClassMemberValidator {
var subClasses = await searchEngine.searchAllSubtypes(interfaceElement);
// check shadowing of class names
for (var element in elements) {
var enclosingElement = element.enclosingElement3;
var enclosingElement = element.enclosingElement;
if (enclosingElement is InterfaceElement &&
enclosingElement.name == name) {
result.addError(

View file

@ -77,7 +77,7 @@ class RenameConstructorRefactoringImpl extends RenameRefactoringImpl {
}
void _analyzePossibleConflicts(RefactoringStatus result) {
var parentClass = element.enclosingElement3;
var parentClass = element.enclosingElement;
// Check if the "newName" is the name of the enclosing class.
if (parentClass.name == newName) {
result.addError('The constructor should not have the same name '
@ -102,7 +102,7 @@ class RenameConstructorRefactoringImpl extends RenameRefactoringImpl {
}
Future<void> _replaceSynthetic() async {
var classElement = element.enclosingElement3;
var classElement = element.enclosingElement;
var result = await sessionHelper.getElementDeclaration(classElement);
if (result == null) {

View file

@ -216,7 +216,7 @@ class _BaseUnitMemberValidator {
var declarations = await searchEngine.searchMemberDeclarations(name);
for (var declaration in declarations) {
var member = declaration.element;
var declaringClass = member.enclosingElement3 as InterfaceElement;
var declaringClass = member.enclosingElement as InterfaceElement;
var memberReferences = await searchEngine.searchReferences(member);
for (var memberReference in memberReferences) {
var refElement = memberReference.element;

View file

@ -82,7 +82,7 @@ Future<Set<ClassMemberElement>> getHierarchyMembers(
SearchEngine searchEngine, ClassMemberElement member) async {
Set<ClassMemberElement> result = HashSet<ClassMemberElement>();
// extension member
var enclosingElement = member.enclosingElement3;
var enclosingElement = member.enclosingElement;
if (enclosingElement is ExtensionElement) {
result.add(member);
return Future.value(result);
@ -126,7 +126,7 @@ Future<Set<ClassMemberElement>> getHierarchyMembers(
Future<List<ParameterElement>> getHierarchyNamedParameters(
SearchEngine searchEngine, ParameterElement element) async {
if (element.isNamed) {
var method = element.enclosingElement3;
var method = element.enclosingElement;
if (method is MethodElement) {
var hierarchyParameters = <ParameterElement>[];
var hierarchyMembers = await getHierarchyMembers(searchEngine, method);

View file

@ -30,15 +30,15 @@ extension ElementExtension on Element {
if (hasDeprecated) {
return true;
}
var ancestor = enclosingElement3;
var ancestor = enclosingElement;
if (ancestor is InterfaceElement) {
if (ancestor.hasDeprecated) {
return true;
}
ancestor = ancestor.enclosingElement3;
ancestor = ancestor.enclosingElement;
}
return ancestor is CompilationUnitElement &&
ancestor.enclosingElement3.hasDeprecated;
ancestor.enclosingElement.hasDeprecated;
}
/// Return this element and all its enclosing elements.
@ -46,7 +46,7 @@ extension ElementExtension on Element {
var current = this;
while (true) {
yield current;
var enclosing = current.enclosingElement3;
var enclosing = current.enclosingElement;
if (enclosing == null) {
break;
}
@ -69,7 +69,7 @@ extension MethodElementExtensions on MethodElement {
if (name != 'cast') {
return false;
}
var definingClass = enclosingElement3;
var definingClass = enclosingElement;
if (definingClass is! ClassElement) {
return false;
}
@ -85,7 +85,7 @@ extension MethodElementExtensions on MethodElement {
if (name != 'toList') {
return false;
}
var definingClass = enclosingElement3;
var definingClass = enclosingElement;
if (definingClass is! ClassElement) {
return false;
}
@ -98,7 +98,7 @@ extension MethodElementExtensions on MethodElement {
if (name != 'toSet') {
return false;
}
var definingClass = enclosingElement3;
var definingClass = enclosingElement;
if (definingClass is! ClassElement) {
return false;
}

View file

@ -203,7 +203,7 @@ class Flutter {
/// Return the presentation for the given Flutter `Widget` creation [node].
String? getWidgetPresentationText(InstanceCreationExpression node) {
var element = node.constructorName.staticElement?.enclosingElement3;
var element = node.constructorName.staticElement?.enclosingElement;
if (!isWidget(element)) {
return null;
}
@ -521,7 +521,7 @@ class Flutter {
/// Return `true` if the given [expr] is a constructor invocation for a
/// class that has the Flutter class `Widget` as a superclass.
bool isWidgetCreation(InstanceCreationExpression? expr) {
var element = expr?.constructorName.staticElement?.enclosingElement3;
var element = expr?.constructorName.staticElement?.enclosingElement;
return isWidget(element);
}

View file

@ -1701,7 +1701,7 @@ class CompletionResult {
var entity = expectedCompletion.syntacticEntity;
var element = _getElement(entity);
if (element != null) {
var parent = element.enclosingElement3;
var parent = element.enclosingElement;
if (parent is InterfaceElement || parent is ExtensionElement) {
if (_isStatic(element)) {
return CompletionGroup.staticMember;

View file

@ -144,7 +144,7 @@ class FlutterDataCollector extends RecursiveAstVisitor<void> {
throw StateError(
'Unresolved constructor name: ${node.constructorName}');
}
var childWidget = element.enclosingElement3.name;
var childWidget = element.enclosingElement.name;
if (!element.librarySource.uri
.toString()
.startsWith('package:flutter/')) {

View file

@ -968,9 +968,9 @@ class RelevanceDataCollector extends RecursiveAstVisitor<void> {
data.recordPercentage(
'Methods with type parameters', node.typeParameters != null);
var element = node.declaredElement!;
if (!element.isStatic && element.enclosingElement3 is InterfaceElement) {
if (!element.isStatic && element.enclosingElement is InterfaceElement) {
var overriddenMembers = inheritanceManager.getOverridden2(
element.enclosingElement3 as InterfaceElement,
element.enclosingElement as InterfaceElement,
Name(element.librarySource.uri, element.name));
if (overriddenMembers != null) {
// Consider limiting this to the most immediate override. If the
@ -1406,7 +1406,7 @@ class RelevanceDataCollector extends RecursiveAstVisitor<void> {
Element? currentElement = element;
while (currentElement != enclosingLibrary) {
depth++;
currentElement = currentElement?.enclosingElement3;
currentElement = currentElement?.enclosingElement;
}
return depth;
}
@ -1688,7 +1688,7 @@ class RelevanceDataCollector extends RecursiveAstVisitor<void> {
var reference = _leftMostIdentifier(node);
var element = reference?.staticElement;
if (element is ParameterElement) {
var definingElement = element.enclosingElement3!;
var definingElement = element.enclosingElement!;
var depth = _parameterReferenceDepth(node, definingElement);
_recordDistance('function depth of referenced parameter', depth);
} else if (element is LocalVariableElement) {

View file

@ -1,3 +1,6 @@
## 5.2.0-dev
* Deprecated `Element.enclosingElement3`, use `enclosingElement` instead.
## 5.1.0
* Deprecated `AstNode.name2`, use `name` instead.
* Deprecated `AstNode.declaredElement2`, use `declaredElement` instead.

View file

@ -57,6 +57,10 @@ import 'package:pub_semver/pub_semver.dart';
/// Clients may not extend, implement or mix-in this class.
@experimental
abstract class AugmentationImportElement implements _ExistingElement {
@override
LibraryOrAugmentationElement get enclosingElement;
@Deprecated('Use enclosingElement instead')
@override
LibraryOrAugmentationElement get enclosingElement3;
@ -236,6 +240,10 @@ abstract class ClassMemberElement implements Element {
// TODO(brianwilkerson) Either remove this class or rename it to something
// more correct.
@override
Element get enclosingElement;
@Deprecated('Use enclosingElement instead')
@override
Element get enclosingElement3;
@ -271,6 +279,11 @@ abstract class CompilationUnitElement implements UriReferencedElement {
/// Return the library, or library augmentation that encloses this unit.
@override
LibraryOrAugmentationElement get enclosingElement;
/// Return the library, or library augmentation that encloses this unit.
@Deprecated('Use enclosingElement instead')
@override
LibraryOrAugmentationElement get enclosingElement3;
/// Return a list containing all of the enums contained in this compilation
@ -344,6 +357,10 @@ abstract class ConstructorElement
@override
String get displayName;
@override
InterfaceElement get enclosingElement;
@Deprecated('Use enclosingElement instead')
@override
InterfaceElement get enclosingElement3;
@ -490,6 +507,12 @@ abstract class Element implements AnalysisTarget {
/// Return the element that either physically or logically encloses this
/// element. This will be `null` if this element is a library because
/// libraries are the top-level elements in the model.
Element? get enclosingElement;
/// Return the element that either physically or logically encloses this
/// element. This will be `null` if this element is a library because
/// libraries are the top-level elements in the model.
@Deprecated('Use enclosingElement instead')
Element? get enclosingElement3;
/// Return `true` if this element has an annotation of the form
@ -1078,6 +1101,10 @@ abstract class ExecutableElement implements FunctionTypedElement {
@override
String get displayName;
@override
Element get enclosingElement;
@Deprecated('Use enclosingElement instead')
@override
Element get enclosingElement3;
@ -1128,6 +1155,10 @@ abstract class ExtensionElement implements TypeParameterizedElement {
/// declared in this extension.
List<PropertyAccessorElement> get accessors;
@override
CompilationUnitElement get enclosingElement;
@Deprecated('Use enclosingElement instead')
@override
CompilationUnitElement get enclosingElement3;
@ -1522,6 +1553,10 @@ abstract class InterfaceOrAugmentationElement
/// class, as is the case when this element represents an enum or a mixin.
List<ConstructorElement> get constructors;
@override
CompilationUnitElement get enclosingElement;
@Deprecated('Use enclosingElement instead')
@override
CompilationUnitElement get enclosingElement3;
@ -1563,6 +1598,10 @@ abstract class InterfaceOrAugmentationElement
///
/// Clients may not extend, implement or mix-in this class.
abstract class LabelElement implements Element {
@override
ExecutableElement get enclosingElement;
@Deprecated('Use enclosingElement instead')
@override
ExecutableElement get enclosingElement3;
@ -2002,6 +2041,11 @@ abstract class PartElement implements _ExistingElement {
abstract class PrefixElement implements _ExistingElement {
/// Return the library, or library augmentation that encloses this element.
@override
LibraryOrAugmentationElement get enclosingElement;
/// Return the library, or library augmentation that encloses this element.
@Deprecated('Use enclosingElement instead')
@override
LibraryOrAugmentationElement get enclosingElement3;
/// Return the imports that share this prefix.
@ -2073,6 +2117,10 @@ abstract class PropertyAccessorElement implements ExecutableElement {
@override
PropertyAccessorElement get declaration;
@override
Element get enclosingElement;
@Deprecated('Use enclosingElement instead')
@override
Element get enclosingElement3;
@ -2192,6 +2240,10 @@ abstract class TypeAliasElement
/// a [FunctionType].
DartType get aliasedType;
@override
CompilationUnitElement get enclosingElement;
@Deprecated('Use enclosingElement instead')
@override
CompilationUnitElement get enclosingElement3;

View file

@ -19,7 +19,7 @@ Element? declaredParameterElement(
SimpleIdentifier node,
Element? element,
) {
if (element == null || element.enclosingElement3 != null) {
if (element == null || element.enclosingElement != null) {
return element;
}
@ -64,7 +64,7 @@ Element? declaredParameterElement(
/// Return the [CompilationUnitElement] that should be used for [element].
/// Throw [StateError] if the [element] is not linked into a unit.
CompilationUnitElement getUnitElement(Element element) {
for (Element? e = element; e != null; e = e.enclosingElement3) {
for (Element? e = element; e != null; e = e.enclosingElement) {
if (e is CompilationUnitElement) {
return e;
}
@ -89,21 +89,21 @@ class ElementNameComponents {
String? parameterName;
if (element is ParameterElement) {
parameterName = element.name;
element = element.enclosingElement3!;
element = element.enclosingElement!;
}
String? classMemberName;
if (element.enclosingElement3 is InterfaceElement ||
element.enclosingElement3 is ExtensionElement) {
if (element.enclosingElement is InterfaceElement ||
element.enclosingElement is ExtensionElement) {
classMemberName = element.name;
element = element.enclosingElement3!;
element = element.enclosingElement!;
}
String? unitMemberName;
if (element.enclosingElement3 is CompilationUnitElement) {
if (element.enclosingElement is CompilationUnitElement) {
unitMemberName = element.name;
if (element is ExtensionElement && unitMemberName == null) {
var enclosingUnit = element.enclosingElement3;
var enclosingUnit = element.enclosingElement;
var indexOf = enclosingUnit.extensions.indexOf(element);
unitMemberName = 'extension-$indexOf';
}
@ -140,7 +140,7 @@ class IndexElementInfo {
} else if (element.isSynthetic) {
if (elementKind == ElementKind.CONSTRUCTOR) {
kind = IndexSyntheticElementKind.constructor;
element = element.enclosingElement3!;
element = element.enclosingElement!;
} else if (element is FunctionElement &&
element.name == FunctionElement.LOAD_LIBRARY_NAME) {
kind = IndexSyntheticElementKind.loadLibrary;
@ -152,7 +152,7 @@ class IndexElementInfo {
} else if (elementKind == ElementKind.GETTER ||
elementKind == ElementKind.SETTER) {
var accessor = element as PropertyAccessorElement;
Element enclosing = element.enclosingElement3;
Element enclosing = element.enclosingElement;
bool isEnumGetter = enclosing is EnumElement;
if (isEnumGetter && accessor.name == 'index') {
kind = IndexSyntheticElementKind.enumIndex;
@ -167,7 +167,7 @@ class IndexElementInfo {
element = accessor.variable;
}
} else if (element is MethodElement) {
Element enclosing = element.enclosingElement3;
Element enclosing = element.enclosingElement;
bool isEnumMethod = enclosing is EnumElement;
if (isEnumMethod && element.name == 'toString') {
kind = IndexSyntheticElementKind.enumToString;
@ -492,14 +492,14 @@ class _IndexContributor extends GeneralizingAstVisitor {
elementKind == ElementKind.TYPE_PARAMETER ||
elementKind == ElementKind.FUNCTION &&
element is FunctionElement &&
element.enclosingElement3 is ExecutableElement ||
element.enclosingElement is ExecutableElement ||
false) {
return;
}
// Ignore named parameters of synthetic functions, e.g. created for LUB.
// These functions are not bound to a source, we cannot index them.
if (elementKind == ElementKind.PARAMETER && element is ParameterElement) {
var enclosingElement = element.enclosingElement3;
var enclosingElement = element.enclosingElement;
if (enclosingElement == null || enclosingElement.isSynthetic) {
return;
}
@ -509,7 +509,7 @@ class _IndexContributor extends GeneralizingAstVisitor {
// named parameters. Ignore them.
if (elementKind == ElementKind.PARAMETER &&
element is ParameterElement &&
element.enclosingElement3 is GenericFunctionTypeElement) {
element.enclosingElement is GenericFunctionTypeElement) {
return;
}
// Add the relation.
@ -989,7 +989,7 @@ class _IndexContributor extends GeneralizingAstVisitor {
ConstructorElement? constructor) {
var seenConstructors = <ConstructorElement?>{};
while (constructor is ConstructorElementImpl && constructor.isSynthetic) {
var enclosing = constructor.enclosingElement3;
var enclosing = constructor.enclosingElement;
if (enclosing is ClassElement && enclosing.isMixinApplication) {
var superInvocation = constructor.constantInitializers
.whereType<SuperConstructorInvocation>()

View file

@ -286,7 +286,7 @@ class Search {
} else if (element is PropertyInducingElement) {
return _searchReferences_Field(element, searchedFiles);
} else if (kind == ElementKind.FUNCTION || kind == ElementKind.METHOD) {
if (element.enclosingElement3 is ExecutableElement) {
if (element.enclosingElement is ExecutableElement) {
return _searchReferences_Local(
element, (n) => n is Block, searchedFiles);
}
@ -434,7 +434,7 @@ class Search {
// Prepare the element name.
String name = element.displayName;
if (element is ConstructorElement) {
name = element.enclosingElement3.displayName;
name = element.enclosingElement.displayName;
}
// Prepare the list of files that reference the element name.
@ -683,7 +683,7 @@ class Search {
));
if (parameter.isNamed ||
parameter.isOptionalPositional ||
parameter.enclosingElement3 is ConstructorElement) {
parameter.enclosingElement is ConstructorElement) {
results.addAll(await _searchReferences(parameter, searchedFiles));
}
return results;
@ -939,7 +939,7 @@ class _FindCompilationUnitDeclarations {
return;
}
var enclosing = element.enclosingElement3;
var enclosing = element.enclosingElement;
String? className;
String? mixinName;

View file

@ -374,7 +374,7 @@ class ConstantVerifier extends RecursiveAstVisitor<void> {
// lookup for ==
var method = element.lookUpConcreteMethod("==", _currentLibrary);
if (method == null ||
(method.enclosingElement3 as ClassElement).isDartCoreObject) {
(method.enclosingElement as ClassElement).isDartCoreObject) {
return false;
}
// there is == that we don't like

View file

@ -215,7 +215,7 @@ class ConstantEvaluationEngine {
void computeDependencies(
ConstantEvaluationTarget constant, ReferenceFinderCallback callback) {
if (constant is ConstFieldElementImpl && constant.isEnumConstant) {
var enclosing = constant.enclosingElement3;
var enclosing = constant.enclosingElement;
if (enclosing is EnumElementImpl) {
if (enclosing.name == 'values') {
return;
@ -275,7 +275,7 @@ class ConstantEvaluationEngine {
}
}
}
for (FieldElement field in constant.enclosingElement3.fields) {
for (FieldElement field in constant.enclosingElement.fields) {
// Note: non-static const isn't allowed but we handle it anyway so
// that we won't be confused by incorrect code.
if ((field.isFinal || field.isConst) &&
@ -389,7 +389,7 @@ class ConstantEvaluationEngine {
return null;
}
var typeProvider = constructor.library.typeProvider;
if (constructor.enclosingElement3 == typeProvider.symbolElement) {
if (constructor.enclosingElement == typeProvider.symbolElement) {
// The dart:core.Symbol has a const factory constructor that redirects
// to dart:_internal.Symbol. That in turn redirects to an external
// const constructor, which we won't be able to evaluate.
@ -413,7 +413,7 @@ class ConstantEvaluationEngine {
static _EnumConstant? _enumConstant(VariableElementImpl element) {
if (element is ConstFieldElementImpl && element.isEnumConstant) {
var enum_ = element.enclosingElement3;
var enum_ = element.enclosingElement;
if (enum_ is EnumElementImpl) {
var index = enum_.constants.indexOf(element);
assert(index >= 0);
@ -890,7 +890,7 @@ class ConstantVisitor extends UnifyingAstVisitor<DartObjectImpl> {
if (element.name == "identical") {
NodeList<Expression> arguments = node.argumentList.arguments;
if (arguments.length == 2) {
var enclosingElement = element.enclosingElement3;
var enclosingElement = element.enclosingElement;
if (enclosingElement is CompilationUnitElement) {
LibraryElement library = enclosingElement.library;
if (library.isDartCore) {
@ -1474,7 +1474,7 @@ class ConstantVisitor extends UnifyingAstVisitor<DartObjectImpl> {
return false;
}
return identifier.name == 'length' &&
identifier.staticElement?.enclosingElement3 is! ExtensionElement;
identifier.staticElement?.enclosingElement is! ExtensionElement;
}
void _reportNotPotentialConstants(AstNode node) {
@ -2175,7 +2175,7 @@ class _InstanceCreationEvaluator {
List<Expression> arguments, {
required bool isNullSafe,
}) {
final definingClass = _constructor.enclosingElement3;
final definingClass = _constructor.enclosingElement;
var argumentCount = arguments.length;
if (_constructor.name == "fromEnvironment") {
if (!_checkFromEnvironmentArguments(arguments, definingType)) {
@ -2286,7 +2286,7 @@ class _InstanceCreationEvaluator {
}
void _checkFields() {
var fields = _constructor.enclosingElement3.fields;
var fields = _constructor.enclosingElement.fields;
for (var field in fields) {
if ((field.isFinal || field.isConst) &&
!field.isStatic &&
@ -2575,7 +2575,7 @@ class _InstanceCreationEvaluator {
}
void _checkTypeParameters() {
var typeParameters = _constructor.enclosingElement3.typeParameters;
var typeParameters = _constructor.enclosingElement.typeParameters;
var typeArguments = _typeArguments;
if (typeParameters.isNotEmpty &&
typeArguments != null &&

View file

@ -231,7 +231,7 @@ class _Collector {
}
if (element is ParameterElement) {
var enclosing = element.enclosingElement3;
var enclosing = element.enclosingElement;
if (enclosing is ConstructorElement &&
isConstConstructorElement(enclosing)) {
if (node.thisOrAncestorOfType<ConstructorInitializer>() != null) {

View file

@ -104,10 +104,14 @@ abstract class AbstractClassElementImpl extends _ExistingElementImpl
String get displayName => name;
@override
CompilationUnitElementImpl get enclosingElement3 {
CompilationUnitElementImpl get enclosingElement {
return _enclosingElement as CompilationUnitElementImpl;
}
@Deprecated('Use enclosingElement instead')
@override
CompilationUnitElementImpl get enclosingElement3 => enclosingElement;
/// Set the fields contained in this class to the given [fields].
set fields(List<FieldElement> fields) {
for (FieldElement field in fields) {
@ -293,7 +297,7 @@ abstract class AbstractClassElementImpl extends _ExistingElementImpl
!getter.isAbstract &&
!getter.isStatic &&
getter.isAccessibleIn2(library) &&
getter.enclosingElement3 != this));
getter.enclosingElement != this));
ExecutableElement? lookUpInheritedConcreteMember(
String name, LibraryElement library) {
@ -313,7 +317,7 @@ abstract class AbstractClassElementImpl extends _ExistingElementImpl
!method.isAbstract &&
!method.isStatic &&
method.isAccessibleIn2(library) &&
method.enclosingElement3 != this));
method.enclosingElement != this));
@override
PropertyAccessorElement? lookUpInheritedConcreteSetter(
@ -323,7 +327,7 @@ abstract class AbstractClassElementImpl extends _ExistingElementImpl
!setter.isAbstract &&
!setter.isStatic &&
setter.isAccessibleIn2(library) &&
setter.enclosingElement3 != this));
setter.enclosingElement != this));
@override
MethodElement? lookUpInheritedMethod(
@ -332,7 +336,7 @@ abstract class AbstractClassElementImpl extends _ExistingElementImpl
(MethodElement method) =>
!method.isStatic &&
method.isAccessibleIn2(library) &&
method.enclosingElement3 != this));
method.enclosingElement != this));
@override
MethodElement? lookUpMethod(String methodName, LibraryElement library) =>
@ -518,9 +522,15 @@ class AugmentationImportElementImpl extends _ExistingElementImpl
required this.uri,
}) : super(null, importKeywordOffset);
@override
LibraryOrAugmentationElementImpl get enclosingElement {
return super.enclosingElement as LibraryOrAugmentationElementImpl;
}
@Deprecated('Use enclosingElement instead')
@override
LibraryOrAugmentationElementImpl get enclosingElement3 {
return super.enclosingElement3 as LibraryOrAugmentationElementImpl;
return enclosingElement;
}
@override
@ -642,7 +652,7 @@ class ClassElementImpl extends ClassOrMixinElementImpl implements ClassElement {
bool get hasNoSuchMethod {
MethodElement? method = lookUpConcreteMethod(
FunctionElement.NO_SUCH_METHOD_METHOD_NAME, library);
var definingClass = method?.enclosingElement3 as ClassElement?;
var definingClass = method?.enclosingElement as ClassElement?;
return definingClass != null && !definingClass.isDartCoreObject;
}
@ -1132,8 +1142,12 @@ class CompilationUnitElementImpl extends UriReferencedElementImpl
}
@override
LibraryOrAugmentationElement get enclosingElement3 =>
super.enclosingElement3 as LibraryOrAugmentationElement;
LibraryOrAugmentationElement get enclosingElement =>
super.enclosingElement as LibraryOrAugmentationElement;
@Deprecated('Use enclosingElement instead')
@override
LibraryOrAugmentationElement get enclosingElement3 => enclosingElement;
@override
CompilationUnitElementImpl get enclosingUnit {
@ -1210,7 +1224,7 @@ class CompilationUnitElementImpl extends UriReferencedElementImpl
}
@override
AnalysisSession get session => enclosingElement3.session;
AnalysisSession get session => enclosingElement.session;
@override
List<TopLevelVariableElement> get topLevelVariables {
@ -1384,7 +1398,7 @@ class ConstructorElementImpl extends ExecutableElementImpl
@override
String get displayName {
var className = enclosingElement3.name;
var className = enclosingElement.name;
var name = this.name;
if (name.isNotEmpty) {
return '$className.$name';
@ -1394,8 +1408,12 @@ class ConstructorElementImpl extends ExecutableElementImpl
}
@override
InterfaceElement get enclosingElement3 =>
super.enclosingElement3 as AbstractClassElementImpl;
InterfaceElement get enclosingElement =>
super.enclosingElement as AbstractClassElementImpl;
@Deprecated('Use enclosingElement instead')
@override
InterfaceElement get enclosingElement3 => enclosingElement;
@override
bool get isConst {
@ -1432,7 +1450,7 @@ class ConstructorElementImpl extends ExecutableElementImpl
@override
Element get nonSynthetic {
return isSynthetic ? enclosingElement3 : this;
return isSynthetic ? enclosingElement : this;
}
@override
@ -1457,7 +1475,7 @@ class ConstructorElementImpl extends ExecutableElementImpl
@override
InterfaceType get returnTypeInternal {
return (_returnType ??= enclosingElement3.thisType) as InterfaceType;
return (_returnType ??= enclosingElement.thisType) as InterfaceType;
}
ConstructorElement? get superConstructor {
@ -1591,7 +1609,7 @@ mixin ConstVariableElement implements ElementImpl, ConstantEvaluationTarget {
if (library == null) {
throw StateError(
'[library: null][this: ($runtimeType) $this]'
'[enclosingElement: $enclosingElement3]'
'[enclosingElement: $enclosingElement]'
'[reference: $reference]',
);
}
@ -1966,7 +1984,7 @@ class ElementAnnotationImpl implements ElementAnnotation {
final element = this.element;
if (element is ConstructorElement) {
return element.library.isDartCore &&
element.enclosingElement3.name == _deprecatedClassName;
element.enclosingElement.name == _deprecatedClassName;
} else if (element is PropertyAccessorElement) {
return element.library.isDartCore &&
element.name == _deprecatedVariableName;
@ -2098,7 +2116,7 @@ class ElementAnnotationImpl implements ElementAnnotation {
}) {
final element = this.element;
return element is ConstructorElement &&
element.enclosingElement3.name == className &&
element.enclosingElement.name == className &&
element.library.name == libraryName;
}
@ -2208,13 +2226,17 @@ abstract class ElementImpl implements Element {
_docComment = doc;
}
@override
Element? get enclosingElement => _enclosingElement;
/// Set the enclosing element of this element to the given [element].
set enclosingElement(Element? element) {
_enclosingElement = element as ElementImpl?;
}
@Deprecated('Use enclosingElement instead')
@override
Element? get enclosingElement3 => _enclosingElement;
Element? get enclosingElement3 => enclosingElement;
/// Return the enclosing unit element (which might be the same as `this`), or
/// `null` if this element is not contained in any compilation unit.
@ -2564,12 +2586,12 @@ abstract class ElementImpl implements Element {
@override
AnalysisSession? get session {
return enclosingElement3?.session;
return enclosingElement?.session;
}
@override
Source? get source {
return enclosingElement3?.source;
return enclosingElement?.source;
}
/// Return the context to resolve type parameters in, or `null` if neither
@ -2674,7 +2696,7 @@ abstract class ElementImpl implements Element {
) {
Element? element = this;
while (element != null && !predicate(element)) {
element = element.enclosingElement3;
element = element.enclosingElement;
}
return element as E?;
}
@ -2684,9 +2706,9 @@ abstract class ElementImpl implements Element {
Element? element = this;
while (element != null && element is! E) {
if (element is CompilationUnitElement) {
element = element.enclosingElement3;
element = element.enclosingElement;
} else {
element = element.enclosingElement3;
element = element.enclosingElement;
}
}
return element as E?;
@ -2756,7 +2778,7 @@ class ElementLocationImpl implements ElementLocation {
Element? ancestor = element;
while (ancestor != null) {
components.insert(0, (ancestor as ElementImpl).identifier);
ancestor = ancestor.enclosingElement3;
ancestor = ancestor.enclosingElement;
}
_components = components;
}
@ -3000,7 +3022,11 @@ abstract class ExecutableElementImpl extends _ExistingElementImpl
ExecutableElementImpl(String super.name, super.offset, {super.reference});
@override
Element get enclosingElement3 => super.enclosingElement3!;
Element get enclosingElement => super.enclosingElement!;
@Deprecated('Use enclosingElement instead')
@override
Element get enclosingElement3 => enclosingElement;
@override
bool get hasImplicitReturnType {
@ -3216,9 +3242,15 @@ class ExtensionElementImpl extends _ExistingElementImpl
@override
String get displayName => name ?? '';
@override
CompilationUnitElementImpl get enclosingElement {
return super.enclosingElement as CompilationUnitElementImpl;
}
@Deprecated('Use enclosingElement instead')
@override
CompilationUnitElementImpl get enclosingElement3 {
return super.enclosingElement3 as CompilationUnitElementImpl;
return enclosingElement;
}
@override
@ -3419,7 +3451,7 @@ class FieldElementImpl extends PropertyInducingElementImpl
///
/// Such fields are `index`, `_name`, and `values`.
bool get isSyntheticEnumField {
return enclosingElement3 is EnumElementImpl &&
return enclosingElement is EnumElementImpl &&
isSynthetic &&
getter?.isSynthetic == true &&
setter == null;
@ -3487,7 +3519,7 @@ class FunctionElementImpl extends ExecutableElementImpl
@override
String get identifier {
String identifier = super.identifier;
Element? enclosing = enclosingElement3;
Element? enclosing = enclosingElement;
if (enclosing is ExecutableElement || enclosing is VariableElement) {
identifier += "@$nameOffset";
}
@ -3687,8 +3719,12 @@ class LabelElementImpl extends ElementImpl implements LabelElement {
String get displayName => name;
@override
ExecutableElement get enclosingElement3 =>
super.enclosingElement3 as ExecutableElement;
ExecutableElement get enclosingElement =>
super.enclosingElement as ExecutableElement;
@Deprecated('Use enclosingElement instead')
@override
ExecutableElement get enclosingElement3 => enclosingElement;
/// Return `true` if this label is associated with a `switch` member (`case
/// ` or`default`).
@ -4606,8 +4642,8 @@ class MethodElementImpl extends ExecutableElementImpl implements MethodElement {
@override
Element get nonSynthetic {
if (isSynthetic && enclosingElement3 is EnumElementImpl) {
return enclosingElement3;
if (isSynthetic && enclosingElement is EnumElementImpl) {
return enclosingElement;
}
return this;
}
@ -4859,6 +4895,10 @@ class MultiplyDefinedElementImpl implements MultiplyDefinedElement {
@override
String? get documentationComment => null;
@override
Element? get enclosingElement => null;
@Deprecated('Use enclosingElement instead')
@override
Element? get enclosingElement3 => null;
@ -5080,7 +5120,11 @@ abstract class NonParameterVariableElementImpl extends VariableElementImpl
NonParameterVariableElementImpl(String super.name, super.offset);
@override
Element get enclosingElement3 => super.enclosingElement3!;
Element get enclosingElement => super.enclosingElement!;
@Deprecated('Use enclosingElement instead')
@override
Element get enclosingElement3 => enclosingElement;
bool get hasInitializer {
return hasModifier(Modifier.HAS_INITIALIZER);
@ -5346,7 +5390,7 @@ class PartElementImpl extends _ExistingElementImpl implements PartElement {
@override
CompilationUnitElementImpl get enclosingUnit {
var enclosingLibrary = enclosingElement3 as LibraryElementImpl;
var enclosingLibrary = enclosingElement as LibraryElementImpl;
return enclosingLibrary._definingCompilationUnit;
}
@ -5378,12 +5422,16 @@ class PrefixElementImpl extends _ExistingElementImpl implements PrefixElement {
String get displayName => name;
@override
LibraryOrAugmentationElementImpl get enclosingElement3 =>
super.enclosingElement3 as LibraryOrAugmentationElementImpl;
LibraryOrAugmentationElementImpl get enclosingElement =>
super.enclosingElement as LibraryOrAugmentationElementImpl;
@Deprecated('Use enclosingElement instead')
@override
LibraryOrAugmentationElementImpl get enclosingElement3 => enclosingElement;
@override
List<LibraryImportElement> get imports2 {
return enclosingElement3.libraryImports
return enclosingElement.libraryImports
.where((import) => import.prefix?.element == this)
.toList();
}
@ -5397,7 +5445,7 @@ class PrefixElementImpl extends _ExistingElementImpl implements PrefixElement {
}
@override
Scope get scope => _scope ??= PrefixScope(enclosingElement3, this);
Scope get scope => _scope ??= PrefixScope(enclosingElement, this);
@override
T? accept<T>(ElementVisitor<T> visitor) => visitor.visitPrefixElement(this);
@ -5539,7 +5587,11 @@ class PropertyAccessorElementImpl_ImplicitGetter
}
@override
Element get enclosingElement3 => variable.enclosingElement3!;
Element get enclosingElement => variable.enclosingElement!;
@Deprecated('Use enclosingElement instead')
@override
Element get enclosingElement3 => enclosingElement;
@override
bool get hasImplicitReturnType => variable.hasImplicitType;
@ -5553,8 +5605,8 @@ class PropertyAccessorElementImpl_ImplicitGetter
if (!variable.isSynthetic) {
return variable;
}
assert(enclosingElement3 is EnumElementImpl);
return enclosingElement3;
assert(enclosingElement is EnumElementImpl);
return enclosingElement;
}
@override
@ -5600,7 +5652,11 @@ class PropertyAccessorElementImpl_ImplicitSetter
}
@override
Element get enclosingElement3 => variable.enclosingElement3!;
Element get enclosingElement => variable.enclosingElement!;
@Deprecated('Use enclosingElement instead')
@override
Element get enclosingElement3 => enclosingElement;
@override
bool get isSetter => true;
@ -5698,10 +5754,10 @@ abstract class PropertyInducingElementImpl
@override
Element get nonSynthetic {
if (isSynthetic) {
if (enclosingElement3 is EnumElementImpl) {
if (enclosingElement is EnumElementImpl) {
// TODO(scheglov) remove 'index'?
if (name == 'index' || name == 'values') {
return enclosingElement3;
return enclosingElement;
}
}
return (getter ?? setter)!;
@ -5842,16 +5898,16 @@ class SuperFormalParameterElementImpl extends ParameterElementImpl
@override
ParameterElement? get superConstructorParameter {
final enclosingElement3 = this.enclosingElement3;
if (enclosingElement3 is ConstructorElementImpl) {
var superConstructor = enclosingElement3.superConstructor;
final enclosingElement = this.enclosingElement;
if (enclosingElement is ConstructorElementImpl) {
var superConstructor = enclosingElement.superConstructor;
if (superConstructor != null) {
var superParameters = superConstructor.parameters;
if (isNamed) {
return superParameters
.firstWhereOrNull((e) => e.isNamed && e.name == name);
} else {
var index = indexIn(enclosingElement3);
var index = indexIn(enclosingElement);
var positionalSuperParameters =
superParameters.where((e) => e.isPositional).toList();
if (index >= 0 && index < positionalSuperParameters.length) {
@ -5953,8 +6009,12 @@ class TypeAliasElementImpl extends _ExistingElementImpl
String get displayName => name;
@override
CompilationUnitElement get enclosingElement3 =>
super.enclosingElement3 as CompilationUnitElement;
CompilationUnitElement get enclosingElement =>
super.enclosingElement as CompilationUnitElement;
@Deprecated('Use enclosingElement instead')
@override
CompilationUnitElement get enclosingElement3 => enclosingElement;
/// Returns whether this alias is a "proper rename" of [aliasedClass], as
/// defined in the constructor-tearoffs specification.
@ -6206,7 +6266,7 @@ class TypeParameterElementImpl extends ElementImpl
return true;
}
if (other is TypeParameterElement) {
if (other.enclosingElement3 == null || enclosingElement3 == null) {
if (other.enclosingElement == null || enclosingElement == null) {
return identical(other, this);
}
return other.location == location;
@ -6431,7 +6491,7 @@ mixin _HasLibraryMixin on ElementImpl {
Source get librarySource => library.source;
@override
Source get source => enclosingElement3!.source!;
Source get source => enclosingElement!.source!;
}
/// Instances of [List]s that are used as "not yet computed" values, they

View file

@ -26,7 +26,7 @@ extension ElementAnnotationExtensions on ElementAnnotation {
}
}
} else if (element is ConstructorElement) {
interfaceElement = element.enclosingElement3;
interfaceElement = element.enclosingElement;
}
if (interfaceElement == null) {
return const <TargetKind>{};
@ -69,21 +69,21 @@ extension ElementExtension on Element {
return true;
}
var ancestor = enclosingElement3;
var ancestor = enclosingElement;
if (ancestor is InterfaceElement) {
if (ancestor.hasDoNotStore) {
return true;
}
ancestor = ancestor.enclosingElement3;
ancestor = ancestor.enclosingElement;
} else if (ancestor is ExtensionElement) {
if (ancestor.hasDoNotStore) {
return true;
}
ancestor = ancestor.enclosingElement3;
ancestor = ancestor.enclosingElement;
}
return ancestor is CompilationUnitElement &&
ancestor.enclosingElement3.hasDoNotStore;
ancestor.enclosingElement.hasDoNotStore;
}
/// Return `true` if this element is an instance member of a class or mixin.
@ -95,7 +95,7 @@ extension ElementExtension on Element {
/// [PropertyAccessorElement]s.
bool get isInstanceMember {
var this_ = this;
var enclosing = this_.enclosingElement3;
var enclosing = this_.enclosingElement;
if (enclosing is InterfaceElement) {
return this_ is MethodElement && !this_.isStatic ||
this_ is PropertyAccessorElement && !this_.isStatic;
@ -106,7 +106,7 @@ extension ElementExtension on Element {
extension ExecutableElementExtension on ExecutableElement {
bool get isEnumConstructor {
return this is ConstructorElement && enclosingElement3 is EnumElementImpl;
return this is ConstructorElement && enclosingElement is EnumElementImpl;
}
}

View file

@ -367,7 +367,7 @@ class InheritanceManager3 {
continue;
}
var class_ = executable.enclosingElement3;
var class_ = executable.enclosingElement;
if (class_ is ClassElement && class_.isDartCoreObject) {
continue;
}
@ -520,7 +520,7 @@ class InheritanceManager3 {
}
var current = currentList.single;
if (candidate.enclosingElement3 == mixinElement) {
if (candidate.enclosingElement == mixinElement) {
namedCandidates[name] = [
isNonNullableByDefault
? candidate
@ -716,7 +716,7 @@ class InheritanceManager3 {
Name name,
ExecutableElement executable,
) {
if (executable.enclosingElement3 == class_) {
if (executable.enclosingElement == class_) {
return executable;
}
@ -906,7 +906,7 @@ class InheritanceManager3 {
}
static bool _isDeclaredInObject(ExecutableElement element) {
var enclosing = element.enclosingElement3;
var enclosing = element.enclosingElement;
// TODO(scheglov) `is! MixinElement` after the separation.
return enclosing is InterfaceElement &&
enclosing.supertype == null &&

View file

@ -44,7 +44,11 @@ class ConstructorMember extends ExecutableMember
String get displayName => declaration.displayName;
@override
InterfaceElement get enclosingElement3 => declaration.enclosingElement3;
InterfaceElement get enclosingElement => declaration.enclosingElement;
@Deprecated('Use enclosingElement instead')
@override
InterfaceElement get enclosingElement3 => enclosingElement;
@override
bool get isConst => declaration.isConst;
@ -345,7 +349,11 @@ class FieldMember extends VariableMember implements FieldElement {
String get displayName => declaration.displayName;
@override
Element get enclosingElement3 => declaration.enclosingElement3;
Element get enclosingElement => declaration.enclosingElement;
@Deprecated('Use enclosingElement instead')
@override
Element get enclosingElement3 => enclosingElement;
@override
PropertyAccessorElement? get getter {
@ -435,7 +443,11 @@ class FunctionMember extends ExecutableMember implements FunctionElement {
FunctionElement get declaration => super.declaration as FunctionElement;
@override
Element get enclosingElement3 => declaration.enclosingElement3;
Element get enclosingElement => declaration.enclosingElement;
@Deprecated('Use enclosingElement instead')
@override
Element get enclosingElement3 => enclosingElement;
@override
bool get isDartCoreIdentical => declaration.isDartCoreIdentical;
@ -494,7 +506,11 @@ abstract class Member implements Element {
String? get documentationComment => _declaration.documentationComment;
@override
Element? get enclosingElement3 => _declaration.enclosingElement3;
Element? get enclosingElement => _declaration.enclosingElement;
@Deprecated('Use enclosingElement instead')
@override
Element? get enclosingElement3 => enclosingElement;
@override
bool get hasAlwaysThrows => _declaration.hasAlwaysThrows;
@ -779,7 +795,11 @@ class MethodMember extends ExecutableMember implements MethodElement {
MethodElement get declaration => super.declaration as MethodElement;
@override
Element get enclosingElement3 => declaration.enclosingElement3;
Element get enclosingElement => declaration.enclosingElement;
@Deprecated('Use enclosingElement instead')
@override
Element get enclosingElement3 => enclosingElement;
@override
String get name => declaration.name;
@ -863,7 +883,11 @@ class ParameterMember extends VariableMember
String? get defaultValueCode => declaration.defaultValueCode;
@override
Element? get enclosingElement3 => declaration.enclosingElement3;
Element? get enclosingElement => declaration.enclosingElement;
@Deprecated('Use enclosingElement instead')
@override
Element? get enclosingElement3 => enclosingElement;
@override
bool get hasDefaultValue => declaration.hasDefaultValue;
@ -1004,7 +1028,11 @@ class PropertyAccessorMember extends ExecutableMember
super.declaration as PropertyAccessorElement;
@override
Element get enclosingElement3 => declaration.enclosingElement3;
Element get enclosingElement => declaration.enclosingElement;
@Deprecated('Use enclosingElement instead')
@override
Element get enclosingElement3 => enclosingElement;
@override
bool get isGetter => declaration.isGetter;

View file

@ -1717,7 +1717,7 @@ class TypeSystemImpl implements TypeSystem {
// If the method being invoked comes from an extension, don't refine the
// type because we can only make guarantees about methods defined in the
// SDK, and the numeric methods we refine are all instance methods.
if (methodElement.enclosingElement3 is ExtensionElement) {
if (methodElement.enclosingElement is ExtensionElement) {
return currentType;
}
@ -1821,7 +1821,7 @@ class TypeSystemImpl implements TypeSystem {
// If the method being invoked comes from an extension, don't refine the
// type because we can only make guarantees about methods defined in the
// SDK, and the numeric methods we refine are all instance methods.
if (methodElement.enclosingElement3 is ExtensionElement) {
if (methodElement.enclosingElement is ExtensionElement) {
return currentType;
}

View file

@ -47,7 +47,7 @@ ConstructorElement? _getActualConstructorElement(
ConstructorElement? constructor) {
var seenConstructors = <ConstructorElement?>{};
while (constructor is ConstructorElementImpl && constructor.isSynthetic) {
var enclosing = constructor.enclosingElement3;
var enclosing = constructor.enclosingElement;
if (enclosing is ClassElement && enclosing.isMixinApplication) {
var superInvocation = constructor.constantInitializers
.whereType<SuperConstructorInvocation>()
@ -77,7 +77,7 @@ LibraryImportElement? _getImportElement(
String prefix,
Element element,
Map<LibraryImportElement, Set<Element>> importElementsMap) {
if (element.enclosingElement3 is! CompilationUnitElement) {
if (element.enclosingElement is! CompilationUnitElement) {
return null;
}
var usedLibrary = element.library;
@ -314,7 +314,7 @@ class ReferencesCollector extends GeneralizingAstVisitor<void> {
length = 0;
}
references.add(MatchInfo(offset, length, kind));
} else if (e != null && e.enclosingElement3 == element) {
} else if (e != null && e.enclosingElement == element) {
kind = MatchKind.REFERENCE;
offset = node.offset;
length = element.nameLength;

View file

@ -30,7 +30,7 @@ class ConstructorReferenceResolver {
node.constructorName.accept(_resolver);
var element = node.constructorName.staticElement;
if (element != null && !element.isFactory) {
final enclosingElement = element.enclosingElement3;
final enclosingElement = element.enclosingElement;
if (enclosingElement is ClassElement && enclosingElement.isAbstract) {
_resolver.errorReporter.reportErrorForNode(
CompileTimeErrorCode

View file

@ -174,7 +174,7 @@ class FunctionReferenceResolver {
ExecutableElement element, {
required bool implicitReceiver,
}) {
var enclosingElement = element.enclosingElement3;
var enclosingElement = element.enclosingElement;
if (implicitReceiver) {
if (_resolver.enclosingExtension != null) {
_resolver.errorReporter.reportErrorForNode(

View file

@ -212,7 +212,7 @@ class MethodInvocationResolver with ScopeHelpers {
ExecutableElement element,
bool nullReceiver,
) {
var enclosingElement = element.enclosingElement3;
var enclosingElement = element.enclosingElement;
if (nullReceiver) {
if (_resolver.enclosingExtension != null) {
_resolver.errorReporter.reportErrorForNode(

View file

@ -569,7 +569,7 @@ class _ErrorHelper {
if (element is LocalVariableElement ||
(element is FunctionElement &&
element.enclosingElement3 is ExecutableElement)) {
element.enclosingElement is ExecutableElement)) {
errorReporter.reportError(
DiagnosticFactory().referencedBeforeDeclaration(
errorReporter.source,

View file

@ -315,7 +315,7 @@ class PropertyElementResolver with ScopeHelpers {
propertyName,
);
} else {
var enclosingElement = element.enclosingElement3;
var enclosingElement = element.enclosingElement;
if (enclosingElement is ExtensionElement &&
enclosingElement.name == null) {
_resolver.errorReporter.reportErrorForNode(

View file

@ -180,9 +180,9 @@ class DiagnosticFactory {
return AnalysisError(
source, errorNode.offset, errorNode.length, errorCode, [
member.name,
member.enclosingElement3.name!,
member.enclosingElement.name!,
member.type,
superMember.enclosingElement3.name!,
superMember.enclosingElement.name!,
superMember.type,
], [
// Only include the context location for INVALID_OVERRIDE because for

View file

@ -91,7 +91,7 @@ class AssignmentVerifier {
_errorReporter.reportErrorForNode(
CompileTimeErrorCode.ASSIGNMENT_TO_FINAL_NO_SETTER,
node,
[variable.name, variable.enclosingElement3.displayName],
[variable.name, variable.enclosingElement.displayName],
);
} else {
_errorReporter.reportErrorForNode(

View file

@ -173,7 +173,7 @@ class BestPracticesVerifier extends RecursiveAstVisitor<void> {
}
}
} else if (parent is ConstructorDeclaration) {
var class_ = parent.declaredElement!.enclosingElement3;
var class_ = parent.declaredElement!.enclosingElement;
if (class_.isPrivate || (parentElement?.isPrivate ?? false)) {
_errorReporter.reportErrorForNode(
HintCode.INVALID_INTERNAL_ANNOTATION, node, []);
@ -325,7 +325,7 @@ class BestPracticesVerifier extends RecursiveAstVisitor<void> {
var invokedElement = element.element!;
var name = invokedElement.name;
if (invokedElement is ConstructorElement) {
var className = invokedElement.enclosingElement3.name;
var className = invokedElement.enclosingElement.name;
if (name!.isEmpty) {
name = className;
} else {
@ -481,7 +481,7 @@ class BestPracticesVerifier extends RecursiveAstVisitor<void> {
final element = field.declaredElement;
if (element is PropertyAccessorElement || element is FieldElement) {
Name name = Name(_currentLibrary.source.uri, element!.name);
Element enclosingElement = element.enclosingElement3!;
Element enclosingElement = element.enclosingElement!;
if (enclosingElement is InterfaceElement) {
var overridden = _inheritanceManager
.getMember2(enclosingElement, name, forSuper: true);
@ -507,7 +507,7 @@ class BestPracticesVerifier extends RecursiveAstVisitor<void> {
_errorReporter.reportErrorForToken(
HintCode.INVALID_OVERRIDE_OF_NON_VIRTUAL_MEMBER, field.name, [
field.name.lexeme,
overriddenElement.enclosingElement3.displayName
overriddenElement.enclosingElement.displayName
]);
}
if (!_invalidAccessVerifier._inTestDirectory) {
@ -650,7 +650,7 @@ class BestPracticesVerifier extends RecursiveAstVisitor<void> {
void visitMethodDeclaration(MethodDeclaration node) {
bool wasInDoNotStoreMember = _inDoNotStoreMember;
var element = node.declaredElement!;
var enclosingElement = element.enclosingElement3;
var enclosingElement = element.enclosingElement;
Name name = Name(_currentLibrary.source.uri, element.name);
@ -700,10 +700,9 @@ class BestPracticesVerifier extends RecursiveAstVisitor<void> {
// always named, so we can safely assume
// `overriddenElement.enclosingElement3.name` is non-`null`.
_errorReporter.reportErrorForToken(
HintCode.INVALID_OVERRIDE_OF_NON_VIRTUAL_MEMBER, node.name, [
node.name.lexeme,
overriddenElement.enclosingElement3.displayName
]);
HintCode.INVALID_OVERRIDE_OF_NON_VIRTUAL_MEMBER,
node.name,
[node.name.lexeme, overriddenElement.enclosingElement.displayName]);
}
super.visitMethodDeclaration(node);
@ -1481,7 +1480,7 @@ class BestPracticesVerifier extends RecursiveAstVisitor<void> {
SimpleIdentifier name = invocation.methodName;
if (name.name == FunctionElement.NO_SUCH_METHOD_METHOD_NAME) {
var methodElement = name.staticElement;
var classElement = methodElement?.enclosingElement3;
var classElement = methodElement?.enclosingElement;
return methodElement is MethodElement &&
classElement is ClassElement &&
!classElement.isDartCoreObject;
@ -1984,7 +1983,7 @@ class _InvalidAccessVerifier {
SimpleIdentifier identifier, Element element) {
bool hasProtected = _hasProtected(element);
if (hasProtected) {
var definingClass = element.enclosingElement3 as InterfaceElement;
var definingClass = element.enclosingElement as InterfaceElement;
if (_hasTypeOrSuperType(_enclosingClass, definingClass)) {
return;
}
@ -2023,7 +2022,7 @@ class _InvalidAccessVerifier {
node = identifier;
}
var definingClass = element.enclosingElement3;
var definingClass = element.enclosingElement;
if (hasProtected) {
_errorReporter.reportErrorForNode(
HintCode.INVALID_USE_OF_PROTECTED_MEMBER,
@ -2079,12 +2078,12 @@ class _InvalidAccessVerifier {
bool _hasProtected(Element element) {
if (element is PropertyAccessorElement &&
element.enclosingElement3 is InterfaceElement &&
element.enclosingElement is InterfaceElement &&
(element.hasProtected || element.variable.hasProtected)) {
return true;
}
if (element is MethodElement &&
element.enclosingElement3 is InterfaceElement &&
element.enclosingElement is InterfaceElement &&
element.hasProtected) {
return true;
}

View file

@ -131,9 +131,9 @@ class CovariantParametersVerifier {
errorNode.length,
[
_thisMember.name,
_thisMember.enclosingElement3.name!,
_thisMember.enclosingElement.name!,
_thisMember.type,
superMember.enclosingElement3.name!,
superMember.enclosingElement.name!,
superMember.type,
],
);
@ -144,7 +144,7 @@ class CovariantParametersVerifier {
List<_SuperMember> _superMembers() {
var classHierarchy = _session.classHierarchy;
var classElement = _thisMember.enclosingElement3 as InterfaceElement;
var classElement = _thisMember.enclosingElement as InterfaceElement;
var interfaces = classHierarchy.implementedInterfaces(classElement);
var superMembers = <_SuperMember>[];
@ -272,6 +272,5 @@ class _SuperParameter {
_SuperParameter(this.element, this.type);
ExecutableElement get member =>
element.enclosingElement3 as ExecutableElement;
ExecutableElement get member => element.enclosingElement as ExecutableElement;
}

View file

@ -167,7 +167,7 @@ abstract class BaseDeprecatedMemberUseVerifier {
// TODO(jwren) We should modify ConstructorElement.getDisplayName(),
// or have the logic centralized elsewhere, instead of doing this logic
// here.
displayName = element.enclosingElement3.displayName;
displayName = element.enclosingElement.displayName;
if (element.displayName.isNotEmpty) {
displayName = "$displayName.${element.displayName}";
}
@ -240,7 +240,7 @@ abstract class BaseDeprecatedMemberUseVerifier {
/// Return `true` if [element] is a [ParameterElement] declared in [node].
static bool _isLocalParameter(Element? element, AstNode? node) {
if (element is ParameterElement) {
var definingFunction = element.enclosingElement3 as ExecutableElement;
var definingFunction = element.enclosingElement as ExecutableElement;
for (; node != null; node = node.parent) {
if (node is ConstructorDeclaration) {

View file

@ -150,7 +150,7 @@ class DuplicateDefinitionVerifier {
[
enumElement.displayName,
baseName,
inherited.enclosingElement3.displayName,
inherited.enclosingElement.displayName,
],
);
}
@ -177,7 +177,7 @@ class DuplicateDefinitionVerifier {
[
enumElement.displayName,
baseName,
inherited.enclosingElement3.displayName,
inherited.enclosingElement.displayName,
],
);
}

View file

@ -53,23 +53,23 @@ class GetterSetterTypesVerifier {
var setterType = setter.parameters[0].type;
if (!_match(getterType, setterType)) {
Element errorElement;
if (getter.enclosingElement3 == element) {
if (getter.enclosingElement == element) {
errorElement = getter;
} else if (setter.enclosingElement3 == element) {
} else if (setter.enclosingElement == element) {
errorElement = setter;
} else {
errorElement = element;
}
var getterName = getter.displayName;
if (getter.enclosingElement3 != element) {
var getterClassName = getter.enclosingElement3.displayName;
if (getter.enclosingElement != element) {
var getterClassName = getter.enclosingElement.displayName;
getterName = '$getterClassName.$getterName';
}
var setterName = setter.displayName;
if (setter.enclosingElement3 != element) {
var setterClassName = setter.enclosingElement3.displayName;
if (setter.enclosingElement != element) {
var setterClassName = setter.enclosingElement.displayName;
setterName = '$setterClassName.$setterName';
}

View file

@ -94,7 +94,7 @@ class GatherUsedImportedElementsVisitor extends RecursiveAstVisitor<void> {
void _recordIfExtensionMember(Element? element) {
if (element != null) {
var enclosingElement = element.enclosingElement3;
var enclosingElement = element.enclosingElement;
if (enclosingElement is ExtensionElement) {
_recordUsedExtension(enclosingElement);
}
@ -165,7 +165,7 @@ class GatherUsedImportedElementsVisitor extends RecursiveAstVisitor<void> {
if (_recordPrefixMap(identifier, element)) {
return;
}
var enclosingElement = element.enclosingElement3;
var enclosingElement = element.enclosingElement;
if (enclosingElement is CompilationUnitElement) {
_recordUsedElement(element);
} else if (enclosingElement is ExtensionElement) {

View file

@ -557,7 +557,7 @@ class _ClassVerifier {
.INVALID_OVERRIDE_DIFFERENT_DEFAULT_VALUES_NAMED,
derivedOptionalNodes[i],
[
baseExecutable.enclosingElement3.displayName,
baseExecutable.enclosingElement.displayName,
baseExecutable.displayName,
name
],
@ -586,7 +586,7 @@ class _ClassVerifier {
.INVALID_OVERRIDE_DIFFERENT_DEFAULT_VALUES_POSITIONAL,
derivedOptionalNodes[i],
[
baseExecutable.enclosingElement3.displayName,
baseExecutable.enclosingElement.displayName,
baseExecutable.displayName
],
);
@ -711,7 +711,7 @@ class _ClassVerifier {
) {
var member = concreteMap[Name(libraryUri, memberName)];
if (member != null) {
var enclosingClass = member.enclosingElement3 as InterfaceElement;
var enclosingClass = member.enclosingElement as InterfaceElement;
if (enclosingClass is! ClassElement || filter(enclosingClass)) {
reporter.reportErrorForToken(
CompileTimeErrorCode.ILLEGAL_CONCRETE_ENUM_MEMBER_INHERITANCE,
@ -752,7 +752,7 @@ class _ClassVerifier {
reporter.reportErrorForToken(
CompileTimeErrorCode.ILLEGAL_ENUM_VALUES_INHERITANCE,
classNameToken,
[inherited.enclosingElement3.name!],
[inherited.enclosingElement.name!],
);
}
}
@ -837,13 +837,13 @@ class _ClassVerifier {
token,
[
name.name,
conflict.getter.enclosingElement3.name!,
conflict.method.enclosingElement3.name!
conflict.getter.enclosingElement.name!,
conflict.method.enclosingElement.name!
],
);
} else if (conflict is CandidatesConflict) {
var candidatesStr = conflict.candidates.map((candidate) {
var className = candidate.enclosingElement3.name;
var className = candidate.enclosingElement.name;
var typeStr = candidate.type.getDisplayString(
withNullability: _isNonNullableByDefault,
);
@ -879,7 +879,7 @@ class _ClassVerifier {
}
var elementName = element.displayName;
var enclosingElement = element.enclosingElement3;
var enclosingElement = element.enclosingElement;
var enclosingName = enclosingElement.displayName;
var description = "$prefix$enclosingName.$elementName";

View file

@ -28,11 +28,11 @@ class MustCallSuperVerifier {
if (element is MethodElement && _hasConcreteSuperMethod(element)) {
_verifySuperIsCalled(
node, overridden.name, overridden.enclosingElement3.name);
node, overridden.name, overridden.enclosingElement.name);
return;
}
var enclosingElement = element.enclosingElement3;
var enclosingElement = element.enclosingElement;
if (enclosingElement is! ClassElement) {
return;
}
@ -42,7 +42,7 @@ class MustCallSuperVerifier {
.lookUpInheritedConcreteGetter(element.name, element.library);
if (inheritedConcreteGetter != null) {
_verifySuperIsCalled(
node, overridden.name, overridden.enclosingElement3.name);
node, overridden.name, overridden.enclosingElement.name);
}
return;
}
@ -57,7 +57,7 @@ class MustCallSuperVerifier {
if (name.endsWith('=')) {
name = name.substring(0, name.length - 1);
}
_verifySuperIsCalled(node, name, overridden.enclosingElement3.name);
_verifySuperIsCalled(node, name, overridden.enclosingElement.name);
}
}
}
@ -73,10 +73,10 @@ class MustCallSuperVerifier {
ExecutableElement? _findOverriddenMemberWithMustCallSuper(
ExecutableElement element) {
//Element member = node.declaredElement;
if (element.enclosingElement3 is! InterfaceElement) {
if (element.enclosingElement is! InterfaceElement) {
return null;
}
var classElement = element.enclosingElement3 as InterfaceElement;
var classElement = element.enclosingElement as InterfaceElement;
String name = element.name;
// Walk up the type hierarchy from [classElement], ignoring direct
@ -118,7 +118,7 @@ class MustCallSuperVerifier {
/// Returns whether [node] overrides a concrete method.
bool _hasConcreteSuperMethod(ExecutableElement element) {
var classElement = element.enclosingElement3 as InterfaceElement;
var classElement = element.enclosingElement as InterfaceElement;
String name = element.name;
if (classElement.supertype.isConcrete(name)) {

View file

@ -97,7 +97,7 @@ class TypeArgumentsVerifier {
return;
}
var enumElement = constructorElement.enclosingElement3;
var enumElement = constructorElement.enclosingElement;
var typeParameters = enumElement.typeParameters;
var typeArgumentList = node.arguments?.typeArguments;

View file

@ -257,7 +257,7 @@ class GatherUsedLocalElementsVisitor extends RecursiveAstVisitor<void> {
usedElements.addElement(parameter);
}
}
var enclosingElement = element?.enclosingElement3;
var enclosingElement = element?.enclosingElement;
if (element == null) {
if (isIdentifierRead) {
usedElements.unresolvedReadMembers.add(node.name);
@ -652,7 +652,7 @@ class UnusedLocalElementsVerifier extends RecursiveAstVisitor<void> {
if (element.isPrivate) {
return false;
}
var enclosingElement = element.enclosingElement3;
var enclosingElement = element.enclosingElement;
if (enclosingElement is EnumElement) {
if (element is ConstructorElement && element.isGenerative) {
@ -680,7 +680,7 @@ class UnusedLocalElementsVerifier extends RecursiveAstVisitor<void> {
bool elementIsStaticVariable =
element is VariableElement && element.isStatic;
if (element.isPublic) {
if (_isPrivateClassOrExtension(element.enclosingElement3!) &&
if (_isPrivateClassOrExtension(element.enclosingElement!) &&
elementIsStaticVariable) {
// Public static fields of private classes, mixins, and extensions are
// inaccessible from outside the library in which they are declared.
@ -717,7 +717,7 @@ class UnusedLocalElementsVerifier extends RecursiveAstVisitor<void> {
element is FunctionElement && !element.isStatic) {
// local variable or function
} else if (element is ParameterElement) {
var enclosingElement = element.enclosingElement3;
var enclosingElement = element.enclosingElement;
// Only report unused parameters of constructors, methods, and functions.
if (enclosingElement is! ConstructorElement &&
enclosingElement is! FunctionElement &&
@ -729,7 +729,7 @@ class UnusedLocalElementsVerifier extends RecursiveAstVisitor<void> {
return true;
}
if (enclosingElement is ConstructorElement &&
enclosingElement.enclosingElement3.typeParameters.isNotEmpty) {
enclosingElement.enclosingElement.typeParameters.isNotEmpty) {
// There is an issue matching arguments of instance creation
// expressions for generic classes with parameters, so for now,
// consider every parameter of a constructor of a generic class
@ -783,7 +783,7 @@ class UnusedLocalElementsVerifier extends RecursiveAstVisitor<void> {
}
Iterable<ExecutableElement> _overriddenElements(Element element) {
var enclosingElement = element.enclosingElement3;
var enclosingElement = element.enclosingElement;
if (enclosingElement is InterfaceElement) {
Name name = Name(_libraryUri, element.name!);
var overridden =
@ -865,7 +865,7 @@ class UnusedLocalElementsVerifier extends RecursiveAstVisitor<void> {
// constructor in the class. A single unused, private constructor may serve
// the purpose of preventing the class from being extended. In serving this
// purpose, the constructor is "used."
if (element.enclosingElement3.constructors.length > 1 &&
if (element.enclosingElement.constructors.length > 1 &&
!_isUsedMember(element)) {
_reportErrorForElement(
HintCode.UNUSED_ELEMENT, element, [element.displayName]);

View file

@ -377,7 +377,7 @@ class ElementResolver {
} else {
if (element.isFactory &&
// Check if we've reported [NO_GENERATIVE_CONSTRUCTORS_IN_SUPERCLASS].
!element.enclosingElement3.constructors
!element.enclosingElement.constructors
.every((constructor) => constructor.isFactory)) {
_errorReporter.reportErrorForNode(
CompileTimeErrorCode.NON_GENERATIVE_CONSTRUCTOR, node, [element]);

View file

@ -116,7 +116,7 @@ class EnclosingExecutableContext {
}
static bool _inFactoryConstructor(Element? element) {
var enclosing = element?.enclosingElement3;
var enclosing = element?.enclosingElement;
if (enclosing == null) {
return false;
}
@ -127,7 +127,7 @@ class EnclosingExecutableContext {
}
static bool _inStaticMethod(Element? element) {
var enclosing = element?.enclosingElement3;
var enclosing = element?.enclosingElement;
if (enclosing == null) {
return false;
}
@ -754,7 +754,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
@override
void visitFunctionDeclaration(FunctionDeclaration node) {
ExecutableElement functionElement = node.declaredElement!;
if (functionElement.enclosingElement3 is! CompilationUnitElement) {
if (functionElement.enclosingElement is! CompilationUnitElement) {
_hiddenElements!.declare(functionElement);
}
@ -1636,7 +1636,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
errorReporter.reportErrorForNode(
CompileTimeErrorCode.ASSIGNMENT_TO_FINAL_NO_SETTER,
highlightedNode,
[variable.name, variable.enclosingElement3.displayName],
[variable.name, variable.enclosingElement.displayName],
);
} else {
errorReporter.reportErrorForNode(
@ -1806,14 +1806,14 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
CompileTimeErrorCode.CONFLICTING_STATIC_AND_INSTANCE, method, [
_enclosingClass!.displayName,
name,
inherited.enclosingElement3.displayName,
inherited.enclosingElement.displayName,
]);
} else if (inherited is PropertyAccessorElement) {
errorReporter.reportErrorForElement(
CompileTimeErrorCode.CONFLICTING_METHOD_AND_FIELD, method, [
_enclosingClass!.displayName,
name,
inherited.enclosingElement3.displayName
inherited.enclosingElement.displayName
]);
}
}
@ -1833,14 +1833,14 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
CompileTimeErrorCode.CONFLICTING_STATIC_AND_INSTANCE, accessor, [
_enclosingClass!.displayName,
name,
inherited.enclosingElement3.displayName,
inherited.enclosingElement.displayName,
]);
} else if (inherited is MethodElement) {
errorReporter.reportErrorForElement(
CompileTimeErrorCode.CONFLICTING_FIELD_AND_METHOD, accessor, [
_enclosingClass!.displayName,
name,
inherited.enclosingElement3.displayName
inherited.enclosingElement.displayName
]);
}
}
@ -2098,11 +2098,11 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
errorReporter.reportErrorForNode(
CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_MIXIN_WITH_FIELD,
constructor.returnType,
["'${field.enclosingElement3.name}.${field.name}'"]);
["'${field.enclosingElement.name}.${field.name}'"]);
return true;
} else if (instanceFields.length > 1) {
var fieldNames = instanceFields
.map((field) => "'${field.enclosingElement3.name}.${field.name}'")
.map((field) => "'${field.enclosingElement.name}.${field.name}'")
.join(', ');
errorReporter.reportErrorForNode(
CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_MIXIN_WITH_FIELDS,
@ -2126,7 +2126,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
errorReporter.reportErrorForNode(
CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_CONST_SUPER,
initializer,
[element.enclosingElement3.displayName]);
[element.enclosingElement.displayName]);
return true;
}
}
@ -2164,7 +2164,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
return;
}
// check if there is non-final field
final classElement = constructorElement.enclosingElement3;
final classElement = constructorElement.enclosingElement;
if (classElement is! ClassElement || !classElement.hasNonFinalField) {
return;
}
@ -2935,7 +2935,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
// OK, instance member
return;
}
Element enclosingElement = element.enclosingElement3;
Element enclosingElement = element.enclosingElement;
if (enclosingElement is ExtensionElement) {
if (target is ExtensionOverride) {
// OK, target is an extension override
@ -3017,7 +3017,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
var constructorElement = node.staticElement;
if (constructorElement != null &&
constructorElement.isGenerative &&
constructorElement.enclosingElement3 is EnumElement) {
constructorElement.enclosingElement is EnumElement) {
if (_currentLibrary.featureSet.isEnabled(Feature.enhanced_enums)) {
errorReporter.reportErrorForNode(
CompileTimeErrorCode.INVALID_REFERENCE_TO_GENERATIVE_ENUM_CONSTRUCTOR,
@ -3060,7 +3060,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
return;
}
// not a class member
Element enclosingElement = element.enclosingElement3;
Element enclosingElement = element.enclosingElement;
if (enclosingElement is! InterfaceElement &&
enclosingElement is! ExtensionElement) {
return;
@ -3194,7 +3194,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
}
// We should only check exported declarations, i.e. top-level.
if (declaredElement.enclosingElement3 is! CompilationUnitElement) {
if (declaredElement.enclosingElement is! CompilationUnitElement) {
return;
}
@ -3534,7 +3534,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
namedType, [
name,
namedType.name.name,
inheritedMember.enclosingElement3.name!
inheritedMember.enclosingElement.name!
]);
return true;
}
@ -4062,7 +4062,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
redirectedElement,
redirectedConstructor,
);
var redirectedClass = redirectedElement?.enclosingElement3;
var redirectedClass = redirectedElement?.enclosingElement;
if (redirectedClass is ClassElement &&
redirectedClass.isAbstract &&
redirectedElement != null &&
@ -4330,7 +4330,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
if (_enclosingExecutable.inStaticMethod || _isInStaticVariableDeclaration) {
var element = identifier.staticElement;
if (element is TypeParameterElement &&
element.enclosingElement3 is InterfaceElement) {
element.enclosingElement is InterfaceElement) {
// The class's type parameters are not in scope for static methods.
// However all other type parameters are legal (e.g. the static method's
// type parameters, or a local function's type parameters).
@ -4572,7 +4572,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
if (element == null || element is TypeParameterElement) {
return;
}
var enclosingElement = element.enclosingElement3;
var enclosingElement = element.enclosingElement;
if (identical(enclosingElement, _enclosingClass)) {
return;
}

View file

@ -204,7 +204,7 @@ class FfiVerifier extends RecursiveAstVisitor<void> {
void visitFunctionExpressionInvocation(FunctionExpressionInvocation node) {
var element = node.staticElement;
if (element is MethodElement) {
var enclosingElement = element.enclosingElement3;
var enclosingElement = element.enclosingElement;
if (enclosingElement.isAllocatorExtension &&
element.name == _allocateExtensionMethodName) {
_validateAllocate(node);
@ -217,7 +217,7 @@ class FfiVerifier extends RecursiveAstVisitor<void> {
void visitIndexExpression(IndexExpression node) {
var element = node.staticElement;
if (element is MethodElement) {
var enclosingElement = element.enclosingElement3;
var enclosingElement = element.enclosingElement;
if (enclosingElement.isNativeStructPointerExtension ||
enclosingElement.isNativeStructArrayExtension) {
if (element.name == '[]') {
@ -230,7 +230,7 @@ class FfiVerifier extends RecursiveAstVisitor<void> {
@override
void visitInstanceCreationExpression(InstanceCreationExpression node) {
var constructor = node.constructorName.staticElement;
var class_ = constructor?.enclosingElement3;
var class_ = constructor?.enclosingElement;
if (class_.isStructSubclass || class_.isUnionSubclass) {
_errorReporter.reportErrorForNode(
FfiCode.CREATION_OF_STRUCT_OR_UNION,
@ -255,7 +255,7 @@ class FfiVerifier extends RecursiveAstVisitor<void> {
void visitMethodInvocation(MethodInvocation node) {
var element = node.methodName.staticElement;
if (element is MethodElement) {
Element enclosingElement = element.enclosingElement3;
Element enclosingElement = element.enclosingElement;
if (enclosingElement.isPointer) {
if (element.name == 'fromFunction') {
_validateFromFunction(node, element);
@ -272,7 +272,7 @@ class FfiVerifier extends RecursiveAstVisitor<void> {
}
}
} else if (element is FunctionElement) {
var enclosingElement = element.enclosingElement3;
var enclosingElement = element.enclosingElement;
if (enclosingElement is CompilationUnitElement) {
if (element.library.name == 'dart.ffi') {
if (element.name == 'sizeOf') {
@ -288,7 +288,7 @@ class FfiVerifier extends RecursiveAstVisitor<void> {
void visitPrefixedIdentifier(PrefixedIdentifier node) {
var element = node.staticElement;
if (element != null) {
var enclosingElement = element.enclosingElement3;
var enclosingElement = element.enclosingElement;
if (enclosingElement.isNativeStructPointerExtension) {
if (element.name == 'ref') {
_validateRefPrefixedIdentifier(node);
@ -302,7 +302,7 @@ class FfiVerifier extends RecursiveAstVisitor<void> {
void visitPropertyAccess(PropertyAccess node) {
var element = node.propertyName.staticElement;
if (element != null) {
var enclosingElement = element.enclosingElement3;
var enclosingElement = element.enclosingElement;
if (enclosingElement.isNativeStructPointerExtension) {
if (element.name == 'ref') {
_validateRefPropertyAccess(node);
@ -361,7 +361,7 @@ class FfiVerifier extends RecursiveAstVisitor<void> {
// Receiver can only be Pointer if the class extends
// NativeFieldWrapperClass1.
if (ffiSignature.normalParameterTypes[0].isPointer) {
final cls = declarationElement.enclosingElement3 as InterfaceElement;
final cls = declarationElement.enclosingElement as InterfaceElement;
if (!_extendsNativeFieldWrapperClass1(cls.thisType)) {
_errorReporter.reportErrorForNode(
FfiCode
@ -613,7 +613,7 @@ class FfiVerifier extends RecursiveAstVisitor<void> {
_PrimitiveDartType _typeForAnnotation(Annotation annotation) {
var element = annotation.element;
if (element is ConstructorElement) {
String name = element.enclosingElement3.name;
String name = element.enclosingElement.name;
if (_primitiveIntegerNativeTypes.contains(name)) {
return _PrimitiveDartType.int;
} else if (_primitiveDoubleNativeTypes.contains(name)) {
@ -732,7 +732,7 @@ class FfiVerifier extends RecursiveAstVisitor<void> {
List<Annotation> extraAnnotations = [];
for (Annotation annotation in annotations) {
if (annotation.element.ffiClass != null ||
annotation.element?.enclosingElement3.isAbiSpecificIntegerSubclass ==
annotation.element?.enclosingElement.isAbiSpecificIntegerSubclass ==
true) {
if (requiredFound) {
extraAnnotations.add(annotation);
@ -1307,7 +1307,7 @@ extension on Annotation {
final element = this.element;
return element is ConstructorElement &&
element.ffiClass != null &&
element.enclosingElement3.name ==
element.enclosingElement.name ==
FfiVerifier._abiSpecificIntegerMappingClassName;
}
@ -1315,21 +1315,21 @@ extension on Annotation {
final element = this.element;
return element is ConstructorElement &&
element.ffiClass != null &&
element.enclosingElement3.name == 'Array';
element.enclosingElement.name == 'Array';
}
bool get isFfiNative {
final element = this.element;
return element is ConstructorElement &&
element.ffiClass != null &&
element.enclosingElement3.name == 'FfiNative';
element.enclosingElement.name == 'FfiNative';
}
bool get isPacked {
final element = this.element;
return element is ConstructorElement &&
element.ffiClass != null &&
element.enclosingElement3.name == 'Packed';
element.enclosingElement.name == 'Packed';
}
}
@ -1373,7 +1373,7 @@ extension on ElementAnnotation {
final element = this.element;
return element is ConstructorElement &&
element.ffiClass != null &&
element.enclosingElement3.name == 'Array';
element.enclosingElement.name == 'Array';
// Note: this is 'Array' instead of '_ArraySize' because it finds the
// forwarding factory instead of the forwarded constructor.
}
@ -1382,7 +1382,7 @@ extension on ElementAnnotation {
final element = this.element;
return element is ConstructorElement &&
element.ffiClass != null &&
element.enclosingElement3.name == 'Packed';
element.enclosingElement.name == 'Packed';
}
int? get packedMemberAlignment {
@ -1397,7 +1397,7 @@ extension on Element? {
ClassElement? get ffiClass {
var element = this;
if (element is ConstructorElement) {
element = element.enclosingElement3;
element = element.enclosingElement;
}
if (element is ClassElement && element.isFfiClass) {
return element;

View file

@ -3924,7 +3924,7 @@ class ScopeResolverVisitor extends UnifyingAstVisitor<void> {
if (node.inSetterContext()) {
_localVariableInfo.potentiallyMutatedInScope.add(element);
if (_enclosingClosure != null &&
element.enclosingElement3 != _enclosingClosure) {
element.enclosingElement != _enclosingClosure) {
_localVariableInfo.potentiallyMutatedInClosure.add(element);
}
}

View file

@ -338,7 +338,7 @@ class LinterContextImpl implements LinterContext {
bool canBeConstConstructor(covariant ConstructorDeclarationImpl node) {
var element = node.declaredElement!;
final classElement = element.enclosingElement3;
final classElement = element.enclosingElement;
if (classElement is ClassElement && classElement.hasNonFinalField) {
return false;
}

View file

@ -201,7 +201,7 @@ abstract class ElementLinkedData<E extends ElementImpl> {
ResolutionReader reader,
ElementImpl element,
) {
var enclosing = element.enclosingElement3;
var enclosing = element.enclosingElement;
if (enclosing is InterfaceElement) {
reader._addTypeParameters(enclosing.typeParameters);
} else if (enclosing is CompilationUnitElement) {
@ -273,7 +273,7 @@ class EnumElementLinkedData extends ElementLinkedData<EnumElementImpl> {
@override
void _read(element, reader) {
element.metadata = reader._readAnnotationList(
unitElement: element.enclosingElement3,
unitElement: element.enclosingElement,
);
_readTypeParameters(reader, element.typeParameters);
element.supertype = reader._readOptionalInterfaceType();
@ -297,7 +297,7 @@ class ExtensionElementLinkedData
@override
void _read(element, reader) {
element.metadata = reader._readAnnotationList(
unitElement: element.enclosingElement3,
unitElement: element.enclosingElement,
);
_readTypeParameters(reader, element.typeParameters);
element.extendedType = reader.readRequiredType();
@ -1558,7 +1558,7 @@ class MixinElementLinkedData extends ElementLinkedData<MixinElementImpl> {
@override
void _read(element, reader) {
element.metadata = reader._readAnnotationList(
unitElement: element.enclosingElement3,
unitElement: element.enclosingElement,
);
_readTypeParameters(reader, element.typeParameters);
element.superclassConstraints = reader._readInterfaceTypeList();
@ -1642,7 +1642,7 @@ class ResolutionReader {
// TODO(scheglov) why to check for empty? If we have this flags.
if (arguments.isNotEmpty) {
var typeParameters =
(element.enclosingElement3 as TypeParameterizedElement)
(element.enclosingElement as TypeParameterizedElement)
.typeParameters;
var substitution = Substitution.fromPairs(typeParameters, arguments);
element =

View file

@ -866,7 +866,7 @@ class ResolutionSink extends _SummaryDataWriter {
return const [];
}
var enclosing = declaration.enclosingElement3;
var enclosing = declaration.enclosingElement;
if (enclosing is TypeParameterizedElement) {
if (enclosing is! InterfaceElement && enclosing is! ExtensionElement) {
return const <DartType>[];

View file

@ -78,7 +78,7 @@ class InformativeDataApplier {
var unitReader = SummaryDataReader(unitInfoBytes);
var unitInfo = _InfoUnit(unitReader);
final enclosing = unitElement.enclosingElement3;
final enclosing = unitElement.enclosingElement;
if (enclosing is LibraryElementImpl) {
if (identical(enclosing.definingCompilationUnit, unitElement)) {
_applyToLibrary(enclosing, unitInfo);

View file

@ -116,7 +116,7 @@ class DeclarationBuilderFromElement {
FieldDeclarationImpl _fieldElement(FieldElement element) {
assert(!_fieldMap.containsKey(element));
final enclosingClass = element.enclosingElement3 as ClassElement;
final enclosingClass = element.enclosingElement as ClassElement;
return FieldDeclarationImpl(
id: macro.RemoteInstance.uniqueId,
identifier: identifier(element),

View file

@ -47,7 +47,7 @@ class ConstantInitializersResolver {
unit.extensions.forEach(_resolveExtensionFields);
unit.mixins2.forEach(_resolveInterfaceFields);
_scope = unit.enclosingElement3.scope;
_scope = unit.enclosingElement.scope;
unit.topLevelVariables.forEach(_resolveVariable);
}
}
@ -174,7 +174,7 @@ class _ConstructorInferenceNode extends _InferenceNode {
}
}
var classElement = _constructor.enclosingElement3;
var classElement = _constructor.enclosingElement;
if (classElement is ClassElement && classElement.isMixinApplication) {
var superType = classElement.supertype;
if (superType != null) {
@ -285,7 +285,7 @@ class _InferenceDependenciesCollector extends RecursiveAstVisitor<void> {
_set.add(element);
if (element.enclosingElement3.typeParameters.isNotEmpty) {
if (element.enclosingElement.typeParameters.isNotEmpty) {
node.argumentList.accept(this);
}
}
@ -356,7 +356,7 @@ class _InitializerInference {
unit.extensions.forEach(_addExtensionElementFields);
unit.mixins2.forEach(_addClassElementFields);
_scope = unit.enclosingElement3.scope;
_scope = unit.enclosingElement.scope;
for (var element in unit.topLevelVariables) {
_addVariableNode(element);
}
@ -526,7 +526,7 @@ class _VariableInferenceNode extends _InferenceNode {
}
void _resolveInitializer({required bool forDependencies}) {
var enclosingElement = _element.enclosingElement3;
var enclosingElement = _element.enclosingElement;
var enclosingClassElement =
enclosingElement is InterfaceElement ? enclosingElement : null;
var astResolver = AstResolver(_walker._linker, _unitElement, _scope,

View file

@ -421,7 +421,7 @@ class InstanceMemberInferrer {
var conflict = conflicts.single;
if (conflict is CandidatesConflict) {
conflictExplanation = conflict.candidates.map((candidate) {
var className = candidate.enclosingElement3.name;
var className = candidate.enclosingElement.name;
var typeStr = candidate.type.getDisplayString(
withNullability: typeSystem.isNonNullableByDefault,
);
@ -537,7 +537,7 @@ class InstanceMemberInferrer {
overridden = overridden.declaration;
// Skip Object itself.
var enclosingElement = overridden.enclosingElement3;
var enclosingElement = overridden.enclosingElement;
if (enclosingElement is ClassElement &&
enclosingElement.isDartCoreObject) {
continue;

View file

@ -8,7 +8,7 @@ import 'package:analyzer/dart/ast/visitor.dart';
import 'package:analyzer/dart/element/element.dart';
MemberId computeMemberId(Element element) {
var enclosingElement = element.enclosingElement3;
var enclosingElement = element.enclosingElement;
if (enclosingElement is CompilationUnitElement) {
var memberName = element.name!;
if (element is PropertyAccessorElement && element.isSetter) {

View file

@ -1,5 +1,5 @@
name: analyzer
version: 5.1.0
version: 5.2.0-dev
description: This package provides a library that performs static analysis of Dart code.
repository: https://github.com/dart-lang/sdk/tree/main/pkg/analyzer

View file

@ -35,7 +35,7 @@ class A {
expect(name3, isNull);
if (annotationElement is ConstructorElement) {
expect(annotationElement, same(name2.staticElement));
expect(annotationElement.enclosingElement3, name1.staticElement);
expect(annotationElement.enclosingElement, name1.staticElement);
expect(annotationElement.displayName, 'A.named');
expect(annotationElement.parameters, isEmpty);
} else {
@ -61,7 +61,7 @@ class A {
expect(name3.staticElement!.displayName, 'A.named');
if (annotationElement is ConstructorElement) {
expect(annotationElement, same(name3.staticElement));
expect(annotationElement.enclosingElement3, name2.staticElement);
expect(annotationElement.enclosingElement, name2.staticElement);
expect(annotationElement.displayName, 'A.named');
expect(annotationElement.parameters, isEmpty);
} else {
@ -87,7 +87,7 @@ class A {
expect(name3.staticElement!.displayName, 'V');
if (annotationElement is PropertyAccessorElement) {
expect(annotationElement, same(name3.staticElement));
expect(annotationElement.enclosingElement3, name2.staticElement);
expect(annotationElement.enclosingElement, name2.staticElement);
expect(annotationElement.displayName, 'V');
} else {
fail('Expected "annotationElement" is PropertyAccessorElement, '
@ -110,7 +110,7 @@ class A {
expect(name2.staticElement!.displayName, 'A');
expect(name3, isNull);
if (annotationElement is ConstructorElement) {
expect(annotationElement.enclosingElement3, name2.staticElement);
expect(annotationElement.enclosingElement, name2.staticElement);
expect(annotationElement.displayName, 'A');
expect(annotationElement.parameters, isEmpty);
} else {
@ -135,7 +135,7 @@ class A {
expect(name3, isNull);
if (annotationElement is PropertyAccessorElement) {
expect(annotationElement, same(name2.staticElement));
expect(annotationElement.enclosingElement3, name1.staticElement);
expect(annotationElement.enclosingElement, name1.staticElement);
expect(annotationElement.displayName, 'V');
} else {
fail('Expected "annotationElement" is PropertyAccessorElement, '
@ -157,7 +157,7 @@ class A {
expect(name2, isNull);
expect(name3, isNull);
if (annotationElement is ConstructorElement) {
expect(annotationElement.enclosingElement3, name1.staticElement);
expect(annotationElement.enclosingElement, name1.staticElement);
expect(annotationElement.displayName, 'A');
expect(annotationElement.parameters, isEmpty);
} else {
@ -179,7 +179,7 @@ const V = 0;
expect(name3, isNull);
if (annotationElement is PropertyAccessorElement) {
expect(annotationElement, same(name1.staticElement));
expect(annotationElement.enclosingElement3, isCompilationUnitElement);
expect(annotationElement.enclosingElement, isCompilationUnitElement);
expect(annotationElement.displayName, 'V');
} else {
fail('Expected "annotationElement" is PropertyAccessorElement, '
@ -201,7 +201,7 @@ const V = 0;
expect(name3, isNull);
if (annotationElement is PropertyAccessorElement) {
expect(annotationElement, same(name2.staticElement));
expect(annotationElement.enclosingElement3, isCompilationUnitElement);
expect(annotationElement.enclosingElement, isCompilationUnitElement);
expect(annotationElement.displayName, 'V');
} else {
fail('Expected "annotationElement" is PropertyAccessorElement, '

View file

@ -1458,7 +1458,7 @@ test(C c) => c.method<bool>(arg: true);
''');
var x = findNode.namedExpression('arg: true');
var y = x.staticParameterElement!;
expect(y.enclosingElement3, isNotNull);
expect(y.enclosingElement, isNotNull);
expect(y.declaration, findElement.parameter('arg'));
}
@ -1471,7 +1471,7 @@ bool test(C c) => c.method<bool>(arg: true);
''');
var x = findNode.namedExpression('arg: true');
var y = x.staticParameterElement!;
expect(y.enclosingElement3, isNotNull);
expect(y.enclosingElement, isNotNull);
expect(y.declaration, findElement.parameter('arg'));
}

View file

@ -71,7 +71,7 @@ class C {
var constructor = findElement.unnamedConstructor('C');
var x = findElement.localFunction('x');
expect(x.enclosingElement3, constructor);
expect(x.enclosingElement, constructor);
}
}

View file

@ -102,7 +102,7 @@ class _InheritanceDataExtractor extends AstDataExtractor<String> {
for (var name in interface.map.keys) {
var executable = interface.map[name]!;
var enclosingClass = executable.enclosingElement3 as InterfaceElement;
var enclosingClass = executable.enclosingElement as InterfaceElement;
if (enclosingClass is ClassElement && enclosingClass.isDartCoreObject) {
continue;
}

View file

@ -972,7 +972,7 @@ main() {
forInvocation.argumentList.arguments[0] as FunctionExpression;
var closureElement = closure.declaredElement as FunctionElementImpl;
expect(closureElement.enclosingElement3, same(mainElement));
expect(closureElement.enclosingElement, same(mainElement));
ParameterElement itemElement = closureElement.parameters[0];
itemElement1 = itemElement;
@ -1013,7 +1013,7 @@ main() {
forInvocation.argumentList.arguments[0] as FunctionExpression;
var closureElement = closure.declaredElement as FunctionElementImpl;
expect(closureElement.enclosingElement3, same(mainElement));
expect(closureElement.enclosingElement, same(mainElement));
ParameterElement itemElement = closureElement.parameters[0];
expect(itemElement, isNot(same(itemElement1)));
@ -1056,7 +1056,7 @@ void foo(List<T> Function<T>() createList) {}
assertType(closure, 'List<T> Function<T>()');
var closureElement = closure.declaredElement as FunctionElementImpl;
expect(closureElement.enclosingElement3, findElement.function('main'));
expect(closureElement.enclosingElement, findElement.function('main'));
assertType(closureElement.returnType, 'List<T>');
expect(closureElement.parameters, isEmpty);
@ -1702,7 +1702,7 @@ main(MyEnum e) {
var methodElement = invocation.methodName.staticElement as MethodElement;
expect(methodElement.name, 'toString');
expect(methodElement.enclosingElement3, same(objectElement));
expect(methodElement.enclosingElement, same(objectElement));
}
test_error_unresolvedTypeAnnotation() async {

View file

@ -1416,7 +1416,7 @@ class _InheritanceManager3Base extends PubPackageResolutionTest {
void _assertExecutable(ExecutableElement? element, String? expected) {
if (expected != null && element != null) {
var enclosingElement = element.enclosingElement3;
var enclosingElement = element.enclosingElement;
var type = element.type;
var typeStr = typeString(type);
@ -1426,7 +1426,7 @@ class _InheritanceManager3Base extends PubPackageResolutionTest {
if (element is PropertyAccessorElement) {
var variable = element.variable;
expect(variable.enclosingElement3, same(element.enclosingElement3));
expect(variable.enclosingElement, same(element.enclosingElement));
expect(variable.name, element.displayName);
if (element.isGetter) {
expect(variable.type, element.returnType);
@ -1508,7 +1508,7 @@ class _InheritanceManager3Base extends PubPackageResolutionTest {
var element = entry.value;
var type = element.type;
var enclosingElement = element.enclosingElement3;
var enclosingElement = element.enclosingElement;
if (enclosingElement.name == 'Object') continue;
var typeStr = type.getDisplayString(withNullability: false);

View file

@ -223,7 +223,7 @@ mixin ResolutionTest implements ResourceProviderMixin {
}
void assertEnclosingElement(Element element, Element expectedEnclosing) {
expect(element.enclosingElement3, expectedEnclosing);
expect(element.enclosingElement, expectedEnclosing);
}
Future<void> assertErrorsInCode(
@ -500,7 +500,7 @@ mixin ResolutionTest implements ResourceProviderMixin {
) {
var actualMapString = Map.fromEntries(
substitution.map.entries.where((entry) {
return entry.key.enclosingElement3 is! ExecutableElement;
return entry.key.enclosingElement is! ExecutableElement;
}).map((entry) {
return MapEntry(
entry.key.name,

Some files were not shown because too many files have changed in this diff Show more