Deprecate Element.enclosingElement2, use 'enclosingElement3'.

Change-Id: I0aba589bd42648eb420051cbe04bb3ef435081e0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/253400
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
Konstantin Shcheglov 2022-08-02 18:00:14 +00:00 committed by Commit Bot
parent 5e45794796
commit 71ef76ddfd
123 changed files with 637 additions and 482 deletions

View file

@ -65,7 +65,7 @@ class CanRenameResponse {
void _analyzePossibleConflicts(
ConstructorElement element, RefactoringStatus result, String newName) {
var parentClass = element.enclosingElement2;
var parentClass = element.enclosingElement3;
// 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,7 +254,7 @@ class CheckNameResponse {
var stateName = flutterState.newName;
var match = await canRename._fileResolver.findReferences2(stateClass);
var sourcePath = stateClass.source.fullName;
var location = stateClass.enclosingElement2.lineInfo
var location = stateClass.enclosingElement3.lineInfo
.getLocation(stateClass.nameOffset);
CiderSearchMatch ciderMatch;
var searchInfo =
@ -297,7 +297,7 @@ class CheckNameResponse {
Future<CiderReplaceMatch?> _replaceSyntheticConstructor() async {
var element = canRename.refactoringElement.element;
var classElement = element.enclosingElement2;
var classElement = element.enclosingElement3;
var fileResolver = canRename._fileResolver;
var libraryPath = classElement!.library!.source.fullName;
@ -382,7 +382,7 @@ class CiderRenameComputer {
}
bool _canRenameElement(Element element) {
var enclosingElement = element.enclosingElement2;
var enclosingElement = element.enclosingElement3;
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.enclosingElement2;
final enclosingElement = element.enclosingElement3;
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?.enclosingElement2;
final classElement = staticElement?.enclosingElement3;
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.enclosingElement2 is CompilationUnitElement;
var isTopLevel = element.enclosingElement3 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.enclosingElement2 is CompilationUnitElement;
var isTopLevel = element.enclosingElement3 is CompilationUnitElement;
HighlightRegionType type;
if (element.isGetter) {
if (isTopLevel) {

View file

@ -71,7 +71,7 @@ class DartUnitHoverComputer {
hover.elementKind = element.kind.displayName;
hover.isDeprecated = element.hasDeprecated;
// not local element
if (element.enclosingElement2 is! ExecutableElement) {
if (element.enclosingElement3 is! ExecutableElement) {
// containing class
var containingClass = element.thisOrAncestorOfType<ClassElement>();
if (containingClass != null && containingClass != element) {
@ -152,7 +152,7 @@ class DartUnitHoverComputer {
element = element.field;
}
if (element is ParameterElement) {
element = element.enclosingElement2;
element = element.enclosingElement3;
}
if (element == null) {
// This can happen when the code is invalid, such as having a field formal
@ -197,9 +197,9 @@ class DartUnitHoverComputer {
var result =
dartdocInfo.processDartdoc(rawDoc, includeSummary: includeSummary);
var documentedElementClass = documentedElement.enclosingElement2;
var documentedElementClass = documentedElement.enclosingElement3;
if (documentedElementClass != null &&
documentedElementClass != element.enclosingElement2) {
documentedElementClass != element.enclosingElement3) {
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.enclosingElement2;
var parent = element.enclosingElement3;
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.enclosingElement2 is ClassElement) {
if (element.enclosingElement3 is ClassElement) {
return _OverriddenElementsFinder(element).find();
}
return OverriddenElements(element, <Element>[], <Element>[]);
@ -109,7 +109,7 @@ class _OverriddenElementsFinder {
final Set<ClassElement> _visited = <ClassElement>{};
factory _OverriddenElementsFinder(Element seed) {
var class_ = seed.enclosingElement2 as ClassElement;
var class_ = seed.enclosingElement3 as ClassElement;
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.enclosingElement2 is CompilationUnitElement) {
nodeElement.enclosingElement3 is CompilationUnitElement) {
var nodeLibrary = nodeElement.library;
var path = nodeLibrary?.definingCompilationUnit.source.fullName;
if (path == null) {

View file

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

View file

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

View file

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

View file

@ -90,7 +90,7 @@ class LibraryElementSuggestionBuilder extends GeneralizingElementVisitor {
if (element.isOperator) {
return;
}
if (element.enclosingElement2 is! CompilationUnitElement) {
if (element.enclosingElement3 is! CompilationUnitElement) {
return;
}
var returnType = element.returnType;
@ -115,7 +115,7 @@ class LibraryElementSuggestionBuilder extends GeneralizingElementVisitor {
@override
void visitPropertyAccessorElement(PropertyAccessorElement element) {
if (opType.includeReturnValueSuggestions) {
var parent = element.enclosingElement2;
var parent = element.enclosingElement3;
if (parent is ClassElement || parent is ExtensionElement) {
builder.suggestAccessor(element, inheritanceDistance: 0.0);
} else {

View file

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

View file

@ -326,7 +326,7 @@ class SuggestionBuilder {
/// referenced using a prefix, then the [prefix] should be provided.
void suggestClass(ClassElement classElement, {String? prefix}) {
var relevance = _computeTopLevelRelevance(classElement,
elementType: _instantiateClassElement(classElement));
elementType: _instantiateInterfaceElement(classElement));
_addBuilder(
_createCompletionSuggestionBuilder(
classElement,
@ -410,7 +410,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.enclosingElement2;
var enclosingClass = constructor.enclosingElement3;
var className = enclosingClass.name;
if (className.isEmpty) {
return;
@ -432,7 +432,7 @@ class SuggestionBuilder {
return;
}
var returnType = _instantiateClassElement(enclosingClass);
var returnType = _instantiateInterfaceElement(enclosingClass);
var relevance =
_computeTopLevelRelevance(constructor, elementType: returnType);
_addBuilder(
@ -458,10 +458,10 @@ class SuggestionBuilder {
} else if (element is ExtensionElement) {
suggestExtension(element, kind: kind);
} else if (element is FunctionElement &&
element.enclosingElement2 is CompilationUnitElement) {
element.enclosingElement3 is CompilationUnitElement) {
suggestTopLevelFunction(element, kind: kind);
} else if (element is PropertyAccessorElement &&
element.enclosingElement2 is CompilationUnitElement) {
element.enclosingElement3 is CompilationUnitElement) {
suggestTopLevelPropertyAccessor(element);
} else if (element is TypeAliasElement) {
suggestTypeAlias(element);
@ -474,7 +474,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.enclosingElement2;
var enumElement = constant.enclosingElement3;
var enumName = enumElement.name;
var completion = '$enumName.$constantName';
var relevance =
@ -706,7 +706,7 @@ class SuggestionBuilder {
inheritanceDistance: inheritanceDistance,
);
var enclosingElement = method.enclosingElement2;
var enclosingElement = method.enclosingElement3;
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.enclosingElement2;
var element = parameter.enclosingElement3;
// If appendColon is false, default values should never be appended.
if (element is ConstructorElement && appendColon) {
if (Flutter.instance.isWidget(element.enclosingElement2)) {
if (Flutter.instance.isWidget(element.enclosingElement3)) {
// Don't bother with nullability. It won't affect default list values.
var defaultValue =
getDefaultStringParameterValue(parameter, withNullability: false);
@ -1010,9 +1010,9 @@ class SuggestionBuilder {
void suggestTopLevelPropertyAccessor(PropertyAccessorElement accessor,
{String? prefix}) {
assert(
accessor.enclosingElement2 is CompilationUnitElement,
accessor.enclosingElement3 is CompilationUnitElement,
'Enclosing element of ${accessor.runtimeType} is '
'${accessor.enclosingElement2.runtimeType}.');
'${accessor.enclosingElement3.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
@ -1062,7 +1062,7 @@ class SuggestionBuilder {
/// referenced using a prefix, then the [prefix] should be provided.
void suggestTopLevelVariable(TopLevelVariableElement variable,
{String? prefix}) {
assert(variable.enclosingElement2 is CompilationUnitElement);
assert(variable.enclosingElement3 is CompilationUnitElement);
var relevance =
_computeTopLevelRelevance(variable, elementType: variable.type);
_addBuilder(
@ -1295,7 +1295,7 @@ class SuggestionBuilder {
withNullability: _isNonNullableByDefault,
);
var enclosingElement = element.enclosingElement2;
var enclosingElement = element.enclosingElement3;
String? declaringType;
if (enclosingElement is ClassElement) {
@ -1354,7 +1354,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.enclosingElement2;
var enclosing = element.enclosingElement3;
if (enclosing is ClassElement) {
return enclosing.name;
} else if (enclosing is ExtensionElement) {
@ -1418,7 +1418,7 @@ class SuggestionBuilder {
}
}
InterfaceType _instantiateClassElement(ClassElement element) {
InterfaceType _instantiateInterfaceElement(InterfaceElement element) {
var typeParameters = element.typeParameters;
var typeArguments = const <DartType>[];
if (typeParameters.isNotEmpty) {

View file

@ -61,7 +61,7 @@ class AddLate extends CorrectionProducer {
getter.isSynthetic &&
!getter.variable.isSynthetic &&
getter.variable.setter == null &&
getter.enclosingElement2 is ClassElement) {
getter.enclosingElement3 is ClassElement) {
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.enclosingElement2;
var declaringElement = invokedElement.enclosingElement3;
if (declaringElement is ClassElement) {
_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.enclosingElement2 == classElement;
constructorElement.enclosingElement3 == classElement;
}
}
@ -567,7 +567,7 @@ class _EnumDescription {
initializer.constructorName.staticElement;
if (constructorElement != null &&
!constructorElement.isFactory &&
constructorElement.enclosingElement2 == classElement) {
constructorElement.enclosingElement3 == 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.enclosingElement2;
var enclosingElement = element.enclosingElement3;
if (enclosingElement is ClassElement) {
referencedClasses.add(enclosingElement);
}

View file

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

View file

@ -43,7 +43,7 @@ class ConvertIntoIsNotEmpty extends CorrectionProducer {
return;
}
// should have "isNotEmpty"
var propertyTarget = propertyElement.enclosingElement2;
var propertyTarget = propertyElement.enclosingElement3;
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.enclosingElement2 != typeProvider.mapElement) {
element.enclosingElement3 != typeProvider.mapElement) {
return;
}
//

View file

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

View file

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

View file

@ -315,7 +315,7 @@ class _ReplacementEditBuilder extends RecursiveAstVisitor<void> {
}
var element = node.staticElement;
if (element is ExecutableElement &&
element.enclosingElement2 == widgetClassElement &&
element.enclosingElement3 == widgetClassElement &&
!elementsToMove.contains(element)) {
var parent = node.parent;
if (parent is PrefixedIdentifier) {
@ -358,7 +358,7 @@ class _StatelessVerifier extends RecursiveAstVisitor<void> {
void visitMethodInvocation(MethodInvocation node) {
var methodElement = node.methodName.staticElement?.declaration;
if (methodElement is ClassMemberElement) {
var classElement = methodElement.enclosingElement2;
var classElement = methodElement.enclosingElement3;
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.enclosingElement2 is! ClassElement) {
if (getter.enclosingElement3 is! ClassElement) {
return;
}

View file

@ -40,7 +40,7 @@ class QualifyReference extends CorrectionProducer {
return;
}
var enclosingElement = memberElement.enclosingElement2;
var enclosingElement = memberElement.enclosingElement3;
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.enclosingElement2 is! ClassElement) {
if (!accessor.isGetter || accessor.enclosingElement3 is! ClassElement) {
// TODO(brianwilkerson) Should we also require that the getter be synthetic?
return;
}

View file

@ -202,7 +202,7 @@ class _MatcherBuilder {
);
}
} else if (parent is SuperConstructorInvocation) {
var superclassName = parent.staticElement?.enclosingElement2.name;
var superclassName = parent.staticElement?.enclosingElement3.name;
if (superclassName != null) {
_addMatcher(
components: [parent.constructorName?.name ?? '', superclassName],
@ -503,7 +503,7 @@ class _MatcherBuilder {
}
}
if (element != null) {
var enclosingElement = element.enclosingElement2;
var enclosingElement = element.enclosingElement3;
if (enclosingElement is ClassElement) {
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.enclosingElement2;
var enclosingElement = element.enclosingElement3;
if (enclosingElement is ClassElement) {
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.enclosingElement2 is! CompilationUnitElement) {
if (element.enclosingElement3 is! CompilationUnitElement) {
return null;
}
var usedLibrary = element.library;

View file

@ -219,7 +219,7 @@ String getElementKindName(Element element) {
String getElementQualifiedName(Element element) {
var kind = element.kind;
if (kind == ElementKind.FIELD || kind == ElementKind.METHOD) {
return '${element.enclosingElement2!.displayName}.${element.displayName}';
return '${element.enclosingElement3!.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!;
@ -1379,7 +1379,7 @@ class CorrectionUtils {
/// Checks if [element] is visible in [targetExecutableElement] or
/// [targetClassElement].
bool _isTypeParameterVisible(TypeParameterElement element) {
var enclosing = element.enclosingElement2;
var enclosing = element.enclosingElement3;
return identical(enclosing, targetExecutableElement) ||
identical(enclosing, targetClassElement);
}

View file

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

View file

@ -122,7 +122,7 @@ class _WidgetDescriptionComputer {
/// The set of classes for which we are currently adding properties,
/// used to prevent infinite recursion.
final Set<ClassElement> classesBeingProcessed = <ClassElement>{};
final Set<InterfaceElement> elementsBeingProcessed = {};
/// The resolved unit with the widget [InstanceCreationExpression].
final ResolvedUnitResult resolvedUnit;
@ -278,8 +278,8 @@ class _WidgetDescriptionComputer {
constructorElement ??= classDescription?.constructor;
if (constructorElement == null) return;
var classElement = constructorElement.enclosingElement2;
if (!classesBeingProcessed.add(classElement)) return;
var classElement = constructorElement.enclosingElement3;
if (!elementsBeingProcessed.add(classElement)) return;
var existingNamed = <String>{};
if (instanceCreation != null) {
@ -320,7 +320,7 @@ class _WidgetDescriptionComputer {
);
}
classesBeingProcessed.remove(classElement);
elementsBeingProcessed.remove(classElement);
}
void _addProperty({
@ -520,7 +520,7 @@ class _WidgetDescriptionComputer {
}
protocol.FlutterWidgetPropertyValueEnumItem _toEnumItem(FieldElement field) {
var classElement = field.enclosingElement2 as ClassElement;
var classElement = field.enclosingElement3 as ClassElement;
var libraryUriStr = '${classElement.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.enclosingElement2 as ClassElement;
var enclosingClass = field.enclosingElement3 as ClassElement;
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.enclosingElement2.name;
var name = element.enclosingElement3.name;
var constructorName = element.name;
if (constructorName.isNotEmpty) {
name = '$name.$constructorName';
@ -728,13 +728,13 @@ 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.enclosingElement2, schema.RECORD_KIND);
constructorElement.enclosingElement3, schema.RECORD_KIND);
var anchorVName =
_vNameAnchor(constructorName.offset, constructorName.end);
addEdge(anchorVName, schema.REF_EDGE, enclosingEltVName);
// TODO(jwren): investigate
// assert (element.enclosingElement2 != null);
// assert (element.enclosingElement3 != null);
}
// visit children
_safelyVisitList(constructorName.type.typeArguments?.arguments);
@ -1419,7 +1419,7 @@ class SignatureElementVisitor extends GeneralizingElementVisitor<StringBuffer> {
@override
StringBuffer visitElement(Element element) {
assert(element is! MultiplyInheritedExecutableElement);
var enclosingElt = element.enclosingElement2!;
var enclosingElt = element.enclosingElement3!;
var buffer = enclosingElt.accept(this)!;
if (buffer.isNotEmpty) {
buffer.write('#');
@ -1451,7 +1451,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.enclosingElement2!.accept(this)!
return element.enclosingElement3!.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.enclosingElement2 is CompilationUnitElement) {
if (element.enclosingElement3 is CompilationUnitElement) {
await _updateElementDeclaration(element);
await _updateElementReferences(element);
}
// method
var field = element.variable;
if (field is FieldElement &&
(field.enclosingElement2 is ClassElement ||
field.enclosingElement2 is ExtensionElement)) {
(field.enclosingElement3 is ClassElement ||
field.enclosingElement3 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.enclosingElement2 is! CompilationUnitElement) {
if (element.enclosingElement3 is! CompilationUnitElement) {
return RefactoringStatus.fatal(
'Only top-level functions can be converted to getters.');
}

View file

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

View file

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

View file

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

View file

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

View file

@ -168,7 +168,7 @@ class _BaseClassMemberValidator {
var declarations = await searchEngine.searchMemberDeclarations(name);
for (var declaration in declarations) {
var nameElement = getSyntheticAccessorVariable(declaration.element);
var nameClass = nameElement.enclosingElement2;
var nameClass = nameElement.enclosingElement3;
// the renamed Element shadows a member of a superclass
if (superClasses.contains(nameClass)) {
result.addError(
@ -276,7 +276,7 @@ class _RenameClassMemberValidator extends _BaseClassMemberValidator {
var subClasses = await searchEngine.searchAllSubtypes(elementClass);
// check shadowing of class names
for (var element in elements) {
var enclosingElement = element.enclosingElement2;
var enclosingElement = element.enclosingElement3;
if (enclosingElement is ClassElement && enclosingElement.name == name) {
result.addError(
'Renamed ${elementKind.displayName} has the same name as the '

View file

@ -82,7 +82,7 @@ class RenameConstructorRefactoringImpl extends RenameRefactoringImpl {
}
void _analyzePossibleConflicts(RefactoringStatus result) {
var parentClass = element.enclosingElement2;
var parentClass = element.enclosingElement3;
// 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 '
@ -107,7 +107,7 @@ class RenameConstructorRefactoringImpl extends RenameRefactoringImpl {
}
Future<void> _replaceSynthetic() async {
var classElement = element.enclosingElement2;
var classElement = element.enclosingElement3;
var result = await AnalysisSessionHelper(session)
.getElementDeclaration(classElement);

View file

@ -214,7 +214,7 @@ class _BaseUnitMemberValidator {
var declarations = await searchEngine.searchMemberDeclarations(name);
for (var declaration in declarations) {
var member = declaration.element;
var declaringClass = member.enclosingElement2 as ClassElement;
var declaringClass = member.enclosingElement3 as ClassElement;
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.enclosingElement2;
var enclosingElement = member.enclosingElement3;
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.enclosingElement2;
var method = element.enclosingElement3;
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 = enclosingElement2;
var ancestor = enclosingElement3;
if (ancestor is ClassElement) {
if (ancestor.hasDeprecated) {
return true;
}
ancestor = ancestor.enclosingElement2;
ancestor = ancestor.enclosingElement3;
}
return ancestor is CompilationUnitElement &&
ancestor.enclosingElement2.hasDeprecated;
ancestor.enclosingElement3.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.enclosingElement2;
var enclosing = current.enclosingElement3;
if (enclosing == null) {
break;
}
@ -69,7 +69,7 @@ extension MethodElementExtensions on MethodElement {
if (name != 'cast') {
return false;
}
var definingClass = enclosingElement2;
var definingClass = enclosingElement3;
if (definingClass is! ClassElement) {
return false;
}
@ -85,7 +85,7 @@ extension MethodElementExtensions on MethodElement {
if (name != 'toList') {
return false;
}
var definingClass = enclosingElement2;
var definingClass = enclosingElement3;
if (definingClass is! ClassElement) {
return false;
}

View file

@ -192,7 +192,7 @@ class Flutter {
/// Return the presentation for the given Flutter `Widget` creation [node].
String? getWidgetPresentationText(InstanceCreationExpression node) {
var element = node.constructorName.staticElement?.enclosingElement2;
var element = node.constructorName.staticElement?.enclosingElement3;
if (!isWidget(element)) {
return null;
}
@ -486,8 +486,8 @@ class Flutter {
/// Return `true` if the given [element] is the Flutter class `Widget`, or its
/// subtype.
bool isWidget(ClassElement? element) {
if (element == null) {
bool isWidget(InterfaceElement? element) {
if (element is! ClassElement) {
return false;
}
if (_isExactWidget(element, _nameWidget, _uriFramework)) {
@ -504,7 +504,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?.enclosingElement2;
var element = expr?.constructorName.staticElement?.enclosingElement3;
return isWidget(element);
}
@ -555,7 +555,9 @@ class Flutter {
/// Return `true` if the given [element] is the exact [type] defined in the
/// file with the given [uri].
bool _isExactWidget(ClassElement? element, String type, Uri uri) {
return element != null && element.name == type && element.source.uri == uri;
bool _isExactWidget(InterfaceElement? element, String type, Uri uri) {
return element is ClassElement &&
element.name == type &&
element.source.uri == uri;
}
}

View file

@ -255,7 +255,7 @@ enum E2 { three, four }''');
expect(element.parameters, isNull);
expect(element.returnType, '_E1');
// TODO(danrubel) determine why enum constant is not marked as deprecated
//engine.ClassElement classElement = engineElement.enclosingElement2;
//engine.ClassElement classElement = engineElement.enclosingElement3;
//expect(classElement.isDeprecated, isTrue);
expect(
element.flags,

View file

@ -1699,7 +1699,7 @@ class CompletionResult {
var entity = expectedCompletion.syntacticEntity;
var element = _getElement(entity);
if (element != null) {
var parent = element.enclosingElement2;
var parent = element.enclosingElement3;
if (parent is ClassElement || 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.enclosingElement2.name;
var childWidget = element.enclosingElement3.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.enclosingElement2 is ClassElement) {
if (!element.isStatic && element.enclosingElement3 is ClassElement) {
var overriddenMembers = inheritanceManager.getOverridden2(
element.enclosingElement2 as ClassElement,
element.enclosingElement3 as ClassElement,
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?.enclosingElement2;
currentElement = currentElement?.enclosingElement3;
}
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.enclosingElement2!;
var definingElement = element.enclosingElement3!;
var depth = _parameterReferenceDepth(node, definingElement);
_recordDistance('function depth of referenced parameter', depth);
} else if (element is LocalVariableElement) {

View file

@ -15,6 +15,8 @@
Use `exceptionParameter2` and `stackTraceParameter2` instead.
* Added `FileResult.isAugmentation` and `isLibrary` to complement `isPart`.
* Deprecated 'XyzDeclaration.name' in AST, use `name2` and `declaredElement` instead.
* Deprecated `Element.enclosingElement2`, use `enclosingElement3` instead. The meaningful change is that
`ConstructorElement.enclosingElement3` returns now `IntefaceElement`, not `ClassElement`.
## 4.3.1
* Fix `identifier` for `LibraryExportElement` and `LibraryImportElement`.

View file

@ -57,13 +57,17 @@ import 'package:pub_semver/pub_semver.dart';
/// Clients may not extend, implement or mix-in this class.
@experimental
abstract class AugmentationImportElement implements _ExistingElement {
@Deprecated('Use enclosingElement2 instead')
@Deprecated('Use enclosingElement3 instead')
@override
LibraryOrAugmentationElement get enclosingElement;
@Deprecated('Use enclosingElement3 instead')
@override
LibraryOrAugmentationElement get enclosingElement2;
@override
LibraryOrAugmentationElement get enclosingElement3;
/// Returns the [LibraryAugmentationElement], if [uri] is a
/// [DirectiveUriWithAugmentation].
LibraryAugmentationElement? get importedAugmentation;
@ -214,13 +218,17 @@ abstract class ClassMemberElement implements Element {
// TODO(brianwilkerson) Either remove this class or rename it to something
// more correct.
@Deprecated('Use enclosingElement2 instead')
@Deprecated('Use enclosingElement3 instead')
@override
Element get enclosingElement;
@Deprecated('Use enclosingElement3 instead')
@override
Element get enclosingElement2;
@override
Element get enclosingElement3;
/// Return `true` if this element is a static element. A static element is an
/// element that is not associated with a particular instance, but rather with
/// an entire library or class.
@ -251,14 +259,18 @@ abstract class CompilationUnitElement implements UriReferencedElement {
/// unit.
List<ClassElement> get classes;
@Deprecated('Use enclosingElement2 instead')
@Deprecated('Use enclosingElement3 instead')
@override
LibraryElement get enclosingElement;
/// Return the library, or library augmentation that encloses this unit.
@Deprecated('Use enclosingElement3 instead')
@override
LibraryOrAugmentationElement get enclosingElement2;
/// Return the library, or library augmentation that encloses this unit.
@override
LibraryOrAugmentationElement get enclosingElement3;
/// Return a list containing all of the enums contained in this compilation
/// unit.
List<ClassElement> get enums;
@ -330,13 +342,17 @@ abstract class ConstructorElement
@override
String get displayName;
@Deprecated('Use enclosingElement2 instead')
@Deprecated('Use enclosingElement3 instead')
@override
ClassElement get enclosingElement;
@Deprecated('Use enclosingElement3 instead')
@override
ClassElement get enclosingElement2;
@override
InterfaceElement get enclosingElement3;
/// Return `true` if this constructor is a const constructor.
bool get isConst;
@ -480,14 +496,20 @@ 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.
@Deprecated('Use enclosingElement2 instead')
@Deprecated('Use enclosingElement3 instead')
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 enclosingElement3 instead')
Element? get enclosingElement2;
/// 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 enclosingElement3;
/// Return `true` if this element has an annotation of the form
/// `@alwaysThrows`.
bool get hasAlwaysThrows;
@ -1090,13 +1112,17 @@ abstract class ExecutableElement implements FunctionTypedElement {
@override
String get displayName;
@Deprecated('Use enclosingElement2 instead')
@Deprecated('Use enclosingElement3 instead')
@override
Element get enclosingElement;
@Deprecated('Use enclosingElement3 instead')
@override
Element get enclosingElement2;
@override
Element get enclosingElement3;
/// Return `true` if this executable element did not have an explicit return
/// type specified for it in the original source.
bool get hasImplicitReturnType;
@ -1158,13 +1184,17 @@ abstract class ExtensionElement implements TypeParameterizedElement {
/// declared in this extension.
List<PropertyAccessorElement> get accessors;
@Deprecated('Use enclosingElement2 instead')
@Deprecated('Use enclosingElement3 instead')
@override
CompilationUnitElement get enclosingElement;
@Deprecated('Use enclosingElement3 instead')
@override
CompilationUnitElement get enclosingElement2;
@override
CompilationUnitElement get enclosingElement3;
/// Return the type that is extended by this extension.
DartType get extendedType;
@ -1389,13 +1419,17 @@ abstract class InterfaceOrAugmentationElement
/// class, as is the case when this element represents an enum or a mixin.
List<ConstructorElement> get constructors;
@Deprecated('Use enclosingElement2 instead')
@Deprecated('Use enclosingElement3 instead')
@override
CompilationUnitElement get enclosingElement;
@Deprecated('Use enclosingElement3 instead')
@override
CompilationUnitElement get enclosingElement2;
@override
CompilationUnitElement get enclosingElement3;
/// Return a list containing all of the fields declared in this class.
List<FieldElement> get fields;
@ -1430,13 +1464,17 @@ abstract class InterfaceOrAugmentationElement
///
/// Clients may not extend, implement or mix-in this class.
abstract class LabelElement implements Element {
@Deprecated('Use enclosingElement2 instead')
@Deprecated('Use enclosingElement3 instead')
@override
ExecutableElement get enclosingElement;
@Deprecated('Use enclosingElement3 instead')
@override
ExecutableElement get enclosingElement2;
@override
ExecutableElement get enclosingElement3;
@override
String get name;
}
@ -1906,14 +1944,18 @@ abstract class PartElement implements _ExistingElement {
///
/// Clients may not extend, implement or mix-in this class.
abstract class PrefixElement implements _ExistingElement {
@Deprecated('Use enclosingElement2 instead')
@Deprecated('Use enclosingElement3 instead')
@override
LibraryElement get enclosingElement;
/// Return the library, or library augmentation that encloses this element.
@Deprecated('Use enclosingElement3 instead')
@override
LibraryOrAugmentationElement get enclosingElement2;
/// Return the library, or library augmentation that encloses this element.
@override
LibraryOrAugmentationElement get enclosingElement3;
/// Return the imports that share this prefix.
@Deprecated('Use imports2 instead')
List<ImportElement> get imports;
@ -1987,13 +2029,17 @@ abstract class PropertyAccessorElement implements ExecutableElement {
@override
PropertyAccessorElement get declaration;
@Deprecated('Use enclosingElement2 instead')
@Deprecated('Use enclosingElement3 instead')
@override
Element get enclosingElement;
@Deprecated('Use enclosingElement3 instead')
@override
Element get enclosingElement2;
@override
Element get enclosingElement3;
/// Return `true` if this accessor represents a getter.
bool get isGetter;
@ -2110,13 +2156,17 @@ abstract class TypeAliasElement
/// a [FunctionType].
DartType get aliasedType;
@Deprecated('Use enclosingElement2 instead')
@Deprecated('Use enclosingElement3 instead')
@override
CompilationUnitElement get enclosingElement;
@Deprecated('Use enclosingElement3 instead')
@override
CompilationUnitElement get enclosingElement2;
@override
CompilationUnitElement get enclosingElement3;
@override
String get name;

View file

@ -19,7 +19,7 @@ Element? declaredParameterElement(
SimpleIdentifier node,
Element? element,
) {
if (element == null || element.enclosingElement2 != null) {
if (element == null || element.enclosingElement3 != 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.enclosingElement2) {
for (Element? e = element; e != null; e = e.enclosingElement3) {
if (e is CompilationUnitElement) {
return e;
}
@ -89,21 +89,21 @@ class ElementNameComponents {
String? parameterName;
if (element is ParameterElement) {
parameterName = element.name;
element = element.enclosingElement2!;
element = element.enclosingElement3!;
}
String? classMemberName;
if (element.enclosingElement2 is ClassElement ||
element.enclosingElement2 is ExtensionElement) {
if (element.enclosingElement3 is ClassElement ||
element.enclosingElement3 is ExtensionElement) {
classMemberName = element.name;
element = element.enclosingElement2!;
element = element.enclosingElement3!;
}
String? unitMemberName;
if (element.enclosingElement2 is CompilationUnitElement) {
if (element.enclosingElement3 is CompilationUnitElement) {
unitMemberName = element.name;
if (element is ExtensionElement && unitMemberName == null) {
var enclosingUnit = element.enclosingElement2;
var enclosingUnit = element.enclosingElement3;
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.enclosingElement2!;
element = element.enclosingElement3!;
} 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.enclosingElement2;
Element enclosing = element.enclosingElement3;
bool isEnumGetter = enclosing is ClassElement && enclosing.isEnum;
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.enclosingElement2;
Element enclosing = element.enclosingElement3;
bool isEnumMethod = enclosing is ClassElement && enclosing.isEnum;
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.enclosingElement2 is ExecutableElement ||
element.enclosingElement3 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.enclosingElement2;
var enclosingElement = element.enclosingElement3;
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.enclosingElement2 is GenericFunctionTypeElement) {
element.enclosingElement3 is GenericFunctionTypeElement) {
return;
}
// Add the relation.
@ -995,8 +995,8 @@ class _IndexContributor extends GeneralizingAstVisitor {
ConstructorElement? constructor) {
var seenConstructors = <ConstructorElement?>{};
while (constructor is ConstructorElementImpl && constructor.isSynthetic) {
var enclosing = constructor.enclosingElement2;
if (enclosing.isMixinApplication) {
var enclosing = constructor.enclosingElement3;
if (enclosing is ClassElement && enclosing.isMixinApplication) {
var superInvocation = constructor.constantInitializers
.whereType<SuperConstructorInvocation>()
.singleOrNull;

View file

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

View file

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

View file

@ -198,7 +198,7 @@ class ConstantEvaluationEngine {
void computeDependencies(
ConstantEvaluationTarget constant, ReferenceFinderCallback callback) {
if (constant is ConstFieldElementImpl && constant.isEnumConstant) {
var enclosing = constant.enclosingElement2;
var enclosing = constant.enclosingElement3;
if (enclosing is EnumElementImpl) {
if (enclosing.name == 'values') {
return;
@ -258,7 +258,7 @@ class ConstantEvaluationEngine {
}
}
}
for (FieldElement field in constant.enclosingElement2.fields) {
for (FieldElement field in constant.enclosingElement3.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) &&
@ -372,7 +372,7 @@ class ConstantEvaluationEngine {
return null;
}
var typeProvider = constructor.library.typeProvider;
if (constructor.enclosingElement2 == typeProvider.symbolElement) {
if (constructor.enclosingElement3 == 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.
@ -396,7 +396,7 @@ class ConstantEvaluationEngine {
static _EnumConstant? _enumConstant(VariableElementImpl element) {
if (element is ConstFieldElementImpl && element.isEnumConstant) {
var enum_ = element.enclosingElement2;
var enum_ = element.enclosingElement3;
if (enum_ is EnumElementImpl) {
var index = enum_.constants.indexOf(element);
assert(index >= 0);
@ -873,7 +873,7 @@ class ConstantVisitor extends UnifyingAstVisitor<DartObjectImpl> {
if (element.name == "identical") {
NodeList<Expression> arguments = node.argumentList.arguments;
if (arguments.length == 2) {
var enclosingElement = element.enclosingElement2;
var enclosingElement = element.enclosingElement3;
if (enclosingElement is CompilationUnitElement) {
LibraryElement library = enclosingElement.library;
if (library.isDartCore) {
@ -1427,7 +1427,7 @@ class ConstantVisitor extends UnifyingAstVisitor<DartObjectImpl> {
return false;
}
return identifier.name == 'length' &&
identifier.staticElement?.enclosingElement2 is! ExtensionElement;
identifier.staticElement?.enclosingElement3 is! ExtensionElement;
}
void _reportNotPotentialConstants(AstNode node) {
@ -2129,7 +2129,7 @@ class _InstanceCreationEvaluator {
List<Expression> arguments, {
required bool isNullSafe,
}) {
ClassElement definingClass = _constructor.enclosingElement2;
final definingClass = _constructor.enclosingElement3;
var argumentCount = arguments.length;
if (_constructor.name == "fromEnvironment") {
if (!_checkFromEnvironmentArguments(arguments, definingType)) {
@ -2232,7 +2232,7 @@ class _InstanceCreationEvaluator {
}
void _checkFields() {
var fields = _constructor.enclosingElement2.fields;
var fields = _constructor.enclosingElement3.fields;
for (var field in fields) {
if ((field.isFinal || field.isConst) &&
!field.isStatic &&
@ -2521,7 +2521,7 @@ class _InstanceCreationEvaluator {
}
void _checkTypeParameters() {
var typeParameters = _constructor.enclosingElement2.typeParameters;
var typeParameters = _constructor.enclosingElement3.typeParameters;
var typeArguments = _typeArguments;
if (typeParameters.isNotEmpty &&
typeArguments != null &&

View file

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

View file

@ -103,17 +103,23 @@ abstract class AbstractClassElementImpl extends _ExistingElementImpl
@override
String get displayName => name;
@Deprecated('Use enclosingElement2 instead')
@Deprecated('Use enclosingElement3 instead')
@override
CompilationUnitElementImpl get enclosingElement {
return _enclosingElement as CompilationUnitElementImpl;
}
@Deprecated('Use enclosingElement3 instead')
@override
CompilationUnitElementImpl get enclosingElement2 {
return _enclosingElement as CompilationUnitElementImpl;
}
@override
CompilationUnitElementImpl get enclosingElement3 {
return _enclosingElement as CompilationUnitElementImpl;
}
/// Set the fields contained in this class to the given [fields].
set fields(List<FieldElement> fields) {
assert(!isMixinApplication);
@ -320,7 +326,7 @@ abstract class AbstractClassElementImpl extends _ExistingElementImpl
!getter.isAbstract &&
!getter.isStatic &&
getter.isAccessibleIn2(library) &&
getter.enclosingElement2 != this));
getter.enclosingElement3 != this));
ExecutableElement? lookUpInheritedConcreteMember(
String name, LibraryElement library) {
@ -340,7 +346,7 @@ abstract class AbstractClassElementImpl extends _ExistingElementImpl
!method.isAbstract &&
!method.isStatic &&
method.isAccessibleIn2(library) &&
method.enclosingElement2 != this));
method.enclosingElement3 != this));
@override
PropertyAccessorElement? lookUpInheritedConcreteSetter(
@ -350,7 +356,7 @@ abstract class AbstractClassElementImpl extends _ExistingElementImpl
!setter.isAbstract &&
!setter.isStatic &&
setter.isAccessibleIn2(library) &&
setter.enclosingElement2 != this));
setter.enclosingElement3 != this));
@override
MethodElement? lookUpInheritedMethod(
@ -359,7 +365,7 @@ abstract class AbstractClassElementImpl extends _ExistingElementImpl
(MethodElement method) =>
!method.isStatic &&
method.isAccessibleIn2(library) &&
method.enclosingElement2 != this));
method.enclosingElement3 != this));
@override
MethodElement? lookUpMethod(String methodName, LibraryElement library) =>
@ -545,17 +551,23 @@ class AugmentationImportElementImpl extends _ExistingElementImpl
required this.uri,
}) : super(null, importKeywordOffset);
@Deprecated('Use enclosingElement2 instead')
@Deprecated('Use enclosingElement3 instead')
@override
LibraryOrAugmentationElementImpl get enclosingElement {
return super.enclosingElement2 as LibraryOrAugmentationElementImpl;
}
@Deprecated('Use enclosingElement3 instead')
@override
LibraryOrAugmentationElementImpl get enclosingElement2 {
return super.enclosingElement2 as LibraryOrAugmentationElementImpl;
}
@override
LibraryOrAugmentationElementImpl get enclosingElement3 {
return super.enclosingElement3 as LibraryOrAugmentationElementImpl;
}
@override
LibraryAugmentationElementImpl? get importedAugmentation {
final uri = this.uri;
@ -714,7 +726,7 @@ class ClassElementImpl extends AbstractClassElementImpl {
bool get hasNoSuchMethod {
MethodElement? method = lookUpConcreteMethod(
FunctionElement.NO_SUCH_METHOD_METHOD_NAME, library);
var definingClass = method?.enclosingElement2 as ClassElement?;
var definingClass = method?.enclosingElement3 as ClassElement?;
return definingClass != null && !definingClass.isDartCoreObject;
}
@ -1140,15 +1152,20 @@ class CompilationUnitElementImpl extends UriReferencedElementImpl
_classes = classes;
}
@Deprecated('Use enclosingElement2 instead')
@Deprecated('Use enclosingElement3 instead')
@override
LibraryElement get enclosingElement =>
super.enclosingElement2 as LibraryElement;
@Deprecated('Use enclosingElement3 instead')
@override
LibraryOrAugmentationElement get enclosingElement2 =>
super.enclosingElement2 as LibraryOrAugmentationElement;
@override
LibraryOrAugmentationElement get enclosingElement3 =>
super.enclosingElement3 as LibraryOrAugmentationElement;
@override
CompilationUnitElementImpl get enclosingUnit {
return this;
@ -1224,7 +1241,7 @@ class CompilationUnitElementImpl extends UriReferencedElementImpl
}
@override
AnalysisSession get session => enclosingElement2.session;
AnalysisSession get session => enclosingElement3.session;
@override
List<TopLevelVariableElement> get topLevelVariables {
@ -1398,7 +1415,7 @@ class ConstructorElementImpl extends ExecutableElementImpl
@override
String get displayName {
var className = enclosingElement2.name;
var className = enclosingElement3.name;
var name = this.name;
if (name.isNotEmpty) {
return '$className.$name';
@ -1407,15 +1424,20 @@ class ConstructorElementImpl extends ExecutableElementImpl
}
}
@Deprecated('Use enclosingElement2 instead')
@Deprecated('Use enclosingElement3 instead')
@override
AbstractClassElementImpl get enclosingElement =>
super.enclosingElement2 as AbstractClassElementImpl;
@Deprecated('Use enclosingElement3 instead')
@override
AbstractClassElementImpl get enclosingElement2 =>
super.enclosingElement2 as AbstractClassElementImpl;
@override
InterfaceElement get enclosingElement3 =>
super.enclosingElement3 as AbstractClassElementImpl;
@override
bool get isConst {
return hasModifier(Modifier.CONST);
@ -1451,7 +1473,7 @@ class ConstructorElementImpl extends ExecutableElementImpl
@override
Element get nonSynthetic {
return isSynthetic ? enclosingElement2 : this;
return isSynthetic ? enclosingElement3 : this;
}
@override
@ -1476,7 +1498,7 @@ class ConstructorElementImpl extends ExecutableElementImpl
@override
InterfaceType get returnTypeInternal {
return (_returnType ??= enclosingElement2.thisType) as InterfaceType;
return (_returnType ??= enclosingElement3.thisType) as InterfaceType;
}
ConstructorElement? get superConstructor {
@ -1605,7 +1627,7 @@ mixin ConstVariableElement implements ElementImpl, ConstantEvaluationTarget {
if (library == null) {
throw StateError(
'[library: null][this: ($runtimeType) $this]'
'[enclosingElement2: $enclosingElement2]'
'[enclosingElement: $enclosingElement3]'
'[reference: $reference]',
);
}
@ -1977,7 +1999,7 @@ class ElementAnnotationImpl implements ElementAnnotation {
final element = this.element;
if (element is ConstructorElement) {
return element.library.isDartCore &&
element.enclosingElement2.name == _DEPRECATED_CLASS_NAME;
element.enclosingElement3.name == _DEPRECATED_CLASS_NAME;
} else if (element is PropertyAccessorElement) {
return element.library.isDartCore &&
element.name == _DEPRECATED_VARIABLE_NAME;
@ -2107,7 +2129,7 @@ class ElementAnnotationImpl implements ElementAnnotation {
}) {
final element = this.element;
return element is ConstructorElement &&
element.enclosingElement2.name == className &&
element.enclosingElement3.name == className &&
element.library.name == libraryName;
}
@ -2221,7 +2243,7 @@ abstract class ElementImpl implements Element {
_docComment = doc;
}
@Deprecated('Use enclosingElement2 instead')
@Deprecated('Use enclosingElement3 instead')
@override
Element? get enclosingElement => _enclosingElement;
@ -2230,9 +2252,13 @@ abstract class ElementImpl implements Element {
_enclosingElement = element as ElementImpl?;
}
@Deprecated('Use enclosingElement3 instead')
@override
Element? get enclosingElement2 => _enclosingElement;
@override
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.
CompilationUnitElementImpl get enclosingUnit {
@ -2581,12 +2607,12 @@ abstract class ElementImpl implements Element {
@override
AnalysisSession? get session {
return enclosingElement2?.session;
return enclosingElement3?.session;
}
@override
Source? get source {
return enclosingElement2?.source;
return enclosingElement3?.source;
}
/// Return the context to resolve type parameters in, or `null` if neither
@ -2696,7 +2722,7 @@ abstract class ElementImpl implements Element {
) {
Element? element = this;
while (element != null && !predicate(element)) {
element = element.enclosingElement2;
element = element.enclosingElement3;
}
return element as E?;
}
@ -2706,9 +2732,9 @@ abstract class ElementImpl implements Element {
Element? element = this;
while (element != null && element is! E) {
if (element is CompilationUnitElement) {
element = element.enclosingElement2;
element = element.enclosingElement3;
} else {
element = element.enclosingElement2;
element = element.enclosingElement3;
}
}
return element as E?;
@ -2787,7 +2813,7 @@ class ElementLocationImpl implements ElementLocation {
Element? ancestor = element;
while (ancestor != null) {
components.insert(0, (ancestor as ElementImpl).identifier);
ancestor = ancestor.enclosingElement2;
ancestor = ancestor.enclosingElement3;
}
_components = components;
}
@ -3044,13 +3070,17 @@ abstract class ExecutableElementImpl extends _ExistingElementImpl
/// [offset].
ExecutableElementImpl(String super.name, super.offset, {super.reference});
@Deprecated('Use enclosingElement2 instead')
@Deprecated('Use enclosingElement3 instead')
@override
Element get enclosingElement => super.enclosingElement2!;
@Deprecated('Use enclosingElement3 instead')
@override
Element get enclosingElement2 => super.enclosingElement2!;
@override
Element get enclosingElement3 => super.enclosingElement3!;
@override
bool get hasImplicitReturnType {
return hasModifier(Modifier.IMPLICIT_TYPE);
@ -3321,17 +3351,23 @@ class ExtensionElementImpl extends _ExistingElementImpl
@override
String get displayName => name ?? '';
@Deprecated('Use enclosingElement2 instead')
@Deprecated('Use enclosingElement3 instead')
@override
CompilationUnitElementImpl get enclosingElement {
return _enclosingElement as CompilationUnitElementImpl;
}
@Deprecated('Use enclosingElement3 instead')
@override
CompilationUnitElementImpl get enclosingElement2 {
return super.enclosingElement2 as CompilationUnitElementImpl;
}
@override
CompilationUnitElementImpl get enclosingElement3 {
return super.enclosingElement3 as CompilationUnitElementImpl;
}
@override
DartType get extendedType =>
ElementTypeProvider.current.getExtendedType(this);
@ -3530,7 +3566,7 @@ class FieldElementImpl extends PropertyInducingElementImpl
///
/// Such fields are `index`, `_name`, and `values`.
bool get isSyntheticEnumField {
return enclosingElement2 is EnumElementImpl &&
return enclosingElement3 is EnumElementImpl &&
isSynthetic &&
getter?.isSynthetic == true &&
setter == null;
@ -3598,7 +3634,7 @@ class FunctionElementImpl extends ExecutableElementImpl
@override
String get identifier {
String identifier = super.identifier;
Element? enclosing = enclosingElement2;
Element? enclosing = enclosingElement3;
if (enclosing is ExecutableElement || enclosing is VariableElement) {
identifier += "@$nameOffset";
}
@ -3866,15 +3902,20 @@ class LabelElementImpl extends ElementImpl implements LabelElement {
@override
String get displayName => name;
@Deprecated('Use enclosingElement2 instead')
@Deprecated('Use enclosingElement3 instead')
@override
ExecutableElement get enclosingElement =>
super.enclosingElement2 as ExecutableElement;
@Deprecated('Use enclosingElement3 instead')
@override
ExecutableElement get enclosingElement2 =>
super.enclosingElement2 as ExecutableElement;
@override
ExecutableElement get enclosingElement3 =>
super.enclosingElement3 as ExecutableElement;
/// Return `true` if this label is associated with a `switch` member (`case
/// ` or`default`).
bool get isOnSwitchMember => _onSwitchMember;
@ -4840,8 +4881,8 @@ class MethodElementImpl extends ExecutableElementImpl implements MethodElement {
@override
Element get nonSynthetic {
if (isSynthetic && enclosingElement2 is EnumElementImpl) {
return enclosingElement2;
if (isSynthetic && enclosingElement3 is EnumElementImpl) {
return enclosingElement3;
}
return this;
}
@ -5087,12 +5128,17 @@ class MultiplyDefinedElementImpl implements MultiplyDefinedElement {
@override
String? get documentationComment => null;
@Deprecated('Use enclosingElement3 instead')
@override
Element? get enclosingElement => null;
@Deprecated('Use enclosingElement3 instead')
@override
Element? get enclosingElement2 => null;
@override
Element? get enclosingElement3 => null;
@override
bool get hasAlwaysThrows => false;
@ -5321,13 +5367,17 @@ abstract class NonParameterVariableElementImpl extends VariableElementImpl
/// [offset].
NonParameterVariableElementImpl(String super.name, super.offset);
@Deprecated('Use enclosingElement2 instead')
@Deprecated('Use enclosingElement3 instead')
@override
Element get enclosingElement => super.enclosingElement2!;
@Deprecated('Use enclosingElement3 instead')
@override
Element get enclosingElement2 => super.enclosingElement2!;
@override
Element get enclosingElement3 => super.enclosingElement3!;
bool get hasInitializer {
return hasModifier(Modifier.HAS_INITIALIZER);
}
@ -5596,7 +5646,7 @@ class PartElementImpl extends _ExistingElementImpl implements PartElement {
@override
CompilationUnitElementImpl get enclosingUnit {
var enclosingLibrary = enclosingElement2 as LibraryElementImpl;
var enclosingLibrary = enclosingElement3 as LibraryElementImpl;
return enclosingLibrary._definingCompilationUnit;
}
@ -5627,15 +5677,20 @@ class PrefixElementImpl extends _ExistingElementImpl implements PrefixElement {
@override
String get displayName => name;
@Deprecated('Use enclosingElement2 instead')
@Deprecated('Use enclosingElement3 instead')
@override
LibraryElement get enclosingElement =>
super.enclosingElement2 as LibraryElement;
@Deprecated('Use enclosingElement3 instead')
@override
LibraryOrAugmentationElementImpl get enclosingElement2 =>
super.enclosingElement2 as LibraryOrAugmentationElementImpl;
@override
LibraryOrAugmentationElementImpl get enclosingElement3 =>
super.enclosingElement3 as LibraryOrAugmentationElementImpl;
@Deprecated('Use imports2 instead')
@override
List<ImportElement> get imports {
@ -5646,7 +5701,7 @@ class PrefixElementImpl extends _ExistingElementImpl implements PrefixElement {
@override
List<LibraryImportElement> get imports2 {
return enclosingElement2.libraryImports
return enclosingElement3.libraryImports
.where((import) => import.prefix?.element == this)
.toList();
}
@ -5660,7 +5715,7 @@ class PrefixElementImpl extends _ExistingElementImpl implements PrefixElement {
}
@override
Scope get scope => _scope ??= PrefixScope(enclosingElement2, this);
Scope get scope => _scope ??= PrefixScope(enclosingElement3, this);
@override
T? accept<T>(ElementVisitor<T> visitor) => visitor.visitPrefixElement(this);
@ -5801,13 +5856,17 @@ class PropertyAccessorElementImpl_ImplicitGetter
reference?.element = this;
}
@Deprecated('Use enclosingElement2 instead')
@Deprecated('Use enclosingElement3 instead')
@override
Element get enclosingElement => variable.enclosingElement2!;
@Deprecated('Use enclosingElement3 instead')
@override
Element get enclosingElement2 => variable.enclosingElement2!;
@override
Element get enclosingElement3 => variable.enclosingElement3!;
@override
bool get hasImplicitReturnType => variable.hasImplicitType;
@ -5820,8 +5879,8 @@ class PropertyAccessorElementImpl_ImplicitGetter
if (!variable.isSynthetic) {
return variable;
}
assert(enclosingElement2 is EnumElementImpl);
return enclosingElement2;
assert(enclosingElement3 is EnumElementImpl);
return enclosingElement3;
}
@override
@ -5866,13 +5925,17 @@ class PropertyAccessorElementImpl_ImplicitSetter
property.setter = this;
}
@Deprecated('Use enclosingElement2 instead')
@Deprecated('Use enclosingElement3 instead')
@override
Element get enclosingElement => variable.enclosingElement2!;
@Deprecated('Use enclosingElement3 instead')
@override
Element get enclosingElement2 => variable.enclosingElement2!;
@override
Element get enclosingElement3 => variable.enclosingElement3!;
@override
bool get isSetter => true;
@ -5969,10 +6032,10 @@ abstract class PropertyInducingElementImpl
@override
Element get nonSynthetic {
if (isSynthetic) {
if (enclosingElement2 is EnumElementImpl) {
if (enclosingElement3 is EnumElementImpl) {
// TODO(scheglov) remove 'index'?
if (name == 'index' || name == 'values') {
return enclosingElement2;
return enclosingElement3;
}
}
return (getter ?? setter)!;
@ -6113,16 +6176,16 @@ class SuperFormalParameterElementImpl extends ParameterElementImpl
@override
ParameterElement? get superConstructorParameter {
final enclosingElement2 = this.enclosingElement2;
if (enclosingElement2 is ConstructorElementImpl) {
var superConstructor = enclosingElement2.superConstructor;
final enclosingElement3 = this.enclosingElement3;
if (enclosingElement3 is ConstructorElementImpl) {
var superConstructor = enclosingElement3.superConstructor;
if (superConstructor != null) {
var superParameters = superConstructor.parameters;
if (isNamed) {
return superParameters
.firstWhereOrNull((e) => e.isNamed && e.name == name);
} else {
var index = indexIn(enclosingElement2);
var index = indexIn(enclosingElement3);
var positionalSuperParameters =
superParameters.where((e) => e.isPositional).toList();
if (index >= 0 && index < positionalSuperParameters.length) {
@ -6223,15 +6286,20 @@ class TypeAliasElementImpl extends _ExistingElementImpl
@override
String get displayName => name;
@Deprecated('Use enclosingElement2 instead')
@Deprecated('Use enclosingElement3 instead')
@override
CompilationUnitElement get enclosingElement =>
super.enclosingElement2 as CompilationUnitElement;
@Deprecated('Use enclosingElement3 instead')
@override
CompilationUnitElement get enclosingElement2 =>
super.enclosingElement2 as CompilationUnitElement;
@override
CompilationUnitElement get enclosingElement3 =>
super.enclosingElement3 as CompilationUnitElement;
/// Returns whether this alias is a "proper rename" of [aliasedClass], as
/// defined in the constructor-tearoffs specification.
bool get isProperRename {
@ -6470,7 +6538,7 @@ class TypeParameterElementImpl extends ElementImpl
return true;
}
if (other is TypeParameterElement) {
if (other.enclosingElement2 == null || enclosingElement2 == null) {
if (other.enclosingElement3 == null || enclosingElement3 == null) {
return identical(other, this);
}
return other.location == location;
@ -6700,7 +6768,7 @@ mixin WrapperElementImpl implements ElementImpl {
String? get documentationComment => base.documentationComment;
@override
Element? get enclosingElement => base.enclosingElement2;
Element? get enclosingElement => base.enclosingElement3;
@override
bool get hasAlwaysThrows => base.hasAlwaysThrows;
@ -6866,7 +6934,7 @@ mixin _HasLibraryMixin on ElementImpl {
Source get librarySource => library.source;
@override
Source get source => enclosingElement2!.source!;
Source get source => enclosingElement3!.source!;
}
/// Instances of [List]s that are used as "not yet computed" values, they

View file

@ -16,21 +16,21 @@ extension ElementAnnotationExtensions on ElementAnnotation {
/// Return the target kinds defined for this [ElementAnnotation].
Set<TargetKind> get targetKinds {
final element = this.element;
ClassElement? classElement;
InterfaceElement? interfaceElement;
if (element is PropertyAccessorElement) {
if (element.isGetter) {
var type = element.returnType;
if (type is InterfaceType) {
classElement = type.element;
interfaceElement = type.element;
}
}
} else if (element is ConstructorElement) {
classElement = element.enclosingElement2;
interfaceElement = element.enclosingElement3;
}
if (classElement == null) {
if (interfaceElement == null) {
return const <TargetKind>{};
}
for (var annotation in classElement.metadata) {
for (var annotation in interfaceElement.metadata) {
if (annotation.isTarget) {
var value = annotation.computeConstantValue()!;
var kinds = <TargetKind>{};
@ -68,21 +68,21 @@ extension ElementExtension on Element {
return true;
}
var ancestor = enclosingElement2;
var ancestor = enclosingElement3;
if (ancestor is ClassElement) {
if (ancestor.hasDoNotStore) {
return true;
}
ancestor = ancestor.enclosingElement2;
ancestor = ancestor.enclosingElement3;
} else if (ancestor is ExtensionElement) {
if (ancestor.hasDoNotStore) {
return true;
}
ancestor = ancestor.enclosingElement2;
ancestor = ancestor.enclosingElement3;
}
return ancestor is CompilationUnitElement &&
ancestor.enclosingElement2.hasDoNotStore;
ancestor.enclosingElement3.hasDoNotStore;
}
/// Return `true` if this element is an instance member of a class or mixin.
@ -94,7 +94,7 @@ extension ElementExtension on Element {
/// [PropertyAccessorElement]s.
bool get isInstanceMember {
var this_ = this;
var enclosing = this_.enclosingElement2;
var enclosing = this_.enclosingElement3;
if (enclosing is ClassElement) {
return this_ is MethodElement && !this_.isStatic ||
this_ is PropertyAccessorElement && !this_.isStatic;
@ -105,7 +105,7 @@ extension ElementExtension on Element {
extension ExecutableElementExtension on ExecutableElement {
bool get isEnumConstructor {
return this is ConstructorElement && enclosingElement2 is EnumElementImpl;
return this is ConstructorElement && enclosingElement3 is EnumElementImpl;
}
}

View file

@ -366,7 +366,7 @@ class InheritanceManager3 {
continue;
}
var class_ = executable.enclosingElement2;
var class_ = executable.enclosingElement3;
if (class_ is ClassElement && class_.isDartCoreObject) {
continue;
}
@ -518,7 +518,7 @@ class InheritanceManager3 {
}
var current = currentList.single;
if (candidate.enclosingElement2 == mixinElement) {
if (candidate.enclosingElement3 == mixinElement) {
namedCandidates[name] = [
isNonNullableByDefault
? candidate
@ -714,7 +714,7 @@ class InheritanceManager3 {
Name name,
ExecutableElement executable,
) {
if (executable.enclosingElement2 == class_) {
if (executable.enclosingElement3 == class_) {
return executable;
}
@ -902,7 +902,7 @@ class InheritanceManager3 {
}
static bool _isDeclaredInObject(ExecutableElement element) {
var enclosing = element.enclosingElement2;
var enclosing = element.enclosingElement3;
return enclosing is ClassElement &&
enclosing.supertype == null &&
!enclosing.isMixin;

View file

@ -43,13 +43,17 @@ class ConstructorMember extends ExecutableMember
@override
String get displayName => declaration.displayName;
@Deprecated('Use enclosingElement2 instead')
@Deprecated('Use enclosingElement3 instead')
@override
ClassElement get enclosingElement => declaration.enclosingElement2;
@Deprecated('Use enclosingElement3 instead')
@override
ClassElement get enclosingElement2 => declaration.enclosingElement2;
@override
InterfaceElement get enclosingElement3 => declaration.enclosingElement3;
@override
bool get isConst => declaration.isConst;
@ -348,12 +352,16 @@ class FieldMember extends VariableMember implements FieldElement {
@override
String get displayName => declaration.displayName;
@Deprecated('Use enclosingElement2 instead')
@Deprecated('Use enclosingElement3 instead')
@override
Element get enclosingElement => declaration.enclosingElement2;
Element get enclosingElement => declaration.enclosingElement3;
@Deprecated('Use enclosingElement3 instead')
@override
Element get enclosingElement2 => declaration.enclosingElement3;
@override
Element get enclosingElement2 => declaration.enclosingElement2;
Element get enclosingElement3 => declaration.enclosingElement3;
@override
PropertyAccessorElement? get getter {
@ -442,12 +450,16 @@ class FunctionMember extends ExecutableMember implements FunctionElement {
@override
FunctionElement get declaration => super.declaration as FunctionElement;
@Deprecated('Use enclosingElement3 instead')
@override
Element get enclosingElement => declaration.enclosingElement2;
Element get enclosingElement => declaration.enclosingElement3;
@Deprecated('Use enclosingElement2 instead')
@Deprecated('Use enclosingElement3 instead')
@override
Element get enclosingElement2 => declaration.enclosingElement2;
Element get enclosingElement2 => declaration.enclosingElement3;
@override
Element get enclosingElement3 => declaration.enclosingElement3;
@override
bool get isDartCoreIdentical => declaration.isDartCoreIdentical;
@ -505,12 +517,16 @@ abstract class Member implements Element {
@override
String? get documentationComment => _declaration.documentationComment;
@Deprecated('Use enclosingElement2 instead')
@Deprecated('Use enclosingElement3 instead')
@override
Element? get enclosingElement => _declaration.enclosingElement2;
Element? get enclosingElement => _declaration.enclosingElement3;
@Deprecated('Use enclosingElement3 instead')
@override
Element? get enclosingElement2 => _declaration.enclosingElement3;
@override
Element? get enclosingElement2 => _declaration.enclosingElement2;
Element? get enclosingElement3 => _declaration.enclosingElement3;
@override
bool get hasAlwaysThrows => _declaration.hasAlwaysThrows;
@ -799,12 +815,16 @@ class MethodMember extends ExecutableMember implements MethodElement {
@override
MethodElement get declaration => super.declaration as MethodElement;
@Deprecated('Use enclosingElement2 instead')
@Deprecated('Use enclosingElement3 instead')
@override
Element get enclosingElement => declaration.enclosingElement2;
Element get enclosingElement => declaration.enclosingElement3;
@Deprecated('Use enclosingElement3 instead')
@override
Element get enclosingElement2 => declaration.enclosingElement3;
@override
Element get enclosingElement2 => declaration.enclosingElement2;
Element get enclosingElement3 => declaration.enclosingElement3;
@override
String get name => declaration.name;
@ -887,12 +907,16 @@ class ParameterMember extends VariableMember
@override
String? get defaultValueCode => declaration.defaultValueCode;
@Deprecated('Use enclosingElement2 instead')
@Deprecated('Use enclosingElement3 instead')
@override
Element? get enclosingElement => declaration.enclosingElement2;
Element? get enclosingElement => declaration.enclosingElement3;
@Deprecated('Use enclosingElement3 instead')
@override
Element? get enclosingElement2 => declaration.enclosingElement3;
@override
Element? get enclosingElement2 => declaration.enclosingElement2;
Element? get enclosingElement3 => declaration.enclosingElement3;
@override
bool get hasDefaultValue => declaration.hasDefaultValue;
@ -1032,12 +1056,16 @@ class PropertyAccessorMember extends ExecutableMember
PropertyAccessorElement get declaration =>
super.declaration as PropertyAccessorElement;
@Deprecated('Use enclosingElement2 instead')
@Deprecated('Use enclosingElement3 instead')
@override
Element get enclosingElement => declaration.enclosingElement2;
Element get enclosingElement => declaration.enclosingElement3;
@Deprecated('Use enclosingElement3 instead')
@override
Element get enclosingElement2 => declaration.enclosingElement3;
@override
Element get enclosingElement2 => declaration.enclosingElement2;
Element get enclosingElement3 => declaration.enclosingElement3;
@override
bool get isGetter => declaration.isGetter;

View file

@ -1696,7 +1696,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.enclosingElement2 is ExtensionElement) {
if (methodElement.enclosingElement3 is ExtensionElement) {
return currentType;
}
@ -1800,7 +1800,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.enclosingElement2 is ExtensionElement) {
if (methodElement.enclosingElement3 is ExtensionElement) {
return currentType;
}

View file

@ -47,8 +47,8 @@ ConstructorElement? _getActualConstructorElement(
ConstructorElement? constructor) {
var seenConstructors = <ConstructorElement?>{};
while (constructor is ConstructorElementImpl && constructor.isSynthetic) {
var enclosing = constructor.enclosingElement2;
if (enclosing.isMixinApplication) {
var enclosing = constructor.enclosingElement3;
if (enclosing is ClassElement && enclosing.isMixinApplication) {
var superInvocation = constructor.constantInitializers
.whereType<SuperConstructorInvocation>()
.singleOrNull;
@ -77,7 +77,7 @@ LibraryImportElement? _getImportElement(
String prefix,
Element element,
Map<LibraryImportElement, Set<Element>> importElementsMap) {
if (element.enclosingElement2 is! CompilationUnitElement) {
if (element.enclosingElement3 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.enclosingElement2 == element) {
} else if (e != null && e.enclosingElement3 == element) {
kind = MatchKind.REFERENCE;
offset = node.offset;
length = element.nameLength;

View file

@ -29,15 +29,16 @@ class ConstructorReferenceResolver {
}
node.constructorName.accept(_resolver);
var element = node.constructorName.staticElement;
if (element != null &&
!element.isFactory &&
element.enclosingElement2.isAbstract) {
_resolver.errorReporter.reportErrorForNode(
CompileTimeErrorCode
.TEAROFF_OF_GENERATIVE_CONSTRUCTOR_OF_ABSTRACT_CLASS,
node,
[],
);
if (element != null && !element.isFactory) {
final enclosingElement = element.enclosingElement3;
if (enclosingElement is ClassElement && enclosingElement.isAbstract) {
_resolver.errorReporter.reportErrorForNode(
CompileTimeErrorCode
.TEAROFF_OF_GENERATIVE_CONSTRUCTOR_OF_ABSTRACT_CLASS,
node,
[],
);
}
}
var name = node.constructorName.name;
if (element == null &&

View file

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

View file

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

View file

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

View file

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

View file

@ -80,14 +80,14 @@ class DiagnosticFactory {
ExecutableElement superMember) {
errorCode ??= CompileTimeErrorCode.INVALID_OVERRIDE;
// Elements enclosing members that can participate in overrides are always
// named, so we can safely assume `_thisMember.enclosingElement2.name` and
// `superMember.enclosingElement2.name` are non-`null`.
// named, so we can safely assume `_thisMember.enclosingElement3.name` and
// `superMember.enclosingElement3.name` are non-`null`.
return AnalysisError(
source, errorNode.offset, errorNode.length, errorCode, [
member.name,
member.enclosingElement2.name!,
member.enclosingElement3.name!,
member.type,
superMember.enclosingElement2.name!,
superMember.enclosingElement3.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.enclosingElement2.displayName],
[variable.name, variable.enclosingElement3.displayName],
);
} else {
_errorReporter.reportErrorForNode(

View file

@ -171,7 +171,7 @@ class BestPracticesVerifier extends RecursiveAstVisitor<void> {
}
}
} else if (parent is ConstructorDeclaration) {
var class_ = parent.declaredElement!.enclosingElement2;
var class_ = parent.declaredElement!.enclosingElement3;
if (class_.isPrivate || (parentElement?.isPrivate ?? false)) {
_errorReporter.reportErrorForNode(
HintCode.INVALID_INTERNAL_ANNOTATION, node, []);
@ -323,7 +323,7 @@ class BestPracticesVerifier extends RecursiveAstVisitor<void> {
var invokedElement = element.element!;
var name = invokedElement.name;
if (invokedElement is ConstructorElement) {
var className = invokedElement.enclosingElement2.name;
var className = invokedElement.enclosingElement3.name;
if (name!.isEmpty) {
name = className;
} else {
@ -471,7 +471,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.enclosingElement2!;
Element enclosingElement = element.enclosingElement3!;
if (enclosingElement is ClassElement) {
var overridden = _inheritanceManager
.getMember2(enclosingElement, name, forSuper: true);
@ -493,11 +493,11 @@ class BestPracticesVerifier extends RecursiveAstVisitor<void> {
_hasNonVirtualAnnotation(overriddenElement)) {
// Overridden members are always inside classes or mixins, which are
// always named, so we can safely assume
// `overriddenElement.enclosingElement2.name` is non-`null`.
// `overriddenElement.enclosingElement3.name` is non-`null`.
_errorReporter.reportErrorForToken(
HintCode.INVALID_OVERRIDE_OF_NON_VIRTUAL_MEMBER, field.name2, [
field.name2.lexeme,
overriddenElement.enclosingElement2.displayName
overriddenElement.enclosingElement3.displayName
]);
}
if (!_invalidAccessVerifier._inTestDirectory) {
@ -640,7 +640,7 @@ class BestPracticesVerifier extends RecursiveAstVisitor<void> {
void visitMethodDeclaration(MethodDeclaration node) {
bool wasInDoNotStoreMember = _inDoNotStoreMember;
var element = node.declaredElement!;
var enclosingElement = element.enclosingElement2;
var enclosingElement = element.enclosingElement3;
Name name = Name(_currentLibrary.source.uri, element.name);
@ -688,11 +688,11 @@ class BestPracticesVerifier extends RecursiveAstVisitor<void> {
_hasNonVirtualAnnotation(overriddenElement)) {
// Overridden members are always inside classes or mixins, which are
// always named, so we can safely assume
// `overriddenElement.enclosingElement2.name` is non-`null`.
// `overriddenElement.enclosingElement3.name` is non-`null`.
_errorReporter.reportErrorForToken(
HintCode.INVALID_OVERRIDE_OF_NON_VIRTUAL_MEMBER, node.name2, [
node.name2.lexeme,
overriddenElement.enclosingElement2.displayName
overriddenElement.enclosingElement3.displayName
]);
}
@ -1470,7 +1470,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?.enclosingElement2;
var classElement = methodElement?.enclosingElement3;
return methodElement is MethodElement &&
classElement is ClassElement &&
!classElement.isDartCoreObject;
@ -1973,7 +1973,7 @@ class _InvalidAccessVerifier {
SimpleIdentifier identifier, Element element) {
bool hasProtected = _hasProtected(element);
if (hasProtected) {
var definingClass = element.enclosingElement2 as ClassElement;
var definingClass = element.enclosingElement3 as ClassElement;
if (_hasTypeOrSuperType(_enclosingClass, definingClass)) {
return;
}
@ -2012,7 +2012,7 @@ class _InvalidAccessVerifier {
node = identifier;
}
var definingClass = element.enclosingElement2;
var definingClass = element.enclosingElement3;
if (hasProtected) {
_errorReporter.reportErrorForNode(
HintCode.INVALID_USE_OF_PROTECTED_MEMBER,
@ -2068,12 +2068,12 @@ class _InvalidAccessVerifier {
bool _hasProtected(Element element) {
if (element is PropertyAccessorElement &&
element.enclosingElement2 is ClassElement &&
element.enclosingElement3 is ClassElement &&
(element.hasProtected || element.variable.hasProtected)) {
return true;
}
if (element is MethodElement &&
element.enclosingElement2 is ClassElement &&
element.enclosingElement3 is ClassElement &&
element.hasProtected) {
return true;
}

View file

@ -123,17 +123,17 @@ class CovariantParametersVerifier {
var superMember = superParameter.member;
// Elements enclosing members that can participate in overrides are
// always named, so we can safely assume
// `_thisMember.enclosingElement2.name` and
// `superMember.enclosingElement2.name` are non-`null`.
// `_thisMember.enclosingElement3.name` and
// `superMember.enclosingElement3.name` are non-`null`.
errorReporter.reportErrorForOffset(
CompileTimeErrorCode.INVALID_OVERRIDE,
errorNode.offset,
errorNode.length,
[
_thisMember.name,
_thisMember.enclosingElement2.name!,
_thisMember.enclosingElement3.name!,
_thisMember.type,
superMember.enclosingElement2.name!,
superMember.enclosingElement3.name!,
superMember.type,
],
);
@ -144,7 +144,7 @@ class CovariantParametersVerifier {
List<_SuperMember> _superMembers() {
var classHierarchy = _session.classHierarchy;
var classElement = _thisMember.enclosingElement2 as ClassElement;
var classElement = _thisMember.enclosingElement3 as ClassElement;
var interfaces = classHierarchy.implementedInterfaces(classElement);
var superMembers = <_SuperMember>[];
@ -273,5 +273,5 @@ class _SuperParameter {
_SuperParameter(this.element, this.type);
ExecutableElement get member =>
element.enclosingElement2 as ExecutableElement;
element.enclosingElement3 as ExecutableElement;
}

View file

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

View file

@ -145,7 +145,7 @@ class DuplicateDefinitionVerifier {
[
enumElement.displayName,
baseName,
inherited.enclosingElement2.displayName,
inherited.enclosingElement3.displayName,
],
);
}
@ -172,7 +172,7 @@ class DuplicateDefinitionVerifier {
[
enumElement.displayName,
baseName,
inherited.enclosingElement2.displayName,
inherited.enclosingElement3.displayName,
],
);
}

View file

@ -53,23 +53,23 @@ class GetterSetterTypesVerifier {
var setterType = setter.parameters[0].type;
if (!_match(getterType, setterType)) {
Element errorElement;
if (getter.enclosingElement2 == classElement) {
if (getter.enclosingElement3 == classElement) {
errorElement = getter;
} else if (setter.enclosingElement2 == classElement) {
} else if (setter.enclosingElement3 == classElement) {
errorElement = setter;
} else {
errorElement = classElement;
}
var getterName = getter.displayName;
if (getter.enclosingElement2 != classElement) {
var getterClassName = getter.enclosingElement2.displayName;
if (getter.enclosingElement3 != classElement) {
var getterClassName = getter.enclosingElement3.displayName;
getterName = '$getterClassName.$getterName';
}
var setterName = setter.displayName;
if (setter.enclosingElement2 != classElement) {
var setterClassName = setter.enclosingElement2.displayName;
if (setter.enclosingElement3 != classElement) {
var setterClassName = setter.enclosingElement3.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.enclosingElement2;
var enclosingElement = element.enclosingElement3;
if (enclosingElement is ExtensionElement) {
_recordUsedExtension(enclosingElement);
}
@ -165,7 +165,7 @@ class GatherUsedImportedElementsVisitor extends RecursiveAstVisitor<void> {
if (_recordPrefixMap(identifier, element)) {
return;
}
var enclosingElement = element.enclosingElement2;
var enclosingElement = element.enclosingElement3;
if (enclosingElement is CompilationUnitElement) {
_recordUsedElement(element);
} else if (enclosingElement is ExtensionElement) {

View file

@ -548,7 +548,7 @@ class _ClassVerifier {
.INVALID_OVERRIDE_DIFFERENT_DEFAULT_VALUES_NAMED,
derivedOptionalNodes[i],
[
baseExecutable.enclosingElement2.displayName,
baseExecutable.enclosingElement3.displayName,
baseExecutable.displayName,
name
],
@ -577,7 +577,7 @@ class _ClassVerifier {
.INVALID_OVERRIDE_DIFFERENT_DEFAULT_VALUES_POSITIONAL,
derivedOptionalNodes[i],
[
baseExecutable.enclosingElement2.displayName,
baseExecutable.enclosingElement3.displayName,
baseExecutable.displayName
],
);
@ -694,7 +694,7 @@ class _ClassVerifier {
) {
var member = concreteMap[Name(libraryUri, memberName)];
if (member != null) {
var enclosingClass = member.enclosingElement2;
var enclosingClass = member.enclosingElement3;
if (enclosingClass is ClassElement && filter(enclosingClass)) {
reporter.reportErrorForToken(
CompileTimeErrorCode.ILLEGAL_CONCRETE_ENUM_MEMBER_INHERITANCE,
@ -735,7 +735,7 @@ class _ClassVerifier {
reporter.reportErrorForToken(
CompileTimeErrorCode.ILLEGAL_ENUM_VALUES_INHERITANCE,
classNameToken,
[inherited.enclosingElement2.name!],
[inherited.enclosingElement3.name!],
);
}
}
@ -811,20 +811,20 @@ class _ClassVerifier {
if (conflict is GetterMethodConflict) {
// Members that participate in inheritance are always enclosed in named
// elements so it is safe to assume that
// `conflict.getter.enclosingElement2.name` and
// `conflict.method.enclosingElement2.name` are both non-`null`.
// `conflict.getter.enclosingElement3.name` and
// `conflict.method.enclosingElement3.name` are both non-`null`.
reporter.reportErrorForToken(
CompileTimeErrorCode.INCONSISTENT_INHERITANCE_GETTER_AND_METHOD,
token,
[
name.name,
conflict.getter.enclosingElement2.name!,
conflict.method.enclosingElement2.name!
conflict.getter.enclosingElement3.name!,
conflict.method.enclosingElement3.name!
],
);
} else if (conflict is CandidatesConflict) {
var candidatesStr = conflict.candidates.map((candidate) {
var className = candidate.enclosingElement2.name;
var className = candidate.enclosingElement3.name;
var typeStr = candidate.type.getDisplayString(
withNullability: _isNonNullableByDefault,
);
@ -860,7 +860,7 @@ class _ClassVerifier {
}
var elementName = element.displayName;
var enclosingElement = element.enclosingElement2;
var enclosingElement = element.enclosingElement3;
var enclosingName = enclosingElement.displayName;
var description = "$prefix$enclosingName.$elementName";

View file

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

View file

@ -97,7 +97,7 @@ class TypeArgumentsVerifier {
return;
}
var enumElement = constructorElement.enclosingElement2;
var enumElement = constructorElement.enclosingElement3;
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?.enclosingElement2;
var enclosingElement = element?.enclosingElement3;
if (element == null) {
if (isIdentifierRead) {
usedElements.unresolvedReadMembers.add(node.name);
@ -598,7 +598,7 @@ class UnusedLocalElementsVerifier extends RecursiveAstVisitor<void> {
if (element.isPrivate) {
return false;
}
var enclosingElement = element.enclosingElement2;
var enclosingElement = element.enclosingElement3;
if (enclosingElement is ClassElement) {
if (enclosingElement.isEnum) {
@ -626,7 +626,7 @@ class UnusedLocalElementsVerifier extends RecursiveAstVisitor<void> {
bool elementIsStaticVariable =
element is VariableElement && element.isStatic;
if (element.isPublic) {
if (_isPrivateClassOrExtension(element.enclosingElement2!) &&
if (_isPrivateClassOrExtension(element.enclosingElement3!) &&
elementIsStaticVariable) {
// Public static fields of private classes, mixins, and extensions are
// inaccessible from outside the library in which they are declared.
@ -663,7 +663,7 @@ class UnusedLocalElementsVerifier extends RecursiveAstVisitor<void> {
element is FunctionElement && !element.isStatic) {
// local variable or function
} else if (element is ParameterElement) {
var enclosingElement = element.enclosingElement2;
var enclosingElement = element.enclosingElement3;
// Only report unused parameters of constructors, methods, and functions.
if (enclosingElement is! ConstructorElement &&
enclosingElement is! FunctionElement &&
@ -675,7 +675,7 @@ class UnusedLocalElementsVerifier extends RecursiveAstVisitor<void> {
return true;
}
if (enclosingElement is ConstructorElement &&
enclosingElement.enclosingElement2.typeParameters.isNotEmpty) {
enclosingElement.enclosingElement3.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
@ -729,7 +729,7 @@ class UnusedLocalElementsVerifier extends RecursiveAstVisitor<void> {
}
Iterable<ExecutableElement> _overriddenElements(Element element) {
var enclosingElement = element.enclosingElement2;
var enclosingElement = element.enclosingElement3;
if (enclosingElement is ClassElement) {
Name name = Name(_libraryUri, element.name!);
var overridden =
@ -811,7 +811,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.enclosingElement2.constructors.length > 1 &&
if (element.enclosingElement3.constructors.length > 1 &&
!_isUsedMember(element)) {
_reportErrorForElement(
HintCode.UNUSED_ELEMENT, element, [element.displayName]);

View file

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

View file

@ -117,7 +117,7 @@ class EnclosingExecutableContext {
}
static bool _inFactoryConstructor(Element? element) {
var enclosing = element?.enclosingElement2;
var enclosing = element?.enclosingElement3;
if (enclosing == null) {
return false;
}
@ -128,7 +128,7 @@ class EnclosingExecutableContext {
}
static bool _inStaticMethod(Element? element) {
var enclosing = element?.enclosingElement2;
var enclosing = element?.enclosingElement3;
if (enclosing == null) {
return false;
}
@ -755,7 +755,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
@override
void visitFunctionDeclaration(FunctionDeclaration node) {
ExecutableElement functionElement = node.declaredElement!;
if (functionElement.enclosingElement2 is! CompilationUnitElement) {
if (functionElement.enclosingElement3 is! CompilationUnitElement) {
_hiddenElements!.declare(functionElement);
}
@ -1637,7 +1637,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
errorReporter.reportErrorForNode(
CompileTimeErrorCode.ASSIGNMENT_TO_FINAL_NO_SETTER,
highlightedNode,
[variable.name, variable.enclosingElement2.displayName],
[variable.name, variable.enclosingElement3.displayName],
);
} else {
errorReporter.reportErrorForNode(
@ -1807,14 +1807,14 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
CompileTimeErrorCode.CONFLICTING_STATIC_AND_INSTANCE, method, [
_enclosingClass!.displayName,
name,
inherited.enclosingElement2.displayName,
inherited.enclosingElement3.displayName,
]);
} else if (inherited is PropertyAccessorElement) {
errorReporter.reportErrorForElement(
CompileTimeErrorCode.CONFLICTING_METHOD_AND_FIELD, method, [
_enclosingClass!.displayName,
name,
inherited.enclosingElement2.displayName
inherited.enclosingElement3.displayName
]);
}
}
@ -1834,14 +1834,14 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
CompileTimeErrorCode.CONFLICTING_STATIC_AND_INSTANCE, accessor, [
_enclosingClass!.displayName,
name,
inherited.enclosingElement2.displayName,
inherited.enclosingElement3.displayName,
]);
} else if (inherited is MethodElement) {
errorReporter.reportErrorForElement(
CompileTimeErrorCode.CONFLICTING_FIELD_AND_METHOD, accessor, [
_enclosingClass!.displayName,
name,
inherited.enclosingElement2.displayName
inherited.enclosingElement3.displayName
]);
}
}
@ -2099,11 +2099,11 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
errorReporter.reportErrorForNode(
CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_MIXIN_WITH_FIELD,
constructor.returnType,
["'${field.enclosingElement2.name}.${field.name}'"]);
["'${field.enclosingElement3.name}.${field.name}'"]);
return true;
} else if (instanceFields.length > 1) {
var fieldNames = instanceFields
.map((field) => "'${field.enclosingElement2.name}.${field.name}'")
.map((field) => "'${field.enclosingElement3.name}.${field.name}'")
.join(', ');
errorReporter.reportErrorForNode(
CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_MIXIN_WITH_FIELDS,
@ -2127,7 +2127,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
errorReporter.reportErrorForNode(
CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_CONST_SUPER,
initializer,
[element.enclosingElement2.displayName]);
[element.enclosingElement3.displayName]);
return true;
}
}
@ -2165,8 +2165,8 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
return;
}
// check if there is non-final field
ClassElement classElement = constructorElement.enclosingElement2;
if (!classElement.hasNonFinalField) {
final classElement = constructorElement.enclosingElement3;
if (classElement is ClassElement && !classElement.hasNonFinalField) {
return;
}
errorReporter.reportErrorForName(
@ -2934,7 +2934,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
// OK, instance member
return;
}
Element enclosingElement = element.enclosingElement2;
Element enclosingElement = element.enclosingElement3;
if (enclosingElement is ExtensionElement) {
if (target is ExtensionOverride) {
// OK, target is an extension override
@ -3016,7 +3016,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
var constructorElement = node.staticElement;
if (constructorElement != null &&
constructorElement.isGenerative &&
constructorElement.enclosingElement2.isEnum) {
constructorElement.enclosingElement3 is EnumElement) {
if (_currentLibrary.featureSet.isEnabled(Feature.enhanced_enums)) {
errorReporter.reportErrorForNode(
CompileTimeErrorCode.INVALID_REFERENCE_TO_GENERATIVE_ENUM_CONSTRUCTOR,
@ -3059,7 +3059,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
return;
}
// not a class member
Element enclosingElement = element.enclosingElement2;
Element enclosingElement = element.enclosingElement3;
if (enclosingElement is! ClassElement &&
enclosingElement is! ExtensionElement) {
return;
@ -3193,7 +3193,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
}
// We should only check exported declarations, i.e. top-level.
if (declaredElement.enclosingElement2 is! CompilationUnitElement) {
if (declaredElement.enclosingElement3 is! CompilationUnitElement) {
return;
}
@ -3523,14 +3523,14 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
);
if (inheritedMember != null) {
// Inherited members are always contained inside named elements, so we
// can safely assume `inheritedMember.enclosingElement2.name` is
// can safely assume `inheritedMember.enclosingElement3.name` is
// non-`null`.
errorReporter.reportErrorForNode(
CompileTimeErrorCode.PRIVATE_COLLISION_IN_MIXIN_APPLICATION,
namedType, [
name,
namedType.name.name,
inheritedMember.enclosingElement2.name!
inheritedMember.enclosingElement3.name!
]);
return true;
}
@ -4058,7 +4058,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
redirectedElement,
redirectedConstructor,
);
var redirectedClass = redirectedElement?.enclosingElement2;
var redirectedClass = redirectedElement?.enclosingElement3;
if (redirectedClass is ClassElement &&
redirectedClass.isAbstract &&
redirectedElement != null &&
@ -4349,7 +4349,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
if (_enclosingExecutable.inStaticMethod || _isInStaticVariableDeclaration) {
var element = identifier.staticElement;
if (element is TypeParameterElement &&
element.enclosingElement2 is ClassElement) {
element.enclosingElement3 is ClassElement) {
// 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).
@ -4591,7 +4591,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
if (element == null || element is TypeParameterElement) {
return;
}
var enclosingElement = element.enclosingElement2;
var enclosingElement = element.enclosingElement3;
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.enclosingElement2;
var enclosingElement = element.enclosingElement3;
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.enclosingElement2;
var enclosingElement = element.enclosingElement3;
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?.enclosingElement2;
var class_ = constructor?.enclosingElement3;
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.enclosingElement2;
Element enclosingElement = element.enclosingElement3;
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.enclosingElement2;
var enclosingElement = element.enclosingElement3;
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.enclosingElement2;
var enclosingElement = element.enclosingElement3;
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.enclosingElement2;
var enclosingElement = element.enclosingElement3;
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.enclosingElement2 as ClassElement;
final cls = declarationElement.enclosingElement3 as ClassElement;
if (!_extendsNativeFieldWrapperClass1(cls.thisType)) {
_errorReporter.reportErrorForNode(
FfiCode
@ -612,7 +612,7 @@ class FfiVerifier extends RecursiveAstVisitor<void> {
_PrimitiveDartType _typeForAnnotation(Annotation annotation) {
var element = annotation.element;
if (element is ConstructorElement) {
String name = element.enclosingElement2.name;
String name = element.enclosingElement3.name;
if (_primitiveIntegerNativeTypes.contains(name)) {
return _PrimitiveDartType.int;
} else if (_primitiveDoubleNativeTypes.contains(name)) {
@ -725,7 +725,7 @@ class FfiVerifier extends RecursiveAstVisitor<void> {
List<Annotation> extraAnnotations = [];
for (Annotation annotation in annotations) {
if (annotation.element.ffiClass != null ||
annotation.element?.enclosingElement2.isAbiSpecificIntegerSubclass ==
annotation.element?.enclosingElement3.isAbiSpecificIntegerSubclass ==
true) {
if (requiredFound) {
extraAnnotations.add(annotation);
@ -1300,7 +1300,7 @@ extension on Annotation {
final element = this.element;
return element is ConstructorElement &&
element.ffiClass != null &&
element.enclosingElement2.name ==
element.enclosingElement3.name ==
FfiVerifier._abiSpecificIntegerMappingClassName;
}
@ -1308,21 +1308,21 @@ extension on Annotation {
final element = this.element;
return element is ConstructorElement &&
element.ffiClass != null &&
element.enclosingElement2.name == 'Array';
element.enclosingElement3.name == 'Array';
}
bool get isFfiNative {
final element = this.element;
return element is ConstructorElement &&
element.ffiClass != null &&
element.enclosingElement2.name == 'FfiNative';
element.enclosingElement3.name == 'FfiNative';
}
bool get isPacked {
final element = this.element;
return element is ConstructorElement &&
element.ffiClass != null &&
element.enclosingElement2.name == 'Packed';
element.enclosingElement3.name == 'Packed';
}
}
@ -1366,7 +1366,7 @@ extension on ElementAnnotation {
final element = this.element;
return element is ConstructorElement &&
element.ffiClass != null &&
element.enclosingElement2.name == 'Array';
element.enclosingElement3.name == 'Array';
// Note: this is 'Array' instead of '_ArraySize' because it finds the
// forwarding factory instead of the forwarded constructor.
}
@ -1375,7 +1375,7 @@ extension on ElementAnnotation {
final element = this.element;
return element is ConstructorElement &&
element.ffiClass != null &&
element.enclosingElement2.name == 'Packed';
element.enclosingElement3.name == 'Packed';
}
int? get packedMemberAlignment {
@ -1390,7 +1390,7 @@ extension on Element? {
ClassElement? get ffiClass {
var element = this;
if (element is ConstructorElement) {
element = element.enclosingElement2;
element = element.enclosingElement3;
}
if (element is ClassElement && element.isFfiClass) {
return element;

View file

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

View file

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

View file

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

View file

@ -847,7 +847,7 @@ class ResolutionSink extends _SummaryDataWriter {
return const [];
}
var enclosing = declaration.enclosingElement2;
var enclosing = declaration.enclosingElement3;
if (enclosing is TypeParameterizedElement) {
if (enclosing is! ClassElement && 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.enclosingElement2;
final enclosing = unitElement.enclosingElement3;
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.enclosingElement2 as ClassElement;
final enclosingClass = element.enclosingElement3 as ClassElement;
return FieldDeclarationImpl(
id: macro.RemoteInstance.uniqueId,
identifier: identifier(element),

View file

@ -47,7 +47,7 @@ class ConstantInitializersResolver {
unit.extensions.forEach(_resolveExtensionFields);
unit.mixins.forEach(_resolveClassFields);
_scope = unit.enclosingElement2.scope;
_scope = unit.enclosingElement3.scope;
unit.topLevelVariables.forEach(_resolveVariable);
}
}
@ -174,8 +174,8 @@ class _ConstructorInferenceNode extends _InferenceNode {
}
}
var classElement = _constructor.enclosingElement2;
if (classElement.isMixinApplication) {
var classElement = _constructor.enclosingElement3;
if (classElement is ClassElement && classElement.isMixinApplication) {
var superType = classElement.supertype;
if (superType != null) {
var index = classElement.constructors.indexOf(_constructor);
@ -285,7 +285,7 @@ class _InferenceDependenciesCollector extends RecursiveAstVisitor<void> {
_set.add(element);
if (element.enclosingElement2.typeParameters.isNotEmpty) {
if (element.enclosingElement3.typeParameters.isNotEmpty) {
node.argumentList.accept(this);
}
}
@ -356,7 +356,7 @@ class _InitializerInference {
unit.extensions.forEach(_addExtensionElementFields);
unit.mixins.forEach(_addClassElementFields);
_scope = unit.enclosingElement2.scope;
_scope = unit.enclosingElement3.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.enclosingElement2;
var enclosingElement = _element.enclosingElement3;
var enclosingClassElement =
enclosingElement is ClassElement ? enclosingElement : null;
var astResolver = AstResolver(_walker._linker, _unitElement, _scope,

View file

@ -424,7 +424,7 @@ class InstanceMemberInferrer {
var conflict = conflicts.single;
if (conflict is CandidatesConflict) {
conflictExplanation = conflict.candidates.map((candidate) {
var className = candidate.enclosingElement2.name;
var className = candidate.enclosingElement3.name;
var typeStr = candidate.type.getDisplayString(
withNullability: typeSystem.isNonNullableByDefault,
);
@ -540,7 +540,7 @@ class InstanceMemberInferrer {
overridden = overridden.declaration;
// Skip Object itself.
var enclosingElement = overridden.enclosingElement2;
var enclosingElement = overridden.enclosingElement3;
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.enclosingElement2;
var enclosingElement = element.enclosingElement3;
if (enclosingElement is CompilationUnitElement) {
var memberName = element.name!;
if (element is PropertyAccessorElement && element.isSetter) {

View file

@ -35,7 +35,7 @@ class A {
expect(name3, isNull);
if (annotationElement is ConstructorElement) {
expect(annotationElement, same(name2.staticElement));
expect(annotationElement.enclosingElement2, name1.staticElement);
expect(annotationElement.enclosingElement3, 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.enclosingElement2, name2.staticElement);
expect(annotationElement.enclosingElement3, 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.enclosingElement2, name2.staticElement);
expect(annotationElement.enclosingElement3, 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.enclosingElement2, name2.staticElement);
expect(annotationElement.enclosingElement3, 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.enclosingElement2, name1.staticElement);
expect(annotationElement.enclosingElement3, 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.enclosingElement2, name1.staticElement);
expect(annotationElement.enclosingElement3, 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.enclosingElement2, isCompilationUnitElement);
expect(annotationElement.enclosingElement3, 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.enclosingElement2, isCompilationUnitElement);
expect(annotationElement.enclosingElement3, 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.enclosingElement2, isNotNull);
expect(y.enclosingElement3, 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.enclosingElement2, isNotNull);
expect(y.enclosingElement3, isNotNull);
expect(y.declaration, findElement.parameter('arg'));
}

View file

@ -74,7 +74,7 @@ class C {
var constructor = findElement.unnamedConstructor('C');
var x = findElement.localFunction('x');
expect(x.enclosingElement2, constructor);
expect(x.enclosingElement3, 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.enclosingElement2 as ClassElement;
var enclosingClass = executable.enclosingElement3 as ClassElement;
if (enclosingClass.isDartCoreObject) continue;
var id = MemberId.internal(

View file

@ -977,7 +977,7 @@ main() {
forInvocation.argumentList.arguments[0] as FunctionExpression;
var closureElement = closure.declaredElement as FunctionElementImpl;
expect(closureElement.enclosingElement2, same(mainElement));
expect(closureElement.enclosingElement3, same(mainElement));
ParameterElement itemElement = closureElement.parameters[0];
itemElement1 = itemElement;
@ -1018,7 +1018,7 @@ main() {
forInvocation.argumentList.arguments[0] as FunctionExpression;
var closureElement = closure.declaredElement as FunctionElementImpl;
expect(closureElement.enclosingElement2, same(mainElement));
expect(closureElement.enclosingElement3, same(mainElement));
ParameterElement itemElement = closureElement.parameters[0];
expect(itemElement, isNot(same(itemElement1)));
@ -1061,7 +1061,7 @@ void foo(List<T> Function<T>() createList) {}
assertType(closure, 'List<T> Function<T>()');
var closureElement = closure.declaredElement as FunctionElementImpl;
expect(closureElement.enclosingElement2, findElement.function('main'));
expect(closureElement.enclosingElement3, findElement.function('main'));
assertType(closureElement.returnType, 'List<T>');
expect(closureElement.parameters, isEmpty);
@ -1707,7 +1707,7 @@ main(MyEnum e) {
var methodElement = invocation.methodName.staticElement as MethodElement;
expect(methodElement.name, 'toString');
expect(methodElement.enclosingElement2, same(objectElement));
expect(methodElement.enclosingElement3, 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.enclosingElement2;
var enclosingElement = element.enclosingElement3;
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.enclosingElement2, same(element.enclosingElement2));
expect(variable.enclosingElement3, same(element.enclosingElement3));
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.enclosingElement2;
var enclosingElement = element.enclosingElement3;
if (enclosingElement.name == 'Object') continue;
var typeStr = type.getDisplayString(withNullability: false);

View file

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

View file

@ -64,7 +64,7 @@ example(List<int> list) {
assertType(findElement.localVar('a').type, 'int');
assertType(findElement.parameter('x').type, 'int');
assertType(findElement.parameter('y').type, 'int');
expect(findNode.binary('x + y').staticElement!.enclosingElement2.name,
expect(findNode.binary('x + y').staticElement!.enclosingElement3.name,
'num');
} else {
await assertErrorsInCode(code, [
@ -130,7 +130,7 @@ test(List<int> list) {
assertType(findElement.localVar('a').type, _isEnabled ? 'int' : 'dynamic');
assertType(findElement.parameter('x').type, _isEnabled ? 'int' : 'Object?');
assertType(findElement.parameter('y').type, 'int');
expect(findNode.binary('+ y').staticElement?.enclosingElement2.name,
expect(findNode.binary('+ y').staticElement?.enclosingElement3.name,
_isEnabled ? 'num' : null);
}
@ -294,7 +294,7 @@ test(List<int> list) {
assertType(findElement.localVar('a').type, 'int?');
assertType(findElement.parameter('x').type, 'int?');
assertType(findElement.parameter('y').type, 'int');
expect(findNode.binary('+ y').staticElement!.enclosingElement2.name, 'num');
expect(findNode.binary('+ y').staticElement!.enclosingElement3.name, 'num');
}
test_horizontal_inference_unnecessary_due_to_explicit_parameter_type_named() async {
@ -311,7 +311,7 @@ test() {
assertType(findElement.localVar('a').type, 'int?');
assertType(findElement.parameter('x').type, 'int?');
assertType(findElement.parameter('y').type, 'int');
expect(findNode.binary('+ y').staticElement!.enclosingElement2.name, 'num');
expect(findNode.binary('+ y').staticElement!.enclosingElement3.name, 'num');
}
test_horizontal_inference_unnecessary_due_to_no_dependency() async {

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