mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 02:07:06 +00:00
Deprecate 'Element.enclosingElement', switch to enclosingElement2.
We need this for: 1. CompilationUnitElement changes its enclosing element from LibraryElement to LibraryOrAugmentationElement 2. Similarly PrefixElement. Change-Id: I5e3719b4ef59d03caab1b20c9172a8c0fd786bdf Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/251900 Reviewed-by: Samuel Rawlins <srawlins@google.com> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
parent
d8d9e06804
commit
2f3269faa1
|
@ -65,7 +65,7 @@ class CanRenameResponse {
|
|||
|
||||
void _analyzePossibleConflicts(
|
||||
ConstructorElement element, RefactoringStatus result, String newName) {
|
||||
var parentClass = element.enclosingElement;
|
||||
var parentClass = element.enclosingElement2;
|
||||
// Check if the "newName" is the name of the enclosing class.
|
||||
if (parentClass.name == newName) {
|
||||
result.addError('The constructor should not have the same name '
|
||||
|
@ -254,8 +254,8 @@ class CheckNameResponse {
|
|||
var stateName = flutterState.newName;
|
||||
var match = await canRename._fileResolver.findReferences2(stateClass);
|
||||
var sourcePath = stateClass.source.fullName;
|
||||
var location =
|
||||
stateClass.enclosingElement.lineInfo.getLocation(stateClass.nameOffset);
|
||||
var location = stateClass.enclosingElement2.lineInfo
|
||||
.getLocation(stateClass.nameOffset);
|
||||
CiderSearchMatch ciderMatch;
|
||||
var searchInfo =
|
||||
CiderSearchInfo(location, stateClass.nameLength, MatchKind.DECLARATION);
|
||||
|
@ -297,7 +297,7 @@ class CheckNameResponse {
|
|||
|
||||
Future<CiderReplaceMatch?> _replaceSyntheticConstructor() async {
|
||||
var element = canRename.refactoringElement.element;
|
||||
var classElement = element.enclosingElement;
|
||||
var classElement = element.enclosingElement2;
|
||||
|
||||
var fileResolver = canRename._fileResolver;
|
||||
var libraryPath = classElement!.library!.source.fullName;
|
||||
|
@ -382,7 +382,7 @@ class CiderRenameComputer {
|
|||
}
|
||||
|
||||
bool _canRenameElement(Element element) {
|
||||
var enclosingElement = element.enclosingElement;
|
||||
var enclosingElement = element.enclosingElement2;
|
||||
if (element is ConstructorElement) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -104,7 +104,7 @@ class CallHierarchyItem {
|
|||
codeRange = _codeRangeForElement(element),
|
||||
file = element.source!.fullName,
|
||||
kind = CallHierarchyKind.forElement(element) {
|
||||
final enclosingElement = element.enclosingElement;
|
||||
final enclosingElement = element.enclosingElement2;
|
||||
final container =
|
||||
enclosingElement != null ? _getContainer(enclosingElement) : null;
|
||||
containerName = container != null ? _getDisplayName(container) : null;
|
||||
|
|
|
@ -83,7 +83,7 @@ class ColorComputer {
|
|||
|
||||
final constructor = expression.constructorName;
|
||||
final staticElement = constructor.staticElement;
|
||||
final classElement = staticElement?.enclosingElement;
|
||||
final classElement = staticElement?.enclosingElement2;
|
||||
final className = classElement?.name;
|
||||
final constructorName = constructor.name?.name;
|
||||
final constructorArgs = expression.argumentList.arguments
|
||||
|
|
|
@ -305,7 +305,7 @@ class DartUnitHighlightsComputer {
|
|||
var parent = node.parent;
|
||||
var isInvocation = parent is MethodInvocation && parent.methodName == node;
|
||||
HighlightRegionType type;
|
||||
var isTopLevel = element.enclosingElement is CompilationUnitElement;
|
||||
var isTopLevel = element.enclosingElement2 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.enclosingElement is CompilationUnitElement;
|
||||
var isTopLevel = element.enclosingElement2 is CompilationUnitElement;
|
||||
HighlightRegionType type;
|
||||
if (element.isGetter) {
|
||||
if (isTopLevel) {
|
||||
|
|
|
@ -71,7 +71,7 @@ class DartUnitHoverComputer {
|
|||
hover.elementKind = element.kind.displayName;
|
||||
hover.isDeprecated = element.hasDeprecated;
|
||||
// not local element
|
||||
if (element.enclosingElement is! ExecutableElement) {
|
||||
if (element.enclosingElement2 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.enclosingElement;
|
||||
element = element.enclosingElement2;
|
||||
}
|
||||
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.enclosingElement;
|
||||
var documentedElementClass = documentedElement.enclosingElement2;
|
||||
if (documentedElementClass != null &&
|
||||
documentedElementClass != element.enclosingElement) {
|
||||
documentedElementClass != element.enclosingElement2) {
|
||||
var documentedClass = documentedElementClass.displayName;
|
||||
result.full = '${result.full}\n\nCopied from `$documentedClass`.';
|
||||
}
|
||||
|
|
|
@ -521,7 +521,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.enclosingElement;
|
||||
var parent = element.enclosingElement2;
|
||||
return parent is engine.CompilationUnitElement &&
|
||||
parent.source.fullName.endsWith('test.dart');
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import 'package:analyzer/dart/element/element.dart';
|
|||
|
||||
/// Return the elements that the given [element] overrides.
|
||||
OverriddenElements findOverriddenElements(Element element) {
|
||||
if (element.enclosingElement is ClassElement) {
|
||||
if (element.enclosingElement2 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.enclosingElement as ClassElement;
|
||||
var class_ = seed.enclosingElement2 as ClassElement;
|
||||
var library = class_.library;
|
||||
var name = seed.displayName;
|
||||
List<ElementKind> kinds;
|
||||
|
|
|
@ -82,7 +82,7 @@ class _Visitor extends UnifyingAstVisitor<void> {
|
|||
!_isConstructorDeclarationReturnType(node)) {
|
||||
var nodeElement = node.writeOrReadElement;
|
||||
if (nodeElement != null &&
|
||||
nodeElement.enclosingElement is CompilationUnitElement) {
|
||||
nodeElement.enclosingElement2 is CompilationUnitElement) {
|
||||
var nodeLibrary = nodeElement.library;
|
||||
var path = nodeLibrary?.definingCompilationUnit.source.fullName;
|
||||
if (path == null) {
|
||||
|
|
|
@ -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.enclosingElement!.displayName;
|
||||
var className = member.enclosingElement2!.displayName;
|
||||
return OverriddenMember(element, className);
|
||||
}
|
||||
|
||||
|
@ -277,7 +277,7 @@ engine.CompilationUnitElement _getUnitElement(engine.Element element) {
|
|||
return element;
|
||||
}
|
||||
|
||||
var enclosingElement = element.enclosingElement;
|
||||
var enclosingElement = element.enclosingElement2;
|
||||
if (enclosingElement is engine.LibraryElement) {
|
||||
element = enclosingElement;
|
||||
}
|
||||
|
|
|
@ -73,6 +73,6 @@ class ElementReferencesComputer {
|
|||
if (element is ConstructorElement) {
|
||||
return false;
|
||||
}
|
||||
return element.enclosingElement is ClassElement;
|
||||
return element.enclosingElement2 is ClassElement;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,10 +35,10 @@ class TypeHierarchyComputer {
|
|||
Element? element = _pivotElement;
|
||||
if (_pivotElement is FieldElement) {
|
||||
_pivotFieldFinal = (_pivotElement as FieldElement).isFinal;
|
||||
element = _pivotElement.enclosingElement;
|
||||
element = _pivotElement.enclosingElement2;
|
||||
}
|
||||
if (_pivotElement is ExecutableElement) {
|
||||
element = _pivotElement.enclosingElement;
|
||||
element = _pivotElement.enclosingElement2;
|
||||
}
|
||||
if (element is ClassElement) {
|
||||
_pivotClass = element;
|
||||
|
|
|
@ -90,7 +90,7 @@ class LibraryElementSuggestionBuilder extends GeneralizingElementVisitor {
|
|||
if (element.isOperator) {
|
||||
return;
|
||||
}
|
||||
if (element.enclosingElement is! CompilationUnitElement) {
|
||||
if (element.enclosingElement2 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.enclosingElement;
|
||||
var parent = element.enclosingElement2;
|
||||
if (parent is ClassElement || parent is ExtensionElement) {
|
||||
builder.suggestAccessor(element, inheritanceDistance: 0.0);
|
||||
} else {
|
||||
|
|
|
@ -258,7 +258,7 @@ class _LocalVisitor extends LocalDeclarationVisitor {
|
|||
.thisOrAncestorOfType<ClassDeclaration>();
|
||||
var enclosingElement = enclosingClass?.declaredElement;
|
||||
if (enclosingElement != null) {
|
||||
var enclosingElement = field.enclosingElement;
|
||||
var enclosingElement = field.enclosingElement2;
|
||||
if (enclosingElement is ClassElement) {
|
||||
inheritanceDistance = request.featureComputer
|
||||
.inheritanceDistanceFeature(enclosingElement, enclosingElement);
|
||||
|
@ -333,7 +333,7 @@ class _LocalVisitor extends LocalDeclarationVisitor {
|
|||
var enclosingClass = request.target.containingNode
|
||||
.thisOrAncestorOfType<ClassDeclaration>();
|
||||
if (enclosingClass != null) {
|
||||
var enclosingElement = element?.enclosingElement;
|
||||
var enclosingElement = element?.enclosingElement2;
|
||||
if (enclosingElement is ClassElement) {
|
||||
inheritanceDistance = request.featureComputer
|
||||
.inheritanceDistanceFeature(
|
||||
|
|
|
@ -409,7 +409,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.enclosingElement;
|
||||
var enclosingClass = constructor.enclosingElement2;
|
||||
var className = enclosingClass.name;
|
||||
if (className.isEmpty) {
|
||||
return;
|
||||
|
@ -457,10 +457,10 @@ class SuggestionBuilder {
|
|||
} else if (element is ExtensionElement) {
|
||||
suggestExtension(element, kind: kind);
|
||||
} else if (element is FunctionElement &&
|
||||
element.enclosingElement is CompilationUnitElement) {
|
||||
element.enclosingElement2 is CompilationUnitElement) {
|
||||
suggestTopLevelFunction(element, kind: kind);
|
||||
} else if (element is PropertyAccessorElement &&
|
||||
element.enclosingElement is CompilationUnitElement) {
|
||||
element.enclosingElement2 is CompilationUnitElement) {
|
||||
suggestTopLevelPropertyAccessor(element);
|
||||
} else if (element is TypeAliasElement) {
|
||||
suggestTypeAlias(element);
|
||||
|
@ -473,7 +473,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.enclosingElement;
|
||||
var enumElement = constant.enclosingElement2;
|
||||
var enumName = enumElement.name;
|
||||
var completion = '$enumName.$constantName';
|
||||
var relevance =
|
||||
|
@ -705,7 +705,7 @@ class SuggestionBuilder {
|
|||
inheritanceDistance: inheritanceDistance,
|
||||
);
|
||||
|
||||
var enclosingElement = method.enclosingElement;
|
||||
var enclosingElement = method.enclosingElement2;
|
||||
if (method.name == 'setState' &&
|
||||
enclosingElement is ClassElement &&
|
||||
flutter.isExactState(enclosingElement)) {
|
||||
|
@ -777,10 +777,10 @@ class SuggestionBuilder {
|
|||
|
||||
// Optionally add Flutter child widget details.
|
||||
// todo (pq): revisit this special casing; likely it can be generalized away
|
||||
var element = parameter.enclosingElement;
|
||||
var element = parameter.enclosingElement2;
|
||||
// If appendColon is false, default values should never be appended.
|
||||
if (element is ConstructorElement && appendColon) {
|
||||
if (Flutter.instance.isWidget(element.enclosingElement)) {
|
||||
if (Flutter.instance.isWidget(element.enclosingElement2)) {
|
||||
// Don't bother with nullability. It won't affect default list values.
|
||||
var defaultValue =
|
||||
getDefaultStringParameterValue(parameter, withNullability: false);
|
||||
|
@ -1009,9 +1009,9 @@ class SuggestionBuilder {
|
|||
void suggestTopLevelPropertyAccessor(PropertyAccessorElement accessor,
|
||||
{String? prefix}) {
|
||||
assert(
|
||||
accessor.enclosingElement is CompilationUnitElement,
|
||||
accessor.enclosingElement2 is CompilationUnitElement,
|
||||
'Enclosing element of ${accessor.runtimeType} is '
|
||||
'${accessor.enclosingElement.runtimeType}.');
|
||||
'${accessor.enclosingElement2.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
|
||||
|
@ -1061,7 +1061,7 @@ class SuggestionBuilder {
|
|||
/// referenced using a prefix, then the [prefix] should be provided.
|
||||
void suggestTopLevelVariable(TopLevelVariableElement variable,
|
||||
{String? prefix}) {
|
||||
assert(variable.enclosingElement is CompilationUnitElement);
|
||||
assert(variable.enclosingElement2 is CompilationUnitElement);
|
||||
var relevance =
|
||||
_computeTopLevelRelevance(variable, elementType: variable.type);
|
||||
_addBuilder(
|
||||
|
@ -1294,7 +1294,7 @@ class SuggestionBuilder {
|
|||
withNullability: _isNonNullableByDefault,
|
||||
);
|
||||
|
||||
var enclosingElement = element.enclosingElement;
|
||||
var enclosingElement = element.enclosingElement2;
|
||||
|
||||
String? declaringType;
|
||||
if (enclosingElement is ClassElement) {
|
||||
|
@ -1353,7 +1353,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.enclosingElement;
|
||||
var enclosing = element.enclosingElement2;
|
||||
if (enclosing is ClassElement) {
|
||||
return enclosing.name;
|
||||
} else if (enclosing is ExtensionElement) {
|
||||
|
|
|
@ -61,7 +61,7 @@ class AddLate extends CorrectionProducer {
|
|||
getter.isSynthetic &&
|
||||
!getter.variable.isSynthetic &&
|
||||
getter.variable.setter == null &&
|
||||
getter.enclosingElement is ClassElement) {
|
||||
getter.enclosingElement2 is ClassElement) {
|
||||
var declarationResult =
|
||||
await sessionHelper.getElementDeclaration(getter.variable);
|
||||
if (declarationResult == null) {
|
||||
|
|
|
@ -43,7 +43,7 @@ class ChangeToStaticAccess extends CorrectionProducer {
|
|||
}
|
||||
|
||||
final target_final = target;
|
||||
var declaringElement = invokedElement.enclosingElement;
|
||||
var declaringElement = invokedElement.enclosingElement2;
|
||||
|
||||
if (declaringElement is ClassElement) {
|
||||
_className = declaringElement.name;
|
||||
|
|
|
@ -80,7 +80,7 @@ class _BaseVisitor extends RecursiveAstVisitor<void> {
|
|||
var constructorElement = node.constructorName.staticElement;
|
||||
return constructorElement != null &&
|
||||
!constructorElement.isFactory &&
|
||||
constructorElement.enclosingElement == classElement;
|
||||
constructorElement.enclosingElement2 == classElement;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -571,7 +571,7 @@ class _EnumDescription {
|
|||
initializer.constructorName.staticElement;
|
||||
if (constructorElement != null &&
|
||||
!constructorElement.isFactory &&
|
||||
constructorElement.enclosingElement == classElement) {
|
||||
constructorElement.enclosingElement2 == classElement) {
|
||||
var fieldValue = fieldElement.computeConstantValue();
|
||||
if (fieldValue != null) {
|
||||
if (fieldList.variables.length != 1) {
|
||||
|
|
|
@ -97,7 +97,7 @@ class _SuperclassReferenceFinder extends RecursiveAstVisitor<void> {
|
|||
|
||||
void _addElement(Element? element) {
|
||||
if (element is ExecutableElement) {
|
||||
var enclosingElement = element.enclosingElement;
|
||||
var enclosingElement = element.enclosingElement2;
|
||||
if (enclosingElement is ClassElement) {
|
||||
referencedClasses.add(enclosingElement);
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ class ConvertIntoFinalField extends CorrectionProducer {
|
|||
if (element == null) {
|
||||
return;
|
||||
}
|
||||
var enclosing = element.enclosingElement;
|
||||
var enclosing = element.enclosingElement2;
|
||||
if (enclosing is ClassElement) {
|
||||
if (enclosing.getSetter(element.name) != null) {
|
||||
return;
|
||||
|
|
|
@ -43,7 +43,7 @@ class ConvertIntoIsNotEmpty extends CorrectionProducer {
|
|||
return;
|
||||
}
|
||||
// should have "isNotEmpty"
|
||||
var propertyTarget = propertyElement.enclosingElement;
|
||||
var propertyTarget = propertyElement.enclosingElement2;
|
||||
if (propertyTarget == null ||
|
||||
getChildren(propertyTarget, 'isNotEmpty').isEmpty) {
|
||||
return;
|
||||
|
|
|
@ -41,7 +41,7 @@ class ConvertMapFromIterableToForLiteral extends CorrectionProducer {
|
|||
var element = creation.constructorName.staticElement;
|
||||
if (element == null ||
|
||||
element.name != 'fromIterable' ||
|
||||
element.enclosingElement != typeProvider.mapElement) {
|
||||
element.enclosingElement2 != typeProvider.mapElement) {
|
||||
return;
|
||||
}
|
||||
//
|
||||
|
|
|
@ -163,7 +163,7 @@ class CreateConstructor extends CorrectionProducer {
|
|||
}
|
||||
|
||||
// prepare target ClassDeclaration
|
||||
var targetElement = constructorElement.enclosingElement;
|
||||
var targetElement = constructorElement.enclosingElement2;
|
||||
var targetResult = await sessionHelper.getElementDeclaration(targetElement);
|
||||
if (targetResult == null) {
|
||||
return;
|
||||
|
|
|
@ -309,7 +309,7 @@ class _ReplacementEditBuilder extends RecursiveAstVisitor<void> {
|
|||
}
|
||||
var element = node.staticElement;
|
||||
if (element is ExecutableElement &&
|
||||
element.enclosingElement == widgetClassElement &&
|
||||
element.enclosingElement2 == widgetClassElement &&
|
||||
!elementsToMove.contains(element)) {
|
||||
var offset = node.offset - linesRange.offset;
|
||||
var qualifier =
|
||||
|
|
|
@ -315,7 +315,7 @@ class _ReplacementEditBuilder extends RecursiveAstVisitor<void> {
|
|||
}
|
||||
var element = node.staticElement;
|
||||
if (element is ExecutableElement &&
|
||||
element.enclosingElement == widgetClassElement &&
|
||||
element.enclosingElement2 == 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.enclosingElement;
|
||||
var classElement = methodElement.enclosingElement2;
|
||||
if (classElement is ClassElement &&
|
||||
Flutter.instance.isExactState(classElement) &&
|
||||
!FlutterConvertToStatelessWidget._isDefaultOverride(
|
||||
|
|
|
@ -45,7 +45,7 @@ class MakeFieldNotFinal extends CorrectionProducer {
|
|||
}
|
||||
|
||||
// It must be a field declaration.
|
||||
if (getter.enclosingElement is! ClassElement) {
|
||||
if (getter.enclosingElement2 is! ClassElement) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ class QualifyReference extends CorrectionProducer {
|
|||
return;
|
||||
}
|
||||
|
||||
var enclosingElement = memberElement.enclosingElement;
|
||||
var enclosingElement = memberElement.enclosingElement2;
|
||||
if (enclosingElement == null ||
|
||||
enclosingElement.library != libraryElement) {
|
||||
// TODO(brianwilkerson) Support qualifying references to members defined
|
||||
|
|
|
@ -28,7 +28,7 @@ class ShadowField extends CorrectionProducer {
|
|||
return;
|
||||
}
|
||||
|
||||
if (!accessor.isGetter || accessor.enclosingElement is! ClassElement) {
|
||||
if (!accessor.isGetter || accessor.enclosingElement2 is! ClassElement) {
|
||||
// TODO(brianwilkerson) Should we also require that the getter be synthetic?
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -201,7 +201,7 @@ class _MatcherBuilder {
|
|||
);
|
||||
}
|
||||
} else if (parent is SuperConstructorInvocation) {
|
||||
var superclassName = parent.staticElement?.enclosingElement.name;
|
||||
var superclassName = parent.staticElement?.enclosingElement2.name;
|
||||
if (superclassName != null) {
|
||||
_addMatcher(
|
||||
components: [parent.constructorName?.name ?? '', superclassName],
|
||||
|
@ -502,7 +502,7 @@ class _MatcherBuilder {
|
|||
}
|
||||
}
|
||||
if (element != null) {
|
||||
var enclosingElement = element.enclosingElement;
|
||||
var enclosingElement = element.enclosingElement2;
|
||||
if (enclosingElement is ClassElement) {
|
||||
return [identifier.name, enclosingElement.name];
|
||||
} else if (enclosingElement is ExtensionElement) {
|
||||
|
|
|
@ -122,7 +122,7 @@ extension on MethodDeclaration {
|
|||
ExecutableElement? overriddenElement() {
|
||||
var element = declaredElement;
|
||||
if (element != null) {
|
||||
var enclosingElement = element.enclosingElement;
|
||||
var enclosingElement = element.enclosingElement2;
|
||||
if (enclosingElement is ClassElement) {
|
||||
var name = Name(enclosingElement.library.source.uri, element.name);
|
||||
return InheritanceManager3().getInherited2(enclosingElement, name);
|
||||
|
|
|
@ -42,7 +42,7 @@ LibraryImportElement? _getImportElement(
|
|||
String prefix,
|
||||
Element element,
|
||||
Map<LibraryImportElement, Set<Element>> importElementsMap) {
|
||||
if (element.enclosingElement is! CompilationUnitElement) {
|
||||
if (element.enclosingElement2 is! CompilationUnitElement) {
|
||||
return null;
|
||||
}
|
||||
var usedLibrary = element.library;
|
||||
|
|
|
@ -220,7 +220,7 @@ String getElementKindName(Element element) {
|
|||
String getElementQualifiedName(Element element) {
|
||||
var kind = element.kind;
|
||||
if (kind == ElementKind.FIELD || kind == ElementKind.METHOD) {
|
||||
return '${element.enclosingElement!.displayName}.${element.displayName}';
|
||||
return '${element.enclosingElement2!.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!;
|
||||
|
@ -1380,7 +1380,7 @@ class CorrectionUtils {
|
|||
/// Checks if [element] is visible in [targetExecutableElement] or
|
||||
/// [targetClassElement].
|
||||
bool _isTypeParameterVisible(TypeParameterElement element) {
|
||||
var enclosing = element.enclosingElement;
|
||||
var enclosing = element.enclosingElement2;
|
||||
return identical(enclosing, targetExecutableElement) ||
|
||||
identical(enclosing, targetClassElement);
|
||||
}
|
||||
|
|
|
@ -463,7 +463,7 @@ class _EdgeInsetsProperty {
|
|||
var constructor = propertyExpression.constructorName.staticElement;
|
||||
if (flutter != null &&
|
||||
constructor != null &&
|
||||
constructor.enclosingElement == classEdgeInsets) {
|
||||
constructor.enclosingElement2 == classEdgeInsets) {
|
||||
var arguments = propertyExpression.argumentList.arguments;
|
||||
var constructorName = constructor.name;
|
||||
if (constructorName == 'all') {
|
||||
|
|
|
@ -278,7 +278,7 @@ class _WidgetDescriptionComputer {
|
|||
constructorElement ??= classDescription?.constructor;
|
||||
if (constructorElement == null) return;
|
||||
|
||||
var classElement = constructorElement.enclosingElement;
|
||||
var classElement = constructorElement.enclosingElement2;
|
||||
if (!classesBeingProcessed.add(classElement)) return;
|
||||
|
||||
var existingNamed = <String>{};
|
||||
|
@ -520,7 +520,7 @@ class _WidgetDescriptionComputer {
|
|||
}
|
||||
|
||||
protocol.FlutterWidgetPropertyValueEnumItem _toEnumItem(FieldElement field) {
|
||||
var classElement = field.enclosingElement as ClassElement;
|
||||
var classElement = field.enclosingElement2 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.enclosingElement as ClassElement;
|
||||
var enclosingClass = field.enclosingElement2 as ClassElement;
|
||||
if (field.isEnumConstant ||
|
||||
_flutter.isExactAlignment(enclosingClass) ||
|
||||
_flutter.isExactAlignmentDirectional(enclosingClass)) {
|
||||
|
|
|
@ -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.enclosingElement.name;
|
||||
var name = element.enclosingElement2.name;
|
||||
var constructorName = element.name;
|
||||
if (constructorName.isNotEmpty) {
|
||||
name = '$name.$constructorName';
|
||||
|
@ -723,13 +723,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.enclosingElement, schema.RECORD_KIND);
|
||||
constructorElement.enclosingElement2, schema.RECORD_KIND);
|
||||
var anchorVName =
|
||||
_vNameAnchor(constructorName.offset, constructorName.end);
|
||||
addEdge(anchorVName, schema.REF_EDGE, enclosingEltVName);
|
||||
|
||||
// TODO(jwren): investigate
|
||||
// assert (element.enclosingElement != null);
|
||||
// assert (element.enclosingElement2 != null);
|
||||
}
|
||||
// visit children
|
||||
_safelyVisitList(constructorName.type.typeArguments?.arguments);
|
||||
|
@ -1422,7 +1422,7 @@ class SignatureElementVisitor extends GeneralizingElementVisitor<StringBuffer> {
|
|||
@override
|
||||
StringBuffer visitElement(Element element) {
|
||||
assert(element is! MultiplyInheritedExecutableElement);
|
||||
var enclosingElt = element.enclosingElement!;
|
||||
var enclosingElt = element.enclosingElement2!;
|
||||
var buffer = enclosingElt.accept(this)!;
|
||||
if (buffer.isNotEmpty) {
|
||||
buffer.write('#');
|
||||
|
@ -1454,7 +1454,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.enclosingElement!.accept(this)!
|
||||
return element.enclosingElement2!.accept(this)!
|
||||
..write('.')
|
||||
..write(element.name);
|
||||
}
|
||||
|
|
|
@ -46,15 +46,15 @@ class ConvertGetterToMethodRefactoringImpl extends RefactoringImpl
|
|||
Future<SourceChange> createChange() async {
|
||||
change = SourceChange(refactoringName);
|
||||
// function
|
||||
if (element.enclosingElement is CompilationUnitElement) {
|
||||
if (element.enclosingElement2 is CompilationUnitElement) {
|
||||
await _updateElementDeclaration(element);
|
||||
await _updateElementReferences(element);
|
||||
}
|
||||
// method
|
||||
var field = element.variable;
|
||||
if (field is FieldElement &&
|
||||
(field.enclosingElement is ClassElement ||
|
||||
field.enclosingElement is ExtensionElement)) {
|
||||
(field.enclosingElement2 is ClassElement ||
|
||||
field.enclosingElement2 is ExtensionElement)) {
|
||||
var elements = await getHierarchyMembers(searchEngine, field);
|
||||
await Future.forEach(elements, (ClassMemberElement member) async {
|
||||
if (member is FieldElement) {
|
||||
|
|
|
@ -72,7 +72,7 @@ class ConvertMethodToGetterRefactoringImpl extends RefactoringImpl
|
|||
RefactoringStatus _checkElement() {
|
||||
// check Element type
|
||||
if (element is FunctionElement) {
|
||||
if (element.enclosingElement is! CompilationUnitElement) {
|
||||
if (element.enclosingElement2 is! CompilationUnitElement) {
|
||||
return RefactoringStatus.fatal(
|
||||
'Only top-level functions can be converted to getters.');
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ Element? _getLocalElement(SimpleIdentifier node) {
|
|||
if (element is LocalVariableElement ||
|
||||
element is ParameterElement ||
|
||||
element is FunctionElement &&
|
||||
element.enclosingElement is! CompilationUnitElement) {
|
||||
element.enclosingElement2 is! CompilationUnitElement) {
|
||||
return element;
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -654,7 +654,7 @@ class _ParametersCollector extends RecursiveAstVisitor<void> {
|
|||
enclosingClass,
|
||||
...enclosingClass.allSupertypes.map((t) => t.element)
|
||||
];
|
||||
return enclosingClasses.contains(element.enclosingElement);
|
||||
return enclosingClasses.contains(element.enclosingElement2);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -212,7 +212,7 @@ class InlineMethodRefactoringImpl extends RefactoringImpl
|
|||
|
||||
@override
|
||||
String? get className {
|
||||
var classElement = _methodElement?.enclosingElement;
|
||||
var classElement = _methodElement?.enclosingElement2;
|
||||
if (classElement is ClassElement) {
|
||||
return classElement.displayName;
|
||||
}
|
||||
|
@ -805,13 +805,13 @@ class _VariablesVisitor extends GeneralizingAstVisitor<void> {
|
|||
} else {
|
||||
return;
|
||||
}
|
||||
if (element.enclosingElement is! ClassElement) {
|
||||
if (element.enclosingElement2 is! ClassElement) {
|
||||
return;
|
||||
}
|
||||
// record the implicit static or instance reference
|
||||
var offset = node.offset;
|
||||
if (element.isStatic) {
|
||||
var className = element.enclosingElement.displayName;
|
||||
var className = element.enclosingElement2.displayName;
|
||||
result.addImplicitClassNameOffset(className, offset);
|
||||
} else {
|
||||
result.addImplicitThisOffset(offset);
|
||||
|
|
|
@ -406,7 +406,7 @@ abstract class RenameRefactoring implements Refactoring {
|
|||
if (element is PropertyAccessorElement) {
|
||||
element = element.variable;
|
||||
}
|
||||
var enclosingElement = element.enclosingElement;
|
||||
var enclosingElement = element.enclosingElement2;
|
||||
if (enclosingElement is CompilationUnitElement) {
|
||||
return RenameUnitMemberRefactoringImpl(workspace, resolvedUnit, element);
|
||||
}
|
||||
|
|
|
@ -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.enclosingElement;
|
||||
var nameClass = nameElement.enclosingElement2;
|
||||
// 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.enclosingElement;
|
||||
var enclosingElement = element.enclosingElement2;
|
||||
if (enclosingElement is ClassElement && enclosingElement.name == name) {
|
||||
result.addError(
|
||||
'Renamed ${elementKind.displayName} has the same name as the '
|
||||
|
|
|
@ -82,7 +82,7 @@ class RenameConstructorRefactoringImpl extends RenameRefactoringImpl {
|
|||
}
|
||||
|
||||
void _analyzePossibleConflicts(RefactoringStatus result) {
|
||||
var parentClass = element.enclosingElement;
|
||||
var parentClass = element.enclosingElement2;
|
||||
// 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.enclosingElement;
|
||||
var classElement = element.enclosingElement2;
|
||||
|
||||
var result = await AnalysisSessionHelper(session)
|
||||
.getElementDeclaration(classElement);
|
||||
|
|
|
@ -214,7 +214,7 @@ class _BaseUnitMemberValidator {
|
|||
var declarations = await searchEngine.searchMemberDeclarations(name);
|
||||
for (var declaration in declarations) {
|
||||
var member = declaration.element;
|
||||
var declaringClass = member.enclosingElement as ClassElement;
|
||||
var declaringClass = member.enclosingElement2 as ClassElement;
|
||||
var memberReferences = await searchEngine.searchReferences(member);
|
||||
for (var memberReference in memberReferences) {
|
||||
var refElement = memberReference.element;
|
||||
|
|
|
@ -82,7 +82,7 @@ Future<Set<ClassMemberElement>> getHierarchyMembers(
|
|||
SearchEngine searchEngine, ClassMemberElement member) async {
|
||||
Set<ClassMemberElement> result = HashSet<ClassMemberElement>();
|
||||
// extension member
|
||||
var enclosingElement = member.enclosingElement;
|
||||
var enclosingElement = member.enclosingElement2;
|
||||
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.enclosingElement;
|
||||
var method = element.enclosingElement2;
|
||||
if (method is MethodElement) {
|
||||
var hierarchyParameters = <ParameterElement>[];
|
||||
var hierarchyMembers = await getHierarchyMembers(searchEngine, method);
|
||||
|
|
|
@ -30,12 +30,12 @@ extension ElementExtension on Element {
|
|||
if (hasDeprecated) {
|
||||
return true;
|
||||
}
|
||||
var ancestor = enclosingElement;
|
||||
var ancestor = enclosingElement2;
|
||||
if (ancestor is ClassElement) {
|
||||
if (ancestor.hasDeprecated) {
|
||||
return true;
|
||||
}
|
||||
ancestor = ancestor.enclosingElement;
|
||||
ancestor = ancestor.enclosingElement2;
|
||||
}
|
||||
return ancestor is CompilationUnitElement &&
|
||||
ancestor.enclosingElement2.hasDeprecated;
|
||||
|
@ -46,7 +46,7 @@ extension ElementExtension on Element {
|
|||
var current = this;
|
||||
while (true) {
|
||||
yield current;
|
||||
var enclosing = current.enclosingElement;
|
||||
var enclosing = current.enclosingElement2;
|
||||
if (enclosing == null) {
|
||||
break;
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ extension MethodElementExtensions on MethodElement {
|
|||
if (name != 'cast') {
|
||||
return false;
|
||||
}
|
||||
var definingClass = enclosingElement;
|
||||
var definingClass = enclosingElement2;
|
||||
if (definingClass is! ClassElement) {
|
||||
return false;
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ extension MethodElementExtensions on MethodElement {
|
|||
if (name != 'toList') {
|
||||
return false;
|
||||
}
|
||||
var definingClass = enclosingElement;
|
||||
var definingClass = enclosingElement2;
|
||||
if (definingClass is! ClassElement) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -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?.enclosingElement;
|
||||
var element = node.constructorName.staticElement?.enclosingElement2;
|
||||
if (!isWidget(element)) {
|
||||
return null;
|
||||
}
|
||||
|
@ -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?.enclosingElement;
|
||||
var element = expr?.constructorName.staticElement?.enclosingElement2;
|
||||
return isWidget(element);
|
||||
}
|
||||
|
||||
|
|
|
@ -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.enclosingElement;
|
||||
//engine.ClassElement classElement = engineElement.enclosingElement2;
|
||||
//expect(classElement.isDeprecated, isTrue);
|
||||
expect(
|
||||
element.flags,
|
||||
|
|
|
@ -1699,7 +1699,7 @@ class CompletionResult {
|
|||
var entity = expectedCompletion.syntacticEntity;
|
||||
var element = _getElement(entity);
|
||||
if (element != null) {
|
||||
var parent = element.enclosingElement;
|
||||
var parent = element.enclosingElement2;
|
||||
if (parent is ClassElement || parent is ExtensionElement) {
|
||||
if (_isStatic(element)) {
|
||||
return CompletionGroup.staticMember;
|
||||
|
|
|
@ -144,7 +144,7 @@ class FlutterDataCollector extends RecursiveAstVisitor<void> {
|
|||
throw StateError(
|
||||
'Unresolved constructor name: ${node.constructorName}');
|
||||
}
|
||||
var childWidget = element.enclosingElement.name;
|
||||
var childWidget = element.enclosingElement2.name;
|
||||
if (!element.librarySource.uri
|
||||
.toString()
|
||||
.startsWith('package:flutter/')) {
|
||||
|
|
|
@ -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.enclosingElement is ClassElement) {
|
||||
if (!element.isStatic && element.enclosingElement2 is ClassElement) {
|
||||
var overriddenMembers = inheritanceManager.getOverridden2(
|
||||
element.enclosingElement as ClassElement,
|
||||
element.enclosingElement2 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?.enclosingElement;
|
||||
currentElement = currentElement?.enclosingElement2;
|
||||
}
|
||||
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.enclosingElement!;
|
||||
var definingElement = element.enclosingElement2!;
|
||||
var depth = _parameterReferenceDepth(node, definingElement);
|
||||
_recordDistance('function depth of referenced parameter', depth);
|
||||
} else if (element is LocalVariableElement) {
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
## 4.3.0-dev
|
||||
* Deprecated `Directive.keyword`, use corresponding `xyzToken` in specific directives.
|
||||
* Deprecated `LibraryElement.parts`, use `parts2` instead.
|
||||
* Deprecated `LibraryElement.exports`, use `libraryexports` instead.
|
||||
* Deprecated `LibraryElement.imports`, use `libraryImports` instead.
|
||||
* Deprecated `Element.enclosingElement`, use `enclosingElement2` instead.
|
||||
|
||||
## 4.2.0
|
||||
* Update SDK constraints to `>=2.17.0 <3.0.0`.
|
||||
|
|
|
@ -57,9 +57,13 @@ 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')
|
||||
@override
|
||||
LibraryOrAugmentationElement get enclosingElement;
|
||||
|
||||
@override
|
||||
LibraryOrAugmentationElement get enclosingElement2;
|
||||
|
||||
/// Returns the [LibraryAugmentationElement], if [uri] is a
|
||||
/// [DirectiveUriWithAugmentation].
|
||||
LibraryAugmentationElement? get importedAugmentation;
|
||||
|
@ -95,9 +99,13 @@ abstract class ClassElement
|
|||
@override
|
||||
String get displayName;
|
||||
|
||||
@Deprecated('Use enclosingElement2 instead')
|
||||
@override
|
||||
CompilationUnitElement get enclosingElement;
|
||||
|
||||
@override
|
||||
CompilationUnitElement get enclosingElement2;
|
||||
|
||||
/// Return a list containing all of the fields declared in this class.
|
||||
List<FieldElement> get fields;
|
||||
|
||||
|
@ -392,9 +400,13 @@ abstract class ClassMemberElement implements Element {
|
|||
// TODO(brianwilkerson) Either remove this class or rename it to something
|
||||
// more correct.
|
||||
|
||||
@Deprecated('Use enclosingElement2 instead')
|
||||
@override
|
||||
Element get enclosingElement;
|
||||
|
||||
@override
|
||||
Element get enclosingElement2;
|
||||
|
||||
/// 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.
|
||||
|
@ -413,11 +425,12 @@ abstract class CompilationUnitElement implements UriReferencedElement {
|
|||
/// unit.
|
||||
List<ClassElement> get classes;
|
||||
|
||||
@Deprecated('Use enclosingElement2 instead')
|
||||
@override
|
||||
LibraryElement get enclosingElement;
|
||||
|
||||
/// Return the library, or library augmentation that encloses this unit.
|
||||
@experimental
|
||||
@override
|
||||
LibraryOrAugmentationElement get enclosingElement2;
|
||||
|
||||
/// Return a list containing all of the enums contained in this compilation
|
||||
|
@ -473,9 +486,13 @@ abstract class ConstructorElement
|
|||
@override
|
||||
String get displayName;
|
||||
|
||||
@Deprecated('Use enclosingElement2 instead')
|
||||
@override
|
||||
ClassElement get enclosingElement;
|
||||
|
||||
@override
|
||||
ClassElement get enclosingElement2;
|
||||
|
||||
/// Return `true` if this constructor is a const constructor.
|
||||
bool get isConst;
|
||||
|
||||
|
@ -619,8 +636,14 @@ 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')
|
||||
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.
|
||||
Element? get enclosingElement2;
|
||||
|
||||
/// Return `true` if this element has an annotation of the form
|
||||
/// `@alwaysThrows`.
|
||||
bool get hasAlwaysThrows;
|
||||
|
@ -1172,9 +1195,13 @@ abstract class ExecutableElement implements FunctionTypedElement {
|
|||
@override
|
||||
String get displayName;
|
||||
|
||||
@Deprecated('Use enclosingElement2 instead')
|
||||
@override
|
||||
Element get enclosingElement;
|
||||
|
||||
@override
|
||||
Element get enclosingElement2;
|
||||
|
||||
/// Return `true` if this executable element did not have an explicit return
|
||||
/// type specified for it in the original source.
|
||||
bool get hasImplicitReturnType;
|
||||
|
@ -1236,9 +1263,13 @@ abstract class ExtensionElement implements TypeParameterizedElement {
|
|||
/// declared in this extension.
|
||||
List<PropertyAccessorElement> get accessors;
|
||||
|
||||
@Deprecated('Use enclosingElement2 instead')
|
||||
@override
|
||||
CompilationUnitElement get enclosingElement;
|
||||
|
||||
@override
|
||||
CompilationUnitElement get enclosingElement2;
|
||||
|
||||
/// Return the type that is extended by this extension.
|
||||
DartType get extendedType;
|
||||
|
||||
|
@ -1408,9 +1439,13 @@ abstract class ImportElementPrefix {
|
|||
///
|
||||
/// Clients may not extend, implement or mix-in this class.
|
||||
abstract class LabelElement implements Element {
|
||||
@Deprecated('Use enclosingElement2 instead')
|
||||
@override
|
||||
ExecutableElement get enclosingElement;
|
||||
|
||||
@override
|
||||
ExecutableElement get enclosingElement2;
|
||||
|
||||
@override
|
||||
String get name;
|
||||
}
|
||||
|
@ -1814,11 +1849,12 @@ abstract class PartElement implements _ExistingElement {
|
|||
///
|
||||
/// Clients may not extend, implement or mix-in this class.
|
||||
abstract class PrefixElement implements _ExistingElement {
|
||||
@Deprecated('Use enclosingElement2 instead')
|
||||
@override
|
||||
LibraryElement get enclosingElement;
|
||||
|
||||
/// Return the library, or library augmentation that encloses this element.
|
||||
@experimental
|
||||
@override
|
||||
LibraryOrAugmentationElement get enclosingElement2;
|
||||
|
||||
/// Return the imports that share this prefix.
|
||||
|
@ -1874,9 +1910,13 @@ abstract class PropertyAccessorElement implements ExecutableElement {
|
|||
@override
|
||||
PropertyAccessorElement get declaration;
|
||||
|
||||
@Deprecated('Use enclosingElement2 instead')
|
||||
@override
|
||||
Element get enclosingElement;
|
||||
|
||||
@override
|
||||
Element get enclosingElement2;
|
||||
|
||||
/// Return `true` if this accessor represents a getter.
|
||||
bool get isGetter;
|
||||
|
||||
|
@ -1993,9 +2033,13 @@ abstract class TypeAliasElement
|
|||
/// a [FunctionType].
|
||||
DartType get aliasedType;
|
||||
|
||||
@Deprecated('Use enclosingElement2 instead')
|
||||
@override
|
||||
CompilationUnitElement get enclosingElement;
|
||||
|
||||
@override
|
||||
CompilationUnitElement get enclosingElement2;
|
||||
|
||||
@override
|
||||
String get name;
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ Element? declaredParameterElement(
|
|||
SimpleIdentifier node,
|
||||
Element? element,
|
||||
) {
|
||||
if (element == null || element.enclosingElement != null) {
|
||||
if (element == null || element.enclosingElement2 != null) {
|
||||
return element;
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,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.enclosingElement) {
|
||||
for (Element? e = element; e != null; e = e.enclosingElement2) {
|
||||
if (e is CompilationUnitElement) {
|
||||
return e;
|
||||
}
|
||||
|
@ -88,21 +88,21 @@ class ElementNameComponents {
|
|||
String? parameterName;
|
||||
if (element is ParameterElement) {
|
||||
parameterName = element.name;
|
||||
element = element.enclosingElement!;
|
||||
element = element.enclosingElement2!;
|
||||
}
|
||||
|
||||
String? classMemberName;
|
||||
if (element.enclosingElement is ClassElement ||
|
||||
element.enclosingElement is ExtensionElement) {
|
||||
if (element.enclosingElement2 is ClassElement ||
|
||||
element.enclosingElement2 is ExtensionElement) {
|
||||
classMemberName = element.name;
|
||||
element = element.enclosingElement!;
|
||||
element = element.enclosingElement2!;
|
||||
}
|
||||
|
||||
String? unitMemberName;
|
||||
if (element.enclosingElement is CompilationUnitElement) {
|
||||
if (element.enclosingElement2 is CompilationUnitElement) {
|
||||
unitMemberName = element.name;
|
||||
if (element is ExtensionElement && unitMemberName == null) {
|
||||
var enclosingUnit = element.enclosingElement;
|
||||
var enclosingUnit = element.enclosingElement2;
|
||||
var indexOf = enclosingUnit.extensions.indexOf(element);
|
||||
unitMemberName = 'extension-$indexOf';
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ class IndexElementInfo {
|
|||
} else if (element.isSynthetic) {
|
||||
if (elementKind == ElementKind.CONSTRUCTOR) {
|
||||
kind = IndexSyntheticElementKind.constructor;
|
||||
element = element.enclosingElement!;
|
||||
element = element.enclosingElement2!;
|
||||
} else if (element is FunctionElement &&
|
||||
element.name == FunctionElement.LOAD_LIBRARY_NAME) {
|
||||
kind = IndexSyntheticElementKind.loadLibrary;
|
||||
|
@ -151,7 +151,7 @@ class IndexElementInfo {
|
|||
} else if (elementKind == ElementKind.GETTER ||
|
||||
elementKind == ElementKind.SETTER) {
|
||||
var accessor = element as PropertyAccessorElement;
|
||||
Element enclosing = element.enclosingElement;
|
||||
Element enclosing = element.enclosingElement2;
|
||||
bool isEnumGetter = enclosing is ClassElement && enclosing.isEnum;
|
||||
if (isEnumGetter && accessor.name == 'index') {
|
||||
kind = IndexSyntheticElementKind.enumIndex;
|
||||
|
@ -166,7 +166,7 @@ class IndexElementInfo {
|
|||
element = accessor.variable;
|
||||
}
|
||||
} else if (element is MethodElement) {
|
||||
Element enclosing = element.enclosingElement;
|
||||
Element enclosing = element.enclosingElement2;
|
||||
bool isEnumMethod = enclosing is ClassElement && enclosing.isEnum;
|
||||
if (isEnumMethod && element.name == 'toString') {
|
||||
kind = IndexSyntheticElementKind.enumToString;
|
||||
|
@ -491,14 +491,14 @@ class _IndexContributor extends GeneralizingAstVisitor {
|
|||
elementKind == ElementKind.TYPE_PARAMETER ||
|
||||
elementKind == ElementKind.FUNCTION &&
|
||||
element is FunctionElement &&
|
||||
element.enclosingElement is ExecutableElement ||
|
||||
element.enclosingElement2 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.enclosingElement;
|
||||
var enclosingElement = element.enclosingElement2;
|
||||
if (enclosingElement == null || enclosingElement.isSynthetic) {
|
||||
return;
|
||||
}
|
||||
|
@ -508,7 +508,7 @@ class _IndexContributor extends GeneralizingAstVisitor {
|
|||
// named parameters. Ignore them.
|
||||
if (elementKind == ElementKind.PARAMETER &&
|
||||
element is ParameterElement &&
|
||||
element.enclosingElement is GenericFunctionTypeElement) {
|
||||
element.enclosingElement2 is GenericFunctionTypeElement) {
|
||||
return;
|
||||
}
|
||||
// Add the relation.
|
||||
|
@ -999,7 +999,7 @@ class _IndexContributor extends GeneralizingAstVisitor {
|
|||
ConstructorElement? constructor) {
|
||||
var seenConstructors = <ConstructorElement?>{};
|
||||
while (constructor is ConstructorElementImpl && constructor.isSynthetic) {
|
||||
var enclosing = constructor.enclosingElement;
|
||||
var enclosing = constructor.enclosingElement2;
|
||||
if (enclosing.isMixinApplication) {
|
||||
var superInvocation = constructor.constantInitializers
|
||||
.whereType<SuperConstructorInvocation>()
|
||||
|
|
|
@ -178,7 +178,7 @@ class ResolvedForCompletionResultImpl {
|
|||
required this.resolvedNodes,
|
||||
});
|
||||
|
||||
LibraryElement get libraryElement => unitElement.enclosingElement;
|
||||
LibraryElement get libraryElement => unitElement.library;
|
||||
}
|
||||
|
||||
class ResolvedLibraryResultImpl extends AnalysisResultImpl
|
||||
|
|
|
@ -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.enclosingElement is ExecutableElement) {
|
||||
if (element.enclosingElement2 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.enclosingElement.displayName;
|
||||
name = element.enclosingElement2.displayName;
|
||||
}
|
||||
|
||||
// Prepare the list of files that reference the element name.
|
||||
|
@ -654,7 +654,7 @@ class Search {
|
|||
));
|
||||
if (parameter.isNamed ||
|
||||
parameter.isOptionalPositional ||
|
||||
parameter.enclosingElement is ConstructorElement) {
|
||||
parameter.enclosingElement2 is ConstructorElement) {
|
||||
results.addAll(await _searchReferences(parameter, searchedFiles));
|
||||
}
|
||||
return results;
|
||||
|
@ -914,7 +914,7 @@ class _FindDeclarations {
|
|||
return;
|
||||
}
|
||||
|
||||
var enclosing = element.enclosingElement;
|
||||
var enclosing = element.enclosingElement2;
|
||||
|
||||
String? className;
|
||||
String? mixinName;
|
||||
|
|
|
@ -373,7 +373,7 @@ class ConstantVerifier extends RecursiveAstVisitor<void> {
|
|||
// lookup for ==
|
||||
var method = element.lookUpConcreteMethod("==", _currentLibrary);
|
||||
if (method == null ||
|
||||
(method.enclosingElement as ClassElement).isDartCoreObject) {
|
||||
(method.enclosingElement2 as ClassElement).isDartCoreObject) {
|
||||
return false;
|
||||
}
|
||||
// there is == that we don't like
|
||||
|
|
|
@ -198,7 +198,7 @@ class ConstantEvaluationEngine {
|
|||
void computeDependencies(
|
||||
ConstantEvaluationTarget constant, ReferenceFinderCallback callback) {
|
||||
if (constant is ConstFieldElementImpl && constant.isEnumConstant) {
|
||||
var enclosing = constant.enclosingElement;
|
||||
var enclosing = constant.enclosingElement2;
|
||||
if (enclosing is EnumElementImpl) {
|
||||
if (enclosing.name == 'values') {
|
||||
return;
|
||||
|
@ -258,7 +258,7 @@ class ConstantEvaluationEngine {
|
|||
}
|
||||
}
|
||||
}
|
||||
for (FieldElement field in constant.enclosingElement.fields) {
|
||||
for (FieldElement field in constant.enclosingElement2.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.enclosingElement == typeProvider.symbolElement) {
|
||||
if (constructor.enclosingElement2 == 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.enclosingElement;
|
||||
var enum_ = element.enclosingElement2;
|
||||
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.enclosingElement;
|
||||
var enclosingElement = element.enclosingElement2;
|
||||
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?.enclosingElement is! ExtensionElement;
|
||||
identifier.staticElement?.enclosingElement2 is! ExtensionElement;
|
||||
}
|
||||
|
||||
void _reportNotPotentialConstants(AstNode node) {
|
||||
|
@ -2129,7 +2129,7 @@ class _InstanceCreationEvaluator {
|
|||
List<Expression> arguments, {
|
||||
required bool isNullSafe,
|
||||
}) {
|
||||
ClassElement definingClass = _constructor.enclosingElement;
|
||||
ClassElement definingClass = _constructor.enclosingElement2;
|
||||
var argumentCount = arguments.length;
|
||||
if (_constructor.name == "fromEnvironment") {
|
||||
if (!_checkFromEnvironmentArguments(arguments, definingType)) {
|
||||
|
@ -2232,7 +2232,7 @@ class _InstanceCreationEvaluator {
|
|||
}
|
||||
|
||||
void _checkFields() {
|
||||
var fields = _constructor.enclosingElement.fields;
|
||||
var fields = _constructor.enclosingElement2.fields;
|
||||
for (var field in fields) {
|
||||
if ((field.isFinal || field.isConst) &&
|
||||
!field.isStatic &&
|
||||
|
@ -2521,7 +2521,7 @@ class _InstanceCreationEvaluator {
|
|||
}
|
||||
|
||||
void _checkTypeParameters() {
|
||||
var typeParameters = _constructor.enclosingElement.typeParameters;
|
||||
var typeParameters = _constructor.enclosingElement2.typeParameters;
|
||||
var typeArguments = _typeArguments;
|
||||
if (typeParameters.isNotEmpty &&
|
||||
typeArguments != null &&
|
||||
|
|
|
@ -227,7 +227,7 @@ class _Collector {
|
|||
}
|
||||
|
||||
if (element is ParameterElement) {
|
||||
var enclosing = element.enclosingElement;
|
||||
var enclosing = element.enclosingElement2;
|
||||
if (enclosing is ConstructorElement &&
|
||||
isConstConstructorElement(enclosing)) {
|
||||
if (node.thisOrAncestorOfType<ConstructorInitializer>() != null) {
|
||||
|
|
|
@ -103,11 +103,17 @@ abstract class AbstractClassElementImpl extends _ExistingElementImpl
|
|||
@override
|
||||
String get displayName => name;
|
||||
|
||||
@Deprecated('Use enclosingElement2 instead')
|
||||
@override
|
||||
CompilationUnitElementImpl get enclosingElement {
|
||||
return _enclosingElement as CompilationUnitElementImpl;
|
||||
}
|
||||
|
||||
@override
|
||||
CompilationUnitElementImpl get enclosingElement2 {
|
||||
return _enclosingElement as CompilationUnitElementImpl;
|
||||
}
|
||||
|
||||
/// Set the fields contained in this class to the given [fields].
|
||||
set fields(List<FieldElement> fields) {
|
||||
assert(!isMixinApplication);
|
||||
|
@ -314,7 +320,7 @@ abstract class AbstractClassElementImpl extends _ExistingElementImpl
|
|||
!getter.isAbstract &&
|
||||
!getter.isStatic &&
|
||||
getter.isAccessibleIn2(library) &&
|
||||
getter.enclosingElement != this));
|
||||
getter.enclosingElement2 != this));
|
||||
|
||||
ExecutableElement? lookUpInheritedConcreteMember(
|
||||
String name, LibraryElement library) {
|
||||
|
@ -334,7 +340,7 @@ abstract class AbstractClassElementImpl extends _ExistingElementImpl
|
|||
!method.isAbstract &&
|
||||
!method.isStatic &&
|
||||
method.isAccessibleIn2(library) &&
|
||||
method.enclosingElement != this));
|
||||
method.enclosingElement2 != this));
|
||||
|
||||
@override
|
||||
PropertyAccessorElement? lookUpInheritedConcreteSetter(
|
||||
|
@ -344,7 +350,7 @@ abstract class AbstractClassElementImpl extends _ExistingElementImpl
|
|||
!setter.isAbstract &&
|
||||
!setter.isStatic &&
|
||||
setter.isAccessibleIn2(library) &&
|
||||
setter.enclosingElement != this));
|
||||
setter.enclosingElement2 != this));
|
||||
|
||||
@override
|
||||
MethodElement? lookUpInheritedMethod(
|
||||
|
@ -353,7 +359,7 @@ abstract class AbstractClassElementImpl extends _ExistingElementImpl
|
|||
(MethodElement method) =>
|
||||
!method.isStatic &&
|
||||
method.isAccessibleIn2(library) &&
|
||||
method.enclosingElement != this));
|
||||
method.enclosingElement2 != this));
|
||||
|
||||
@override
|
||||
MethodElement? lookUpMethod(String methodName, LibraryElement library) =>
|
||||
|
@ -539,9 +545,15 @@ class AugmentationImportElementImpl extends _ExistingElementImpl
|
|||
required this.uri,
|
||||
}) : super(null, importKeywordOffset);
|
||||
|
||||
@Deprecated('Use enclosingElement2 instead')
|
||||
@override
|
||||
LibraryOrAugmentationElementImpl get enclosingElement {
|
||||
return super.enclosingElement as LibraryOrAugmentationElementImpl;
|
||||
return super.enclosingElement2 as LibraryOrAugmentationElementImpl;
|
||||
}
|
||||
|
||||
@override
|
||||
LibraryOrAugmentationElementImpl get enclosingElement2 {
|
||||
return super.enclosingElement2 as LibraryOrAugmentationElementImpl;
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -690,7 +702,7 @@ class ClassElementImpl extends AbstractClassElementImpl {
|
|||
bool get hasNoSuchMethod {
|
||||
MethodElement? method = lookUpConcreteMethod(
|
||||
FunctionElement.NO_SUCH_METHOD_METHOD_NAME, library);
|
||||
var definingClass = method?.enclosingElement as ClassElement?;
|
||||
var definingClass = method?.enclosingElement2 as ClassElement?;
|
||||
return definingClass != null && !definingClass.isDartCoreObject;
|
||||
}
|
||||
|
||||
|
@ -1115,13 +1127,14 @@ class CompilationUnitElementImpl extends UriReferencedElementImpl
|
|||
_classes = classes;
|
||||
}
|
||||
|
||||
@Deprecated('Use enclosingElement2 instead')
|
||||
@override
|
||||
LibraryElement get enclosingElement =>
|
||||
super.enclosingElement as LibraryElement;
|
||||
super.enclosingElement2 as LibraryElement;
|
||||
|
||||
@override
|
||||
LibraryOrAugmentationElement get enclosingElement2 =>
|
||||
super.enclosingElement as LibraryOrAugmentationElement;
|
||||
super.enclosingElement2 as LibraryOrAugmentationElement;
|
||||
|
||||
@override
|
||||
CompilationUnitElementImpl get enclosingUnit {
|
||||
|
@ -1198,7 +1211,7 @@ class CompilationUnitElementImpl extends UriReferencedElementImpl
|
|||
}
|
||||
|
||||
@override
|
||||
AnalysisSession get session => enclosingElement.session;
|
||||
AnalysisSession get session => enclosingElement2.session;
|
||||
|
||||
@override
|
||||
List<TopLevelVariableElement> get topLevelVariables {
|
||||
|
@ -1366,7 +1379,7 @@ class ConstructorElementImpl extends ExecutableElementImpl
|
|||
|
||||
@override
|
||||
String get displayName {
|
||||
var className = enclosingElement.name;
|
||||
var className = enclosingElement2.name;
|
||||
var name = this.name;
|
||||
if (name.isNotEmpty) {
|
||||
return '$className.$name';
|
||||
|
@ -1375,9 +1388,14 @@ class ConstructorElementImpl extends ExecutableElementImpl
|
|||
}
|
||||
}
|
||||
|
||||
@Deprecated('Use enclosingElement2 instead')
|
||||
@override
|
||||
AbstractClassElementImpl get enclosingElement =>
|
||||
super.enclosingElement as AbstractClassElementImpl;
|
||||
super.enclosingElement2 as AbstractClassElementImpl;
|
||||
|
||||
@override
|
||||
AbstractClassElementImpl get enclosingElement2 =>
|
||||
super.enclosingElement2 as AbstractClassElementImpl;
|
||||
|
||||
@override
|
||||
bool get isConst {
|
||||
|
@ -1414,7 +1432,7 @@ class ConstructorElementImpl extends ExecutableElementImpl
|
|||
|
||||
@override
|
||||
Element get nonSynthetic {
|
||||
return isSynthetic ? enclosingElement : this;
|
||||
return isSynthetic ? enclosingElement2 : this;
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -1439,7 +1457,7 @@ class ConstructorElementImpl extends ExecutableElementImpl
|
|||
|
||||
@override
|
||||
InterfaceType get returnTypeInternal {
|
||||
return (_returnType ??= enclosingElement.thisType) as InterfaceType;
|
||||
return (_returnType ??= enclosingElement2.thisType) as InterfaceType;
|
||||
}
|
||||
|
||||
ConstructorElement? get superConstructor {
|
||||
|
@ -1568,7 +1586,7 @@ mixin ConstVariableElement implements ElementImpl, ConstantEvaluationTarget {
|
|||
if (library == null) {
|
||||
throw StateError(
|
||||
'[library: null][this: ($runtimeType) $this]'
|
||||
'[enclosingElement: $enclosingElement]'
|
||||
'[enclosingElement2: $enclosingElement2]'
|
||||
'[reference: $reference]',
|
||||
);
|
||||
}
|
||||
|
@ -1936,7 +1954,7 @@ class ElementAnnotationImpl implements ElementAnnotation {
|
|||
final element = this.element;
|
||||
if (element is ConstructorElement) {
|
||||
return element.library.isDartCore &&
|
||||
element.enclosingElement.name == _DEPRECATED_CLASS_NAME;
|
||||
element.enclosingElement2.name == _DEPRECATED_CLASS_NAME;
|
||||
} else if (element is PropertyAccessorElement) {
|
||||
return element.library.isDartCore &&
|
||||
element.name == _DEPRECATED_VARIABLE_NAME;
|
||||
|
@ -2063,7 +2081,7 @@ class ElementAnnotationImpl implements ElementAnnotation {
|
|||
}) {
|
||||
final element = this.element;
|
||||
return element is ConstructorElement &&
|
||||
element.enclosingElement.name == className &&
|
||||
element.enclosingElement2.name == className &&
|
||||
element.library.name == libraryName;
|
||||
}
|
||||
|
||||
|
@ -2177,6 +2195,7 @@ abstract class ElementImpl implements Element {
|
|||
_docComment = doc;
|
||||
}
|
||||
|
||||
@Deprecated('Use enclosingElement2 instead')
|
||||
@override
|
||||
Element? get enclosingElement => _enclosingElement;
|
||||
|
||||
|
@ -2185,6 +2204,9 @@ abstract class ElementImpl implements Element {
|
|||
_enclosingElement = element as ElementImpl?;
|
||||
}
|
||||
|
||||
@override
|
||||
Element? get enclosingElement2 => _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 {
|
||||
|
@ -2521,12 +2543,12 @@ abstract class ElementImpl implements Element {
|
|||
|
||||
@override
|
||||
AnalysisSession? get session {
|
||||
return enclosingElement?.session;
|
||||
return enclosingElement2?.session;
|
||||
}
|
||||
|
||||
@override
|
||||
Source? get source {
|
||||
return enclosingElement?.source;
|
||||
return enclosingElement2?.source;
|
||||
}
|
||||
|
||||
/// Return the context to resolve type parameters in, or `null` if neither
|
||||
|
@ -2634,7 +2656,7 @@ abstract class ElementImpl implements Element {
|
|||
) {
|
||||
Element? element = this;
|
||||
while (element != null && !predicate(element)) {
|
||||
element = element.enclosingElement;
|
||||
element = element.enclosingElement2;
|
||||
}
|
||||
return element as E?;
|
||||
}
|
||||
|
@ -2646,7 +2668,7 @@ abstract class ElementImpl implements Element {
|
|||
if (element is CompilationUnitElement) {
|
||||
element = element.enclosingElement2;
|
||||
} else {
|
||||
element = element.enclosingElement;
|
||||
element = element.enclosingElement2;
|
||||
}
|
||||
}
|
||||
return element as E?;
|
||||
|
@ -2725,12 +2747,7 @@ class ElementLocationImpl implements ElementLocation {
|
|||
Element? ancestor = element;
|
||||
while (ancestor != null) {
|
||||
components.insert(0, (ancestor as ElementImpl).identifier);
|
||||
if (ancestor is CompilationUnitElementImpl) {
|
||||
// TODO(scheglov) switch everything to `enclosingElement2`.
|
||||
ancestor = ancestor.enclosingElement2;
|
||||
} else {
|
||||
ancestor = ancestor.enclosingElement;
|
||||
}
|
||||
ancestor = ancestor.enclosingElement2;
|
||||
}
|
||||
_components = components;
|
||||
}
|
||||
|
@ -2974,8 +2991,12 @@ abstract class ExecutableElementImpl extends _ExistingElementImpl
|
|||
/// [offset].
|
||||
ExecutableElementImpl(String super.name, super.offset, {super.reference});
|
||||
|
||||
@Deprecated('Use enclosingElement2 instead')
|
||||
@override
|
||||
Element get enclosingElement => super.enclosingElement!;
|
||||
Element get enclosingElement => super.enclosingElement2!;
|
||||
|
||||
@override
|
||||
Element get enclosingElement2 => super.enclosingElement2!;
|
||||
|
||||
@override
|
||||
bool get hasImplicitReturnType {
|
||||
|
@ -3247,11 +3268,17 @@ class ExtensionElementImpl extends _ExistingElementImpl
|
|||
@override
|
||||
String get displayName => name ?? '';
|
||||
|
||||
@Deprecated('Use enclosingElement2 instead')
|
||||
@override
|
||||
CompilationUnitElementImpl get enclosingElement {
|
||||
return _enclosingElement as CompilationUnitElementImpl;
|
||||
}
|
||||
|
||||
@override
|
||||
CompilationUnitElementImpl get enclosingElement2 {
|
||||
return super.enclosingElement2 as CompilationUnitElementImpl;
|
||||
}
|
||||
|
||||
@override
|
||||
DartType get extendedType =>
|
||||
ElementTypeProvider.current.getExtendedType(this);
|
||||
|
@ -3444,7 +3471,7 @@ class FieldElementImpl extends PropertyInducingElementImpl
|
|||
///
|
||||
/// Such fields are `index`, `_name`, and `values`.
|
||||
bool get isSyntheticEnumField {
|
||||
return enclosingElement is EnumElementImpl &&
|
||||
return enclosingElement2 is EnumElementImpl &&
|
||||
isSynthetic &&
|
||||
getter?.isSynthetic == true &&
|
||||
setter == null;
|
||||
|
@ -3512,7 +3539,7 @@ class FunctionElementImpl extends ExecutableElementImpl
|
|||
@override
|
||||
String get identifier {
|
||||
String identifier = super.identifier;
|
||||
Element? enclosing = enclosingElement;
|
||||
Element? enclosing = enclosingElement2;
|
||||
if (enclosing is ExecutableElement || enclosing is VariableElement) {
|
||||
identifier += "@$nameOffset";
|
||||
}
|
||||
|
@ -3780,9 +3807,14 @@ class LabelElementImpl extends ElementImpl implements LabelElement {
|
|||
@override
|
||||
String get displayName => name;
|
||||
|
||||
@Deprecated('Use enclosingElement2 instead')
|
||||
@override
|
||||
ExecutableElement get enclosingElement =>
|
||||
super.enclosingElement as ExecutableElement;
|
||||
super.enclosingElement2 as ExecutableElement;
|
||||
|
||||
@override
|
||||
ExecutableElement get enclosingElement2 =>
|
||||
super.enclosingElement2 as ExecutableElement;
|
||||
|
||||
/// Return `true` if this label is associated with a `switch` member (`case
|
||||
/// ` or`default`).
|
||||
|
@ -4738,8 +4770,8 @@ class MethodElementImpl extends ExecutableElementImpl implements MethodElement {
|
|||
|
||||
@override
|
||||
Element get nonSynthetic {
|
||||
if (isSynthetic && enclosingElement is EnumElementImpl) {
|
||||
return enclosingElement;
|
||||
if (isSynthetic && enclosingElement2 is EnumElementImpl) {
|
||||
return enclosingElement2;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
@ -4976,6 +5008,9 @@ class MultiplyDefinedElementImpl implements MultiplyDefinedElement {
|
|||
@override
|
||||
Element? get enclosingElement => null;
|
||||
|
||||
@override
|
||||
Element? get enclosingElement2 => null;
|
||||
|
||||
@override
|
||||
bool get hasAlwaysThrows => false;
|
||||
|
||||
|
@ -5201,8 +5236,12 @@ abstract class NonParameterVariableElementImpl extends VariableElementImpl
|
|||
/// [offset].
|
||||
NonParameterVariableElementImpl(String super.name, super.offset);
|
||||
|
||||
@Deprecated('Use enclosingElement2 instead')
|
||||
@override
|
||||
Element get enclosingElement => super.enclosingElement!;
|
||||
Element get enclosingElement => super.enclosingElement2!;
|
||||
|
||||
@override
|
||||
Element get enclosingElement2 => super.enclosingElement2!;
|
||||
|
||||
bool get hasInitializer {
|
||||
return hasModifier(Modifier.HAS_INITIALIZER);
|
||||
|
@ -5472,7 +5511,7 @@ class PartElementImpl extends _ExistingElementImpl implements PartElement {
|
|||
|
||||
@override
|
||||
CompilationUnitElementImpl get enclosingUnit {
|
||||
var enclosingLibrary = enclosingElement as LibraryElementImpl;
|
||||
var enclosingLibrary = enclosingElement2 as LibraryElementImpl;
|
||||
return enclosingLibrary._definingCompilationUnit;
|
||||
}
|
||||
|
||||
|
@ -5506,11 +5545,11 @@ class PrefixElementImpl extends _ExistingElementImpl implements PrefixElement {
|
|||
@Deprecated('Use enclosingElement2 instead')
|
||||
@override
|
||||
LibraryElement get enclosingElement =>
|
||||
super.enclosingElement as LibraryElement;
|
||||
super.enclosingElement2 as LibraryElement;
|
||||
|
||||
@override
|
||||
LibraryOrAugmentationElementImpl get enclosingElement2 =>
|
||||
super.enclosingElement as LibraryOrAugmentationElementImpl;
|
||||
super.enclosingElement2 as LibraryOrAugmentationElementImpl;
|
||||
|
||||
@Deprecated('Use imports2 instead')
|
||||
@override
|
||||
|
@ -5671,8 +5710,12 @@ class PropertyAccessorElementImpl_ImplicitGetter
|
|||
reference?.element = this;
|
||||
}
|
||||
|
||||
@Deprecated('Use enclosingElement2 instead')
|
||||
@override
|
||||
Element get enclosingElement => variable.enclosingElement!;
|
||||
Element get enclosingElement => variable.enclosingElement2!;
|
||||
|
||||
@override
|
||||
Element get enclosingElement2 => variable.enclosingElement2!;
|
||||
|
||||
@override
|
||||
bool get hasImplicitReturnType => variable.hasImplicitType;
|
||||
|
@ -5686,8 +5729,8 @@ class PropertyAccessorElementImpl_ImplicitGetter
|
|||
if (!variable.isSynthetic) {
|
||||
return variable;
|
||||
}
|
||||
assert(enclosingElement is EnumElementImpl);
|
||||
return enclosingElement;
|
||||
assert(enclosingElement2 is EnumElementImpl);
|
||||
return enclosingElement2;
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -5732,8 +5775,12 @@ class PropertyAccessorElementImpl_ImplicitSetter
|
|||
property.setter = this;
|
||||
}
|
||||
|
||||
@Deprecated('Use enclosingElement2 instead')
|
||||
@override
|
||||
Element get enclosingElement => variable.enclosingElement!;
|
||||
Element get enclosingElement => variable.enclosingElement2!;
|
||||
|
||||
@override
|
||||
Element get enclosingElement2 => variable.enclosingElement2!;
|
||||
|
||||
@override
|
||||
bool get isSetter => true;
|
||||
|
@ -5831,10 +5878,10 @@ abstract class PropertyInducingElementImpl
|
|||
@override
|
||||
Element get nonSynthetic {
|
||||
if (isSynthetic) {
|
||||
if (enclosingElement is EnumElementImpl) {
|
||||
if (enclosingElement2 is EnumElementImpl) {
|
||||
// TODO(scheglov) remove 'index'?
|
||||
if (name == 'index' || name == 'values') {
|
||||
return enclosingElement;
|
||||
return enclosingElement2;
|
||||
}
|
||||
}
|
||||
return (getter ?? setter)!;
|
||||
|
@ -5975,16 +6022,16 @@ class SuperFormalParameterElementImpl extends ParameterElementImpl
|
|||
|
||||
@override
|
||||
ParameterElement? get superConstructorParameter {
|
||||
final enclosingElement = this.enclosingElement;
|
||||
if (enclosingElement is ConstructorElementImpl) {
|
||||
var superConstructor = enclosingElement.superConstructor;
|
||||
final enclosingElement2 = this.enclosingElement2;
|
||||
if (enclosingElement2 is ConstructorElementImpl) {
|
||||
var superConstructor = enclosingElement2.superConstructor;
|
||||
if (superConstructor != null) {
|
||||
var superParameters = superConstructor.parameters;
|
||||
if (isNamed) {
|
||||
return superParameters
|
||||
.firstWhereOrNull((e) => e.isNamed && e.name == name);
|
||||
} else {
|
||||
var index = indexIn(enclosingElement);
|
||||
var index = indexIn(enclosingElement2);
|
||||
var positionalSuperParameters =
|
||||
superParameters.where((e) => e.isPositional).toList();
|
||||
if (index >= 0 && index < positionalSuperParameters.length) {
|
||||
|
@ -6085,9 +6132,14 @@ class TypeAliasElementImpl extends _ExistingElementImpl
|
|||
@override
|
||||
String get displayName => name;
|
||||
|
||||
@Deprecated('Use enclosingElement2 instead')
|
||||
@override
|
||||
CompilationUnitElement get enclosingElement =>
|
||||
super.enclosingElement as CompilationUnitElement;
|
||||
super.enclosingElement2 as CompilationUnitElement;
|
||||
|
||||
@override
|
||||
CompilationUnitElement get enclosingElement2 =>
|
||||
super.enclosingElement2 as CompilationUnitElement;
|
||||
|
||||
/// Returns whether this alias is a "proper rename" of [aliasedClass], as
|
||||
/// defined in the constructor-tearoffs specification.
|
||||
|
@ -6327,7 +6379,7 @@ class TypeParameterElementImpl extends ElementImpl
|
|||
return true;
|
||||
}
|
||||
if (other is TypeParameterElement) {
|
||||
if (other.enclosingElement == null || enclosingElement == null) {
|
||||
if (other.enclosingElement2 == null || enclosingElement2 == null) {
|
||||
return identical(other, this);
|
||||
}
|
||||
return other.location == location;
|
||||
|
@ -6557,7 +6609,7 @@ mixin WrapperElementImpl implements ElementImpl {
|
|||
String? get documentationComment => base.documentationComment;
|
||||
|
||||
@override
|
||||
Element? get enclosingElement => base.enclosingElement;
|
||||
Element? get enclosingElement => base.enclosingElement2;
|
||||
|
||||
@override
|
||||
bool get hasAlwaysThrows => base.hasAlwaysThrows;
|
||||
|
@ -6723,7 +6775,7 @@ mixin _HasLibraryMixin on ElementImpl {
|
|||
Source get librarySource => library.source;
|
||||
|
||||
@override
|
||||
Source get source => enclosingElement!.source!;
|
||||
Source get source => enclosingElement2!.source!;
|
||||
}
|
||||
|
||||
/// Instances of [List]s that are used as "not yet computed" values, they
|
||||
|
|
|
@ -25,7 +25,7 @@ extension ElementAnnotationExtensions on ElementAnnotation {
|
|||
}
|
||||
}
|
||||
} else if (element is ConstructorElement) {
|
||||
classElement = element.enclosingElement;
|
||||
classElement = element.enclosingElement2;
|
||||
}
|
||||
if (classElement == null) {
|
||||
return const <TargetKind>{};
|
||||
|
@ -68,17 +68,17 @@ extension ElementExtension on Element {
|
|||
return true;
|
||||
}
|
||||
|
||||
var ancestor = enclosingElement;
|
||||
var ancestor = enclosingElement2;
|
||||
if (ancestor is ClassElement) {
|
||||
if (ancestor.hasDoNotStore) {
|
||||
return true;
|
||||
}
|
||||
ancestor = ancestor.enclosingElement;
|
||||
ancestor = ancestor.enclosingElement2;
|
||||
} else if (ancestor is ExtensionElement) {
|
||||
if (ancestor.hasDoNotStore) {
|
||||
return true;
|
||||
}
|
||||
ancestor = ancestor.enclosingElement;
|
||||
ancestor = ancestor.enclosingElement2;
|
||||
}
|
||||
|
||||
return ancestor is CompilationUnitElement &&
|
||||
|
@ -94,7 +94,7 @@ extension ElementExtension on Element {
|
|||
/// [PropertyAccessorElement]s.
|
||||
bool get isInstanceMember {
|
||||
var this_ = this;
|
||||
var enclosing = this_.enclosingElement;
|
||||
var enclosing = this_.enclosingElement2;
|
||||
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 && enclosingElement is EnumElementImpl;
|
||||
return this is ConstructorElement && enclosingElement2 is EnumElementImpl;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -366,7 +366,7 @@ class InheritanceManager3 {
|
|||
continue;
|
||||
}
|
||||
|
||||
var class_ = executable.enclosingElement;
|
||||
var class_ = executable.enclosingElement2;
|
||||
if (class_ is ClassElement && class_.isDartCoreObject) {
|
||||
continue;
|
||||
}
|
||||
|
@ -518,7 +518,7 @@ class InheritanceManager3 {
|
|||
}
|
||||
|
||||
var current = currentList.single;
|
||||
if (candidate.enclosingElement == mixinElement) {
|
||||
if (candidate.enclosingElement2 == mixinElement) {
|
||||
namedCandidates[name] = [
|
||||
isNonNullableByDefault
|
||||
? candidate
|
||||
|
@ -714,7 +714,7 @@ class InheritanceManager3 {
|
|||
Name name,
|
||||
ExecutableElement executable,
|
||||
) {
|
||||
if (executable.enclosingElement == class_) {
|
||||
if (executable.enclosingElement2 == class_) {
|
||||
return executable;
|
||||
}
|
||||
|
||||
|
@ -902,7 +902,7 @@ class InheritanceManager3 {
|
|||
}
|
||||
|
||||
static bool _isDeclaredInObject(ExecutableElement element) {
|
||||
var enclosing = element.enclosingElement;
|
||||
var enclosing = element.enclosingElement2;
|
||||
return enclosing is ClassElement &&
|
||||
enclosing.supertype == null &&
|
||||
!enclosing.isMixin;
|
||||
|
|
|
@ -37,8 +37,12 @@ class ConstructorMember extends ExecutableMember
|
|||
@override
|
||||
String get displayName => declaration.displayName;
|
||||
|
||||
@Deprecated('Use enclosingElement2 instead')
|
||||
@override
|
||||
ClassElement get enclosingElement => declaration.enclosingElement;
|
||||
ClassElement get enclosingElement => declaration.enclosingElement2;
|
||||
|
||||
@override
|
||||
ClassElement get enclosingElement2 => declaration.enclosingElement2;
|
||||
|
||||
@override
|
||||
bool get isConst => declaration.isConst;
|
||||
|
@ -332,8 +336,12 @@ class FieldMember extends VariableMember implements FieldElement {
|
|||
@override
|
||||
String get displayName => declaration.displayName;
|
||||
|
||||
@Deprecated('Use enclosingElement2 instead')
|
||||
@override
|
||||
Element get enclosingElement => declaration.enclosingElement;
|
||||
Element get enclosingElement => declaration.enclosingElement2;
|
||||
|
||||
@override
|
||||
Element get enclosingElement2 => declaration.enclosingElement2;
|
||||
|
||||
@override
|
||||
PropertyAccessorElement? get getter {
|
||||
|
@ -423,7 +431,11 @@ class FunctionMember extends ExecutableMember implements FunctionElement {
|
|||
FunctionElement get declaration => super.declaration as FunctionElement;
|
||||
|
||||
@override
|
||||
Element get enclosingElement => declaration.enclosingElement;
|
||||
Element get enclosingElement => declaration.enclosingElement2;
|
||||
|
||||
@Deprecated('Use enclosingElement2 instead')
|
||||
@override
|
||||
Element get enclosingElement2 => declaration.enclosingElement2;
|
||||
|
||||
@override
|
||||
bool get isDartCoreIdentical => declaration.isDartCoreIdentical;
|
||||
|
@ -480,8 +492,12 @@ abstract class Member implements Element {
|
|||
@override
|
||||
String? get documentationComment => _declaration.documentationComment;
|
||||
|
||||
@Deprecated('Use enclosingElement2 instead')
|
||||
@override
|
||||
Element? get enclosingElement => _declaration.enclosingElement;
|
||||
Element? get enclosingElement => _declaration.enclosingElement2;
|
||||
|
||||
@override
|
||||
Element? get enclosingElement2 => _declaration.enclosingElement2;
|
||||
|
||||
@override
|
||||
bool get hasAlwaysThrows => _declaration.hasAlwaysThrows;
|
||||
|
@ -761,8 +777,12 @@ class MethodMember extends ExecutableMember implements MethodElement {
|
|||
@override
|
||||
MethodElement get declaration => super.declaration as MethodElement;
|
||||
|
||||
@Deprecated('Use enclosingElement2 instead')
|
||||
@override
|
||||
Element get enclosingElement => declaration.enclosingElement;
|
||||
Element get enclosingElement => declaration.enclosingElement2;
|
||||
|
||||
@override
|
||||
Element get enclosingElement2 => declaration.enclosingElement2;
|
||||
|
||||
@override
|
||||
String get name => declaration.name;
|
||||
|
@ -845,8 +865,12 @@ class ParameterMember extends VariableMember
|
|||
@override
|
||||
String? get defaultValueCode => declaration.defaultValueCode;
|
||||
|
||||
@Deprecated('Use enclosingElement2 instead')
|
||||
@override
|
||||
Element? get enclosingElement => declaration.enclosingElement;
|
||||
Element? get enclosingElement => declaration.enclosingElement2;
|
||||
|
||||
@override
|
||||
Element? get enclosingElement2 => declaration.enclosingElement2;
|
||||
|
||||
@override
|
||||
bool get hasDefaultValue => declaration.hasDefaultValue;
|
||||
|
@ -980,8 +1004,12 @@ class PropertyAccessorMember extends ExecutableMember
|
|||
PropertyAccessorElement get declaration =>
|
||||
super.declaration as PropertyAccessorElement;
|
||||
|
||||
@Deprecated('Use enclosingElement2 instead')
|
||||
@override
|
||||
Element get enclosingElement => declaration.enclosingElement;
|
||||
Element get enclosingElement => declaration.enclosingElement2;
|
||||
|
||||
@override
|
||||
Element get enclosingElement2 => declaration.enclosingElement2;
|
||||
|
||||
@override
|
||||
bool get isGetter => declaration.isGetter;
|
||||
|
|
|
@ -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.enclosingElement is ExtensionElement) {
|
||||
if (methodElement.enclosingElement2 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.enclosingElement is ExtensionElement) {
|
||||
if (methodElement.enclosingElement2 is ExtensionElement) {
|
||||
return currentType;
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ ConstructorElement? _getActualConstructorElement(
|
|||
ConstructorElement? constructor) {
|
||||
var seenConstructors = <ConstructorElement?>{};
|
||||
while (constructor is ConstructorElementImpl && constructor.isSynthetic) {
|
||||
var enclosing = constructor.enclosingElement;
|
||||
var enclosing = constructor.enclosingElement2;
|
||||
if (enclosing.isMixinApplication) {
|
||||
var superInvocation = constructor.constantInitializers
|
||||
.whereType<SuperConstructorInvocation>()
|
||||
|
@ -73,7 +73,7 @@ LibraryImportElement? _getImportElement(
|
|||
String prefix,
|
||||
Element element,
|
||||
Map<LibraryImportElement, Set<Element>> importElementsMap) {
|
||||
if (element.enclosingElement is! CompilationUnitElement) {
|
||||
if (element.enclosingElement2 is! CompilationUnitElement) {
|
||||
return null;
|
||||
}
|
||||
var usedLibrary = element.library;
|
||||
|
@ -310,7 +310,7 @@ class ReferencesCollector extends GeneralizingAstVisitor<void> {
|
|||
length = 0;
|
||||
}
|
||||
references.add(MatchInfo(offset, length, kind));
|
||||
} else if (e != null && e.enclosingElement == element) {
|
||||
} else if (e != null && e.enclosingElement2 == element) {
|
||||
kind = MatchKind.REFERENCE;
|
||||
offset = node.offset;
|
||||
length = element.nameLength;
|
||||
|
|
|
@ -31,7 +31,7 @@ class ConstructorReferenceResolver {
|
|||
var element = node.constructorName.staticElement;
|
||||
if (element != null &&
|
||||
!element.isFactory &&
|
||||
element.enclosingElement.isAbstract) {
|
||||
element.enclosingElement2.isAbstract) {
|
||||
_resolver.errorReporter.reportErrorForNode(
|
||||
CompileTimeErrorCode
|
||||
.TEAROFF_OF_GENERATIVE_CONSTRUCTOR_OF_ABSTRACT_CLASS,
|
||||
|
|
|
@ -175,7 +175,7 @@ class FunctionReferenceResolver {
|
|||
ExecutableElement element, {
|
||||
required bool implicitReceiver,
|
||||
}) {
|
||||
var enclosingElement = element.enclosingElement;
|
||||
var enclosingElement = element.enclosingElement2;
|
||||
if (implicitReceiver) {
|
||||
if (_resolver.enclosingExtension != null) {
|
||||
_resolver.errorReporter.reportErrorForNode(
|
||||
|
|
|
@ -220,7 +220,7 @@ class MethodInvocationResolver with ScopeHelpers {
|
|||
ExecutableElement element,
|
||||
bool nullReceiver,
|
||||
) {
|
||||
var enclosingElement = element.enclosingElement;
|
||||
var enclosingElement = element.enclosingElement2;
|
||||
if (nullReceiver) {
|
||||
if (_resolver.enclosingExtension != null) {
|
||||
_resolver.errorReporter.reportErrorForNode(
|
||||
|
|
|
@ -568,7 +568,7 @@ class _ErrorHelper {
|
|||
|
||||
if (element is LocalVariableElement ||
|
||||
(element is FunctionElement &&
|
||||
element.enclosingElement is ExecutableElement)) {
|
||||
element.enclosingElement2 is ExecutableElement)) {
|
||||
errorReporter.reportError(
|
||||
DiagnosticFactory().referencedBeforeDeclaration(
|
||||
errorReporter.source,
|
||||
|
|
|
@ -291,7 +291,7 @@ class PropertyElementResolver with ScopeHelpers {
|
|||
propertyName,
|
||||
);
|
||||
} else {
|
||||
var enclosingElement = element.enclosingElement;
|
||||
var enclosingElement = element.enclosingElement2;
|
||||
if (enclosingElement is ExtensionElement &&
|
||||
enclosingElement.name == null) {
|
||||
_resolver.errorReporter.reportErrorForNode(
|
||||
|
|
|
@ -79,14 +79,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.enclosingElement.name` and
|
||||
// `superMember.enclosingElement.name` are non-`null`.
|
||||
// named, so we can safely assume `_thisMember.enclosingElement2.name` and
|
||||
// `superMember.enclosingElement2.name` are non-`null`.
|
||||
return AnalysisError(
|
||||
source, errorNode.offset, errorNode.length, errorCode, [
|
||||
member.name,
|
||||
member.enclosingElement.name!,
|
||||
member.enclosingElement2.name!,
|
||||
member.type,
|
||||
superMember.enclosingElement.name!,
|
||||
superMember.enclosingElement2.name!,
|
||||
superMember.type,
|
||||
], [
|
||||
// Only include the context location for INVALID_OVERRIDE because for
|
||||
|
|
|
@ -91,7 +91,7 @@ class AssignmentVerifier {
|
|||
_errorReporter.reportErrorForNode(
|
||||
CompileTimeErrorCode.ASSIGNMENT_TO_FINAL_NO_SETTER,
|
||||
node,
|
||||
[variable.name, variable.enclosingElement.displayName],
|
||||
[variable.name, variable.enclosingElement2.displayName],
|
||||
);
|
||||
} else {
|
||||
_errorReporter.reportErrorForNode(
|
||||
|
|
|
@ -171,7 +171,7 @@ class BestPracticesVerifier extends RecursiveAstVisitor<void> {
|
|||
}
|
||||
}
|
||||
} else if (parent is ConstructorDeclaration) {
|
||||
var class_ = parent.declaredElement!.enclosingElement;
|
||||
var class_ = parent.declaredElement!.enclosingElement2;
|
||||
if (class_.isPrivate || (parentElement?.isPrivate ?? false)) {
|
||||
_errorReporter.reportErrorForNode(
|
||||
HintCode.INVALID_INTERNAL_ANNOTATION, node, []);
|
||||
|
@ -301,7 +301,7 @@ class BestPracticesVerifier extends RecursiveAstVisitor<void> {
|
|||
var invokedElement = element.element!;
|
||||
var name = invokedElement.name;
|
||||
if (invokedElement is ConstructorElement) {
|
||||
var className = invokedElement.enclosingElement.name;
|
||||
var className = invokedElement.enclosingElement2.name;
|
||||
if (name!.isEmpty) {
|
||||
name = className;
|
||||
} else {
|
||||
|
@ -449,7 +449,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.enclosingElement!;
|
||||
Element enclosingElement = element.enclosingElement2!;
|
||||
if (enclosingElement is ClassElement) {
|
||||
var overridden = _inheritanceManager
|
||||
.getMember2(enclosingElement, name, forSuper: true);
|
||||
|
@ -471,11 +471,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.enclosingElement.name` is non-`null`.
|
||||
// `overriddenElement.enclosingElement2.name` is non-`null`.
|
||||
_errorReporter.reportErrorForNode(
|
||||
HintCode.INVALID_OVERRIDE_OF_NON_VIRTUAL_MEMBER, field.name, [
|
||||
field.name.name,
|
||||
overriddenElement.enclosingElement.displayName
|
||||
overriddenElement.enclosingElement2.displayName
|
||||
]);
|
||||
}
|
||||
if (!_invalidAccessVerifier._inTestDirectory) {
|
||||
|
@ -618,7 +618,7 @@ class BestPracticesVerifier extends RecursiveAstVisitor<void> {
|
|||
void visitMethodDeclaration(MethodDeclaration node) {
|
||||
bool wasInDoNotStoreMember = _inDoNotStoreMember;
|
||||
var element = node.declaredElement!;
|
||||
var enclosingElement = element.enclosingElement;
|
||||
var enclosingElement = element.enclosingElement2;
|
||||
|
||||
Name name = Name(_currentLibrary.source.uri, element.name);
|
||||
|
||||
|
@ -665,11 +665,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.enclosingElement.name` is non-`null`.
|
||||
// `overriddenElement.enclosingElement2.name` is non-`null`.
|
||||
_errorReporter.reportErrorForNode(
|
||||
HintCode.INVALID_OVERRIDE_OF_NON_VIRTUAL_MEMBER,
|
||||
node.name,
|
||||
[node.name.name, overriddenElement.enclosingElement.displayName]);
|
||||
[node.name.name, overriddenElement.enclosingElement2.displayName]);
|
||||
}
|
||||
|
||||
super.visitMethodDeclaration(node);
|
||||
|
@ -1439,7 +1439,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?.enclosingElement;
|
||||
var classElement = methodElement?.enclosingElement2;
|
||||
return methodElement is MethodElement &&
|
||||
classElement is ClassElement &&
|
||||
!classElement.isDartCoreObject;
|
||||
|
@ -1943,7 +1943,7 @@ class _InvalidAccessVerifier {
|
|||
SimpleIdentifier identifier, Element element) {
|
||||
bool hasProtected = _hasProtected(element);
|
||||
if (hasProtected) {
|
||||
var definingClass = element.enclosingElement as ClassElement;
|
||||
var definingClass = element.enclosingElement2 as ClassElement;
|
||||
if (_hasTypeOrSuperType(_enclosingClass, definingClass)) {
|
||||
return;
|
||||
}
|
||||
|
@ -1982,7 +1982,7 @@ class _InvalidAccessVerifier {
|
|||
node = identifier;
|
||||
}
|
||||
|
||||
var definingClass = element.enclosingElement;
|
||||
var definingClass = element.enclosingElement2;
|
||||
if (hasProtected) {
|
||||
_errorReporter.reportErrorForNode(
|
||||
HintCode.INVALID_USE_OF_PROTECTED_MEMBER,
|
||||
|
@ -2038,12 +2038,12 @@ class _InvalidAccessVerifier {
|
|||
|
||||
bool _hasProtected(Element element) {
|
||||
if (element is PropertyAccessorElement &&
|
||||
element.enclosingElement is ClassElement &&
|
||||
element.enclosingElement2 is ClassElement &&
|
||||
(element.hasProtected || element.variable.hasProtected)) {
|
||||
return true;
|
||||
}
|
||||
if (element is MethodElement &&
|
||||
element.enclosingElement is ClassElement &&
|
||||
element.enclosingElement2 is ClassElement &&
|
||||
element.hasProtected) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -123,16 +123,16 @@ class CovariantParametersVerifier {
|
|||
var superMember = superParameter.member;
|
||||
// Elements enclosing members that can participate in overrides are
|
||||
// always named, so we can safely assume
|
||||
// `_thisMember.enclosingElement.name` and
|
||||
// `superMember.enclosingElement.name` are non-`null`.
|
||||
// `_thisMember.enclosingElement2.name` and
|
||||
// `superMember.enclosingElement2.name` are non-`null`.
|
||||
errorReporter.reportErrorForNode(
|
||||
CompileTimeErrorCode.INVALID_OVERRIDE,
|
||||
errorNode,
|
||||
[
|
||||
_thisMember.name,
|
||||
_thisMember.enclosingElement.name!,
|
||||
_thisMember.enclosingElement2.name!,
|
||||
_thisMember.type,
|
||||
superMember.enclosingElement.name!,
|
||||
superMember.enclosingElement2.name!,
|
||||
superMember.type,
|
||||
],
|
||||
);
|
||||
|
@ -143,7 +143,7 @@ class CovariantParametersVerifier {
|
|||
|
||||
List<_SuperMember> _superMembers() {
|
||||
var classHierarchy = _session.classHierarchy;
|
||||
var classElement = _thisMember.enclosingElement as ClassElement;
|
||||
var classElement = _thisMember.enclosingElement2 as ClassElement;
|
||||
var interfaces = classHierarchy.implementedInterfaces(classElement);
|
||||
|
||||
var superMembers = <_SuperMember>[];
|
||||
|
@ -271,5 +271,6 @@ class _SuperParameter {
|
|||
|
||||
_SuperParameter(this.element, this.type);
|
||||
|
||||
ExecutableElement get member => element.enclosingElement as ExecutableElement;
|
||||
ExecutableElement get member =>
|
||||
element.enclosingElement2 as ExecutableElement;
|
||||
}
|
||||
|
|
|
@ -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.enclosingElement.displayName;
|
||||
displayName = element.enclosingElement2.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.enclosingElement as ExecutableElement;
|
||||
var definingFunction = element.enclosingElement2 as ExecutableElement;
|
||||
|
||||
for (; node != null; node = node.parent) {
|
||||
if (node is ConstructorDeclaration) {
|
||||
|
|
|
@ -141,7 +141,7 @@ class DuplicateDefinitionVerifier {
|
|||
[
|
||||
enumElement.displayName,
|
||||
baseName,
|
||||
inherited.enclosingElement.displayName,
|
||||
inherited.enclosingElement2.displayName,
|
||||
],
|
||||
);
|
||||
}
|
||||
|
@ -168,7 +168,7 @@ class DuplicateDefinitionVerifier {
|
|||
[
|
||||
enumElement.displayName,
|
||||
baseName,
|
||||
inherited.enclosingElement.displayName,
|
||||
inherited.enclosingElement2.displayName,
|
||||
],
|
||||
);
|
||||
}
|
||||
|
|
|
@ -53,23 +53,23 @@ class GetterSetterTypesVerifier {
|
|||
var setterType = setter.parameters[0].type;
|
||||
if (!_match(getterType, setterType)) {
|
||||
Element errorElement;
|
||||
if (getter.enclosingElement == classElement) {
|
||||
if (getter.enclosingElement2 == classElement) {
|
||||
errorElement = getter;
|
||||
} else if (setter.enclosingElement == classElement) {
|
||||
} else if (setter.enclosingElement2 == classElement) {
|
||||
errorElement = setter;
|
||||
} else {
|
||||
errorElement = classElement;
|
||||
}
|
||||
|
||||
var getterName = getter.displayName;
|
||||
if (getter.enclosingElement != classElement) {
|
||||
var getterClassName = getter.enclosingElement.displayName;
|
||||
if (getter.enclosingElement2 != classElement) {
|
||||
var getterClassName = getter.enclosingElement2.displayName;
|
||||
getterName = '$getterClassName.$getterName';
|
||||
}
|
||||
|
||||
var setterName = setter.displayName;
|
||||
if (setter.enclosingElement != classElement) {
|
||||
var setterClassName = setter.enclosingElement.displayName;
|
||||
if (setter.enclosingElement2 != classElement) {
|
||||
var setterClassName = setter.enclosingElement2.displayName;
|
||||
setterName = '$setterClassName.$setterName';
|
||||
}
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ class GatherUsedImportedElementsVisitor extends RecursiveAstVisitor<void> {
|
|||
|
||||
void _recordIfExtensionMember(Element? element) {
|
||||
if (element != null) {
|
||||
var enclosingElement = element.enclosingElement;
|
||||
var enclosingElement = element.enclosingElement2;
|
||||
if (enclosingElement is ExtensionElement) {
|
||||
_recordUsedExtension(enclosingElement);
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ class GatherUsedImportedElementsVisitor extends RecursiveAstVisitor<void> {
|
|||
if (_recordPrefixMap(identifier, element)) {
|
||||
return;
|
||||
}
|
||||
var enclosingElement = element.enclosingElement;
|
||||
var enclosingElement = element.enclosingElement2;
|
||||
if (enclosingElement is CompilationUnitElement) {
|
||||
_recordUsedElement(element);
|
||||
} else if (enclosingElement is ExtensionElement) {
|
||||
|
|
|
@ -529,7 +529,7 @@ class _ClassVerifier {
|
|||
.INVALID_OVERRIDE_DIFFERENT_DEFAULT_VALUES_NAMED,
|
||||
derivedOptionalNodes[i],
|
||||
[
|
||||
baseExecutable.enclosingElement.displayName,
|
||||
baseExecutable.enclosingElement2.displayName,
|
||||
baseExecutable.displayName,
|
||||
name
|
||||
],
|
||||
|
@ -558,7 +558,7 @@ class _ClassVerifier {
|
|||
.INVALID_OVERRIDE_DIFFERENT_DEFAULT_VALUES_POSITIONAL,
|
||||
derivedOptionalNodes[i],
|
||||
[
|
||||
baseExecutable.enclosingElement.displayName,
|
||||
baseExecutable.enclosingElement2.displayName,
|
||||
baseExecutable.displayName
|
||||
],
|
||||
);
|
||||
|
@ -675,7 +675,7 @@ class _ClassVerifier {
|
|||
) {
|
||||
var member = concreteMap[Name(libraryUri, memberName)];
|
||||
if (member != null) {
|
||||
var enclosingClass = member.enclosingElement;
|
||||
var enclosingClass = member.enclosingElement2;
|
||||
if (enclosingClass is ClassElement && filter(enclosingClass)) {
|
||||
reporter.reportErrorForNode(
|
||||
CompileTimeErrorCode.ILLEGAL_CONCRETE_ENUM_MEMBER_INHERITANCE,
|
||||
|
@ -716,7 +716,7 @@ class _ClassVerifier {
|
|||
reporter.reportErrorForNode(
|
||||
CompileTimeErrorCode.ILLEGAL_ENUM_VALUES_INHERITANCE,
|
||||
classNameNode,
|
||||
[inherited.enclosingElement.name!],
|
||||
[inherited.enclosingElement2.name!],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -792,20 +792,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.enclosingElement.name` and
|
||||
// `conflict.method.enclosingElement.name` are both non-`null`.
|
||||
// `conflict.getter.enclosingElement2.name` and
|
||||
// `conflict.method.enclosingElement2.name` are both non-`null`.
|
||||
reporter.reportErrorForNode(
|
||||
CompileTimeErrorCode.INCONSISTENT_INHERITANCE_GETTER_AND_METHOD,
|
||||
node,
|
||||
[
|
||||
name.name,
|
||||
conflict.getter.enclosingElement.name!,
|
||||
conflict.method.enclosingElement.name!
|
||||
conflict.getter.enclosingElement2.name!,
|
||||
conflict.method.enclosingElement2.name!
|
||||
],
|
||||
);
|
||||
} else if (conflict is CandidatesConflict) {
|
||||
var candidatesStr = conflict.candidates.map((candidate) {
|
||||
var className = candidate.enclosingElement.name;
|
||||
var className = candidate.enclosingElement2.name;
|
||||
var typeStr = candidate.type.getDisplayString(
|
||||
withNullability: _isNonNullableByDefault,
|
||||
);
|
||||
|
@ -844,7 +844,7 @@ class _ClassVerifier {
|
|||
}
|
||||
|
||||
var elementName = element.displayName;
|
||||
var enclosingElement = element.enclosingElement;
|
||||
var enclosingElement = element.enclosingElement2;
|
||||
var enclosingName = enclosingElement.displayName;
|
||||
var description = "$prefix$enclosingName.$elementName";
|
||||
|
||||
|
|
|
@ -28,17 +28,17 @@ class MustCallSuperVerifier {
|
|||
|
||||
if (element is MethodElement && _hasConcreteSuperMethod(element)) {
|
||||
_verifySuperIsCalled(
|
||||
node, overridden.name, overridden.enclosingElement.name);
|
||||
node, overridden.name, overridden.enclosingElement2.name);
|
||||
return;
|
||||
}
|
||||
|
||||
var enclosingElement = element.enclosingElement as ClassElement;
|
||||
var enclosingElement = element.enclosingElement2 as ClassElement;
|
||||
if (element is PropertyAccessorElement && element.isGetter) {
|
||||
var inheritedConcreteGetter = enclosingElement
|
||||
.lookUpInheritedConcreteGetter(element.name, element.library);
|
||||
if (inheritedConcreteGetter != null) {
|
||||
_verifySuperIsCalled(
|
||||
node, overridden.name, overridden.enclosingElement.name);
|
||||
node, overridden.name, overridden.enclosingElement2.name);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ class MustCallSuperVerifier {
|
|||
if (name.endsWith('=')) {
|
||||
name = name.substring(0, name.length - 1);
|
||||
}
|
||||
_verifySuperIsCalled(node, name, overridden.enclosingElement.name);
|
||||
_verifySuperIsCalled(node, name, overridden.enclosingElement2.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -69,10 +69,10 @@ class MustCallSuperVerifier {
|
|||
ExecutableElement? _findOverriddenMemberWithMustCallSuper(
|
||||
ExecutableElement element) {
|
||||
//Element member = node.declaredElement;
|
||||
if (element.enclosingElement is! ClassElement) {
|
||||
if (element.enclosingElement2 is! ClassElement) {
|
||||
return null;
|
||||
}
|
||||
var classElement = element.enclosingElement as ClassElement;
|
||||
var classElement = element.enclosingElement2 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.enclosingElement as ClassElement;
|
||||
var classElement = element.enclosingElement2 as ClassElement;
|
||||
String name = element.name;
|
||||
|
||||
if (classElement.supertype.isConcrete(name)) {
|
||||
|
|
|
@ -97,7 +97,7 @@ class TypeArgumentsVerifier {
|
|||
return;
|
||||
}
|
||||
|
||||
var enumElement = constructorElement.enclosingElement;
|
||||
var enumElement = constructorElement.enclosingElement2;
|
||||
var typeParameters = enumElement.typeParameters;
|
||||
|
||||
var typeArgumentList = node.arguments?.typeArguments;
|
||||
|
|
|
@ -257,7 +257,7 @@ class GatherUsedLocalElementsVisitor extends RecursiveAstVisitor<void> {
|
|||
usedElements.addElement(parameter);
|
||||
}
|
||||
}
|
||||
var enclosingElement = element?.enclosingElement;
|
||||
var enclosingElement = element?.enclosingElement2;
|
||||
if (element == null) {
|
||||
if (isIdentifierRead) {
|
||||
usedElements.unresolvedReadMembers.add(node.name);
|
||||
|
@ -516,7 +516,7 @@ class UnusedLocalElementsVerifier extends RecursiveAstVisitor<void> {
|
|||
if (element.isPrivate) {
|
||||
return false;
|
||||
}
|
||||
var enclosingElement = element.enclosingElement;
|
||||
var enclosingElement = element.enclosingElement2;
|
||||
|
||||
if (enclosingElement is ClassElement) {
|
||||
if (enclosingElement.isEnum) {
|
||||
|
@ -544,7 +544,7 @@ class UnusedLocalElementsVerifier extends RecursiveAstVisitor<void> {
|
|||
bool elementIsStaticVariable =
|
||||
element is VariableElement && element.isStatic;
|
||||
if (element.isPublic) {
|
||||
if (_isPrivateClassOrExtension(element.enclosingElement!) &&
|
||||
if (_isPrivateClassOrExtension(element.enclosingElement2!) &&
|
||||
elementIsStaticVariable) {
|
||||
// Public static fields of private classes, mixins, and extensions are
|
||||
// inaccessible from outside the library in which they are declared.
|
||||
|
@ -581,7 +581,7 @@ class UnusedLocalElementsVerifier extends RecursiveAstVisitor<void> {
|
|||
element is FunctionElement && !element.isStatic) {
|
||||
// local variable or function
|
||||
} else if (element is ParameterElement) {
|
||||
var enclosingElement = element.enclosingElement;
|
||||
var enclosingElement = element.enclosingElement2;
|
||||
// Only report unused parameters of constructors, methods, and functions.
|
||||
if (enclosingElement is! ConstructorElement &&
|
||||
enclosingElement is! FunctionElement &&
|
||||
|
@ -593,7 +593,7 @@ class UnusedLocalElementsVerifier extends RecursiveAstVisitor<void> {
|
|||
return true;
|
||||
}
|
||||
if (enclosingElement is ConstructorElement &&
|
||||
enclosingElement.enclosingElement.typeParameters.isNotEmpty) {
|
||||
enclosingElement.enclosingElement2.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
|
||||
|
@ -647,7 +647,7 @@ class UnusedLocalElementsVerifier extends RecursiveAstVisitor<void> {
|
|||
}
|
||||
|
||||
Iterable<ExecutableElement> _overriddenElements(Element element) {
|
||||
var enclosingElement = element.enclosingElement;
|
||||
var enclosingElement = element.enclosingElement2;
|
||||
if (enclosingElement is ClassElement) {
|
||||
Name name = Name(_libraryUri, element.name!);
|
||||
var overridden =
|
||||
|
@ -729,7 +729,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.enclosingElement.constructors.length > 1 &&
|
||||
if (element.enclosingElement2.constructors.length > 1 &&
|
||||
!_isUsedMember(element)) {
|
||||
_reportErrorForElement(
|
||||
HintCode.UNUSED_ELEMENT, element, [element.displayName]);
|
||||
|
|
|
@ -357,7 +357,7 @@ class ElementResolver {
|
|||
} else {
|
||||
if (element.isFactory &&
|
||||
// Check if we've reported [NO_GENERATIVE_CONSTRUCTORS_IN_SUPERCLASS].
|
||||
!element.enclosingElement.constructors
|
||||
!element.enclosingElement2.constructors
|
||||
.every((constructor) => constructor.isFactory)) {
|
||||
_errorReporter.reportErrorForNode(
|
||||
CompileTimeErrorCode.NON_GENERATIVE_CONSTRUCTOR, node, [element]);
|
||||
|
|
|
@ -117,7 +117,7 @@ class EnclosingExecutableContext {
|
|||
}
|
||||
|
||||
static bool _inFactoryConstructor(Element? element) {
|
||||
var enclosing = element?.enclosingElement;
|
||||
var enclosing = element?.enclosingElement2;
|
||||
if (enclosing == null) {
|
||||
return false;
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ class EnclosingExecutableContext {
|
|||
}
|
||||
|
||||
static bool _inStaticMethod(Element? element) {
|
||||
var enclosing = element?.enclosingElement;
|
||||
var enclosing = element?.enclosingElement2;
|
||||
if (enclosing == null) {
|
||||
return false;
|
||||
}
|
||||
|
@ -746,7 +746,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
|
|||
@override
|
||||
void visitFunctionDeclaration(FunctionDeclaration node) {
|
||||
ExecutableElement functionElement = node.declaredElement!;
|
||||
if (functionElement.enclosingElement is! CompilationUnitElement) {
|
||||
if (functionElement.enclosingElement2 is! CompilationUnitElement) {
|
||||
_hiddenElements!.declare(functionElement);
|
||||
}
|
||||
|
||||
|
@ -1624,7 +1624,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
|
|||
errorReporter.reportErrorForNode(
|
||||
CompileTimeErrorCode.ASSIGNMENT_TO_FINAL_NO_SETTER,
|
||||
highlightedNode,
|
||||
[variable.name, variable.enclosingElement.displayName],
|
||||
[variable.name, variable.enclosingElement2.displayName],
|
||||
);
|
||||
} else {
|
||||
errorReporter.reportErrorForNode(
|
||||
|
@ -1797,14 +1797,14 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
|
|||
CompileTimeErrorCode.CONFLICTING_STATIC_AND_INSTANCE, method, [
|
||||
_enclosingClass!.displayName,
|
||||
name,
|
||||
inherited.enclosingElement.displayName,
|
||||
inherited.enclosingElement2.displayName,
|
||||
]);
|
||||
} else if (inherited is PropertyAccessorElement) {
|
||||
errorReporter.reportErrorForElement(
|
||||
CompileTimeErrorCode.CONFLICTING_METHOD_AND_FIELD, method, [
|
||||
_enclosingClass!.displayName,
|
||||
name,
|
||||
inherited.enclosingElement.displayName
|
||||
inherited.enclosingElement2.displayName
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -1824,14 +1824,14 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
|
|||
CompileTimeErrorCode.CONFLICTING_STATIC_AND_INSTANCE, accessor, [
|
||||
_enclosingClass!.displayName,
|
||||
name,
|
||||
inherited.enclosingElement.displayName,
|
||||
inherited.enclosingElement2.displayName,
|
||||
]);
|
||||
} else if (inherited is MethodElement) {
|
||||
errorReporter.reportErrorForElement(
|
||||
CompileTimeErrorCode.CONFLICTING_FIELD_AND_METHOD, accessor, [
|
||||
_enclosingClass!.displayName,
|
||||
name,
|
||||
inherited.enclosingElement.displayName
|
||||
inherited.enclosingElement2.displayName
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -2089,11 +2089,11 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
|
|||
errorReporter.reportErrorForNode(
|
||||
CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_MIXIN_WITH_FIELD,
|
||||
constructor.returnType,
|
||||
["'${field.enclosingElement.name}.${field.name}'"]);
|
||||
["'${field.enclosingElement2.name}.${field.name}'"]);
|
||||
return true;
|
||||
} else if (instanceFields.length > 1) {
|
||||
var fieldNames = instanceFields
|
||||
.map((field) => "'${field.enclosingElement.name}.${field.name}'")
|
||||
.map((field) => "'${field.enclosingElement2.name}.${field.name}'")
|
||||
.join(', ');
|
||||
errorReporter.reportErrorForNode(
|
||||
CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_MIXIN_WITH_FIELDS,
|
||||
|
@ -2117,7 +2117,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
|
|||
errorReporter.reportErrorForNode(
|
||||
CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_CONST_SUPER,
|
||||
initializer,
|
||||
[element.enclosingElement.displayName]);
|
||||
[element.enclosingElement2.displayName]);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -2155,7 +2155,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
|
|||
return;
|
||||
}
|
||||
// check if there is non-final field
|
||||
ClassElement classElement = constructorElement.enclosingElement;
|
||||
ClassElement classElement = constructorElement.enclosingElement2;
|
||||
if (!classElement.hasNonFinalField) {
|
||||
return;
|
||||
}
|
||||
|
@ -2921,7 +2921,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
|
|||
// OK, instance member
|
||||
return;
|
||||
}
|
||||
Element enclosingElement = element.enclosingElement;
|
||||
Element enclosingElement = element.enclosingElement2;
|
||||
if (enclosingElement is ExtensionElement) {
|
||||
if (target is ExtensionOverride) {
|
||||
// OK, target is an extension override
|
||||
|
@ -3003,7 +3003,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
|
|||
var constructorElement = node.staticElement;
|
||||
if (constructorElement != null &&
|
||||
constructorElement.isGenerative &&
|
||||
constructorElement.enclosingElement.isEnum) {
|
||||
constructorElement.enclosingElement2.isEnum) {
|
||||
if (_currentLibrary.featureSet.isEnabled(Feature.enhanced_enums)) {
|
||||
errorReporter.reportErrorForNode(
|
||||
CompileTimeErrorCode.INVALID_REFERENCE_TO_GENERATIVE_ENUM_CONSTRUCTOR,
|
||||
|
@ -3046,7 +3046,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
|
|||
return;
|
||||
}
|
||||
// not a class member
|
||||
Element enclosingElement = element.enclosingElement;
|
||||
Element enclosingElement = element.enclosingElement2;
|
||||
if (enclosingElement is! ClassElement &&
|
||||
enclosingElement is! ExtensionElement) {
|
||||
return;
|
||||
|
@ -3182,7 +3182,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
|
|||
var element = nameNode.staticElement!;
|
||||
|
||||
// We should only check exported declarations, i.e. top-level.
|
||||
if (element.enclosingElement is! CompilationUnitElement) {
|
||||
if (element.enclosingElement2 is! CompilationUnitElement) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -3496,14 +3496,14 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
|
|||
);
|
||||
if (inheritedMember != null) {
|
||||
// Inherited members are always contained inside named elements, so we
|
||||
// can safely assume `inheritedMember.enclosingElement.name` is
|
||||
// can safely assume `inheritedMember.enclosingElement2.name` is
|
||||
// non-`null`.
|
||||
errorReporter.reportErrorForNode(
|
||||
CompileTimeErrorCode.PRIVATE_COLLISION_IN_MIXIN_APPLICATION,
|
||||
namedType, [
|
||||
name,
|
||||
namedType.name.name,
|
||||
inheritedMember.enclosingElement.name!
|
||||
inheritedMember.enclosingElement2.name!
|
||||
]);
|
||||
return true;
|
||||
}
|
||||
|
@ -4032,7 +4032,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
|
|||
redirectedElement,
|
||||
redirectedConstructor,
|
||||
);
|
||||
var redirectedClass = redirectedElement?.enclosingElement;
|
||||
var redirectedClass = redirectedElement?.enclosingElement2;
|
||||
if (redirectedClass is ClassElement &&
|
||||
redirectedClass.isAbstract &&
|
||||
redirectedElement != null &&
|
||||
|
@ -4323,7 +4323,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
|
|||
if (_enclosingExecutable.inStaticMethod || _isInStaticVariableDeclaration) {
|
||||
var element = identifier.staticElement;
|
||||
if (element is TypeParameterElement &&
|
||||
element.enclosingElement is ClassElement) {
|
||||
element.enclosingElement2 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).
|
||||
|
@ -4565,7 +4565,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
|
|||
if (element == null || element is TypeParameterElement) {
|
||||
return;
|
||||
}
|
||||
var enclosingElement = element.enclosingElement;
|
||||
var enclosingElement = element.enclosingElement2;
|
||||
if (identical(enclosingElement, _enclosingClass)) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -202,7 +202,7 @@ class FfiVerifier extends RecursiveAstVisitor<void> {
|
|||
void visitFunctionExpressionInvocation(FunctionExpressionInvocation node) {
|
||||
var element = node.staticElement;
|
||||
if (element is MethodElement) {
|
||||
var enclosingElement = element.enclosingElement;
|
||||
var enclosingElement = element.enclosingElement2;
|
||||
if (enclosingElement.isAllocatorExtension &&
|
||||
element.name == _allocateExtensionMethodName) {
|
||||
_validateAllocate(node);
|
||||
|
@ -215,7 +215,7 @@ class FfiVerifier extends RecursiveAstVisitor<void> {
|
|||
void visitIndexExpression(IndexExpression node) {
|
||||
var element = node.staticElement;
|
||||
if (element is MethodElement) {
|
||||
var enclosingElement = element.enclosingElement;
|
||||
var enclosingElement = element.enclosingElement2;
|
||||
if (enclosingElement.isNativeStructPointerExtension ||
|
||||
enclosingElement.isNativeStructArrayExtension) {
|
||||
if (element.name == '[]') {
|
||||
|
@ -228,7 +228,7 @@ class FfiVerifier extends RecursiveAstVisitor<void> {
|
|||
@override
|
||||
void visitInstanceCreationExpression(InstanceCreationExpression node) {
|
||||
var constructor = node.constructorName.staticElement;
|
||||
var class_ = constructor?.enclosingElement;
|
||||
var class_ = constructor?.enclosingElement2;
|
||||
if (class_.isStructSubclass || class_.isUnionSubclass) {
|
||||
_errorReporter.reportErrorForNode(
|
||||
FfiCode.CREATION_OF_STRUCT_OR_UNION,
|
||||
|
@ -253,7 +253,7 @@ class FfiVerifier extends RecursiveAstVisitor<void> {
|
|||
void visitMethodInvocation(MethodInvocation node) {
|
||||
var element = node.methodName.staticElement;
|
||||
if (element is MethodElement) {
|
||||
Element enclosingElement = element.enclosingElement;
|
||||
Element enclosingElement = element.enclosingElement2;
|
||||
if (enclosingElement.isPointer) {
|
||||
if (element.name == 'fromFunction') {
|
||||
_validateFromFunction(node, element);
|
||||
|
@ -270,7 +270,7 @@ class FfiVerifier extends RecursiveAstVisitor<void> {
|
|||
}
|
||||
}
|
||||
} else if (element is FunctionElement) {
|
||||
var enclosingElement = element.enclosingElement;
|
||||
var enclosingElement = element.enclosingElement2;
|
||||
if (enclosingElement is CompilationUnitElement) {
|
||||
if (element.library.name == 'dart.ffi') {
|
||||
if (element.name == 'sizeOf') {
|
||||
|
@ -286,7 +286,7 @@ class FfiVerifier extends RecursiveAstVisitor<void> {
|
|||
void visitPrefixedIdentifier(PrefixedIdentifier node) {
|
||||
var element = node.staticElement;
|
||||
if (element != null) {
|
||||
var enclosingElement = element.enclosingElement;
|
||||
var enclosingElement = element.enclosingElement2;
|
||||
if (enclosingElement.isNativeStructPointerExtension) {
|
||||
if (element.name == 'ref') {
|
||||
_validateRefPrefixedIdentifier(node);
|
||||
|
@ -300,7 +300,7 @@ class FfiVerifier extends RecursiveAstVisitor<void> {
|
|||
void visitPropertyAccess(PropertyAccess node) {
|
||||
var element = node.propertyName.staticElement;
|
||||
if (element != null) {
|
||||
var enclosingElement = element.enclosingElement;
|
||||
var enclosingElement = element.enclosingElement2;
|
||||
if (enclosingElement.isNativeStructPointerExtension) {
|
||||
if (element.name == 'ref') {
|
||||
_validateRefPropertyAccess(node);
|
||||
|
@ -356,7 +356,7 @@ class FfiVerifier extends RecursiveAstVisitor<void> {
|
|||
// Receiver can only be Pointer if the class extends
|
||||
// NativeFieldWrapperClass1.
|
||||
if (ffiSignature.normalParameterTypes[0].isPointer) {
|
||||
final cls = declarationElement.enclosingElement as ClassElement;
|
||||
final cls = declarationElement.enclosingElement2 as ClassElement;
|
||||
if (!_extendsNativeFieldWrapperClass1(cls.thisType)) {
|
||||
_errorReporter.reportErrorForNode(
|
||||
FfiCode
|
||||
|
@ -585,7 +585,7 @@ class FfiVerifier extends RecursiveAstVisitor<void> {
|
|||
_PrimitiveDartType _typeForAnnotation(Annotation annotation) {
|
||||
var element = annotation.element;
|
||||
if (element is ConstructorElement) {
|
||||
String name = element.enclosingElement.name;
|
||||
String name = element.enclosingElement2.name;
|
||||
if (_primitiveIntegerNativeTypes.contains(name)) {
|
||||
return _PrimitiveDartType.int;
|
||||
} else if (_primitiveDoubleNativeTypes.contains(name)) {
|
||||
|
@ -698,7 +698,7 @@ class FfiVerifier extends RecursiveAstVisitor<void> {
|
|||
List<Annotation> extraAnnotations = [];
|
||||
for (Annotation annotation in annotations) {
|
||||
if (annotation.element.ffiClass != null ||
|
||||
annotation.element?.enclosingElement.isAbiSpecificIntegerSubclass ==
|
||||
annotation.element?.enclosingElement2.isAbiSpecificIntegerSubclass ==
|
||||
true) {
|
||||
if (requiredFound) {
|
||||
extraAnnotations.add(annotation);
|
||||
|
@ -1243,7 +1243,7 @@ extension on Annotation {
|
|||
final element = this.element;
|
||||
return element is ConstructorElement &&
|
||||
element.ffiClass != null &&
|
||||
element.enclosingElement.name ==
|
||||
element.enclosingElement2.name ==
|
||||
FfiVerifier._abiSpecificIntegerMappingClassName;
|
||||
}
|
||||
|
||||
|
@ -1251,21 +1251,21 @@ extension on Annotation {
|
|||
final element = this.element;
|
||||
return element is ConstructorElement &&
|
||||
element.ffiClass != null &&
|
||||
element.enclosingElement.name == 'Array';
|
||||
element.enclosingElement2.name == 'Array';
|
||||
}
|
||||
|
||||
bool get isFfiNative {
|
||||
final element = this.element;
|
||||
return element is ConstructorElement &&
|
||||
element.ffiClass != null &&
|
||||
element.enclosingElement.name == 'FfiNative';
|
||||
element.enclosingElement2.name == 'FfiNative';
|
||||
}
|
||||
|
||||
bool get isPacked {
|
||||
final element = this.element;
|
||||
return element is ConstructorElement &&
|
||||
element.ffiClass != null &&
|
||||
element.enclosingElement.name == 'Packed';
|
||||
element.enclosingElement2.name == 'Packed';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1309,7 +1309,7 @@ extension on ElementAnnotation {
|
|||
final element = this.element;
|
||||
return element is ConstructorElement &&
|
||||
element.ffiClass != null &&
|
||||
element.enclosingElement.name == 'Array';
|
||||
element.enclosingElement2.name == 'Array';
|
||||
// Note: this is 'Array' instead of '_ArraySize' because it finds the
|
||||
// forwarding factory instead of the forwarded constructor.
|
||||
}
|
||||
|
@ -1318,7 +1318,7 @@ extension on ElementAnnotation {
|
|||
final element = this.element;
|
||||
return element is ConstructorElement &&
|
||||
element.ffiClass != null &&
|
||||
element.enclosingElement.name == 'Packed';
|
||||
element.enclosingElement2.name == 'Packed';
|
||||
}
|
||||
|
||||
int? get packedMemberAlignment {
|
||||
|
@ -1333,7 +1333,7 @@ extension on Element? {
|
|||
ClassElement? get ffiClass {
|
||||
var element = this;
|
||||
if (element is ConstructorElement) {
|
||||
element = element.enclosingElement;
|
||||
element = element.enclosingElement2;
|
||||
}
|
||||
if (element is ClassElement && element.isFfiClass) {
|
||||
return element;
|
||||
|
|
|
@ -3605,7 +3605,7 @@ class ScopeResolverVisitor extends UnifyingAstVisitor<void> {
|
|||
if (node.inSetterContext()) {
|
||||
_localVariableInfo.potentiallyMutatedInScope.add(element);
|
||||
if (_enclosingClosure != null &&
|
||||
element.enclosingElement != _enclosingClosure) {
|
||||
element.enclosingElement2 != _enclosingClosure) {
|
||||
_localVariableInfo.potentiallyMutatedInClosure.add(element);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -338,7 +338,7 @@ class LinterContextImpl implements LinterContext {
|
|||
bool canBeConstConstructor(covariant ConstructorDeclarationImpl node) {
|
||||
var element = node.declaredElement!;
|
||||
|
||||
ClassElement classElement = element.enclosingElement;
|
||||
ClassElement classElement = element.enclosingElement2;
|
||||
if (classElement.hasNonFinalField) return false;
|
||||
|
||||
var oldKeyword = node.constKeyword;
|
||||
|
|
|
@ -200,7 +200,7 @@ abstract class ElementLinkedData<E extends ElementImpl> {
|
|||
ResolutionReader reader,
|
||||
ElementImpl element,
|
||||
) {
|
||||
var enclosing = element.enclosingElement;
|
||||
var enclosing = element.enclosingElement2;
|
||||
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.enclosingElement,
|
||||
unitElement: element.enclosingElement2,
|
||||
);
|
||||
_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.enclosingElement,
|
||||
unitElement: element.enclosingElement2,
|
||||
);
|
||||
_readTypeParameters(reader, element.typeParameters);
|
||||
element.extendedType = reader.readRequiredType();
|
||||
|
@ -1550,7 +1550,7 @@ class MixinElementLinkedData extends ElementLinkedData<MixinElementImpl> {
|
|||
@override
|
||||
void _read(element, reader) {
|
||||
element.metadata = reader._readAnnotationList(
|
||||
unitElement: element.enclosingElement,
|
||||
unitElement: element.enclosingElement2,
|
||||
);
|
||||
_readTypeParameters(reader, element.typeParameters);
|
||||
element.superclassConstraints = reader._readInterfaceTypeList();
|
||||
|
@ -1634,7 +1634,7 @@ class ResolutionReader {
|
|||
// TODO(scheglov) why to check for empty? If we have this flags.
|
||||
if (arguments.isNotEmpty) {
|
||||
var typeParameters =
|
||||
(element.enclosingElement as TypeParameterizedElement)
|
||||
(element.enclosingElement2 as TypeParameterizedElement)
|
||||
.typeParameters;
|
||||
var substitution = Substitution.fromPairs(typeParameters, arguments);
|
||||
element =
|
||||
|
|
|
@ -847,7 +847,7 @@ class ResolutionSink extends _SummaryDataWriter {
|
|||
return const [];
|
||||
}
|
||||
|
||||
var enclosing = declaration.enclosingElement;
|
||||
var enclosing = declaration.enclosingElement2;
|
||||
if (enclosing is TypeParameterizedElement) {
|
||||
if (enclosing is! ClassElement && enclosing is! ExtensionElement) {
|
||||
return const <DartType>[];
|
||||
|
|
|
@ -110,7 +110,7 @@ class DeclarationBuilderFromElement {
|
|||
|
||||
FieldDeclarationImpl _fieldElement(FieldElement element) {
|
||||
assert(!_fieldMap.containsKey(element));
|
||||
final enclosingClass = element.enclosingElement as ClassElement;
|
||||
final enclosingClass = element.enclosingElement2 as ClassElement;
|
||||
return FieldDeclarationImpl(
|
||||
id: macro.RemoteInstance.uniqueId,
|
||||
identifier: identifier(element),
|
||||
|
|
|
@ -174,7 +174,7 @@ class _ConstructorInferenceNode extends _InferenceNode {
|
|||
}
|
||||
}
|
||||
|
||||
var classElement = _constructor.enclosingElement;
|
||||
var classElement = _constructor.enclosingElement2;
|
||||
if (classElement.isMixinApplication) {
|
||||
var superType = classElement.supertype;
|
||||
if (superType != null) {
|
||||
|
@ -285,7 +285,7 @@ class _InferenceDependenciesCollector extends RecursiveAstVisitor<void> {
|
|||
|
||||
_set.add(element);
|
||||
|
||||
if (element.enclosingElement.typeParameters.isNotEmpty) {
|
||||
if (element.enclosingElement2.typeParameters.isNotEmpty) {
|
||||
node.argumentList.accept(this);
|
||||
}
|
||||
}
|
||||
|
@ -526,7 +526,7 @@ class _VariableInferenceNode extends _InferenceNode {
|
|||
}
|
||||
|
||||
void _resolveInitializer({required bool forDependencies}) {
|
||||
var enclosingElement = _element.enclosingElement;
|
||||
var enclosingElement = _element.enclosingElement2;
|
||||
var enclosingClassElement =
|
||||
enclosingElement is ClassElement ? enclosingElement : null;
|
||||
var astResolver = AstResolver(_walker._linker, _unitElement, _scope,
|
||||
|
|
|
@ -424,7 +424,7 @@ class InstanceMemberInferrer {
|
|||
var conflict = conflicts.single;
|
||||
if (conflict is CandidatesConflict) {
|
||||
conflictExplanation = conflict.candidates.map((candidate) {
|
||||
var className = candidate.enclosingElement.name;
|
||||
var className = candidate.enclosingElement2.name;
|
||||
var typeStr = candidate.type.getDisplayString(
|
||||
withNullability: typeSystem.isNonNullableByDefault,
|
||||
);
|
||||
|
@ -540,7 +540,7 @@ class InstanceMemberInferrer {
|
|||
overridden = overridden.declaration;
|
||||
|
||||
// Skip Object itself.
|
||||
var enclosingElement = overridden.enclosingElement;
|
||||
var enclosingElement = overridden.enclosingElement2;
|
||||
if (enclosingElement is ClassElement &&
|
||||
enclosingElement.isDartCoreObject) {
|
||||
continue;
|
||||
|
|
|
@ -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.enclosingElement;
|
||||
var enclosingElement = element.enclosingElement2;
|
||||
if (enclosingElement is CompilationUnitElement) {
|
||||
var memberName = element.name!;
|
||||
if (element is PropertyAccessorElement && element.isSetter) {
|
||||
|
|
|
@ -35,7 +35,7 @@ class A {
|
|||
expect(name3, isNull);
|
||||
if (annotationElement is ConstructorElement) {
|
||||
expect(annotationElement, same(name2.staticElement));
|
||||
expect(annotationElement.enclosingElement, name1.staticElement);
|
||||
expect(annotationElement.enclosingElement2, 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.enclosingElement, name2.staticElement);
|
||||
expect(annotationElement.enclosingElement2, 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.enclosingElement, name2.staticElement);
|
||||
expect(annotationElement.enclosingElement2, 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.enclosingElement, name2.staticElement);
|
||||
expect(annotationElement.enclosingElement2, 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.enclosingElement, name1.staticElement);
|
||||
expect(annotationElement.enclosingElement2, 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.enclosingElement, name1.staticElement);
|
||||
expect(annotationElement.enclosingElement2, 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.enclosingElement, isCompilationUnitElement);
|
||||
expect(annotationElement.enclosingElement2, 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.enclosingElement, isCompilationUnitElement);
|
||||
expect(annotationElement.enclosingElement2, isCompilationUnitElement);
|
||||
expect(annotationElement.displayName, 'V');
|
||||
} else {
|
||||
fail('Expected "annotationElement" is PropertyAccessorElement, '
|
||||
|
|
|
@ -1458,7 +1458,7 @@ test(C c) => c.method<bool>(arg: true);
|
|||
''');
|
||||
var x = findNode.namedExpression('arg: true');
|
||||
var y = x.staticParameterElement!;
|
||||
expect(y.enclosingElement, isNotNull);
|
||||
expect(y.enclosingElement2, 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.enclosingElement, isNotNull);
|
||||
expect(y.enclosingElement2, isNotNull);
|
||||
expect(y.declaration, findElement.parameter('arg'));
|
||||
}
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ class C {
|
|||
|
||||
var constructor = findElement.unnamedConstructor('C');
|
||||
var x = findElement.localFunction('x');
|
||||
expect(x.enclosingElement, constructor);
|
||||
expect(x.enclosingElement2, constructor);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -102,7 +102,7 @@ class _InheritanceDataExtractor extends AstDataExtractor<String> {
|
|||
for (var name in interface.map.keys) {
|
||||
var executable = interface.map[name]!;
|
||||
|
||||
var enclosingClass = executable.enclosingElement as ClassElement;
|
||||
var enclosingClass = executable.enclosingElement2 as ClassElement;
|
||||
if (enclosingClass.isDartCoreObject) continue;
|
||||
|
||||
var id = MemberId.internal(
|
||||
|
|
|
@ -978,7 +978,7 @@ main() {
|
|||
forInvocation.argumentList.arguments[0] as FunctionExpression;
|
||||
|
||||
var closureElement = closure.declaredElement as FunctionElementImpl;
|
||||
expect(closureElement.enclosingElement, same(mainElement));
|
||||
expect(closureElement.enclosingElement2, same(mainElement));
|
||||
|
||||
ParameterElement itemElement = closureElement.parameters[0];
|
||||
itemElement1 = itemElement;
|
||||
|
@ -1019,7 +1019,7 @@ main() {
|
|||
forInvocation.argumentList.arguments[0] as FunctionExpression;
|
||||
|
||||
var closureElement = closure.declaredElement as FunctionElementImpl;
|
||||
expect(closureElement.enclosingElement, same(mainElement));
|
||||
expect(closureElement.enclosingElement2, same(mainElement));
|
||||
|
||||
ParameterElement itemElement = closureElement.parameters[0];
|
||||
expect(itemElement, isNot(same(itemElement1)));
|
||||
|
@ -1062,7 +1062,7 @@ void foo(List<T> Function<T>() createList) {}
|
|||
assertType(closure, 'List<T> Function<T>()');
|
||||
|
||||
var closureElement = closure.declaredElement as FunctionElementImpl;
|
||||
expect(closureElement.enclosingElement, findElement.function('main'));
|
||||
expect(closureElement.enclosingElement2, findElement.function('main'));
|
||||
assertType(closureElement.returnType, 'List<T>');
|
||||
expect(closureElement.parameters, isEmpty);
|
||||
|
||||
|
@ -1708,7 +1708,7 @@ main(MyEnum e) {
|
|||
|
||||
var methodElement = invocation.methodName.staticElement as MethodElement;
|
||||
expect(methodElement.name, 'toString');
|
||||
expect(methodElement.enclosingElement, same(objectElement));
|
||||
expect(methodElement.enclosingElement2, same(objectElement));
|
||||
}
|
||||
|
||||
test_error_unresolvedTypeAnnotation() async {
|
||||
|
|
|
@ -1416,7 +1416,7 @@ class _InheritanceManager3Base extends PubPackageResolutionTest {
|
|||
|
||||
void _assertExecutable(ExecutableElement? element, String? expected) {
|
||||
if (expected != null && element != null) {
|
||||
var enclosingElement = element.enclosingElement;
|
||||
var enclosingElement = element.enclosingElement2;
|
||||
|
||||
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.enclosingElement, same(element.enclosingElement));
|
||||
expect(variable.enclosingElement2, same(element.enclosingElement2));
|
||||
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.enclosingElement;
|
||||
var enclosingElement = element.enclosingElement2;
|
||||
if (enclosingElement.name == 'Object') continue;
|
||||
|
||||
var typeStr = type.getDisplayString(withNullability: false);
|
||||
|
|
|
@ -214,7 +214,7 @@ mixin ResolutionTest implements ResourceProviderMixin {
|
|||
}
|
||||
|
||||
void assertEnclosingElement(Element element, Element expectedEnclosing) {
|
||||
expect(element.enclosingElement, expectedEnclosing);
|
||||
expect(element.enclosingElement2, expectedEnclosing);
|
||||
}
|
||||
|
||||
Future<void> assertErrorsInCode(
|
||||
|
@ -500,7 +500,7 @@ mixin ResolutionTest implements ResourceProviderMixin {
|
|||
) {
|
||||
var actualMapString = Map.fromEntries(
|
||||
substitution.map.entries.where((entry) {
|
||||
return entry.key.enclosingElement is! ExecutableElement;
|
||||
return entry.key.enclosingElement2 is! ExecutableElement;
|
||||
}).map((entry) {
|
||||
return MapEntry(
|
||||
entry.key.name,
|
||||
|
|
|
@ -64,8 +64,8 @@ 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!.enclosingElement.name, 'num');
|
||||
expect(findNode.binary('x + y').staticElement!.enclosingElement2.name,
|
||||
'num');
|
||||
} else {
|
||||
await assertErrorsInCode(code, [
|
||||
error(HintCode.UNUSED_LOCAL_VARIABLE, 32, 1),
|
||||
|
@ -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?.enclosingElement.name,
|
||||
expect(findNode.binary('+ y').staticElement?.enclosingElement2.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!.enclosingElement.name, 'num');
|
||||
expect(findNode.binary('+ y').staticElement!.enclosingElement2.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!.enclosingElement.name, 'num');
|
||||
expect(findNode.binary('+ y').staticElement!.enclosingElement2.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
Loading…
Reference in a new issue