Elements. Rename XyzElement2 into XyzElement.
The CL was done with rename + adding typedef for each class. Change-Id: Ia25cc581d2e42cf7d12a85a3579af952d5c232ee Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/424687 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
committed by
Commit Queue
parent
1bc77c82c0
commit
b2fdd8a345
@@ -13,7 +13,7 @@ import 'package:analyzer/src/dart/element/element.dart';
|
||||
import 'package:analyzer/src/utilities/extensions/element.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
Element convertElement(engine.Element2 element) {
|
||||
Element convertElement(engine.Element element) {
|
||||
var kind = convertElementToElementKind(element);
|
||||
var name = getElementDisplayName(element);
|
||||
var elementTypeParameters = _getTypeParametersString(element);
|
||||
@@ -120,14 +120,14 @@ ElementKind convertElementKind(engine.ElementKind kind) {
|
||||
return ElementKind.UNKNOWN;
|
||||
}
|
||||
|
||||
/// Return an [ElementKind] corresponding to the given [engine.Element2].
|
||||
ElementKind convertElementToElementKind(engine.Element2 element) {
|
||||
if (element is engine.EnumElement2) {
|
||||
/// Return an [ElementKind] corresponding to the given [engine.Element].
|
||||
ElementKind convertElementToElementKind(engine.Element element) {
|
||||
if (element is engine.EnumElement) {
|
||||
return ElementKind.ENUM;
|
||||
} else if (element is engine.MixinElement2) {
|
||||
} else if (element is engine.MixinElement) {
|
||||
return ElementKind.MIXIN;
|
||||
}
|
||||
if (element is engine.FieldElement2 && element.isEnumConstant) {
|
||||
if (element is engine.FieldElement && element.isEnumConstant) {
|
||||
return ElementKind.ENUM_CONSTANT;
|
||||
}
|
||||
return convertElementKind(element.kind);
|
||||
@@ -145,7 +145,7 @@ Element convertLibraryFragment(CompilationUnitElementImpl fragment) {
|
||||
);
|
||||
}
|
||||
|
||||
String getElementDisplayName(engine.Element2 element) {
|
||||
String getElementDisplayName(engine.Element element) {
|
||||
if (element is engine.LibraryFragment) {
|
||||
return path.basename((element as engine.LibraryFragment).source.fullName);
|
||||
} else {
|
||||
@@ -153,17 +153,17 @@ String getElementDisplayName(engine.Element2 element) {
|
||||
}
|
||||
}
|
||||
|
||||
String? getParametersString(engine.Element2 element) {
|
||||
String? getParametersString(engine.Element element) {
|
||||
// TODO(scheglov): expose the corresponding feature from ExecutableElement
|
||||
List<engine.FormalParameterElement> parameters;
|
||||
if (element is engine.ExecutableElement2) {
|
||||
if (element is engine.ExecutableElement) {
|
||||
// valid getters don't have parameters
|
||||
if (element.kind == engine.ElementKind.GETTER &&
|
||||
element.formalParameters.isEmpty) {
|
||||
return null;
|
||||
}
|
||||
parameters = element.formalParameters.toList();
|
||||
} else if (element is engine.TypeAliasElement2) {
|
||||
} else if (element is engine.TypeAliasElement) {
|
||||
var aliasedType = element.aliasedType;
|
||||
if (aliasedType is FunctionType) {
|
||||
parameters = aliasedType.formalParameters.toList();
|
||||
@@ -202,11 +202,11 @@ String? getParametersString(engine.Element2 element) {
|
||||
return '($sb)';
|
||||
}
|
||||
|
||||
String? _getTypeParametersString(engine.Element2 element) {
|
||||
List<engine.TypeParameterElement2>? typeParameters;
|
||||
if (element is engine.InterfaceElement2) {
|
||||
String? _getTypeParametersString(engine.Element element) {
|
||||
List<engine.TypeParameterElement>? typeParameters;
|
||||
if (element is engine.InterfaceElement) {
|
||||
typeParameters = element.typeParameters2;
|
||||
} else if (element is engine.TypeAliasElement2) {
|
||||
} else if (element is engine.TypeAliasElement) {
|
||||
typeParameters = element.typeParameters2;
|
||||
}
|
||||
if (typeParameters == null || typeParameters.isEmpty) {
|
||||
@@ -215,41 +215,41 @@ String? _getTypeParametersString(engine.Element2 element) {
|
||||
return '<${typeParameters.join(', ')}>';
|
||||
}
|
||||
|
||||
bool _isAbstract(engine.Element2 element) {
|
||||
if (element is engine.ClassElement2) {
|
||||
bool _isAbstract(engine.Element element) {
|
||||
if (element is engine.ClassElement) {
|
||||
return element.isAbstract;
|
||||
}
|
||||
if (element is engine.MethodElement2) {
|
||||
if (element is engine.MethodElement) {
|
||||
return element.isAbstract;
|
||||
}
|
||||
if (element is engine.MixinElement2) {
|
||||
if (element is engine.MixinElement) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool _isConst(engine.Element2 element) {
|
||||
if (element is engine.ConstructorElement2) {
|
||||
bool _isConst(engine.Element element) {
|
||||
if (element is engine.ConstructorElement) {
|
||||
return element.isConst;
|
||||
}
|
||||
if (element is engine.VariableElement2) {
|
||||
if (element is engine.VariableElement) {
|
||||
return element.isConst;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool _isFinal(engine.Element2 element) {
|
||||
if (element is engine.VariableElement2) {
|
||||
bool _isFinal(engine.Element element) {
|
||||
if (element is engine.VariableElement) {
|
||||
return element.isFinal;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool _isStatic(engine.Element2 element) {
|
||||
if (element is engine.ExecutableElement2) {
|
||||
bool _isStatic(engine.Element element) {
|
||||
if (element is engine.ExecutableElement) {
|
||||
return element.isStatic;
|
||||
}
|
||||
if (element is engine.PropertyInducingElement2) {
|
||||
if (element is engine.PropertyInducingElement) {
|
||||
return element.isStatic;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -639,10 +639,10 @@ abstract class AnalysisServer {
|
||||
/// Gets the current version number of a document (if known).
|
||||
int? getDocumentVersion(String path);
|
||||
|
||||
/// Return a [Future] that completes with the [Element2] at the given
|
||||
/// Return a [Future] that completes with the [Element] at the given
|
||||
/// [offset] of the given [file], or with `null` if there is no node at the
|
||||
/// [offset] or the node does not have an element.
|
||||
Future<Element2?> getElementAtOffset(String file, int offset) async {
|
||||
Future<Element?> getElementAtOffset(String file, int offset) async {
|
||||
var unitResult = await getResolvedUnit(file);
|
||||
if (unitResult == null) {
|
||||
return null;
|
||||
|
||||
@@ -190,7 +190,7 @@ class CiderCompletionComputer {
|
||||
/// Return cached, or compute unprefixed suggestions for all elements
|
||||
/// exported from the library.
|
||||
List<CompletionSuggestionBuilder> _importedLibrarySuggestions({
|
||||
required LibraryElement2 element,
|
||||
required LibraryElement element,
|
||||
required OperationPerformanceImpl performance,
|
||||
}) {
|
||||
performance.getDataInt('libraryCount').increment();
|
||||
@@ -212,7 +212,7 @@ class CiderCompletionComputer {
|
||||
/// Compute all unprefixed suggestions for all elements exported from
|
||||
/// the library.
|
||||
List<CompletionSuggestionBuilder> _librarySuggestions(
|
||||
LibraryElement2 element,
|
||||
LibraryElement element,
|
||||
) {
|
||||
var suggestionBuilder = SuggestionBuilder(
|
||||
_dartCompletionRequest,
|
||||
|
||||
@@ -83,10 +83,10 @@ class _CiderDartFixContextImpl extends DartFixContext {
|
||||
}) : super(instrumentationService: InstrumentationService.NULL_SERVICE);
|
||||
|
||||
@override
|
||||
Future<Map<LibraryElement2, Element2>> getTopLevelDeclarations(
|
||||
Future<Map<LibraryElement, Element>> getTopLevelDeclarations(
|
||||
String name,
|
||||
) async {
|
||||
var result = <LibraryElement2, Element2>{};
|
||||
var result = <LibraryElement, Element>{};
|
||||
var files = _fileResolver.getFilesWithTopLevelDeclarations(name);
|
||||
for (var file in files) {
|
||||
var kind = file.kind;
|
||||
@@ -101,5 +101,5 @@ class _CiderDartFixContextImpl extends DartFixContext {
|
||||
}
|
||||
|
||||
@override
|
||||
Stream<LibraryElement2> librariesWithExtensions(Name memberName) async* {}
|
||||
Stream<LibraryElement> librariesWithExtensions(Name memberName) async* {}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ class LibraryElementSuggestionBuilder
|
||||
final String? prefix;
|
||||
|
||||
/// The set of libraries that have been, or are currently being, visited.
|
||||
final Set<LibraryElement2> visitedLibraries = <LibraryElement2>{};
|
||||
final Set<LibraryElement> visitedLibraries = <LibraryElement>{};
|
||||
|
||||
factory LibraryElementSuggestionBuilder(
|
||||
DartCompletionRequest request,
|
||||
@@ -59,7 +59,7 @@ class LibraryElementSuggestionBuilder
|
||||
);
|
||||
|
||||
@override
|
||||
void visitClassElement(ClassElement2 element) {
|
||||
void visitClassElement(ClassElement element) {
|
||||
AstNode node = request.target.containingNode;
|
||||
var libraryElement = request.libraryElement;
|
||||
if (node is ExtendsClause && !element.isExtendableIn2(libraryElement)) {
|
||||
@@ -74,17 +74,17 @@ class LibraryElementSuggestionBuilder
|
||||
}
|
||||
|
||||
@override
|
||||
void visitElement(Element2 element) {
|
||||
void visitElement(Element element) {
|
||||
// ignored
|
||||
}
|
||||
|
||||
@override
|
||||
visitEnumElement(EnumElement2 element) {
|
||||
visitEnumElement(EnumElement element) {
|
||||
_visitInterfaceElement(element);
|
||||
}
|
||||
|
||||
@override
|
||||
void visitExtensionElement(ExtensionElement2 element) {
|
||||
void visitExtensionElement(ExtensionElement element) {
|
||||
if (opType.includeReturnValueSuggestions) {
|
||||
if (element.name3 != null) {
|
||||
builder.suggestExtension(element, kind: kind, prefix: prefix);
|
||||
@@ -93,7 +93,7 @@ class LibraryElementSuggestionBuilder
|
||||
}
|
||||
|
||||
@override
|
||||
void visitExtensionTypeElement(ExtensionTypeElement2 element) {
|
||||
void visitExtensionTypeElement(ExtensionTypeElement element) {
|
||||
_visitInterfaceElement(element);
|
||||
}
|
||||
|
||||
@@ -105,9 +105,9 @@ class LibraryElementSuggestionBuilder
|
||||
variable != null &&
|
||||
variable.isConst)) {
|
||||
var parent = element.enclosingElement2;
|
||||
if (parent is InterfaceElement2 || parent is ExtensionElement2) {
|
||||
if (parent is InterfaceElement || parent is ExtensionElement) {
|
||||
if (element.isSynthetic) {
|
||||
if (variable is FieldElement2) {
|
||||
if (variable is FieldElement) {
|
||||
builder.suggestField(variable, inheritanceDistance: 0.0);
|
||||
}
|
||||
} else {
|
||||
@@ -120,14 +120,14 @@ class LibraryElementSuggestionBuilder
|
||||
}
|
||||
|
||||
@override
|
||||
void visitLibraryElement(LibraryElement2 element) {
|
||||
void visitLibraryElement(LibraryElement element) {
|
||||
if (visitedLibraries.add(element)) {
|
||||
element.visitChildren2(this);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
visitMixinElement(MixinElement2 element) {
|
||||
visitMixinElement(MixinElement element) {
|
||||
AstNode node = request.target.containingNode;
|
||||
if (node is ImplementsClause &&
|
||||
!element.isImplementableIn2(request.libraryElement)) {
|
||||
@@ -144,7 +144,7 @@ class LibraryElementSuggestionBuilder
|
||||
variable != null &&
|
||||
variable.isConst)) {
|
||||
var parent = element.enclosingElement2;
|
||||
if (parent is InterfaceElement2 || parent is ExtensionElement2) {
|
||||
if (parent is InterfaceElement || parent is ExtensionElement) {
|
||||
if (!element.isSynthetic) {
|
||||
builder.suggestSetter(element, inheritanceDistance: 0.0);
|
||||
}
|
||||
@@ -169,14 +169,14 @@ class LibraryElementSuggestionBuilder
|
||||
}
|
||||
|
||||
@override
|
||||
void visitTopLevelVariableElement(TopLevelVariableElement2 element) {
|
||||
void visitTopLevelVariableElement(TopLevelVariableElement element) {
|
||||
if (opType.includeReturnValueSuggestions && !element.isSynthetic) {
|
||||
builder.suggestTopLevelVariable(element, prefix: prefix);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void visitTypeAliasElement(TypeAliasElement2 element) {
|
||||
void visitTypeAliasElement(TypeAliasElement element) {
|
||||
if (opType.includeTypeNameSuggestions) {
|
||||
builder.suggestTypeAlias(element, prefix: prefix);
|
||||
}
|
||||
@@ -186,10 +186,10 @@ class LibraryElementSuggestionBuilder
|
||||
///
|
||||
/// If [onlyConst] is `true`, only `const` constructors will be suggested.
|
||||
void _addConstructorSuggestions(
|
||||
ClassElement2 element, {
|
||||
ClassElement element, {
|
||||
bool onlyConst = false,
|
||||
}) {
|
||||
if (element is EnumElement2) {
|
||||
if (element is EnumElement) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -207,11 +207,11 @@ class LibraryElementSuggestionBuilder
|
||||
}
|
||||
}
|
||||
|
||||
void _visitInterfaceElement(InterfaceElement2 element) {
|
||||
void _visitInterfaceElement(InterfaceElement element) {
|
||||
if (opType.includeTypeNameSuggestions) {
|
||||
builder.suggestInterface(element, prefix: prefix);
|
||||
}
|
||||
if (element is ClassElement2) {
|
||||
if (element is ClassElement) {
|
||||
if (opType.includeConstructorSuggestions) {
|
||||
_addConstructorSuggestions(element);
|
||||
} else if (opType.includeAnnotationSuggestions) {
|
||||
|
||||
@@ -43,21 +43,21 @@ class CanRenameResponse {
|
||||
RefactoringStatus? status;
|
||||
if (element is FormalParameterElement) {
|
||||
status = validateParameterName(name);
|
||||
} else if (element is VariableElement2) {
|
||||
} else if (element is VariableElement) {
|
||||
status = validateVariableName(name);
|
||||
} else if (element is LocalFunctionElement ||
|
||||
element is TopLevelFunctionElement) {
|
||||
status = validateFunctionName(name);
|
||||
} else if (element is FieldElement2) {
|
||||
} else if (element is FieldElement) {
|
||||
status = validateFieldName(name);
|
||||
} else if (element is MethodElement2) {
|
||||
} else if (element is MethodElement) {
|
||||
status = validateMethodName(name);
|
||||
} else if (element is TypeAliasElement2) {
|
||||
} else if (element is TypeAliasElement) {
|
||||
status = validateTypeAliasName(name);
|
||||
} else if (element is InterfaceElement2) {
|
||||
} else if (element is InterfaceElement) {
|
||||
status = validateClassName(name);
|
||||
_flutterWidgetState = _findFlutterStateClass(element, name);
|
||||
} else if (element is ConstructorElement2) {
|
||||
} else if (element is ConstructorElement) {
|
||||
status = validateConstructorName(name);
|
||||
_analyzePossibleConflicts(element, status, name);
|
||||
} else if (element is MockLibraryImportElement) {
|
||||
@@ -71,7 +71,7 @@ class CanRenameResponse {
|
||||
}
|
||||
|
||||
void _analyzePossibleConflicts(
|
||||
ConstructorElement2 element,
|
||||
ConstructorElement element,
|
||||
RefactoringStatus result,
|
||||
String newName,
|
||||
) {
|
||||
@@ -95,8 +95,8 @@ class CanRenameResponse {
|
||||
}
|
||||
}
|
||||
|
||||
FlutterWidgetState? _findFlutterStateClass(Element2 element, String newName) {
|
||||
if (element is ClassElement2 && element.isStatefulWidgetDeclaration) {
|
||||
FlutterWidgetState? _findFlutterStateClass(Element element, String newName) {
|
||||
if (element is ClassElement && element.isStatefulWidgetDeclaration) {
|
||||
var oldStateName = '${element.displayName}State';
|
||||
var library = element.library2;
|
||||
var state =
|
||||
@@ -128,9 +128,9 @@ class CheckNameResponse {
|
||||
String get oldName => canRename.refactoringElement.element.displayName;
|
||||
|
||||
Future<RenameResponse?> computeRenameRanges2() async {
|
||||
var elements = <Element2>[];
|
||||
var elements = <Element>[];
|
||||
var element = canRename.refactoringElement.element;
|
||||
if (element is PropertyInducingElement2 && element.isSynthetic) {
|
||||
if (element is PropertyInducingElement && element.isSynthetic) {
|
||||
var property = element;
|
||||
var getter = property.getter2;
|
||||
var setter = property.setter2;
|
||||
@@ -149,7 +149,7 @@ class CheckNameResponse {
|
||||
flutterRename = await _computeFlutterStateName();
|
||||
}
|
||||
var replaceMatches = <CiderReplaceMatch>[];
|
||||
if (element is ConstructorElement2) {
|
||||
if (element is ConstructorElement) {
|
||||
for (var match in matches) {
|
||||
var replaceInfo = <ReplaceInfo>[];
|
||||
for (var ref in match.references) {
|
||||
@@ -231,11 +231,11 @@ class CheckNameResponse {
|
||||
}
|
||||
|
||||
Future<List<ReplaceInfo>> _addElementDeclaration(
|
||||
Element2 element,
|
||||
Element element,
|
||||
String sourcePath,
|
||||
) async {
|
||||
var infos = <ReplaceInfo>[];
|
||||
if (element is PropertyInducingElement2 && element.isSynthetic) {
|
||||
if (element is PropertyInducingElement && element.isSynthetic) {
|
||||
var getter = element.getter2;
|
||||
if (getter != null) {
|
||||
infos.add(
|
||||
@@ -433,10 +433,10 @@ class CiderRenameComputer {
|
||||
if (element.library2?.isInSdk == true) {
|
||||
return null;
|
||||
}
|
||||
if (element is MethodElement2 && element.isOperator) {
|
||||
if (element is MethodElement && element.isOperator) {
|
||||
return null;
|
||||
}
|
||||
if (element is PropertyAccessorElement2) {
|
||||
if (element is PropertyAccessorElement) {
|
||||
element = element.variable3;
|
||||
if (element == null) {
|
||||
return null;
|
||||
@@ -452,20 +452,20 @@ class CiderRenameComputer {
|
||||
return null;
|
||||
}
|
||||
|
||||
bool _canRenameElement(Element2 element) {
|
||||
bool _canRenameElement(Element element) {
|
||||
var enclosingElement = element.enclosingElement2;
|
||||
if (element is ConstructorElement2) {
|
||||
if (element is ConstructorElement) {
|
||||
return true;
|
||||
}
|
||||
if (element is MockLibraryImportElement) {
|
||||
return true;
|
||||
}
|
||||
if (element is LabelElement2 || element is LocalElement2) {
|
||||
if (element is LabelElement || element is LocalElement) {
|
||||
return true;
|
||||
}
|
||||
if (enclosingElement is InterfaceElement2 ||
|
||||
enclosingElement is ExtensionElement2 ||
|
||||
enclosingElement is LibraryElement2) {
|
||||
if (enclosingElement is InterfaceElement ||
|
||||
enclosingElement is ExtensionElement ||
|
||||
enclosingElement is LibraryElement) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -492,7 +492,7 @@ class FlutterWidgetRename {
|
||||
|
||||
/// The corresponding `State` declaration of a Flutter `StatefulWidget`.
|
||||
class FlutterWidgetState {
|
||||
ClassElement2 state;
|
||||
ClassElement state;
|
||||
String newName;
|
||||
|
||||
FlutterWidgetState(this.state, this.newName);
|
||||
|
||||
@@ -19,7 +19,7 @@ import 'package:analyzer/utilities/extensions/ast.dart';
|
||||
///
|
||||
/// This is used to construct (and group calls by) a [CallHierarchyItem] that
|
||||
/// contains calls and also locate their containers for additional labelling.
|
||||
Element2? _getContainer(Element2 element) {
|
||||
Element? _getContainer(Element element) {
|
||||
// TODO(brianwilkerson): This used to use the compilation unit as a container
|
||||
// which allowed users to see the path to the containing file, but that's
|
||||
// been lost. Consider trying to restore that behavior.
|
||||
@@ -42,9 +42,9 @@ Element2? _getContainer(Element2 element) {
|
||||
}
|
||||
|
||||
/// Gets a user-friendly display name for [element].
|
||||
String _getDisplayName(Element2 element) {
|
||||
String _getDisplayName(Element element) {
|
||||
return switch (element) {
|
||||
LibraryElement2() => element.firstFragment.source.shortName,
|
||||
LibraryElement() => element.firstFragment.source.shortName,
|
||||
GetterElement() => 'get ${element.displayName}',
|
||||
SetterElement() => 'set ${element.displayName}',
|
||||
_ => element.displayName,
|
||||
@@ -102,7 +102,7 @@ class CallHierarchyItem {
|
||||
required this.codeRange,
|
||||
});
|
||||
|
||||
CallHierarchyItem.forElement(Element2 element)
|
||||
CallHierarchyItem.forElement(Element element)
|
||||
: displayName = _getDisplayName(element),
|
||||
nameRange = _nameRangeForElement(element),
|
||||
codeRange = _codeRangeForElement(element),
|
||||
@@ -117,7 +117,7 @@ class CallHierarchyItem {
|
||||
}
|
||||
|
||||
/// Returns the [SourceRange] of the code for [element].
|
||||
static SourceRange _codeRangeForElement(Element2 element) {
|
||||
static SourceRange _codeRangeForElement(Element element) {
|
||||
// For synthetic items (like implicit constructors), use the nonSynthetic
|
||||
// element for the location.
|
||||
element = _nonSynthetic(element);
|
||||
@@ -130,7 +130,7 @@ class CallHierarchyItem {
|
||||
}
|
||||
|
||||
/// Returns the [SourceRange] of the name for [element].
|
||||
static SourceRange _nameRangeForElement(Element2 element) {
|
||||
static SourceRange _nameRangeForElement(Element element) {
|
||||
// For synthetic items (like implicit constructors), use the nonSynthetic
|
||||
// element for the location.
|
||||
element = _nonSynthetic(element);
|
||||
@@ -143,7 +143,7 @@ class CallHierarchyItem {
|
||||
: SourceRange(fragment.nameOffset, fragment.nameLength);
|
||||
}
|
||||
|
||||
static Element2 _nonSynthetic(Element2 element) {
|
||||
static Element _nonSynthetic(Element element) {
|
||||
element = element.nonSynthetic2;
|
||||
if (element.isSynthetic) {
|
||||
element = element.enclosingElement2 ?? element;
|
||||
@@ -177,7 +177,7 @@ enum CallHierarchyKind {
|
||||
ElementKind.SETTER: property,
|
||||
};
|
||||
|
||||
static CallHierarchyKind forElement(Element2 element) =>
|
||||
static CallHierarchyKind forElement(Element element) =>
|
||||
_elementMapping[element.kind] ?? unknown;
|
||||
}
|
||||
|
||||
@@ -224,14 +224,14 @@ class DartCallHierarchyComputer {
|
||||
// implicit constructors do not have.
|
||||
// Here, we map them back to the synthetic constructor element.
|
||||
var isImplicitConstructor =
|
||||
element is InterfaceElement2 &&
|
||||
element is InterfaceElement &&
|
||||
target.kind == CallHierarchyKind.constructor;
|
||||
if (isImplicitConstructor) {
|
||||
element = element.unnamedConstructor2;
|
||||
}
|
||||
|
||||
// We only find incoming calls to executable elements.
|
||||
if (element is! ExecutableElement2) {
|
||||
if (element is! ExecutableElement) {
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -240,7 +240,7 @@ class DartCallHierarchyComputer {
|
||||
|
||||
// Group results by their container, since we only want to return a single
|
||||
// entry for a body, with a set of ranges within.
|
||||
var resultsByContainer = <Element2, CallHierarchyCalls>{};
|
||||
var resultsByContainer = <Element, CallHierarchyCalls>{};
|
||||
// We may need to fetch parsed results for the other files, reuse them
|
||||
// across calls.
|
||||
var parsedUnits = <String, SomeParsedUnitResult?>{};
|
||||
@@ -293,7 +293,7 @@ class DartCallHierarchyComputer {
|
||||
|
||||
// Group results by their target, since we only want to return a single
|
||||
// entry for each target, with a set of ranges that call it.
|
||||
var resultsByTarget = <Element2, CallHierarchyCalls>{};
|
||||
var resultsByTarget = <Element, CallHierarchyCalls>{};
|
||||
for (var referenceNode in referenceNodes) {
|
||||
var target = _getElementOfNode(referenceNode);
|
||||
if (target == null) {
|
||||
@@ -316,14 +316,14 @@ class DartCallHierarchyComputer {
|
||||
|
||||
/// Finds a target for starting call hierarchy navigation at [offset].
|
||||
///
|
||||
/// If [offset] is an invocation, returns information about the [Element2] it
|
||||
/// If [offset] is an invocation, returns information about the [Element] it
|
||||
/// refers to.
|
||||
CallHierarchyItem? findTarget(int offset) {
|
||||
var node = _findTargetNode(offset);
|
||||
var element = _getElementOfNode(node);
|
||||
|
||||
// We only return targets that are executable elements.
|
||||
return element is ExecutableElement2
|
||||
return element is ExecutableElement
|
||||
? CallHierarchyItem.forElement(element)
|
||||
: null;
|
||||
}
|
||||
@@ -359,10 +359,10 @@ class DartCallHierarchyComputer {
|
||||
return node;
|
||||
}
|
||||
|
||||
/// Return the [Element2] of the given [node], or `null` if [node] is `null`,
|
||||
/// Return the [Element] of the given [node], or `null` if [node] is `null`,
|
||||
/// does not have an element, or the element is not a valid target for call
|
||||
/// hierarchy.
|
||||
Element2? _getElementOfNode(AstNode? node) {
|
||||
Element? _getElementOfNode(AstNode? node) {
|
||||
if (node == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -382,7 +382,7 @@ class DartCallHierarchyComputer {
|
||||
|
||||
// Don't consider synthetic getter/setter for a field to be executable
|
||||
// since they don't contain any executable code.
|
||||
if (element is PropertyAccessorElement2 && element.isSynthetic) {
|
||||
if (element is PropertyAccessorElement && element.isSynthetic) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -394,7 +394,7 @@ class DartCallHierarchyComputer {
|
||||
/// This is used to ensure calls are only returned for the expected target
|
||||
/// if source code has changed since the earlier request that provided
|
||||
/// [target] to the client.
|
||||
bool _isMatchingElement(Element2 element, CallHierarchyItem target) {
|
||||
bool _isMatchingElement(Element element, CallHierarchyItem target) {
|
||||
return _getDisplayName(element) == target.displayName;
|
||||
}
|
||||
|
||||
|
||||
@@ -225,15 +225,15 @@ class ColorComputer {
|
||||
}
|
||||
|
||||
/// Checks whether this elements library is dart:ui.
|
||||
bool _isDartUi(Element2? element) => element?.library2?.name3 == 'dart.ui';
|
||||
bool _isDartUi(Element? element) => element?.library2?.name3 == 'dart.ui';
|
||||
|
||||
/// Checks whether this elements library is Flutter Material colors.
|
||||
bool _isFlutterMaterial(Element2? element) =>
|
||||
bool _isFlutterMaterial(Element? element) =>
|
||||
element?.library2?.identifier ==
|
||||
'package:flutter/src/material/colors.dart';
|
||||
|
||||
/// Checks whether this elements library is Flutter Painting colors.
|
||||
bool _isFlutterPainting(Element2? element) =>
|
||||
bool _isFlutterPainting(Element? element) =>
|
||||
element?.library2?.identifier ==
|
||||
'package:flutter/src/painting/colors.dart';
|
||||
|
||||
|
||||
@@ -7,18 +7,18 @@ import 'package:analysis_server/src/utilities/extensions/element.dart';
|
||||
import 'package:analyzer/dart/element/element.dart';
|
||||
import 'package:analyzer/src/dartdoc/dartdoc_directive_info.dart';
|
||||
|
||||
/// Computes documentation for an [Element2].
|
||||
/// Computes documentation for an [Element].
|
||||
class DartDocumentationComputer {
|
||||
final DartdocDirectiveInfo dartdocInfo;
|
||||
|
||||
DartDocumentationComputer(this.dartdocInfo);
|
||||
|
||||
Documentation? compute(
|
||||
Element2 elementBeingDocumented, {
|
||||
Element elementBeingDocumented, {
|
||||
bool includeSummary = false,
|
||||
}) {
|
||||
var element = switch (elementBeingDocumented) {
|
||||
FieldFormalParameterElement2() => elementBeingDocumented.field2,
|
||||
FieldFormalParameterElement() => elementBeingDocumented.field2,
|
||||
FormalParameterElement() => elementBeingDocumented.enclosingElement2,
|
||||
_ => elementBeingDocumented,
|
||||
};
|
||||
@@ -28,8 +28,8 @@ class DartDocumentationComputer {
|
||||
return null;
|
||||
}
|
||||
|
||||
Element2? documentedElement;
|
||||
Element2? documentedGetter;
|
||||
Element? documentedElement;
|
||||
Element? documentedGetter;
|
||||
|
||||
// Look for documentation comments of overridden members
|
||||
var overridden = findOverriddenElements(element);
|
||||
@@ -37,7 +37,7 @@ class DartDocumentationComputer {
|
||||
element,
|
||||
...overridden.superElements,
|
||||
...overridden.interfaceElements,
|
||||
if (element case PropertyAccessorElement2(variable3: var variable?))
|
||||
if (element case PropertyAccessorElement(variable3: var variable?))
|
||||
variable,
|
||||
];
|
||||
for (var candidate in candidates) {
|
||||
@@ -81,7 +81,7 @@ class DartDocumentationComputer {
|
||||
/// Compute documentation for [element] and return either the summary or full
|
||||
/// docs (or `null`) depending on `preference`.
|
||||
String? computePreferred(
|
||||
Element2 element,
|
||||
Element element,
|
||||
DocumentationPreference preference,
|
||||
) {
|
||||
if (preference == DocumentationPreference.none) {
|
||||
|
||||
@@ -102,7 +102,7 @@ class DartUnitHighlightsComputer {
|
||||
void _addIdentifierRegion({
|
||||
required AstNode parent,
|
||||
required Token nameToken,
|
||||
required Element2? element,
|
||||
required Element? element,
|
||||
}) {
|
||||
if (_addIdentifierRegion_keyword(nameToken)) {
|
||||
return;
|
||||
@@ -177,9 +177,9 @@ class DartUnitHighlightsComputer {
|
||||
bool _addIdentifierRegion_class(
|
||||
AstNode parent,
|
||||
Token nameToken,
|
||||
Element2? element,
|
||||
Element? element,
|
||||
) {
|
||||
if (element is! InterfaceElement2) {
|
||||
if (element is! InterfaceElement) {
|
||||
return false;
|
||||
}
|
||||
// prepare type
|
||||
@@ -194,9 +194,9 @@ class DartUnitHighlightsComputer {
|
||||
type = HighlightRegionType.CONSTRUCTOR;
|
||||
semanticType = SemanticTokenTypes.class_;
|
||||
semanticModifiers = {CustomSemanticTokenModifiers.constructor};
|
||||
} else if (element is EnumElement2) {
|
||||
} else if (element is EnumElement) {
|
||||
type = HighlightRegionType.ENUM;
|
||||
} else if (element is ExtensionTypeElement2) {
|
||||
} else if (element is ExtensionTypeElement) {
|
||||
type = HighlightRegionType.EXTENSION_TYPE;
|
||||
} else {
|
||||
type = HighlightRegionType.CLASS;
|
||||
@@ -224,9 +224,9 @@ class DartUnitHighlightsComputer {
|
||||
bool _addIdentifierRegion_constructor(
|
||||
AstNode parent,
|
||||
Token nameToken,
|
||||
Element2? element,
|
||||
Element? element,
|
||||
) {
|
||||
if (element is! ConstructorElement2) {
|
||||
if (element is! ConstructorElement) {
|
||||
return false;
|
||||
}
|
||||
return _addRegion_token(
|
||||
@@ -243,8 +243,8 @@ class DartUnitHighlightsComputer {
|
||||
);
|
||||
}
|
||||
|
||||
bool _addIdentifierRegion_extension(Token nameToken, Element2? element) {
|
||||
if (element is! ExtensionElement2) {
|
||||
bool _addIdentifierRegion_extension(Token nameToken, Element? element) {
|
||||
if (element is! ExtensionElement) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -254,11 +254,11 @@ class DartUnitHighlightsComputer {
|
||||
bool _addIdentifierRegion_field(
|
||||
AstNode parent,
|
||||
Token nameToken,
|
||||
Element2? element,
|
||||
Element? element,
|
||||
) {
|
||||
// Compute the type of the identifier.
|
||||
HighlightRegionType? type;
|
||||
if (element is FieldElement2) {
|
||||
if (element is FieldElement) {
|
||||
if (element.isEnumConstant) {
|
||||
type = HighlightRegionType.ENUM_CONSTANT;
|
||||
} else if (element.isStatic) {
|
||||
@@ -266,14 +266,14 @@ class DartUnitHighlightsComputer {
|
||||
} else {
|
||||
type = HighlightRegionType.INSTANCE_FIELD_REFERENCE;
|
||||
}
|
||||
} else if (element is TopLevelVariableElement2) {
|
||||
} else if (element is TopLevelVariableElement) {
|
||||
type = HighlightRegionType.TOP_LEVEL_VARIABLE_DECLARATION;
|
||||
} else if (element is GetterElement) {
|
||||
var accessor = element;
|
||||
var variable = accessor.variable3;
|
||||
if (variable is TopLevelVariableElement2) {
|
||||
if (variable is TopLevelVariableElement) {
|
||||
type = HighlightRegionType.TOP_LEVEL_GETTER_REFERENCE;
|
||||
} else if (variable is FieldElement2 && variable.isEnumConstant) {
|
||||
} else if (variable is FieldElement && variable.isEnumConstant) {
|
||||
type = HighlightRegionType.ENUM_CONSTANT;
|
||||
} else if (accessor.isStatic) {
|
||||
type = HighlightRegionType.STATIC_GETTER_REFERENCE;
|
||||
@@ -283,9 +283,9 @@ class DartUnitHighlightsComputer {
|
||||
} else if (element is SetterElement) {
|
||||
var accessor = element;
|
||||
var variable = accessor.variable3;
|
||||
if (variable is TopLevelVariableElement2) {
|
||||
if (variable is TopLevelVariableElement) {
|
||||
type = HighlightRegionType.TOP_LEVEL_SETTER_REFERENCE;
|
||||
} else if (variable is FieldElement2 && variable.isEnumConstant) {
|
||||
} else if (variable is FieldElement && variable.isEnumConstant) {
|
||||
type = HighlightRegionType.ENUM_CONSTANT;
|
||||
} else if (accessor.isStatic) {
|
||||
type = HighlightRegionType.STATIC_SETTER_REFERENCE;
|
||||
@@ -321,7 +321,7 @@ class DartUnitHighlightsComputer {
|
||||
bool _addIdentifierRegion_function(
|
||||
AstNode parent,
|
||||
Token nameToken,
|
||||
Element2? element,
|
||||
Element? element,
|
||||
) {
|
||||
if (element is! TopLevelFunctionElement &&
|
||||
element is! LocalFunctionElement) {
|
||||
@@ -345,7 +345,7 @@ class DartUnitHighlightsComputer {
|
||||
bool _addIdentifierRegion_getterSetterDeclaration(
|
||||
AstNode parent,
|
||||
Token nameToken,
|
||||
Element2? element,
|
||||
Element? element,
|
||||
) {
|
||||
// should be declaration
|
||||
if (!(parent is MethodDeclaration || parent is FunctionDeclaration)) {
|
||||
@@ -376,8 +376,8 @@ class DartUnitHighlightsComputer {
|
||||
return _addRegion_token(nameToken, type);
|
||||
}
|
||||
|
||||
bool _addIdentifierRegion_importPrefix(Token nameToken, Element2? element) {
|
||||
if (element is! PrefixElement2) {
|
||||
bool _addIdentifierRegion_importPrefix(Token nameToken, Element? element) {
|
||||
if (element is! PrefixElement) {
|
||||
return false;
|
||||
}
|
||||
return _addRegion_token(nameToken, HighlightRegionType.IMPORT_PREFIX);
|
||||
@@ -395,15 +395,15 @@ class DartUnitHighlightsComputer {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool _addIdentifierRegion_label(Token nameToken, Element2? element) {
|
||||
if (element is! LabelElement2) {
|
||||
bool _addIdentifierRegion_label(Token nameToken, Element? element) {
|
||||
if (element is! LabelElement) {
|
||||
return false;
|
||||
}
|
||||
return _addRegion_token(nameToken, HighlightRegionType.LABEL);
|
||||
}
|
||||
|
||||
bool _addIdentifierRegion_localVariable(Token nameToken, Element2? element) {
|
||||
if (element is! LocalVariableElement2) {
|
||||
bool _addIdentifierRegion_localVariable(Token nameToken, Element? element) {
|
||||
if (element is! LocalVariableElement) {
|
||||
return false;
|
||||
}
|
||||
// OK
|
||||
@@ -417,9 +417,9 @@ class DartUnitHighlightsComputer {
|
||||
bool _addIdentifierRegion_method(
|
||||
AstNode parent,
|
||||
Token nameToken,
|
||||
Element2? element,
|
||||
Element? element,
|
||||
) {
|
||||
if (element is! MethodElement2) {
|
||||
if (element is! MethodElement) {
|
||||
return false;
|
||||
}
|
||||
var isStatic = element.isStatic;
|
||||
@@ -444,7 +444,7 @@ class DartUnitHighlightsComputer {
|
||||
bool _addIdentifierRegion_parameter(
|
||||
AstNode parent,
|
||||
Token nameToken,
|
||||
Element2? element,
|
||||
Element? element,
|
||||
) {
|
||||
if (element is! FormalParameterElement) {
|
||||
return false;
|
||||
@@ -458,8 +458,8 @@ class DartUnitHighlightsComputer {
|
||||
return _addRegion_token(nameToken, type, semanticTokenModifiers: modifiers);
|
||||
}
|
||||
|
||||
bool _addIdentifierRegion_typeAlias(Token nameToken, Element2? element) {
|
||||
if (element is TypeAliasElement2) {
|
||||
bool _addIdentifierRegion_typeAlias(Token nameToken, Element? element) {
|
||||
if (element is TypeAliasElement) {
|
||||
var type =
|
||||
element.aliasedType is FunctionType
|
||||
? HighlightRegionType.FUNCTION_TYPE_ALIAS
|
||||
@@ -469,8 +469,8 @@ class DartUnitHighlightsComputer {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool _addIdentifierRegion_typeParameter(Token nameToken, Element2? element) {
|
||||
if (element is! TypeParameterElement2) {
|
||||
bool _addIdentifierRegion_typeParameter(Token nameToken, Element? element) {
|
||||
if (element is! TypeParameterElement) {
|
||||
return false;
|
||||
}
|
||||
return _addRegion_token(
|
||||
@@ -483,7 +483,7 @@ class DartUnitHighlightsComputer {
|
||||
bool _addIdentifierRegion_unresolvedInstanceMemberReference(
|
||||
AstNode parent,
|
||||
Token nameToken,
|
||||
Element2? element,
|
||||
Element? element,
|
||||
) {
|
||||
// unresolved
|
||||
if (element != null) {
|
||||
@@ -518,7 +518,7 @@ class DartUnitHighlightsComputer {
|
||||
/// Returns a set of additional semantic token modifiers that apply to
|
||||
/// [element].
|
||||
Set<SemanticTokenModifiers>? _additionalModifiersForElement(
|
||||
Element2? element,
|
||||
Element? element,
|
||||
) {
|
||||
return (element?.isWildcardVariable ?? false)
|
||||
? {CustomSemanticTokenModifiers.wildcard}
|
||||
@@ -1507,7 +1507,7 @@ class _DartUnitHighlightsComputerVisitor extends RecursiveAstVisitor<void> {
|
||||
// Patterns can be method tear-offs as well as getters:
|
||||
// https://github.com/dart-lang/sdk/issues/59976#issuecomment-2613558317
|
||||
var type = switch (node.element2) {
|
||||
MethodElement2() => HighlightRegionType.INSTANCE_METHOD_TEAR_OFF,
|
||||
MethodElement() => HighlightRegionType.INSTANCE_METHOD_TEAR_OFF,
|
||||
_ => HighlightRegionType.INSTANCE_GETTER_REFERENCE,
|
||||
};
|
||||
|
||||
@@ -1794,14 +1794,14 @@ class _DartUnitHighlightsComputerVisitor extends RecursiveAstVisitor<void> {
|
||||
@override
|
||||
void visitVariableDeclaration(VariableDeclaration node) {
|
||||
var element = node.declaredFragment?.element ?? node.declaredElement2;
|
||||
if (element is FieldElement2) {
|
||||
if (element is FieldElement) {
|
||||
computer._addRegion_token(
|
||||
node.name,
|
||||
element.isStatic
|
||||
? HighlightRegionType.STATIC_FIELD_DECLARATION
|
||||
: HighlightRegionType.INSTANCE_FIELD_DECLARATION,
|
||||
);
|
||||
} else if (element is LocalVariableElement2) {
|
||||
} else if (element is LocalVariableElement) {
|
||||
computer._addRegion_token(
|
||||
node.name,
|
||||
element.type is DynamicType
|
||||
@@ -1811,7 +1811,7 @@ class _DartUnitHighlightsComputerVisitor extends RecursiveAstVisitor<void> {
|
||||
element,
|
||||
),
|
||||
);
|
||||
} else if (element is TopLevelVariableElement2) {
|
||||
} else if (element is TopLevelVariableElement) {
|
||||
computer._addRegion_token(
|
||||
node.name,
|
||||
HighlightRegionType.TOP_LEVEL_VARIABLE_DECLARATION,
|
||||
@@ -1888,7 +1888,7 @@ class _DartUnitHighlightsComputerVisitor extends RecursiveAstVisitor<void> {
|
||||
/// Returns a set of additional semantic token modifiers that apply to
|
||||
/// [element].
|
||||
Set<SemanticTokenModifiers>? _additionalModifiersForElement(
|
||||
Element2? element,
|
||||
Element? element,
|
||||
) {
|
||||
return computer._additionalModifiersForElement(element);
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ class DartUnitHoverComputer {
|
||||
hover.isDeprecated = a.metadata2.hasDeprecated;
|
||||
}
|
||||
// not local element
|
||||
if (element.enclosingElement2 is! ExecutableElement2) {
|
||||
if (element.enclosingElement2 is! ExecutableElement) {
|
||||
// containing class
|
||||
hover.containingClassDescription = _containingClass(element);
|
||||
// containing library
|
||||
@@ -98,8 +98,8 @@ class DartUnitHoverComputer {
|
||||
}
|
||||
|
||||
/// Gets the name of the containing class of [element].
|
||||
String? _containingClass(Element2 element) {
|
||||
var containingClass = element.thisOrAncestorOfType2<InterfaceElement2>();
|
||||
String? _containingClass(Element element) {
|
||||
var containingClass = element.thisOrAncestorOfType2<InterfaceElement>();
|
||||
return containingClass != null && containingClass != element
|
||||
? containingClass.displayName
|
||||
: null;
|
||||
@@ -110,7 +110,7 @@ class DartUnitHoverComputer {
|
||||
/// This is usually `element.getDisplayString()` but may contain additional
|
||||
/// information to disambiguate things like constructors from types (and
|
||||
/// whether they are const).
|
||||
String? _elementDisplayString(AstNode node, Element2? element) {
|
||||
String? _elementDisplayString(AstNode node, Element? element) {
|
||||
var displayString = element?.displayString2(multiline: true);
|
||||
|
||||
if (displayString != null &&
|
||||
@@ -146,7 +146,7 @@ class DartUnitHoverComputer {
|
||||
}
|
||||
|
||||
/// Returns information about the library that contains [element].
|
||||
_LibraryInfo _libraryInfo(Element2 element) {
|
||||
_LibraryInfo _libraryInfo(Element element) {
|
||||
var library = element.library2;
|
||||
if (library == null) {
|
||||
return null;
|
||||
@@ -218,7 +218,7 @@ class DartUnitHoverComputer {
|
||||
// hovers because information about those functions are already available
|
||||
// by hovering over the function name or the operator.
|
||||
SetterElement() => null,
|
||||
MethodElement2 method when method.isOperator => null,
|
||||
MethodElement method when method.isOperator => null,
|
||||
_ => _elementDisplayString(node, parameter),
|
||||
};
|
||||
}
|
||||
@@ -243,16 +243,16 @@ class DartUnitHoverComputer {
|
||||
}
|
||||
|
||||
/// Returns information about the static type of [node].
|
||||
String? _typeDisplayString(AstNode node, Element2? element) {
|
||||
String? _typeDisplayString(AstNode node, Element? element) {
|
||||
var parent = node.parent;
|
||||
DartType? staticType;
|
||||
if (node is Expression &&
|
||||
(element == null ||
|
||||
element is VariableElement2 ||
|
||||
element is VariableElement ||
|
||||
element is GetterElement ||
|
||||
element is SetterElement)) {
|
||||
staticType = _getTypeOfDeclarationOrReference(node);
|
||||
} else if (element is VariableElement2) {
|
||||
} else if (element is VariableElement) {
|
||||
staticType = element.type;
|
||||
} else if (parent is MethodInvocation && parent.methodName == node) {
|
||||
staticType = parent.staticInvokeType;
|
||||
@@ -270,7 +270,7 @@ class DartUnitHoverComputer {
|
||||
static DartType? _getTypeOfDeclarationOrReference(Expression node) {
|
||||
if (node is SimpleIdentifier) {
|
||||
var element = node.element;
|
||||
if (element is VariableElement2) {
|
||||
if (element is VariableElement) {
|
||||
if (node.inDeclarationContext()) {
|
||||
return element.type;
|
||||
}
|
||||
|
||||
@@ -203,7 +203,7 @@ class DartInlayHintComputer {
|
||||
}
|
||||
}
|
||||
|
||||
Location? _locationForElement(Element2? element) {
|
||||
Location? _locationForElement(Element? element) {
|
||||
if (element == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -272,7 +272,7 @@ class _DartInlayHintComputerVisitor extends GeneralizingAstVisitor<void> {
|
||||
}
|
||||
|
||||
var declaration = node.declaredElement2;
|
||||
if (declaration is LocalVariableElement2) {
|
||||
if (declaration is LocalVariableElement) {
|
||||
_computer._addTypePrefix(node.name, declaration.type);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,20 +35,20 @@ class DartLazyTypeHierarchyComputer {
|
||||
|
||||
DartLazyTypeHierarchyComputer(this._result);
|
||||
|
||||
/// Finds subtypes for the [Element2] at [location].
|
||||
/// Finds subtypes for the [Element] at [location].
|
||||
Future<List<TypeHierarchyRelatedItem>?> findSubtypes(
|
||||
ElementLocation location,
|
||||
SearchEngine searchEngine,
|
||||
) async {
|
||||
var targetElement = await _findTargetElement(location);
|
||||
if (targetElement is! InterfaceElement2) {
|
||||
if (targetElement is! InterfaceElement) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return _getSubtypes(targetElement, searchEngine);
|
||||
}
|
||||
|
||||
/// Finds supertypes for the [Element2] at [location].
|
||||
/// Finds supertypes for the [Element] at [location].
|
||||
Future<List<TypeHierarchyRelatedItem>?> findSupertypes(
|
||||
ElementLocation location,
|
||||
) async {
|
||||
@@ -76,7 +76,7 @@ class DartLazyTypeHierarchyComputer {
|
||||
(node) => _isValidTargetDeclaration(node),
|
||||
);
|
||||
var element = declaration?.declaredFragment?.element;
|
||||
if (element is InterfaceElement2) {
|
||||
if (element is InterfaceElement) {
|
||||
type = element.thisType;
|
||||
}
|
||||
}
|
||||
@@ -86,22 +86,20 @@ class DartLazyTypeHierarchyComputer {
|
||||
: null;
|
||||
}
|
||||
|
||||
/// Locate the [Element2] referenced by [location].
|
||||
Future<InterfaceElement2?> _findTargetElement(
|
||||
ElementLocation location,
|
||||
) async {
|
||||
/// Locate the [Element] referenced by [location].
|
||||
Future<InterfaceElement?> _findTargetElement(ElementLocation location) async {
|
||||
var element = await location.locateIn(_result.session);
|
||||
return element is InterfaceElement2 ? element : null;
|
||||
return element is InterfaceElement ? element : null;
|
||||
}
|
||||
|
||||
/// Gets immediate subtypes for the class/mixin [target].
|
||||
Future<List<TypeHierarchyRelatedItem>> _getSubtypes(
|
||||
InterfaceElement2 target,
|
||||
InterfaceElement target,
|
||||
SearchEngine searchEngine,
|
||||
) async {
|
||||
/// Helper to convert a [SearchMatch] to a [TypeHierarchyRelatedItem].
|
||||
TypeHierarchyRelatedItem? toHierarchyItem(SearchMatch match) {
|
||||
var element = match.element as InterfaceElement2;
|
||||
var element = match.element as InterfaceElement;
|
||||
var type = element.thisType;
|
||||
switch (match.kind) {
|
||||
case MatchKind.REFERENCE_IN_EXTENDS_CLAUSE:
|
||||
@@ -122,7 +120,7 @@ class DartLazyTypeHierarchyComputer {
|
||||
target,
|
||||
SearchEngineCache(),
|
||||
);
|
||||
var seenElements = <Element2>{};
|
||||
var seenElements = <Element>{};
|
||||
return matches
|
||||
.where((match) => seenElements.add(match.element))
|
||||
.map(toHierarchyItem)
|
||||
@@ -202,14 +200,14 @@ class TypeHierarchyItem {
|
||||
});
|
||||
|
||||
TypeHierarchyItem._forElement({
|
||||
required InterfaceElement2 element,
|
||||
required InterfaceElement element,
|
||||
required this.location,
|
||||
}) : displayName = _displayNameForElement(element),
|
||||
nameRange = _nameRangeForElement(element),
|
||||
codeRange = _codeRangeForElement(element),
|
||||
file = element.firstFragment.libraryFragment.source.fullName;
|
||||
|
||||
static TypeHierarchyItem? forElement(InterfaceElement2 element) {
|
||||
static TypeHierarchyItem? forElement(InterfaceElement element) {
|
||||
var location = ElementLocation.forElement(element);
|
||||
if (location == null) return null;
|
||||
|
||||
@@ -217,19 +215,19 @@ class TypeHierarchyItem {
|
||||
}
|
||||
|
||||
/// Returns the [SourceRange] of the code for [element].
|
||||
static SourceRange _codeRangeForElement(Element2 element) {
|
||||
static SourceRange _codeRangeForElement(Element element) {
|
||||
// Non-synthetic elements should always have code locations.
|
||||
var firstFragment = element.nonSynthetic2.firstFragment as ElementImpl;
|
||||
return SourceRange(firstFragment.codeOffset!, firstFragment.codeLength!);
|
||||
}
|
||||
|
||||
/// Returns a name to display in the hierarchy for [element].
|
||||
static String _displayNameForElement(InterfaceElement2 element) {
|
||||
static String _displayNameForElement(InterfaceElement element) {
|
||||
return element.baseElement.thisType.getDisplayString();
|
||||
}
|
||||
|
||||
/// Returns the [SourceRange] of the name for [element].
|
||||
static SourceRange _nameRangeForElement(Element2 element) {
|
||||
static SourceRange _nameRangeForElement(Element element) {
|
||||
var fragment = element.nonSynthetic2.firstFragment;
|
||||
|
||||
// Some non-synthetic items can still have invalid nameOffsets (for example
|
||||
@@ -288,7 +286,7 @@ class TypeHierarchyRelatedItem extends TypeHierarchyItem {
|
||||
);
|
||||
|
||||
static TypeHierarchyRelatedItem? _forElement(
|
||||
InterfaceElement2 element, {
|
||||
InterfaceElement element, {
|
||||
required TypeHierarchyItemRelationship relationship,
|
||||
}) {
|
||||
var location = ElementLocation.forElement(element);
|
||||
|
||||
@@ -534,7 +534,7 @@ class _FunctionBodyOutlinesVisitor extends RecursiveAstVisitor<void> {
|
||||
|
||||
/// Return `true` if the given [element] is the method 'group' defined in the
|
||||
/// test package.
|
||||
bool isGroup(engine.ExecutableElement2? element) {
|
||||
bool isGroup(engine.ExecutableElement? element) {
|
||||
if (element != null && element.metadata2.hasIsTestGroup) {
|
||||
return true;
|
||||
}
|
||||
@@ -545,7 +545,7 @@ class _FunctionBodyOutlinesVisitor extends RecursiveAstVisitor<void> {
|
||||
|
||||
/// Return `true` if the given [element] is the method 'test' defined in the
|
||||
/// test package.
|
||||
bool isTest(engine.ExecutableElement2? element) {
|
||||
bool isTest(engine.ExecutableElement? element) {
|
||||
if (element != null && element.metadata2.hasIsTest) {
|
||||
return true;
|
||||
}
|
||||
@@ -597,7 +597,7 @@ class _FunctionBodyOutlinesVisitor extends RecursiveAstVisitor<void> {
|
||||
var nameNode = node.methodName;
|
||||
|
||||
var nameElement = nameNode.element;
|
||||
if (nameElement is! engine.ExecutableElement2) {
|
||||
if (nameElement is! engine.ExecutableElement) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,11 +10,11 @@ import 'package:analyzer/dart/element/element.dart';
|
||||
import 'package:collection/collection.dart';
|
||||
|
||||
/// Return the elements that the given [element] overrides.
|
||||
OverriddenElements findOverriddenElements(Element2 element) {
|
||||
if (element.enclosingElement2 is InterfaceElement2) {
|
||||
OverriddenElements findOverriddenElements(Element element) {
|
||||
if (element.enclosingElement2 is InterfaceElement) {
|
||||
return _OverriddenElementsFinder(element).find();
|
||||
}
|
||||
return OverriddenElements(element, <Element2>[], <Element2>[]);
|
||||
return OverriddenElements(element, <Element>[], <Element>[]);
|
||||
}
|
||||
|
||||
/// A computer for class member overrides in a Dart [CompilationUnit].
|
||||
@@ -42,7 +42,7 @@ class DartUnitOverridesComputer {
|
||||
|
||||
/// Add a new [proto.Override] for the declaration with the given name
|
||||
/// [token].
|
||||
void _addOverride(Token token, Element2? element) {
|
||||
void _addOverride(Token token, Element? element) {
|
||||
if (element != null) {
|
||||
var overridesResult = _OverriddenElementsFinder(element).find();
|
||||
var superElements = overridesResult.superElements;
|
||||
@@ -98,38 +98,38 @@ class DartUnitOverridesComputer {
|
||||
/// The container with elements that a class member overrides.
|
||||
class OverriddenElements {
|
||||
/// The element that overrides other class members.
|
||||
final Element2 element;
|
||||
final Element element;
|
||||
|
||||
/// The elements that [element] overrides and which is defined in a class that
|
||||
/// is a superclass of the class that defines [element].
|
||||
final List<Element2> superElements;
|
||||
final List<Element> superElements;
|
||||
|
||||
/// The elements that [element] overrides and which is defined in a class that
|
||||
/// which is implemented by the class that defines [element].
|
||||
final List<Element2> interfaceElements;
|
||||
final List<Element> interfaceElements;
|
||||
|
||||
OverriddenElements(this.element, this.superElements, this.interfaceElements);
|
||||
}
|
||||
|
||||
class _OverriddenElementsFinder {
|
||||
Element2 _seed;
|
||||
LibraryElement2 _library;
|
||||
InterfaceElement2 _class;
|
||||
Element _seed;
|
||||
LibraryElement _library;
|
||||
InterfaceElement _class;
|
||||
String _name;
|
||||
List<ElementKind> _kinds;
|
||||
|
||||
final List<Element2> _superElements = <Element2>[];
|
||||
final List<Element2> _interfaceElements = <Element2>[];
|
||||
final Set<InterfaceElement2> _visited = {};
|
||||
final List<Element> _superElements = <Element>[];
|
||||
final List<Element> _interfaceElements = <Element>[];
|
||||
final Set<InterfaceElement> _visited = {};
|
||||
|
||||
factory _OverriddenElementsFinder(Element2 seed) {
|
||||
var class_ = seed.enclosingElement2 as InterfaceElement2;
|
||||
factory _OverriddenElementsFinder(Element seed) {
|
||||
var class_ = seed.enclosingElement2 as InterfaceElement;
|
||||
var library = class_.library2;
|
||||
var name = seed.displayName;
|
||||
List<ElementKind> kinds;
|
||||
if (seed is FieldElement2) {
|
||||
if (seed is FieldElement) {
|
||||
kinds = [ElementKind.GETTER, if (!seed.isFinal) ElementKind.SETTER];
|
||||
} else if (seed is MethodElement2) {
|
||||
} else if (seed is MethodElement) {
|
||||
kinds = const [ElementKind.METHOD];
|
||||
} else if (seed is GetterElement) {
|
||||
kinds = const [ElementKind.GETTER];
|
||||
@@ -159,7 +159,7 @@ class _OverriddenElementsFinder {
|
||||
return OverriddenElements(_seed, _superElements, _interfaceElements);
|
||||
}
|
||||
|
||||
void _addInterfaceOverrides(InterfaceElement2? class_, bool checkType) {
|
||||
void _addInterfaceOverrides(InterfaceElement? class_, bool checkType) {
|
||||
if (class_ == null) {
|
||||
return;
|
||||
}
|
||||
@@ -179,7 +179,7 @@ class _OverriddenElementsFinder {
|
||||
}
|
||||
// super
|
||||
_addInterfaceOverrides(class_.supertype?.element3, checkType);
|
||||
if (class_ is MixinElement2) {
|
||||
if (class_ is MixinElement) {
|
||||
for (var constraint in class_.superclassConstraints) {
|
||||
_addInterfaceOverrides(constraint.element3, true);
|
||||
}
|
||||
@@ -187,7 +187,7 @@ class _OverriddenElementsFinder {
|
||||
}
|
||||
|
||||
void _addSuperOverrides(
|
||||
InterfaceElement2? class_, {
|
||||
InterfaceElement? class_, {
|
||||
bool withThisType = true,
|
||||
}) {
|
||||
if (class_ == null) {
|
||||
@@ -208,16 +208,16 @@ class _OverriddenElementsFinder {
|
||||
for (var mixin_ in class_.mixins) {
|
||||
_addSuperOverrides(mixin_.element3);
|
||||
}
|
||||
if (class_ is MixinElement2) {
|
||||
if (class_ is MixinElement) {
|
||||
for (var constraint in class_.superclassConstraints) {
|
||||
_addSuperOverrides(constraint.element3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Element2? _lookupMember(InterfaceElement2 classElement) {
|
||||
Element2? findMatchingElement(Iterable<Element2> elements) {
|
||||
return elements.firstWhereOrNull((Element2 element) {
|
||||
Element? _lookupMember(InterfaceElement classElement) {
|
||||
Element? findMatchingElement(Iterable<Element> elements) {
|
||||
return elements.firstWhereOrNull((Element element) {
|
||||
if (!identical(element.library2, _library) && _name.startsWith('_')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -38,14 +38,14 @@ class DartUnitSignatureComputer {
|
||||
}
|
||||
var (argumentList, argument) = argumentAndList;
|
||||
String? name;
|
||||
Element2? element;
|
||||
Element? element;
|
||||
List<FormalParameterElement>? parameters;
|
||||
var parent = argumentList.parent;
|
||||
if (parent is MethodInvocation) {
|
||||
name = parent.methodName.name;
|
||||
element = ElementLocator.locate2(parent);
|
||||
parameters =
|
||||
element is FunctionTypedElement2 ? element.formalParameters : null;
|
||||
element is FunctionTypedElement ? element.formalParameters : null;
|
||||
} else if (parent is InstanceCreationExpression) {
|
||||
name = parent.constructorName.type.qualifiedName;
|
||||
var constructorName = parent.constructorName.name;
|
||||
@@ -54,7 +54,7 @@ class DartUnitSignatureComputer {
|
||||
}
|
||||
element = ElementLocator.locate2(parent);
|
||||
parameters =
|
||||
element is FunctionTypedElement2 ? element.formalParameters : null;
|
||||
element is FunctionTypedElement ? element.formalParameters : null;
|
||||
} else if (parent case FunctionExpressionInvocation(
|
||||
function: Identifier function,
|
||||
)) {
|
||||
@@ -64,7 +64,7 @@ class DartUnitSignatureComputer {
|
||||
// Standard function expression.
|
||||
element = function.element;
|
||||
parameters = functionType.formalParameters;
|
||||
} else if (parent.element case ExecutableElement2 executableElement) {
|
||||
} else if (parent.element case ExecutableElement executableElement) {
|
||||
// Callable class instance (where we'll look at the `call` method).
|
||||
element = executableElement;
|
||||
parameters = executableElement.formalParameters;
|
||||
|
||||
@@ -43,13 +43,13 @@ class DartTypeArgumentsSignatureComputer {
|
||||
return null;
|
||||
}
|
||||
var parent = argumentList.parent;
|
||||
Element2? element;
|
||||
Element? element;
|
||||
if (parent is NamedType) {
|
||||
element = parent.element2;
|
||||
} else if (parent is MethodInvocation) {
|
||||
element = ElementLocator.locate2(parent.methodName);
|
||||
}
|
||||
if (element is! TypeParameterizedElement2 ||
|
||||
if (element is! TypeParameterizedElement ||
|
||||
element.typeParameters2.isEmpty) {
|
||||
return null;
|
||||
}
|
||||
@@ -87,7 +87,7 @@ class DartTypeArgumentsSignatureComputer {
|
||||
lsp.SignatureHelp? _toSignatureHelp(
|
||||
String label,
|
||||
String? documentation,
|
||||
List<TypeParameterElement2> typeParameters,
|
||||
List<TypeParameterElement> typeParameters,
|
||||
) {
|
||||
var parameters =
|
||||
typeParameters
|
||||
|
||||
@@ -342,7 +342,7 @@ class ImportElementsComputer {
|
||||
/// Computes the best URI to import [what] into [from].
|
||||
///
|
||||
/// Copied from DartFileEditBuilderImpl.
|
||||
String _getLibrarySourceUri(LibraryElement2 from, Source what) {
|
||||
String _getLibrarySourceUri(LibraryElement from, Source what) {
|
||||
var whatPath = what.fullName;
|
||||
// check if an absolute URI (such as 'dart:' or 'package:')
|
||||
var whatUri = what.uri;
|
||||
@@ -362,7 +362,7 @@ class ImportElementsComputer {
|
||||
|
||||
if (prefix.isNotEmpty) {
|
||||
var prefixElement = scope.lookup(prefix).getter2;
|
||||
if (prefixElement is PrefixElement2) {
|
||||
if (prefixElement is PrefixElement) {
|
||||
scope = prefixElement.scope;
|
||||
} else {
|
||||
return false;
|
||||
|
||||
@@ -108,14 +108,14 @@ class _Visitor extends UnifyingAstVisitor<void> {
|
||||
}
|
||||
}
|
||||
|
||||
void _addElement(String prefix, Element2? element) {
|
||||
void _addElement(String prefix, Element? element) {
|
||||
if (element == null) {
|
||||
return;
|
||||
}
|
||||
if (element is PrefixElement2) {
|
||||
if (element is PrefixElement) {
|
||||
return;
|
||||
}
|
||||
if (element.enclosingElement2 is! LibraryElement2) {
|
||||
if (element.enclosingElement2 is! LibraryElement) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ class _Visitor extends UnifyingAstVisitor<void> {
|
||||
String _getPrefixFrom(SimpleIdentifier identifier) {
|
||||
if (identifier.offset <= endOffset && identifier.end >= startOffset) {
|
||||
var prefixElement = identifier.element;
|
||||
if (prefixElement is PrefixElement2) {
|
||||
if (prefixElement is PrefixElement) {
|
||||
return prefixElement.name3 ?? '';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ class ImplementedComputer {
|
||||
}
|
||||
}
|
||||
|
||||
void _addImplementedClass(InterfaceElement2 element) {
|
||||
void _addImplementedClass(InterfaceElement element) {
|
||||
for (var fragment in element.fragments) {
|
||||
var offset = fragment.nameOffset2;
|
||||
var name = fragment.name2;
|
||||
@@ -42,7 +42,7 @@ class ImplementedComputer {
|
||||
}
|
||||
}
|
||||
|
||||
void _addImplementedMember(Element2 element) {
|
||||
void _addImplementedMember(Element element) {
|
||||
for (var fragment in element.fragments) {
|
||||
var offset = fragment.nameOffset2;
|
||||
var name = fragment.name2;
|
||||
@@ -52,7 +52,7 @@ class ImplementedComputer {
|
||||
}
|
||||
}
|
||||
|
||||
void _addMemberIfImplemented(Element2 element) {
|
||||
void _addMemberIfImplemented(Element element) {
|
||||
if (element.isSynthetic || _isStatic(element)) {
|
||||
return;
|
||||
}
|
||||
@@ -61,9 +61,9 @@ class ImplementedComputer {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _computeForInterfaceElement(InterfaceElement2 element) async {
|
||||
Future<void> _computeForInterfaceElement(InterfaceElement element) async {
|
||||
// Always include Object and its members.
|
||||
if (element is ClassElement2 && element.isDartCoreObject) {
|
||||
if (element is ClassElement && element.isDartCoreObject) {
|
||||
_addImplementedClass(element);
|
||||
element.getters2.forEach(_addImplementedMember);
|
||||
element.setters2.forEach(_addImplementedMember);
|
||||
@@ -83,16 +83,16 @@ class ImplementedComputer {
|
||||
}
|
||||
}
|
||||
|
||||
bool _hasOverride(Element2 element) {
|
||||
bool _hasOverride(Element element) {
|
||||
var name = element.displayName;
|
||||
return subtypeMembers!.contains(name);
|
||||
}
|
||||
|
||||
/// Return `true` if the given [element] is a static element.
|
||||
static bool _isStatic(Element2 element) {
|
||||
if (element is ExecutableElement2) {
|
||||
static bool _isStatic(Element element) {
|
||||
if (element is ExecutableElement) {
|
||||
return element.isStatic;
|
||||
} else if (element is PropertyInducingElement2) {
|
||||
} else if (element is PropertyInducingElement) {
|
||||
return element.isStatic;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -35,7 +35,7 @@ void addDartOccurrences(OccurrencesCollector collector, CompilationUnit unit) {
|
||||
}
|
||||
|
||||
class DartUnitOccurrencesComputerVisitor extends RecursiveAstVisitor<void> {
|
||||
final Map<Element2, List<(int, int)>> elementsOffsetLengths = {};
|
||||
final Map<Element, List<(int, int)>> elementsOffsetLengths = {};
|
||||
|
||||
@override
|
||||
void visitAssignedVariablePattern(AssignedVariablePattern node) {
|
||||
@@ -100,7 +100,7 @@ class DartUnitOccurrencesComputerVisitor extends RecursiveAstVisitor<void> {
|
||||
|
||||
@override
|
||||
void visitDeclaredVariablePattern(DeclaredVariablePattern node) {
|
||||
if (node.declaredElement2 case BindPatternVariableElement2(:var join2?)) {
|
||||
if (node.declaredElement2 case BindPatternVariableElement(:var join2?)) {
|
||||
_addOccurrence(join2.baseElement, node.name);
|
||||
} else {
|
||||
_addOccurrence(node.declaredElement2!, node.name);
|
||||
@@ -149,7 +149,7 @@ class DartUnitOccurrencesComputerVisitor extends RecursiveAstVisitor<void> {
|
||||
@override
|
||||
void visitFieldFormalParameter(FieldFormalParameter node) {
|
||||
var declaredElement = node.declaredFragment?.element;
|
||||
if (declaredElement is FieldFormalParameterElement2) {
|
||||
if (declaredElement is FieldFormalParameterElement) {
|
||||
var field = declaredElement.field2;
|
||||
if (field != null) {
|
||||
_addOccurrence(field, node.name);
|
||||
@@ -285,11 +285,11 @@ class DartUnitOccurrencesComputerVisitor extends RecursiveAstVisitor<void> {
|
||||
super.visitVariableDeclaration(node);
|
||||
}
|
||||
|
||||
void _addOccurrence(Element2 element, Token token) {
|
||||
void _addOccurrence(Element element, Token token) {
|
||||
_addOccurrenceAt(element, token.offset, token.length);
|
||||
}
|
||||
|
||||
void _addOccurrenceAt(Element2 element, int offset, int length) {
|
||||
void _addOccurrenceAt(Element element, int offset, int length) {
|
||||
var canonicalElement = _canonicalizeElement(element);
|
||||
if (canonicalElement == null) {
|
||||
return;
|
||||
@@ -302,11 +302,11 @@ class DartUnitOccurrencesComputerVisitor extends RecursiveAstVisitor<void> {
|
||||
offsetLengths.add((offset, length));
|
||||
}
|
||||
|
||||
Element2? _canonicalizeElement(Element2 element) {
|
||||
Element2? canonicalElement = element;
|
||||
if (canonicalElement is FieldFormalParameterElement2) {
|
||||
Element? _canonicalizeElement(Element element) {
|
||||
Element? canonicalElement = element;
|
||||
if (canonicalElement is FieldFormalParameterElement) {
|
||||
canonicalElement = canonicalElement.field2;
|
||||
} else if (canonicalElement is PropertyAccessorElement2) {
|
||||
} else if (canonicalElement is PropertyAccessorElement) {
|
||||
canonicalElement = canonicalElement.variable3;
|
||||
}
|
||||
return canonicalElement?.baseElement;
|
||||
|
||||
@@ -80,7 +80,7 @@ class EditGetAvailableRefactoringsHandler extends LegacyHandler {
|
||||
if (element != null) {
|
||||
var refactoringWorkspace = server.refactoringWorkspace;
|
||||
// try CONVERT_METHOD_TO_GETTER
|
||||
if (element is ExecutableElement2) {
|
||||
if (element is ExecutableElement) {
|
||||
if (ConvertMethodToGetterRefactoring(
|
||||
refactoringWorkspace,
|
||||
resolvedUnit.session,
|
||||
|
||||
@@ -32,10 +32,10 @@ class SearchFindElementReferencesHandler extends LegacyHandler {
|
||||
var file = params.file;
|
||||
// prepare element
|
||||
var element = await server.getElementAtOffset(file, params.offset);
|
||||
if (element is FieldFormalParameterElement2) {
|
||||
if (element is FieldFormalParameterElement) {
|
||||
element = element.field2;
|
||||
}
|
||||
if (element is PropertyAccessorElement2) {
|
||||
if (element is PropertyAccessorElement) {
|
||||
element = element.variable3;
|
||||
}
|
||||
// respond
|
||||
|
||||
@@ -129,10 +129,10 @@ Future<lsp.CompletionItem?> toLspCompletionItem(
|
||||
: null;
|
||||
var isCallable =
|
||||
element != null &&
|
||||
(element is ConstructorElement2 ||
|
||||
(element is ConstructorElement ||
|
||||
element is LocalFunctionElement ||
|
||||
element is TopLevelFunctionElement ||
|
||||
element is MethodElement2);
|
||||
element is MethodElement);
|
||||
var isInvocation =
|
||||
(suggestion is ExecutableSuggestion &&
|
||||
suggestion.kind == server.CompletionSuggestionKind.INVOCATION) ||
|
||||
@@ -236,7 +236,7 @@ Future<lsp.CompletionItem?> toLspCompletionItem(
|
||||
if (suggestion is ElementBasedSuggestion) {
|
||||
var element = (suggestion as ElementBasedSuggestion).element;
|
||||
|
||||
if (element is ExecutableElement2 && element is! PropertyAccessorElement2) {
|
||||
if (element is ExecutableElement && element is! PropertyAccessorElement) {
|
||||
parameterNames =
|
||||
element.formalParameters.map((parameter) {
|
||||
return parameter.displayName;
|
||||
@@ -440,28 +440,28 @@ lsp.CompletionItemKind? _candidateToCompletionItemKind(
|
||||
return getCompletionKind().firstWhereOrNull(isSupported);
|
||||
}
|
||||
|
||||
/// Get the [lsp.CompletionItemKind] based on the [Element2] for
|
||||
/// Get the [lsp.CompletionItemKind] based on the [Element] for
|
||||
/// an [ElementBasedSuggestion].
|
||||
List<lsp.CompletionItemKind> _elementToCompletionItemKind(
|
||||
Element2 element,
|
||||
Element element,
|
||||
Set<lsp.CompletionItemKind> supportedCompletionKinds,
|
||||
) {
|
||||
if (element is ClassElement2) {
|
||||
if (element is ClassElement) {
|
||||
return const [lsp.CompletionItemKind.Class];
|
||||
}
|
||||
if (element is ConstructorElement2) {
|
||||
if (element is ConstructorElement) {
|
||||
return const [lsp.CompletionItemKind.Constructor];
|
||||
}
|
||||
if (element is EnumElement2) {
|
||||
if (element is EnumElement) {
|
||||
return const [lsp.CompletionItemKind.Enum];
|
||||
}
|
||||
if (element is ExtensionElement2) {
|
||||
if (element is ExtensionElement) {
|
||||
return const [lsp.CompletionItemKind.Method];
|
||||
}
|
||||
if (element is ExtensionTypeElement2) {
|
||||
if (element is ExtensionTypeElement) {
|
||||
return const [lsp.CompletionItemKind.Class];
|
||||
}
|
||||
if (element is FieldElement2) {
|
||||
if (element is FieldElement) {
|
||||
if (element.isEnumConstant) {
|
||||
return const [
|
||||
lsp.CompletionItemKind.EnumMember,
|
||||
@@ -476,37 +476,37 @@ List<lsp.CompletionItemKind> _elementToCompletionItemKind(
|
||||
if (element is TopLevelFunctionElement) {
|
||||
return const [lsp.CompletionItemKind.Function];
|
||||
}
|
||||
if (element is LabelElement2) {
|
||||
if (element is LabelElement) {
|
||||
return const [lsp.CompletionItemKind.Text];
|
||||
}
|
||||
if (element is LibraryElement2) {
|
||||
if (element is LibraryElement) {
|
||||
return const [lsp.CompletionItemKind.Module];
|
||||
}
|
||||
if (element is LocalVariableElement2) {
|
||||
if (element is LocalVariableElement) {
|
||||
return const [lsp.CompletionItemKind.Variable];
|
||||
}
|
||||
if (element is MethodElement2) {
|
||||
if (element is MethodElement) {
|
||||
return const [lsp.CompletionItemKind.Method];
|
||||
}
|
||||
if (element is MixinElement2) {
|
||||
if (element is MixinElement) {
|
||||
return const [lsp.CompletionItemKind.Class];
|
||||
}
|
||||
if (element is FormalParameterElement) {
|
||||
return const [lsp.CompletionItemKind.Variable];
|
||||
}
|
||||
if (element is PrefixElement2) {
|
||||
if (element is PrefixElement) {
|
||||
return const [lsp.CompletionItemKind.Variable];
|
||||
}
|
||||
if (element is PropertyAccessorElement2) {
|
||||
if (element is PropertyAccessorElement) {
|
||||
return const [lsp.CompletionItemKind.Property];
|
||||
}
|
||||
if (element is TopLevelVariableElement2) {
|
||||
if (element is TopLevelVariableElement) {
|
||||
return const [lsp.CompletionItemKind.Variable];
|
||||
}
|
||||
if (element is TypeAliasElement2) {
|
||||
if (element is TypeAliasElement) {
|
||||
return const [lsp.CompletionItemKind.Class];
|
||||
}
|
||||
if (element is TypeParameterElement2) {
|
||||
if (element is TypeParameterElement) {
|
||||
return const [
|
||||
lsp.CompletionItemKind.TypeParameter,
|
||||
lsp.CompletionItemKind.Variable,
|
||||
@@ -666,7 +666,7 @@ String _getDisplayText(
|
||||
|
||||
/// If the [element] has a documentation comment, return it.
|
||||
_ElementDocumentation? _getDocsFromComputer(
|
||||
Element2 element,
|
||||
Element element,
|
||||
DartCompletionRequest request,
|
||||
) {
|
||||
var doc = request.documentationComputer.compute(
|
||||
@@ -684,7 +684,7 @@ _ElementDocumentation? _getDocsFromComputer(
|
||||
|
||||
/// If the [element] has a documentation comment, return it.
|
||||
String? _getDocumentation(
|
||||
Element2 element,
|
||||
Element element,
|
||||
DartCompletionRequest request,
|
||||
DocumentationPreference includeDocumentation,
|
||||
) {
|
||||
|
||||
@@ -425,7 +425,7 @@ class DartCodeActionsProducer extends AbstractCodeActionsProducer {
|
||||
);
|
||||
|
||||
// Method to Getter
|
||||
if (element is ExecutableElement2 &&
|
||||
if (element is ExecutableElement &&
|
||||
ConvertMethodToGetterRefactoring(
|
||||
server.refactoringWorkspace,
|
||||
unitResult.session,
|
||||
|
||||
@@ -144,7 +144,7 @@ abstract class AbstractRefactorCommandHandler extends SimpleEditCommandHandler
|
||||
case RefactoringKind.CONVERT_METHOD_TO_GETTER:
|
||||
var node = result.unit.nodeCovering(offset: offset);
|
||||
var element = node?.getElement();
|
||||
if (element is ExecutableElement2) {
|
||||
if (element is ExecutableElement) {
|
||||
var refactor = ConvertMethodToGetterRefactoring(
|
||||
server.refactoringWorkspace,
|
||||
result.session,
|
||||
|
||||
+5
-5
@@ -29,7 +29,7 @@ typedef EditableInvocationInfo =
|
||||
mixin EditableArgumentsMixin {
|
||||
DartdocDirectiveInfo getDartdocDirectiveInfoFor(ResolvedUnitResult result);
|
||||
|
||||
String? getDocumentation(ResolvedUnitResult result, Element2 element) {
|
||||
String? getDocumentation(ResolvedUnitResult result, Element element) {
|
||||
var dartDocInfo = getDartdocDirectiveInfoFor(result);
|
||||
var dartDocComputer = DartDocumentationComputer(dartDocInfo);
|
||||
var dartDoc = dartDocComputer.compute(element);
|
||||
@@ -76,7 +76,7 @@ mixin EditableArgumentsMixin {
|
||||
invocation.argumentList,
|
||||
),
|
||||
MethodInvocation(
|
||||
methodName: Identifier(element: ExecutableElement2 element),
|
||||
methodName: Identifier(element: ExecutableElement element),
|
||||
) =>
|
||||
(element.formalParameters, invocation.argumentList),
|
||||
_ => (null, null),
|
||||
@@ -160,11 +160,11 @@ mixin EditableArgumentsMixin {
|
||||
|
||||
/// Returns a list of the constants of an enum constant prefixed with the enum
|
||||
/// name.
|
||||
List<String> getQualifiedEnumConstantNames(EnumElement2 element3) =>
|
||||
List<String> getQualifiedEnumConstantNames(EnumElement element3) =>
|
||||
element3.constants2.map(getQualifiedEnumConstantName).nonNulls.toList();
|
||||
|
||||
/// Returns the name of an enum constant prefixed with the enum name.
|
||||
static String? getQualifiedEnumConstantName(FieldElement2 enumConstant) {
|
||||
static String? getQualifiedEnumConstantName(FieldElement enumConstant) {
|
||||
var enumName = enumConstant.enclosingElement2.name3;
|
||||
var name = enumConstant.name3;
|
||||
return enumName != null && name != null ? '$enumName.$name' : null;
|
||||
@@ -183,7 +183,7 @@ extension on InvocationExpressionImpl {
|
||||
// We only support @widgetFactory on extension methods.
|
||||
var element = switch (function) {
|
||||
Identifier(:var element)
|
||||
when element?.enclosingElement2 is ExtensionElement2 =>
|
||||
when element?.enclosingElement2 is ExtensionElement =>
|
||||
element,
|
||||
_ => null,
|
||||
};
|
||||
|
||||
+1
-1
@@ -210,7 +210,7 @@ class EditArgumentHandler extends SharedMessageHandler<EditArgumentParams, Null>
|
||||
),
|
||||
);
|
||||
} else if (parameter.type case InterfaceType(
|
||||
:EnumElement2 element3,
|
||||
:EnumElement element3,
|
||||
) when value is String?) {
|
||||
var allowedValues = getQualifiedEnumConstantNames(element3);
|
||||
if (allowedValues.contains(value)) {
|
||||
|
||||
+3
-3
@@ -201,7 +201,7 @@ class EditableArgumentsHandler
|
||||
type = 'string';
|
||||
value = values.argumentValue?.toStringValue();
|
||||
defaultValue = values.parameterValue?.toStringValue();
|
||||
} else if (parameter.type case InterfaceType(:EnumElement2 element3)) {
|
||||
} else if (parameter.type case InterfaceType(:EnumElement element3)) {
|
||||
type = 'enum';
|
||||
options = getQualifiedEnumConstantNames(element3);
|
||||
value = values.argumentValue?.toEnumStringValue(element3);
|
||||
@@ -253,10 +253,10 @@ class EditableArgumentsHandler
|
||||
}
|
||||
|
||||
extension on DartObject? {
|
||||
Object? toEnumStringValue(EnumElement2 element3) {
|
||||
Object? toEnumStringValue(EnumElement element3) {
|
||||
var valueObject = this;
|
||||
if (valueObject?.type case InterfaceType(
|
||||
element3: EnumElement2 valueElement,
|
||||
element3: EnumElement valueElement,
|
||||
) when element3 == valueElement) {
|
||||
var index = valueObject?.getField('index')?.toIntValue();
|
||||
if (index != null) {
|
||||
|
||||
@@ -84,7 +84,7 @@ class ImportsHandler
|
||||
}
|
||||
|
||||
var enclosingElement = element.enclosingElement2;
|
||||
if (enclosingElement is ExtensionElement2) {
|
||||
if (enclosingElement is ExtensionElement) {
|
||||
element = enclosingElement;
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ class ImportsHandler
|
||||
List<Location> _getImportLocations(
|
||||
ResolvedLibraryResult libraryResult,
|
||||
ResolvedUnitResult? unitResult,
|
||||
Element2 element,
|
||||
Element element,
|
||||
String? prefix,
|
||||
) {
|
||||
var elementName = element.name3;
|
||||
@@ -132,7 +132,7 @@ class ImportsHandler
|
||||
/// [unit].
|
||||
List<Location> _getImportsInUnit(
|
||||
CompilationUnit unit,
|
||||
Element2 element, {
|
||||
Element element, {
|
||||
required String? prefix,
|
||||
required String elementName,
|
||||
}) {
|
||||
@@ -149,7 +149,7 @@ class ImportsHandler
|
||||
: import.namespace.getPrefixed2(prefix, elementName);
|
||||
|
||||
var isMatch =
|
||||
element is MultiplyDefinedElement2
|
||||
element is MultiplyDefinedElement
|
||||
? element.conflictingElements2.contains(importedElement)
|
||||
: element == importedElement;
|
||||
|
||||
|
||||
@@ -77,26 +77,26 @@ class SuperHandler
|
||||
}
|
||||
|
||||
class _SuperComputer {
|
||||
Fragment? computeSuper(Element2 element) {
|
||||
Fragment? computeSuper(Element element) {
|
||||
return switch (element) {
|
||||
ConstructorElement2 element => _findSuperConstructor(element),
|
||||
InterfaceElement2 element => _findSuperClass(element),
|
||||
ConstructorElement element => _findSuperConstructor(element),
|
||||
InterfaceElement element => _findSuperClass(element),
|
||||
_ => _findSuperMember(element),
|
||||
};
|
||||
}
|
||||
|
||||
Fragment? _findSuperClass(InterfaceElement2 element) {
|
||||
Fragment? _findSuperClass(InterfaceElement element) {
|
||||
// For super classes, we use the first fragment (the original declaration).
|
||||
// This differs from methods/getters because we jump to the end of the
|
||||
// augmentation chain for those.
|
||||
return element.supertype?.element3.firstFragment;
|
||||
}
|
||||
|
||||
Fragment? _findSuperConstructor(ConstructorElement2 element) {
|
||||
Fragment? _findSuperConstructor(ConstructorElement element) {
|
||||
return _lastFragment(element.superConstructor2);
|
||||
}
|
||||
|
||||
Fragment? _findSuperMember(Element2 element) {
|
||||
Fragment? _findSuperMember(Element element) {
|
||||
var session = element.session;
|
||||
if (session is! AnalysisSessionImpl) {
|
||||
return null;
|
||||
@@ -104,7 +104,7 @@ class _SuperComputer {
|
||||
|
||||
var inheritanceManager = session.inheritanceManager;
|
||||
|
||||
if (element is! ExecutableElement2 && element is! FieldElement2) {
|
||||
if (element is! ExecutableElement && element is! FieldElement) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ class _SuperComputer {
|
||||
return null;
|
||||
}
|
||||
|
||||
var interfaceElement = element.thisOrAncestorOfType2<InterfaceElement2>();
|
||||
var interfaceElement = element.thisOrAncestorOfType2<InterfaceElement>();
|
||||
if (interfaceElement == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -122,7 +122,7 @@ class _SuperComputer {
|
||||
return _lastFragment(member);
|
||||
}
|
||||
|
||||
Fragment? _lastFragment(Element2? element) {
|
||||
Fragment? _lastFragment(Element? element) {
|
||||
Fragment? fragment = element?.firstFragment;
|
||||
while (fragment?.nextFragment != null) {
|
||||
fragment = fragment?.nextFragment;
|
||||
|
||||
@@ -226,7 +226,7 @@ class DefinitionHandler
|
||||
// for the code range because otherwise previews will just show `(int a)`
|
||||
// which is not what the user expects.
|
||||
if (codeFragment.element.enclosingElement2
|
||||
case ExtensionTypeElement2 enclosingElement
|
||||
case ExtensionTypeElement enclosingElement
|
||||
when enclosingElement.primaryConstructor2 == codeFragment.element) {
|
||||
codeFragment = codeFragment.enclosingFragment;
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ class DocumentColorPresentationHandler
|
||||
Future<ColorPresentation> _createColorPresentation({
|
||||
required ResolvedUnitResult unit,
|
||||
required SourceRange editRange,
|
||||
required InterfaceElement2 colorType,
|
||||
required InterfaceElement colorType,
|
||||
required String typeName,
|
||||
required String invocationString,
|
||||
required bool includeConstKeyword,
|
||||
@@ -250,8 +250,8 @@ class DocumentColorPresentationHandler
|
||||
parent is PrefixedIdentifier ? parent.element : node.element;
|
||||
|
||||
return switch (element) {
|
||||
PropertyAccessorElement2(:var variable3) => variable3?.isConst ?? false,
|
||||
VariableElement2() => element.isConst,
|
||||
PropertyAccessorElement(:var variable3) => variable3?.isConst ?? false,
|
||||
VariableElement() => element.isConst,
|
||||
_ => false,
|
||||
};
|
||||
} else {
|
||||
|
||||
@@ -76,7 +76,7 @@ class ImplementationHandler
|
||||
}
|
||||
var needsMember = helper.findMemberElement(interfaceElement) != null;
|
||||
|
||||
var allSubtypes = <InterfaceElement2>{};
|
||||
var allSubtypes = <InterfaceElement>{};
|
||||
await performance.runAsync(
|
||||
'appendAllSubtypes',
|
||||
(performance) => server.searchEngine.appendAllSubtypes(
|
||||
|
||||
@@ -13,7 +13,7 @@ import 'package:analysis_server/src/lsp/registration/feature_registration.dart';
|
||||
import 'package:analysis_server/src/services/correction/dart/convert_null_check_to_null_aware_element_or_entry.dart';
|
||||
import 'package:analyzer/dart/ast/ast.dart';
|
||||
import 'package:analyzer/dart/ast/visitor.dart';
|
||||
import 'package:analyzer/dart/element/element.dart';
|
||||
import 'package:analyzer/dart/element/element.dart' as analyzer;
|
||||
import 'package:analyzer/dart/element/type.dart';
|
||||
import 'package:analyzer/source/line_info.dart';
|
||||
import 'package:analyzer/src/dart/element/extensions.dart';
|
||||
@@ -124,7 +124,7 @@ class InlineValueRegistrations extends FeatureRegistration
|
||||
/// is recorded multiple times.
|
||||
class _InlineValueCollector {
|
||||
/// A map of elements and their inline value.
|
||||
final Map<Element2, InlineValue> values = {};
|
||||
final Map<analyzer.Element, InlineValue> values = {};
|
||||
|
||||
/// The range for which simple inline values should be returned.
|
||||
///
|
||||
@@ -153,7 +153,7 @@ class _InlineValueCollector {
|
||||
///
|
||||
/// Expression values are sent to the client without expressions because the
|
||||
/// client can use the range from the source to get the expression.
|
||||
void recordExpression(Element2? element, int offset, int length) {
|
||||
void recordExpression(analyzer.Element? element, int offset, int length) {
|
||||
assert(offset >= 0);
|
||||
assert(length > 0);
|
||||
if (element == null) return;
|
||||
@@ -180,7 +180,7 @@ class _InlineValueCollector {
|
||||
/// Variable inline values are sent to the client without names because the
|
||||
/// client can infer the name from the range and look it up from the debuggers
|
||||
/// Scopes/Variables.
|
||||
void recordVariableLookup(Element2? element, int offset, int length) {
|
||||
void recordVariableLookup(analyzer.Element? element, int offset, int length) {
|
||||
assert(offset >= 0);
|
||||
assert(length > 0);
|
||||
if (element == null || element.isWildcardVariable) return;
|
||||
@@ -214,10 +214,10 @@ class _InlineValueCollector {
|
||||
|
||||
/// Returns whether [element] is something that should never be eagerly
|
||||
/// evaluated because of potential side-effects (such as `iterable.length`).
|
||||
bool _isExcludedElement(Element2 element) {
|
||||
bool _isExcludedElement(analyzer.Element element) {
|
||||
return switch (element) {
|
||||
VariableElement2() => _isExcludedType(element.type),
|
||||
GetterElement() => _isExcludedType(element.returnType),
|
||||
analyzer.VariableElement() => _isExcludedType(element.type),
|
||||
analyzer.GetterElement() => _isExcludedType(element.returnType),
|
||||
_ => false,
|
||||
};
|
||||
}
|
||||
@@ -236,7 +236,7 @@ class _InlineValueCollector {
|
||||
|
||||
/// Records an inline value [value] for [element] if it is within range and is
|
||||
/// the latest one in the source for that element.
|
||||
void _record(InlineValue value, Element2 element) {
|
||||
void _record(InlineValue value, analyzer.Element element) {
|
||||
// Don't create values for any elements that are excluded types.
|
||||
if (_isExcludedElement(element)) {
|
||||
return;
|
||||
@@ -307,8 +307,8 @@ class _InlineValueVisitor extends GeneralizingAstVisitor<void> {
|
||||
|
||||
// Never produce values for obvious enum getters (this includes `values`).
|
||||
var isEnumGetter =
|
||||
node.element is GetterElement &&
|
||||
node.element?.enclosingElement2 is EnumElement2;
|
||||
node.element is analyzer.GetterElement &&
|
||||
node.element?.enclosingElement2 is analyzer.EnumElement;
|
||||
|
||||
if (!isTarget && !isEnumGetter) {
|
||||
collector.recordExpression(node.element, node.offset, node.length);
|
||||
@@ -347,8 +347,8 @@ class _InlineValueVisitor extends GeneralizingAstVisitor<void> {
|
||||
var isInvocation = parent is InvocationExpression;
|
||||
if (!isTarget && !isInvocation) {
|
||||
switch (node.element) {
|
||||
case LocalVariableElement2(name3: _?):
|
||||
case FormalParameterElement():
|
||||
case analyzer.LocalVariableElement(name3: _?):
|
||||
case analyzer.FormalParameterElement():
|
||||
collector.recordVariableLookup(
|
||||
node.element,
|
||||
node.offset,
|
||||
|
||||
@@ -51,7 +51,7 @@ class ReferencesHandler
|
||||
);
|
||||
}
|
||||
|
||||
List<Location> _getDeclarations(Element2 element) {
|
||||
List<Location> _getDeclarations(Element element) {
|
||||
return element.nonSynthetic2.fragments
|
||||
.map((fragment) => fragmentToLocation(uriConverter, fragment))
|
||||
.nonNulls
|
||||
@@ -68,8 +68,8 @@ class ReferencesHandler
|
||||
node = _getReferenceTargetNode(node);
|
||||
|
||||
var element = switch (node?.getElement()) {
|
||||
FieldFormalParameterElement2(:var field2?) => field2,
|
||||
PropertyAccessorElement2(:var variable3?) => variable3,
|
||||
FieldFormalParameterElement(:var field2?) => field2,
|
||||
PropertyAccessorElement(:var variable3?) => variable3,
|
||||
var element => element,
|
||||
};
|
||||
|
||||
|
||||
@@ -321,7 +321,7 @@ class RenameHandler extends LspMessageHandler<RenameParams, WorkspaceEdit?> {
|
||||
|
||||
bool _isClassRename(RenameRefactoring refactoring) =>
|
||||
refactoring is RenameUnitMemberRefactoringImpl &&
|
||||
refactoring.element is InterfaceElement2;
|
||||
refactoring.element is InterfaceElement;
|
||||
|
||||
/// Asks the user whether they would like to rename the file along with the
|
||||
/// class.
|
||||
|
||||
@@ -9,7 +9,7 @@ import 'package:analysis_server/src/lsp/mapping.dart';
|
||||
import 'package:analysis_server/src/lsp/registration/feature_registration.dart';
|
||||
import 'package:analyzer/dart/ast/ast.dart';
|
||||
import 'package:analyzer/dart/ast/syntactic_entity.dart';
|
||||
import 'package:analyzer/dart/element/element.dart';
|
||||
import 'package:analyzer/dart/element/element.dart' as analyzer;
|
||||
import 'package:analyzer/dart/element/type.dart';
|
||||
import 'package:analyzer/source/line_info.dart';
|
||||
import 'package:analyzer/src/dart/ast/extensions.dart';
|
||||
@@ -85,7 +85,7 @@ class TypeDefinitionHandler
|
||||
if (node is NamedType) {
|
||||
originEntity = node.name2;
|
||||
var element = node.element2;
|
||||
if (element case InterfaceElement2 element) {
|
||||
if (element case analyzer.InterfaceElement element) {
|
||||
type = element.thisType;
|
||||
}
|
||||
} else if (node is VariableDeclaration) {
|
||||
@@ -105,13 +105,13 @@ class TypeDefinitionHandler
|
||||
return success(_emptyResult);
|
||||
}
|
||||
|
||||
Element2? element;
|
||||
analyzer.Element? element;
|
||||
if (type is InterfaceType) {
|
||||
element = type.element3;
|
||||
} else if (type is TypeParameterType) {
|
||||
element = type.element3;
|
||||
}
|
||||
if (element is! Element2) {
|
||||
if (element is! analyzer.Element) {
|
||||
return success(_emptyResult);
|
||||
}
|
||||
|
||||
@@ -155,9 +155,9 @@ class TypeDefinitionHandler
|
||||
|
||||
/// Creates an LSP [Location] for navigating to [targetFragment].
|
||||
Location _toLocation(
|
||||
Fragment targetFragment,
|
||||
analyzer.Fragment targetFragment,
|
||||
Range targetNameRange,
|
||||
LibraryFragment targetUnit,
|
||||
analyzer.LibraryFragment targetUnit,
|
||||
) {
|
||||
return Location(
|
||||
uri: uriConverter.toClientUri(targetUnit.source.fullName),
|
||||
@@ -172,9 +172,9 @@ class TypeDefinitionHandler
|
||||
LocationLink _toLocationLink(
|
||||
SyntacticEntity originEntity,
|
||||
LineInfo originLineInfo,
|
||||
Fragment targetFragment,
|
||||
analyzer.Fragment targetFragment,
|
||||
Range targetNameRange,
|
||||
LibraryFragment targetUnit,
|
||||
analyzer.LibraryFragment targetUnit,
|
||||
) {
|
||||
var (codeOffset, codeLength) = switch (targetFragment) {
|
||||
ElementImpl e => (e.codeOffset, e.codeLength),
|
||||
@@ -203,9 +203,9 @@ class TypeDefinitionHandler
|
||||
static DartType? _getType(Expression node) {
|
||||
if (node is SimpleIdentifier) {
|
||||
var element = node.element;
|
||||
if (element case InterfaceElement2 element) {
|
||||
if (element case analyzer.InterfaceElement element) {
|
||||
return element.thisType;
|
||||
} else if (element case VariableElement2 element) {
|
||||
} else if (element case analyzer.VariableElement element) {
|
||||
if (node.inDeclarationContext()) {
|
||||
return element.type;
|
||||
}
|
||||
@@ -216,8 +216,8 @@ class TypeDefinitionHandler
|
||||
} else if (node.inSetterContext()) {
|
||||
var writeElement = node.writeOrReadElement2;
|
||||
if (writeElement
|
||||
case GetterElement(:var variable3) ||
|
||||
SetterElement(:var variable3)) {
|
||||
case analyzer.GetterElement(:var variable3) ||
|
||||
analyzer.SetterElement(:var variable3)) {
|
||||
return variable3?.type;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,8 +58,8 @@ void doSourceChange_addSourceEdit(
|
||||
change.addEdit(file, isNewFile ? -1 : 0, edit);
|
||||
}
|
||||
|
||||
String? getAliasedTypeString(engine.Element2 element) {
|
||||
if (element is engine.TypeAliasElement2) {
|
||||
String? getAliasedTypeString(engine.Element element) {
|
||||
if (element is engine.TypeAliasElement) {
|
||||
var aliasedType = element.aliasedType;
|
||||
return aliasedType.getDisplayString();
|
||||
}
|
||||
@@ -68,8 +68,8 @@ String? getAliasedTypeString(engine.Element2 element) {
|
||||
|
||||
/// Returns a color hex code (in the form '#FFFFFF') if [element] represents
|
||||
/// a color.
|
||||
String? getColorHexString(engine.Element2? element) {
|
||||
if (element is engine.VariableElement2) {
|
||||
String? getColorHexString(engine.Element? element) {
|
||||
if (element is engine.VariableElement) {
|
||||
var dartValue = element.computeConstantValue();
|
||||
if (dartValue != null) {
|
||||
var color = ColorComputer.getColorForObject(dartValue);
|
||||
@@ -85,17 +85,17 @@ String? getColorHexString(engine.Element2? element) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String? getReturnTypeString(engine.Element2 element) {
|
||||
if (element is engine.ExecutableElement2) {
|
||||
String? getReturnTypeString(engine.Element element) {
|
||||
if (element is engine.ExecutableElement) {
|
||||
if (element.kind == engine.ElementKind.SETTER) {
|
||||
return null;
|
||||
} else {
|
||||
return element.returnType.getDisplayString();
|
||||
}
|
||||
} else if (element is engine.VariableElement2) {
|
||||
} else if (element is engine.VariableElement) {
|
||||
var type = element.type;
|
||||
return type.getDisplayString();
|
||||
} else if (element is engine.TypeAliasElement2) {
|
||||
} else if (element is engine.TypeAliasElement) {
|
||||
var aliasedType = element.aliasedType;
|
||||
if (aliasedType is FunctionType) {
|
||||
var returnType = aliasedType.returnType;
|
||||
@@ -236,8 +236,8 @@ DiagnosticMessage newDiagnosticMessage(
|
||||
);
|
||||
}
|
||||
|
||||
/// Create a Location based on an [engine.Element2].
|
||||
Location? newLocation_fromElement(engine.Element2? element) {
|
||||
/// Create a Location based on an [engine.Element].
|
||||
Location? newLocation_fromElement(engine.Element? element) {
|
||||
if (element == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -297,7 +297,7 @@ Location newLocation_fromUnit(
|
||||
}
|
||||
|
||||
/// Construct based on an element from the analyzer engine.
|
||||
OverriddenMember newOverriddenMember_fromEngine(engine.Element2 member) {
|
||||
OverriddenMember newOverriddenMember_fromEngine(engine.Element member) {
|
||||
var element = convertElement(member);
|
||||
var className = member.enclosingElement2!.displayName;
|
||||
return OverriddenMember(element, className);
|
||||
@@ -344,7 +344,7 @@ SourceEdit newSourceEdit_range(
|
||||
return SourceEdit(range.offset, range.length, replacement, id: id);
|
||||
}
|
||||
|
||||
List<Element> _computePath(engine.Element2 element) {
|
||||
List<Element> _computePath(engine.Element element) {
|
||||
var path = <Element>[];
|
||||
for (var fragment in element.firstFragment.withAncestors) {
|
||||
if (fragment is engine.LibraryFragment) {
|
||||
@@ -355,8 +355,8 @@ List<Element> _computePath(engine.Element2 element) {
|
||||
return path;
|
||||
}
|
||||
|
||||
engine.LibraryFragment _getUnitElement(engine.Element2 element) {
|
||||
if (element is engine.LibraryElement2) {
|
||||
engine.LibraryFragment _getUnitElement(engine.Element element) {
|
||||
if (element is engine.LibraryElement) {
|
||||
return element.firstFragment;
|
||||
}
|
||||
var fragment = element.firstFragment.libraryFragment;
|
||||
|
||||
@@ -17,7 +17,7 @@ class ElementReferencesComputer {
|
||||
|
||||
/// Computes [SearchMatch]es for [element] references.
|
||||
Future<List<SearchMatch>> compute(
|
||||
Element2 element,
|
||||
Element element,
|
||||
bool withPotential, {
|
||||
OperationPerformanceImpl? performance,
|
||||
}) async {
|
||||
@@ -47,9 +47,9 @@ class ElementReferencesComputer {
|
||||
}
|
||||
|
||||
/// Returns a [Future] completing with a [List] of references to [element] or
|
||||
/// to the corresponding hierarchy [Element2]s.
|
||||
/// to the corresponding hierarchy [Element]s.
|
||||
Future<List<SearchMatch>> _findElementsReferences(
|
||||
Element2 element,
|
||||
Element element,
|
||||
OperationPerformanceImpl performance,
|
||||
) async {
|
||||
var allResults = <SearchMatch>[];
|
||||
@@ -68,18 +68,18 @@ class ElementReferencesComputer {
|
||||
}
|
||||
|
||||
/// Returns a [Future] completing with a [List] of references to [element].
|
||||
Future<List<SearchMatch>> _findSingleElementReferences(Element2 element) {
|
||||
Future<List<SearchMatch>> _findSingleElementReferences(Element element) {
|
||||
return searchEngine.searchReferences(element);
|
||||
}
|
||||
|
||||
/// Returns a [Future] completing with [Element2]s to search references to.
|
||||
/// Returns a [Future] completing with [Element]s to search references to.
|
||||
///
|
||||
/// If an instance member or a named [FormalParameterElement] is given, each
|
||||
/// corresponding [Element2] in the hierarchy is returned.
|
||||
/// corresponding [Element] in the hierarchy is returned.
|
||||
///
|
||||
/// Otherwise, only references to [element] should be searched.
|
||||
Future<Iterable<Element2>> _getRefElements(
|
||||
Element2 element,
|
||||
Future<Iterable<Element>> _getRefElements(
|
||||
Element element,
|
||||
OperationPerformanceImpl performance,
|
||||
) async {
|
||||
if (element is FormalParameterElement && element.isNamed) {
|
||||
@@ -88,9 +88,9 @@ class ElementReferencesComputer {
|
||||
(_) => getHierarchyNamedParameters(searchEngine, element),
|
||||
);
|
||||
}
|
||||
if (element is MethodElement2 ||
|
||||
element is FieldElement2 ||
|
||||
element is ConstructorElement2) {
|
||||
if (element is MethodElement ||
|
||||
element is FieldElement ||
|
||||
element is ConstructorElement) {
|
||||
var (members, parameters) = await performance.runAsync(
|
||||
'getHierarchyMembers',
|
||||
(performance) => getHierarchyMembersAndParameters(
|
||||
@@ -110,10 +110,10 @@ class ElementReferencesComputer {
|
||||
return newSearchResult_fromMatch(match);
|
||||
}
|
||||
|
||||
static bool _isMemberElement(Element2 element) {
|
||||
if (element is ConstructorElement2) {
|
||||
static bool _isMemberElement(Element element) {
|
||||
if (element is ConstructorElement) {
|
||||
return false;
|
||||
}
|
||||
return element.enclosingElement2 is InterfaceElement2;
|
||||
return element.enclosingElement2 is InterfaceElement;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,17 +11,17 @@ import 'package:analysis_server/src/services/search/search_engine.dart';
|
||||
import 'package:analyzer/dart/element/element.dart';
|
||||
import 'package:analyzer/dart/element/type.dart';
|
||||
|
||||
/// A computer for a type hierarchy of an [Element2].
|
||||
/// A computer for a type hierarchy of an [Element].
|
||||
class TypeHierarchyComputer {
|
||||
final SearchEngine _searchEngine;
|
||||
final TypeHierarchyComputerHelper helper;
|
||||
|
||||
final List<TypeHierarchyItem> _items = <TypeHierarchyItem>[];
|
||||
final List<InterfaceElement2> _itemClassElements = [];
|
||||
final Map<Element2, TypeHierarchyItem> _elementItemMap =
|
||||
HashMap<Element2, TypeHierarchyItem>();
|
||||
final List<InterfaceElement> _itemClassElements = [];
|
||||
final Map<Element, TypeHierarchyItem> _elementItemMap =
|
||||
HashMap<Element, TypeHierarchyItem>();
|
||||
|
||||
TypeHierarchyComputer(this._searchEngine, Element2 pivotElement)
|
||||
TypeHierarchyComputer(this._searchEngine, Element pivotElement)
|
||||
: helper = TypeHierarchyComputerHelper.fromElement(pivotElement);
|
||||
|
||||
/// Returns the computed type hierarchy, maybe `null`.
|
||||
@@ -49,7 +49,7 @@ class TypeHierarchyComputer {
|
||||
Future<void> _createSubclasses(
|
||||
TypeHierarchyItem item,
|
||||
int itemId,
|
||||
InterfaceElement2 classElement,
|
||||
InterfaceElement classElement,
|
||||
SearchEngineCache searchEngineCache,
|
||||
) async {
|
||||
var subElements = await getDirectSubClasses(
|
||||
@@ -100,7 +100,7 @@ class TypeHierarchyComputer {
|
||||
}
|
||||
|
||||
int _createSuperItem(
|
||||
InterfaceElement2 classElement,
|
||||
InterfaceElement classElement,
|
||||
List<DartType>? typeArguments,
|
||||
) {
|
||||
// check for recursion
|
||||
@@ -160,12 +160,12 @@ class TypeHierarchyComputer {
|
||||
}
|
||||
|
||||
class TypeHierarchyComputerHelper {
|
||||
final Element2 pivotElement;
|
||||
final LibraryElement2 pivotLibrary;
|
||||
final Element pivotElement;
|
||||
final LibraryElement pivotLibrary;
|
||||
final ElementKind pivotKind;
|
||||
final String? pivotName;
|
||||
final bool pivotFieldFinal;
|
||||
final InterfaceElement2? pivotClass;
|
||||
final InterfaceElement? pivotClass;
|
||||
|
||||
TypeHierarchyComputerHelper(
|
||||
this.pivotElement,
|
||||
@@ -176,19 +176,19 @@ class TypeHierarchyComputerHelper {
|
||||
this.pivotClass,
|
||||
);
|
||||
|
||||
factory TypeHierarchyComputerHelper.fromElement(Element2 pivotElement) {
|
||||
factory TypeHierarchyComputerHelper.fromElement(Element pivotElement) {
|
||||
// try to find enclosing ClassElement
|
||||
Element2? element = pivotElement;
|
||||
Element? element = pivotElement;
|
||||
bool pivotFieldFinal = false;
|
||||
if (pivotElement is FieldElement2) {
|
||||
if (pivotElement is FieldElement) {
|
||||
pivotFieldFinal = pivotElement.isFinal;
|
||||
element = pivotElement.enclosingElement2;
|
||||
}
|
||||
if (pivotElement is ExecutableElement2) {
|
||||
if (pivotElement is ExecutableElement) {
|
||||
element = pivotElement.enclosingElement2;
|
||||
}
|
||||
InterfaceElement2? pivotClass;
|
||||
if (element is InterfaceElement2) {
|
||||
InterfaceElement? pivotClass;
|
||||
if (element is InterfaceElement) {
|
||||
pivotClass = element;
|
||||
}
|
||||
|
||||
@@ -202,10 +202,10 @@ class TypeHierarchyComputerHelper {
|
||||
);
|
||||
}
|
||||
|
||||
ExecutableElement2? findMemberElement(InterfaceElement2 clazz) {
|
||||
ExecutableElement? findMemberElement(InterfaceElement clazz) {
|
||||
// Members of extension types don't override anything.
|
||||
// They redeclare, and resolved statically.
|
||||
if (pivotClass is ExtensionTypeElement2 || clazz is ExtensionTypeElement2) {
|
||||
if (pivotClass is ExtensionTypeElement || clazz is ExtensionTypeElement) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -213,7 +213,7 @@ class TypeHierarchyComputerHelper {
|
||||
if (pivotName == null) {
|
||||
return null;
|
||||
}
|
||||
ExecutableElement2? result;
|
||||
ExecutableElement? result;
|
||||
// try to find in the class itself
|
||||
if (pivotKind == ElementKind.METHOD) {
|
||||
result = clazz.getMethod2(pivotName);
|
||||
|
||||
@@ -50,7 +50,7 @@ sealed class CandidateSuggestion {
|
||||
final class ClassSuggestion extends ImportableSuggestion
|
||||
implements ElementBasedSuggestion {
|
||||
@override
|
||||
final ClassElement2 element;
|
||||
final ClassElement element;
|
||||
|
||||
/// Initialize a newly created candidate suggestion to suggest the [element].
|
||||
ClassSuggestion({
|
||||
@@ -146,7 +146,7 @@ final class ClosureSuggestion extends CandidateSuggestion with SuggestionData {
|
||||
final class ConstructorSuggestion extends ExecutableSuggestion
|
||||
implements ElementBasedSuggestion {
|
||||
@override
|
||||
final ConstructorElement2 element;
|
||||
final ConstructorElement element;
|
||||
|
||||
/// Whether the class name is already, implicitly or explicitly, at the call
|
||||
/// site. That is, whether we are completing after a period.
|
||||
@@ -213,7 +213,7 @@ final class ConstructorSuggestion extends ExecutableSuggestion
|
||||
|
||||
abstract interface class ElementBasedSuggestion {
|
||||
/// The element on which the suggestion is based.
|
||||
Element2 get element;
|
||||
Element get element;
|
||||
}
|
||||
|
||||
/// The information about a candidate suggestion based on a static field in a
|
||||
@@ -222,7 +222,7 @@ abstract interface class ElementBasedSuggestion {
|
||||
final class EnumConstantSuggestion extends ImportableSuggestion
|
||||
implements ElementBasedSuggestion {
|
||||
@override
|
||||
final FieldElement2 element;
|
||||
final FieldElement element;
|
||||
|
||||
/// Whether the name of the enum should be included in the completion.
|
||||
final bool includeEnumName;
|
||||
@@ -250,7 +250,7 @@ final class EnumConstantSuggestion extends ImportableSuggestion
|
||||
final class EnumSuggestion extends ImportableSuggestion
|
||||
implements ElementBasedSuggestion {
|
||||
@override
|
||||
final EnumElement2 element;
|
||||
final EnumElement element;
|
||||
|
||||
/// Initialize a newly created candidate suggestion to suggest the [element].
|
||||
EnumSuggestion({
|
||||
@@ -287,7 +287,7 @@ sealed class ExecutableSuggestion extends ImportableSuggestion {
|
||||
final class ExtensionSuggestion extends ExecutableSuggestion
|
||||
implements ElementBasedSuggestion {
|
||||
@override
|
||||
final ExtensionElement2 element;
|
||||
final ExtensionElement element;
|
||||
|
||||
/// Initialize a newly created candidate suggestion to suggest the [element].
|
||||
ExtensionSuggestion({
|
||||
@@ -305,7 +305,7 @@ final class ExtensionSuggestion extends ExecutableSuggestion
|
||||
final class ExtensionTypeSuggestion extends ImportableSuggestion
|
||||
implements ElementBasedSuggestion {
|
||||
@override
|
||||
final ExtensionTypeElement2 element;
|
||||
final ExtensionTypeElement element;
|
||||
|
||||
/// Initialize a newly created candidate suggestion to suggest the [element].
|
||||
ExtensionTypeSuggestion({
|
||||
@@ -321,12 +321,12 @@ final class ExtensionTypeSuggestion extends ImportableSuggestion
|
||||
/// The information about a candidate suggestion based on a field.
|
||||
final class FieldSuggestion extends CandidateSuggestion with MemberSuggestion {
|
||||
@override
|
||||
final FieldElement2 element;
|
||||
final FieldElement element;
|
||||
|
||||
/// The element defined by the declaration in which the suggestion is to be
|
||||
/// applied, or `null` if the completion is in a static context.
|
||||
@override
|
||||
final InterfaceElement2? referencingInterface;
|
||||
final InterfaceElement? referencingInterface;
|
||||
|
||||
/// Indicates the context, whether the completion is in the body of the
|
||||
/// declaration.
|
||||
@@ -395,7 +395,7 @@ final class GetterSuggestion extends ImportableSuggestion
|
||||
/// The element defined by the declaration in which the suggestion is to be
|
||||
/// applied, or `null` if the completion is in a static context.
|
||||
@override
|
||||
final InterfaceElement2? referencingInterface;
|
||||
final InterfaceElement? referencingInterface;
|
||||
|
||||
/// Whether the accessor is being invoked with a target.
|
||||
final bool withEnclosingName;
|
||||
@@ -424,9 +424,9 @@ final class GetterSuggestion extends ImportableSuggestion
|
||||
/// we either fail with assertion, or return `null`.
|
||||
String? get _enclosingClassOrExtensionName {
|
||||
var enclosing = element.enclosingElement2;
|
||||
if (enclosing is InterfaceElement2) {
|
||||
if (enclosing is InterfaceElement) {
|
||||
return enclosing.displayName;
|
||||
} else if (enclosing is ExtensionElement2) {
|
||||
} else if (enclosing is ExtensionElement) {
|
||||
return enclosing.displayName;
|
||||
} else {
|
||||
assert(false, 'Expected ClassElement or ExtensionElement');
|
||||
@@ -523,9 +523,9 @@ final class ImportData {
|
||||
/// A suggestion based on an import prefix.
|
||||
final class ImportPrefixSuggestion extends CandidateSuggestion
|
||||
implements ElementBasedSuggestion {
|
||||
final LibraryElement2 libraryElement;
|
||||
final LibraryElement libraryElement;
|
||||
|
||||
final PrefixElement2 prefixElement;
|
||||
final PrefixElement prefixElement;
|
||||
|
||||
ImportPrefixSuggestion({
|
||||
required this.libraryElement,
|
||||
@@ -537,7 +537,7 @@ final class ImportPrefixSuggestion extends CandidateSuggestion
|
||||
String get completion => prefixElement.displayName;
|
||||
|
||||
@override
|
||||
Element2 get element => prefixElement;
|
||||
Element get element => prefixElement;
|
||||
}
|
||||
|
||||
/// The information about a candidate suggestion based on a keyword.
|
||||
@@ -656,7 +656,7 @@ final class LocalFunctionSuggestion extends ExecutableSuggestion
|
||||
final class LocalVariableSuggestion extends CandidateSuggestion
|
||||
implements ElementBasedSuggestion {
|
||||
@override
|
||||
final LocalVariableElement2 element;
|
||||
final LocalVariableElement element;
|
||||
|
||||
/// The number of local variables between the completion location and the
|
||||
/// declaration of this variable.
|
||||
@@ -678,7 +678,7 @@ final class LocalVariableSuggestion extends CandidateSuggestion
|
||||
mixin MemberSuggestion implements ElementBasedSuggestion {
|
||||
/// The element defined by the declaration in which the suggestion is to be
|
||||
/// applied, or `null` if the completion is in a static context.
|
||||
InterfaceElement2? get referencingInterface;
|
||||
InterfaceElement? get referencingInterface;
|
||||
|
||||
/// Returns the value of the inheritance distance feature.
|
||||
///
|
||||
@@ -686,10 +686,10 @@ mixin MemberSuggestion implements ElementBasedSuggestion {
|
||||
double inheritanceDistance(FeatureComputer featureComputer) {
|
||||
var inheritanceDistance = 0.0;
|
||||
var element = this.element;
|
||||
if (!(element is FieldElement2 && element.isEnumConstant)) {
|
||||
if (!(element is FieldElement && element.isEnumConstant)) {
|
||||
var declaringClass = element.enclosingElement2;
|
||||
var referencingInterface = this.referencingInterface;
|
||||
if (referencingInterface != null && declaringClass is InterfaceElement2) {
|
||||
if (referencingInterface != null && declaringClass is InterfaceElement) {
|
||||
inheritanceDistance = featureComputer.inheritanceDistanceFeature(
|
||||
referencingInterface,
|
||||
declaringClass,
|
||||
@@ -704,12 +704,12 @@ mixin MemberSuggestion implements ElementBasedSuggestion {
|
||||
final class MethodSuggestion extends ExecutableSuggestion
|
||||
with MemberSuggestion {
|
||||
@override
|
||||
final MethodElement2 element;
|
||||
final MethodElement element;
|
||||
|
||||
/// The element defined by the declaration in which the suggestion is to be
|
||||
/// applied, or `null` if the completion is in a static context.
|
||||
@override
|
||||
final InterfaceElement2? referencingInterface;
|
||||
final InterfaceElement? referencingInterface;
|
||||
|
||||
/// Initialize a newly created candidate suggestion to suggest the [element].
|
||||
MethodSuggestion({
|
||||
@@ -728,7 +728,7 @@ final class MethodSuggestion extends ExecutableSuggestion
|
||||
final class MixinSuggestion extends ImportableSuggestion
|
||||
implements ElementBasedSuggestion {
|
||||
@override
|
||||
final MixinElement2 element;
|
||||
final MixinElement element;
|
||||
|
||||
/// Initialize a newly created candidate suggestion to suggest the [element].
|
||||
MixinSuggestion({
|
||||
@@ -852,7 +852,7 @@ class OverrideData {
|
||||
final class OverrideSuggestion extends CandidateSuggestion
|
||||
implements ElementBasedSuggestion {
|
||||
@override
|
||||
final ExecutableElement2 element;
|
||||
final ExecutableElement element;
|
||||
|
||||
/// Whether `super` should be invoked in the body of the override.
|
||||
final bool shouldInvokeSuper;
|
||||
@@ -957,12 +957,12 @@ final class RecordLiteralNamedFieldSuggestion extends CandidateSuggestion
|
||||
final class SetStateMethodSuggestion extends ExecutableSuggestion
|
||||
with MemberSuggestion, SuggestionData {
|
||||
@override
|
||||
final MethodElement2 element;
|
||||
final MethodElement element;
|
||||
|
||||
/// The element defined by the declaration in which the suggestion is to be
|
||||
/// applied, or `null` if the completion is in a static context.
|
||||
@override
|
||||
final InterfaceElement2? referencingInterface;
|
||||
final InterfaceElement? referencingInterface;
|
||||
|
||||
/// The identation to be used for a multi-line completion.
|
||||
final String indent;
|
||||
@@ -1009,7 +1009,7 @@ final class SetterSuggestion extends ImportableSuggestion
|
||||
/// The element defined by the declaration in which the suggestion is to be
|
||||
/// applied, or `null` if the completion is in a static context.
|
||||
@override
|
||||
final InterfaceElement2? referencingInterface;
|
||||
final InterfaceElement? referencingInterface;
|
||||
|
||||
/// Whether the accessor is being invoked with a target.
|
||||
final bool withEnclosingName;
|
||||
@@ -1038,9 +1038,9 @@ final class SetterSuggestion extends ImportableSuggestion
|
||||
/// we either fail with assertion, or return `null`.
|
||||
String? get _enclosingClassOrExtensionName {
|
||||
var enclosing = element.enclosingElement2;
|
||||
if (enclosing is InterfaceElement2) {
|
||||
if (enclosing is InterfaceElement) {
|
||||
return enclosing.displayName;
|
||||
} else if (enclosing is ExtensionElement2) {
|
||||
} else if (enclosing is ExtensionElement) {
|
||||
return enclosing.displayName;
|
||||
} else {
|
||||
assert(false, 'Expected ClassElement or ExtensionElement');
|
||||
@@ -1063,7 +1063,7 @@ final class SetterSuggestion extends ImportableSuggestion
|
||||
final class StaticFieldSuggestion extends ImportableSuggestion
|
||||
implements ElementBasedSuggestion {
|
||||
@override
|
||||
final FieldElement2 element;
|
||||
final FieldElement element;
|
||||
|
||||
/// Initialize a newly created candidate suggestion to suggest the [element].
|
||||
StaticFieldSuggestion({
|
||||
@@ -1174,7 +1174,7 @@ final class TopLevelSetterSuggestion extends ImportableSuggestion
|
||||
final class TopLevelVariableSuggestion extends ImportableSuggestion
|
||||
implements ElementBasedSuggestion {
|
||||
@override
|
||||
final TopLevelVariableElement2 element;
|
||||
final TopLevelVariableElement element;
|
||||
|
||||
/// Initialize a newly created candidate suggestion to suggest the [element].
|
||||
TopLevelVariableSuggestion({
|
||||
@@ -1191,7 +1191,7 @@ final class TopLevelVariableSuggestion extends ImportableSuggestion
|
||||
final class TypeAliasSuggestion extends ImportableSuggestion
|
||||
implements ElementBasedSuggestion {
|
||||
@override
|
||||
final TypeAliasElement2 element;
|
||||
final TypeAliasElement element;
|
||||
|
||||
/// Initialize a newly created candidate suggestion to suggest the [element].
|
||||
TypeAliasSuggestion({
|
||||
@@ -1208,7 +1208,7 @@ final class TypeAliasSuggestion extends ImportableSuggestion
|
||||
final class TypeParameterSuggestion extends CandidateSuggestion
|
||||
implements ElementBasedSuggestion {
|
||||
@override
|
||||
final TypeParameterElement2 element;
|
||||
final TypeParameterElement element;
|
||||
|
||||
/// Initialize a newly created candidate suggestion to suggest the [element].
|
||||
TypeParameterSuggestion({required this.element, required super.matcherScore});
|
||||
|
||||
@@ -250,7 +250,7 @@ class DartCompletionRequest {
|
||||
final FeatureComputer featureComputer;
|
||||
|
||||
/// The library element of the file in which completion is requested.
|
||||
final LibraryElement2 libraryElement;
|
||||
final LibraryElement libraryElement;
|
||||
|
||||
/// The library fragment of the file in which completion is requested.
|
||||
final LibraryFragment libraryFragment;
|
||||
|
||||
@@ -58,7 +58,7 @@ class CompletionState {
|
||||
}
|
||||
|
||||
/// The element of the library containing the completion location.
|
||||
LibraryElement2 get libraryElement => request.libraryElement;
|
||||
LibraryElement get libraryElement => request.libraryElement;
|
||||
|
||||
/// The type of quotes preferred for [String]s as specified in [CodeStyleOptions].
|
||||
String get preferredQuoteForStrings =>
|
||||
|
||||
@@ -161,7 +161,7 @@ class DeclarationHelper {
|
||||
}
|
||||
|
||||
/// Add suggestions for all constructors of [element].
|
||||
void addConstructorNamesForElement({required InterfaceElement2 element}) {
|
||||
void addConstructorNamesForElement({required InterfaceElement element}) {
|
||||
var constructors = element.constructors2;
|
||||
for (var constructor in constructors) {
|
||||
_suggestConstructor(
|
||||
@@ -197,7 +197,7 @@ class DeclarationHelper {
|
||||
}
|
||||
|
||||
/// Add suggestions for declarations through [prefixElement].
|
||||
void addDeclarationsThroughImportPrefix(PrefixElement2 prefixElement) {
|
||||
void addDeclarationsThroughImportPrefix(PrefixElement prefixElement) {
|
||||
for (var importElement in prefixElement.imports) {
|
||||
var importedLibrary = importElement.importedLibrary2;
|
||||
if (importedLibrary == null) {
|
||||
@@ -232,7 +232,7 @@ class DeclarationHelper {
|
||||
/// be skipped because the cursor is inside that field's name.
|
||||
void addFieldsForInitializers(
|
||||
ConstructorDeclaration constructor,
|
||||
FieldElement2? fieldToInclude,
|
||||
FieldElement? fieldToInclude,
|
||||
) {
|
||||
var constructorElement = constructor.declaredFragment?.element;
|
||||
var containingElement = constructorElement?.enclosingElement2;
|
||||
@@ -240,12 +240,12 @@ class DeclarationHelper {
|
||||
return;
|
||||
}
|
||||
|
||||
var fieldsToSkip = <FieldElement2>{};
|
||||
var fieldsToSkip = <FieldElement>{};
|
||||
// Skip fields that are already initialized in the initializer list.
|
||||
for (var initializer in constructor.initializers) {
|
||||
if (initializer is ConstructorFieldInitializer) {
|
||||
var fieldElement = initializer.fieldName.element;
|
||||
if (fieldElement is FieldElement2) {
|
||||
if (fieldElement is FieldElement) {
|
||||
fieldsToSkip.add(fieldElement);
|
||||
}
|
||||
}
|
||||
@@ -255,7 +255,7 @@ class DeclarationHelper {
|
||||
parameter = parameter.notDefault;
|
||||
if (parameter is FieldFormalParameter) {
|
||||
var parameterElement = parameter.declaredFragment?.element;
|
||||
if (parameterElement is FieldFormalParameterElement2) {
|
||||
if (parameterElement is FieldFormalParameterElement) {
|
||||
var field = parameterElement.field2;
|
||||
if (field != null) {
|
||||
fieldsToSkip.add(field);
|
||||
@@ -279,7 +279,7 @@ class DeclarationHelper {
|
||||
/// Add suggestions for all of the top-level declarations that are exported
|
||||
/// from the [library] except for those whose name is in the set of
|
||||
/// [excludedNames].
|
||||
void addFromLibrary(LibraryElement2 library, Set<String> excludedNames) {
|
||||
void addFromLibrary(LibraryElement library, Set<String> excludedNames) {
|
||||
for (var entry in library.exportNamespace.definedNames2.entries) {
|
||||
if (!excludedNames.contains(entry.key)) {
|
||||
_addImportedElement(entry.value);
|
||||
@@ -430,9 +430,9 @@ class DeclarationHelper {
|
||||
}
|
||||
}
|
||||
|
||||
/// Add members from the given [ExtensionElement2].
|
||||
/// Add members from the given [ExtensionElement].
|
||||
void addMembersFromExtensionElement(
|
||||
ExtensionElement2 extension, {
|
||||
ExtensionElement extension, {
|
||||
ImportData? importData,
|
||||
required Set<String> excludedGetters,
|
||||
required bool includeMethods,
|
||||
@@ -482,7 +482,7 @@ class DeclarationHelper {
|
||||
|
||||
/// Adds suggestions for any constructors that are visible within the not yet
|
||||
/// imported [library].
|
||||
void addNotImportedConstructors(LibraryElement2 library) {
|
||||
void addNotImportedConstructors(LibraryElement library) {
|
||||
var importData = ImportData(
|
||||
libraryUri: library.uri,
|
||||
prefix: null,
|
||||
@@ -494,7 +494,7 @@ class DeclarationHelper {
|
||||
/// Add members from all the applicable extensions that are visible in the
|
||||
/// not yet imported [library] that are applicable for the given [type].
|
||||
void addNotImportedExtensionMethods({
|
||||
required LibraryElement2 library,
|
||||
required LibraryElement library,
|
||||
required DartType type,
|
||||
required Set<String> excludedGetters,
|
||||
required bool includeMethods,
|
||||
@@ -502,7 +502,7 @@ class DeclarationHelper {
|
||||
}) {
|
||||
var libraryElement = library;
|
||||
var applicableExtensions = library.exportNamespace.definedNames2.values
|
||||
.whereType<ExtensionElement2>()
|
||||
.whereType<ExtensionElement>()
|
||||
.applicableTo(
|
||||
targetLibrary: libraryElement,
|
||||
// Ignore nullability, consistent with non-extension members.
|
||||
@@ -534,7 +534,7 @@ class DeclarationHelper {
|
||||
|
||||
/// Adds suggestions for any top-level declarations that are visible within
|
||||
/// the not yet imported [library].
|
||||
void addNotImportedTopLevelDeclarations(LibraryElement2 library) {
|
||||
void addNotImportedTopLevelDeclarations(LibraryElement library) {
|
||||
var importData = ImportData(
|
||||
libraryUri: library.uri,
|
||||
prefix: null,
|
||||
@@ -603,8 +603,8 @@ class DeclarationHelper {
|
||||
/// Add suggestions for all of the constructor in the [library] that could be
|
||||
/// a redirection target for the [redirectingConstructor].
|
||||
void addPossibleRedirectionsInLibrary(
|
||||
ConstructorElement2 redirectingConstructor,
|
||||
LibraryElement2 library,
|
||||
ConstructorElement redirectingConstructor,
|
||||
LibraryElement library,
|
||||
) {
|
||||
var classElement = redirectingConstructor.enclosingElement2;
|
||||
var classType = classElement.thisType;
|
||||
@@ -627,15 +627,15 @@ class DeclarationHelper {
|
||||
}
|
||||
|
||||
/// Add any static members defined by the given [element].
|
||||
void addStaticMembersOfElement(Element2 element) {
|
||||
if (element is TypeAliasElement2) {
|
||||
void addStaticMembersOfElement(Element element) {
|
||||
if (element is TypeAliasElement) {
|
||||
var aliasedType = element.aliasedType;
|
||||
if (aliasedType is InterfaceType) {
|
||||
element = aliasedType.element3;
|
||||
}
|
||||
}
|
||||
switch (element) {
|
||||
case EnumElement2():
|
||||
case EnumElement():
|
||||
_addStaticMembers(
|
||||
getters: element.getters2,
|
||||
setters: element.setters2,
|
||||
@@ -644,7 +644,7 @@ class DeclarationHelper {
|
||||
fields: element.fields2,
|
||||
methods: element.methods2,
|
||||
);
|
||||
case ExtensionElement2():
|
||||
case ExtensionElement():
|
||||
_addStaticMembers(
|
||||
getters: element.getters2,
|
||||
setters: element.setters2,
|
||||
@@ -653,7 +653,7 @@ class DeclarationHelper {
|
||||
fields: element.fields2,
|
||||
methods: element.methods2,
|
||||
);
|
||||
case InterfaceElement2():
|
||||
case InterfaceElement():
|
||||
_addStaticMembers(
|
||||
getters: element.getters2,
|
||||
setters: element.setters2,
|
||||
@@ -667,7 +667,7 @@ class DeclarationHelper {
|
||||
|
||||
/// Adds suggestions for any constructors that are declared within the
|
||||
/// [library].
|
||||
void _addConstructors(LibraryElement2 library, ImportData importData) {
|
||||
void _addConstructors(LibraryElement library, ImportData importData) {
|
||||
for (var element in library.classes) {
|
||||
_suggestConstructors(
|
||||
element.constructors2,
|
||||
@@ -689,19 +689,19 @@ class DeclarationHelper {
|
||||
/// Adds suggestions for any constructors that are visible through type
|
||||
/// aliases declared within the `importData.libraryUri`.
|
||||
void _addConstructorsForAliasedElement(
|
||||
TypeAliasElement2 alias,
|
||||
TypeAliasElement alias,
|
||||
ImportData? importData,
|
||||
) {
|
||||
var aliasedElement = alias.aliasedElement2;
|
||||
if (aliasedElement is ClassElement2) {
|
||||
if (aliasedElement is ClassElement) {
|
||||
_suggestConstructors(
|
||||
aliasedElement.constructors2,
|
||||
importData,
|
||||
allowNonFactory: !aliasedElement.isAbstract,
|
||||
);
|
||||
} else if (aliasedElement is ExtensionTypeElement2) {
|
||||
} else if (aliasedElement is ExtensionTypeElement) {
|
||||
_suggestConstructors(aliasedElement.constructors2, importData);
|
||||
} else if (aliasedElement is MixinElement2) {
|
||||
} else if (aliasedElement is MixinElement) {
|
||||
_suggestConstructors(aliasedElement.constructors2, importData);
|
||||
}
|
||||
}
|
||||
@@ -709,7 +709,7 @@ class DeclarationHelper {
|
||||
/// Adds suggestions for any constructors that are visible within the
|
||||
/// [library].
|
||||
void _addConstructorsImportedFrom({
|
||||
required LibraryElement2 library,
|
||||
required LibraryElement library,
|
||||
required Namespace namespace,
|
||||
required String? prefix,
|
||||
}) {
|
||||
@@ -720,15 +720,15 @@ class DeclarationHelper {
|
||||
);
|
||||
for (var element in namespace.definedNames2.values) {
|
||||
switch (element) {
|
||||
case ClassElement2():
|
||||
case ClassElement():
|
||||
_suggestConstructors(
|
||||
element.constructors2,
|
||||
importData,
|
||||
allowNonFactory: !element.isAbstract,
|
||||
);
|
||||
case ExtensionTypeElement2():
|
||||
case ExtensionTypeElement():
|
||||
_suggestConstructors(element.constructors2, importData);
|
||||
case TypeAliasElement2():
|
||||
case TypeAliasElement():
|
||||
_addConstructorsForAliasedElement(element, importData);
|
||||
}
|
||||
}
|
||||
@@ -737,7 +737,7 @@ class DeclarationHelper {
|
||||
/// Adds suggestions for any top-level declarations that are visible within
|
||||
/// the [library].
|
||||
void _addDeclarationsImportedFrom({
|
||||
required LibraryElement2 library,
|
||||
required LibraryElement library,
|
||||
required Namespace namespace,
|
||||
required String? prefix,
|
||||
}) {
|
||||
@@ -799,7 +799,7 @@ class DeclarationHelper {
|
||||
} else {
|
||||
// All fields induce a getter.
|
||||
var variable = getter.variable3;
|
||||
if (variable is FieldElement2) {
|
||||
if (variable is FieldElement) {
|
||||
_suggestField(field: variable);
|
||||
}
|
||||
}
|
||||
@@ -828,27 +828,27 @@ class DeclarationHelper {
|
||||
///
|
||||
/// The [importData] indicates how the library is, or should be, imported.
|
||||
void _addExternalTopLevelDeclarations({
|
||||
required LibraryElement2 library,
|
||||
required LibraryElement library,
|
||||
required Namespace namespace,
|
||||
required ImportData importData,
|
||||
}) {
|
||||
for (var element in namespace.definedNames2.values) {
|
||||
switch (element) {
|
||||
case ClassElement2():
|
||||
case ClassElement():
|
||||
_suggestClass(element, importData);
|
||||
case EnumElement2():
|
||||
case EnumElement():
|
||||
_suggestEnum(element, importData);
|
||||
case ExtensionElement2():
|
||||
case ExtensionElement():
|
||||
if (!mustBeType) {
|
||||
_suggestExtension(element, importData);
|
||||
}
|
||||
case ExtensionTypeElement2():
|
||||
case ExtensionTypeElement():
|
||||
_suggestExtensionType(element, importData);
|
||||
case TopLevelFunctionElement():
|
||||
if (!mustBeType) {
|
||||
_suggestTopLevelFunction(element, importData);
|
||||
}
|
||||
case MixinElement2():
|
||||
case MixinElement():
|
||||
_suggestMixin(element, importData);
|
||||
case GetterElement():
|
||||
if (!mustBeType) {
|
||||
@@ -864,11 +864,11 @@ class DeclarationHelper {
|
||||
}
|
||||
_suggestTopLevelProperty(element, importData);
|
||||
}
|
||||
case TopLevelVariableElement2():
|
||||
case TopLevelVariableElement():
|
||||
if (!mustBeType) {
|
||||
_suggestTopLevelVariable(element, importData);
|
||||
}
|
||||
case TypeAliasElement2():
|
||||
case TypeAliasElement():
|
||||
_suggestTypeAlias(element, importData);
|
||||
}
|
||||
}
|
||||
@@ -893,7 +893,7 @@ class DeclarationHelper {
|
||||
|
||||
/// Adds suggestions for any constructors that are imported into the
|
||||
/// [library].
|
||||
void _addImportedConstructors(LibraryElement2 library) {
|
||||
void _addImportedConstructors(LibraryElement library) {
|
||||
// TODO(brianwilkerson): This will create suggestions for elements that
|
||||
// conflict with different elements imported from a different library. Not
|
||||
// sure whether that's the desired behavior.
|
||||
@@ -911,7 +911,7 @@ class DeclarationHelper {
|
||||
|
||||
/// Adds suggestions for any top-level declarations that are imported into the
|
||||
/// [library].
|
||||
void _addImportedDeclarations(LibraryElement2 library) {
|
||||
void _addImportedDeclarations(LibraryElement library) {
|
||||
// TODO(brianwilkerson): This will create suggestions for elements that
|
||||
// conflict with different elements imported from a different library. Not
|
||||
// sure whether that's the desired behavior.
|
||||
@@ -937,26 +937,26 @@ class DeclarationHelper {
|
||||
}
|
||||
|
||||
/// Adds a suggestion for the top-level [element].
|
||||
void _addImportedElement(Element2 element) {
|
||||
void _addImportedElement(Element element) {
|
||||
var matcherScore = state.matcher.score(element.displayName);
|
||||
if (matcherScore != -1) {
|
||||
var suggestion = switch (element) {
|
||||
ClassElement2() => ClassSuggestion(
|
||||
ClassElement() => ClassSuggestion(
|
||||
importData: null,
|
||||
element: element,
|
||||
matcherScore: matcherScore,
|
||||
),
|
||||
EnumElement2() => EnumSuggestion(
|
||||
EnumElement() => EnumSuggestion(
|
||||
importData: null,
|
||||
element: element,
|
||||
matcherScore: matcherScore,
|
||||
),
|
||||
ExtensionElement2() => ExtensionSuggestion(
|
||||
ExtensionElement() => ExtensionSuggestion(
|
||||
importData: null,
|
||||
element: element,
|
||||
matcherScore: matcherScore,
|
||||
),
|
||||
ExtensionTypeElement2() => ExtensionTypeSuggestion(
|
||||
ExtensionTypeElement() => ExtensionTypeSuggestion(
|
||||
importData: null,
|
||||
element: element,
|
||||
matcherScore: matcherScore,
|
||||
@@ -967,21 +967,21 @@ class DeclarationHelper {
|
||||
kind: _executableSuggestionKind,
|
||||
matcherScore: matcherScore,
|
||||
),
|
||||
MixinElement2() => MixinSuggestion(
|
||||
MixinElement() => MixinSuggestion(
|
||||
importData: null,
|
||||
element: element,
|
||||
matcherScore: matcherScore,
|
||||
),
|
||||
PropertyAccessorElement2() => _createSuggestionFromTopLevelProperty(
|
||||
PropertyAccessorElement() => _createSuggestionFromTopLevelProperty(
|
||||
element,
|
||||
matcherScore,
|
||||
),
|
||||
TopLevelVariableElement2() => TopLevelVariableSuggestion(
|
||||
TopLevelVariableElement() => TopLevelVariableSuggestion(
|
||||
importData: null,
|
||||
element: element,
|
||||
matcherScore: matcherScore,
|
||||
),
|
||||
TypeAliasElement2() => TypeAliasSuggestion(
|
||||
TypeAliasElement() => TypeAliasSuggestion(
|
||||
importData: null,
|
||||
element: element,
|
||||
matcherScore: matcherScore,
|
||||
@@ -1008,7 +1008,7 @@ class DeclarationHelper {
|
||||
_ => null,
|
||||
};
|
||||
var element = fragment?.element;
|
||||
if (!mustBeStatic && element is ExtensionElement2) {
|
||||
if (!mustBeStatic && element is ExtensionElement) {
|
||||
var thisType = element.thisType;
|
||||
if (thisType is InterfaceType) {
|
||||
_addInstanceMembers(
|
||||
@@ -1020,19 +1020,19 @@ class DeclarationHelper {
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (element is! InterfaceElement2) {
|
||||
if (element is! InterfaceElement) {
|
||||
return;
|
||||
}
|
||||
var referencingInterface = _referencingInterfaceFor(element);
|
||||
var members = request.inheritanceManager.getInheritedMap(element);
|
||||
for (var member in members.values) {
|
||||
switch (member) {
|
||||
case MethodElement2():
|
||||
case MethodElement():
|
||||
_suggestMethod(
|
||||
method: member,
|
||||
referencingInterface: referencingInterface,
|
||||
);
|
||||
case PropertyAccessorElement2():
|
||||
case PropertyAccessorElement():
|
||||
_suggestProperty(
|
||||
accessor: member,
|
||||
referencingInterface: referencingInterface,
|
||||
@@ -1064,12 +1064,12 @@ class DeclarationHelper {
|
||||
? request.inheritanceManager.getInheritedConcreteMap(type.element3)
|
||||
: request.inheritanceManager.getInterface2(type.element3).map2;
|
||||
|
||||
var membersByName = <String, List<ExecutableElement2>>{};
|
||||
var membersByName = <String, List<ExecutableElement>>{};
|
||||
for (var rawMember in map.values) {
|
||||
if (_canAccessInstanceMember(rawMember)) {
|
||||
var name = rawMember.displayName;
|
||||
membersByName
|
||||
.putIfAbsent(name, () => <ExecutableElement2>[])
|
||||
.putIfAbsent(name, () => <ExecutableElement>[])
|
||||
.add(rawMember);
|
||||
}
|
||||
}
|
||||
@@ -1077,7 +1077,7 @@ class DeclarationHelper {
|
||||
for (var entry in membersByName.entries) {
|
||||
var members = entry.value;
|
||||
var rawMember = members.bestMember;
|
||||
if (rawMember is MethodElement2) {
|
||||
if (rawMember is MethodElement) {
|
||||
if (includeMethods) {
|
||||
if (rawMember.isOperator) {
|
||||
continue;
|
||||
@@ -1085,7 +1085,7 @@ class DeclarationHelper {
|
||||
// Exclude static methods when completion on an instance.
|
||||
var member = ExecutableMember.from(rawMember, substitution);
|
||||
_suggestMethod(
|
||||
method: member as MethodElement2,
|
||||
method: member as MethodElement,
|
||||
referencingInterface: referencingInterface,
|
||||
);
|
||||
}
|
||||
@@ -1093,7 +1093,7 @@ class DeclarationHelper {
|
||||
if (!excludedGetters.contains(entry.key)) {
|
||||
var member = ExecutableMember.from(rawMember, substitution);
|
||||
_suggestProperty(
|
||||
accessor: member as PropertyAccessorElement2,
|
||||
accessor: member as PropertyAccessorElement,
|
||||
referencingInterface: referencingInterface,
|
||||
);
|
||||
}
|
||||
@@ -1101,7 +1101,7 @@ class DeclarationHelper {
|
||||
if (includeSetters) {
|
||||
var member = ExecutableMember.from(rawMember, substitution);
|
||||
_suggestProperty(
|
||||
accessor: member as PropertyAccessorElement2,
|
||||
accessor: member as PropertyAccessorElement,
|
||||
referencingInterface: referencingInterface,
|
||||
);
|
||||
}
|
||||
@@ -1269,7 +1269,7 @@ class DeclarationHelper {
|
||||
}
|
||||
|
||||
/// Completion is inside the declaration of the [element].
|
||||
void _addMembersOfEnclosingInstance(InstanceElement2 element) {
|
||||
void _addMembersOfEnclosingInstance(InstanceElement element) {
|
||||
var referencingInterface = _referencingInterfaceFor(element);
|
||||
|
||||
for (var accessor in element.getters2) {
|
||||
@@ -1370,7 +1370,7 @@ class DeclarationHelper {
|
||||
}
|
||||
case GenericTypeAlias():
|
||||
var element = declaration.declaredFragment?.element;
|
||||
if (element is TypeAliasElement2) {
|
||||
if (element is TypeAliasElement) {
|
||||
_suggestTypeParameters(element.typeParameters2);
|
||||
}
|
||||
case MixinDeclaration():
|
||||
@@ -1389,10 +1389,10 @@ class DeclarationHelper {
|
||||
void _addStaticMembers({
|
||||
required List<GetterElement> getters,
|
||||
required List<SetterElement> setters,
|
||||
required List<ConstructorElement2> constructors,
|
||||
required Element2 containingElement,
|
||||
required List<FieldElement2> fields,
|
||||
required List<MethodElement2> methods,
|
||||
required List<ConstructorElement> constructors,
|
||||
required Element containingElement,
|
||||
required List<FieldElement> fields,
|
||||
required List<MethodElement> methods,
|
||||
}) {
|
||||
for (var getter in getters) {
|
||||
if (getter.isStatic &&
|
||||
@@ -1411,7 +1411,7 @@ class DeclarationHelper {
|
||||
for (var field in fields) {
|
||||
if (field.isStatic &&
|
||||
(!field.isSynthetic ||
|
||||
(containingElement is EnumElement2 && field.name3 == 'values')) &&
|
||||
(containingElement is EnumElement && field.name3 == 'values')) &&
|
||||
field.isVisibleIn(request.libraryElement)) {
|
||||
if (field.isEnumConstant) {
|
||||
var enumElement = field.enclosingElement2;
|
||||
@@ -1434,7 +1434,7 @@ class DeclarationHelper {
|
||||
}
|
||||
if (!mustBeAssignable) {
|
||||
var allowNonFactory =
|
||||
containingElement is ClassElement2 && !containingElement.isAbstract;
|
||||
containingElement is ClassElement && !containingElement.isAbstract;
|
||||
for (var constructor in constructors) {
|
||||
if (constructor.isVisibleIn(request.libraryElement) &&
|
||||
(allowNonFactory || constructor.isFactory)) {
|
||||
@@ -1458,7 +1458,7 @@ class DeclarationHelper {
|
||||
/// the [library].
|
||||
///
|
||||
/// The [library] is the library in which completion is being requested.
|
||||
void _addTopLevelDeclarations(LibraryElement2 library) {
|
||||
void _addTopLevelDeclarations(LibraryElement library) {
|
||||
for (var element in library.classes) {
|
||||
_suggestClass(element, null);
|
||||
}
|
||||
@@ -1505,7 +1505,7 @@ class DeclarationHelper {
|
||||
}
|
||||
}
|
||||
|
||||
bool _canAccessInstanceMember(ExecutableElement2 element) {
|
||||
bool _canAccessInstanceMember(ExecutableElement element) {
|
||||
if (element.isStatic) {
|
||||
return false;
|
||||
}
|
||||
@@ -1527,7 +1527,7 @@ class DeclarationHelper {
|
||||
|
||||
if (element.isProtected) {
|
||||
var elementInterface = element.enclosingElement2;
|
||||
if (elementInterface is! InterfaceElement2) {
|
||||
if (elementInterface is! InterfaceElement) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1566,14 +1566,14 @@ class DeclarationHelper {
|
||||
}
|
||||
|
||||
ImportableSuggestion? _createSuggestionFromTopLevelProperty(
|
||||
PropertyAccessorElement2 element,
|
||||
PropertyAccessorElement element,
|
||||
double matcherScore, {
|
||||
ImportData? importData,
|
||||
}) {
|
||||
if (element.isSynthetic) {
|
||||
if (element is GetterElement) {
|
||||
var variable = element.variable3;
|
||||
if (variable is TopLevelVariableElement2) {
|
||||
if (variable is TopLevelVariableElement) {
|
||||
return TopLevelVariableSuggestion(
|
||||
importData: importData,
|
||||
element: variable,
|
||||
@@ -1609,12 +1609,12 @@ class DeclarationHelper {
|
||||
|
||||
/// Returns the interface element for the type of `this` within the
|
||||
/// declaration of the given class-like [element].
|
||||
InterfaceElement2? _referencingInterfaceFor(Element2 element) {
|
||||
if (element is InterfaceElement2) {
|
||||
InterfaceElement? _referencingInterfaceFor(Element element) {
|
||||
if (element is InterfaceElement) {
|
||||
return element;
|
||||
} else if (element is InstanceElement2) {
|
||||
} else if (element is InstanceElement) {
|
||||
var thisElement = element.thisType.element3;
|
||||
if (thisElement is InterfaceElement2) {
|
||||
if (thisElement is InterfaceElement) {
|
||||
return thisElement;
|
||||
}
|
||||
}
|
||||
@@ -1622,7 +1622,7 @@ class DeclarationHelper {
|
||||
}
|
||||
|
||||
/// Adds a suggestion for the class represented by the [element].
|
||||
void _suggestClass(ClassElement2 element, ImportData? importData) {
|
||||
void _suggestClass(ClassElement element, ImportData? importData) {
|
||||
if (visibilityTracker.isVisible(element: element, importData: importData)) {
|
||||
if ((mustBeExtendable &&
|
||||
!element.isExtendableIn2(request.libraryElement)) ||
|
||||
@@ -1655,7 +1655,7 @@ class DeclarationHelper {
|
||||
|
||||
/// Adds a suggestion for the constructor represented by the [element].
|
||||
void _suggestConstructor(
|
||||
ConstructorElement2 element, {
|
||||
ConstructorElement element, {
|
||||
required ImportData? importData,
|
||||
required bool hasClassName,
|
||||
required bool isConstructorRedirect,
|
||||
@@ -1711,7 +1711,7 @@ class DeclarationHelper {
|
||||
|
||||
/// Adds a suggestion for each of the [constructors].
|
||||
void _suggestConstructors(
|
||||
List<ConstructorElement2> constructors,
|
||||
List<ConstructorElement> constructors,
|
||||
ImportData? importData, {
|
||||
bool allowNonFactory = true,
|
||||
}) {
|
||||
@@ -1732,7 +1732,7 @@ class DeclarationHelper {
|
||||
}
|
||||
|
||||
/// Adds a suggestion for the enum represented by the [element].
|
||||
void _suggestEnum(EnumElement2 element, ImportData? importData) {
|
||||
void _suggestEnum(EnumElement element, ImportData? importData) {
|
||||
if (visibilityTracker.isVisible(element: element, importData: importData)) {
|
||||
if (mustBeExtendable || mustBeImplementable || mustBeMixable) {
|
||||
return;
|
||||
@@ -1759,7 +1759,7 @@ class DeclarationHelper {
|
||||
}
|
||||
|
||||
/// Adds a suggestion for the extension represented by the [element].
|
||||
void _suggestExtension(ExtensionElement2 element, ImportData? importData) {
|
||||
void _suggestExtension(ExtensionElement element, ImportData? importData) {
|
||||
if (visibilityTracker.isVisible(element: element, importData: importData)) {
|
||||
if (mustBeExtendable || mustBeImplementable || mustBeMixable) {
|
||||
return;
|
||||
@@ -1785,7 +1785,7 @@ class DeclarationHelper {
|
||||
|
||||
/// Adds a suggestion for the extension type represented by the [element].
|
||||
void _suggestExtensionType(
|
||||
ExtensionTypeElement2 element,
|
||||
ExtensionTypeElement element,
|
||||
ImportData? importData,
|
||||
) {
|
||||
if (visibilityTracker.isVisible(element: element, importData: importData)) {
|
||||
@@ -1815,8 +1815,8 @@ class DeclarationHelper {
|
||||
/// [referencingInterface] is provided, it should be the class in which
|
||||
/// completion was requested.
|
||||
void _suggestField({
|
||||
required FieldElement2 field,
|
||||
InterfaceElement2? referencingInterface,
|
||||
required FieldElement field,
|
||||
InterfaceElement? referencingInterface,
|
||||
bool isInDeclaration = false,
|
||||
}) {
|
||||
if (visibilityTracker.isVisible(element: field, importData: null)) {
|
||||
@@ -1846,7 +1846,7 @@ class DeclarationHelper {
|
||||
}
|
||||
|
||||
/// Adds a suggestion for the local function represented by the [element].
|
||||
void _suggestLocalFunction(ExecutableElement2 element) {
|
||||
void _suggestLocalFunction(ExecutableElement element) {
|
||||
if (element is LocalFunctionElement &&
|
||||
visibilityTracker.isVisible(element: element, importData: null)) {
|
||||
if (mustBeAssignable ||
|
||||
@@ -1879,10 +1879,10 @@ class DeclarationHelper {
|
||||
/// [referencingInterface] is provided, it should be the class in which
|
||||
/// completion was requested.
|
||||
void _suggestMethod({
|
||||
required MethodElement2 method,
|
||||
required MethodElement method,
|
||||
bool ignoreVisibility = false,
|
||||
ImportData? importData,
|
||||
InterfaceElement2? referencingInterface,
|
||||
InterfaceElement? referencingInterface,
|
||||
}) {
|
||||
if (ignoreVisibility ||
|
||||
visibilityTracker.isVisible(element: method, importData: importData)) {
|
||||
@@ -1895,7 +1895,7 @@ class DeclarationHelper {
|
||||
if (matcherScore != -1) {
|
||||
var enclosingElement = method.enclosingElement2;
|
||||
if (method.name3 == 'setState' &&
|
||||
enclosingElement is ClassElement2 &&
|
||||
enclosingElement is ClassElement &&
|
||||
enclosingElement.isExactState) {
|
||||
var suggestion = SetStateMethodSuggestion(
|
||||
element: method,
|
||||
@@ -1920,7 +1920,7 @@ class DeclarationHelper {
|
||||
}
|
||||
|
||||
/// Adds a suggestion for the mixin represented by the [element].
|
||||
void _suggestMixin(MixinElement2 element, ImportData? importData) {
|
||||
void _suggestMixin(MixinElement element, ImportData? importData) {
|
||||
if (visibilityTracker.isVisible(element: element, importData: importData)) {
|
||||
if (mustBeExtendable ||
|
||||
(mustBeImplementable &&
|
||||
@@ -1971,10 +1971,10 @@ class DeclarationHelper {
|
||||
/// [referencingInterface] is provided, it should be the class in which
|
||||
/// completion was requested.
|
||||
void _suggestProperty({
|
||||
required PropertyAccessorElement2 accessor,
|
||||
required PropertyAccessorElement accessor,
|
||||
bool ignoreVisibility = false,
|
||||
ImportData? importData,
|
||||
InterfaceElement2? referencingInterface,
|
||||
InterfaceElement? referencingInterface,
|
||||
bool isInDeclaration = false,
|
||||
}) {
|
||||
if (ignoreVisibility ||
|
||||
@@ -1997,7 +1997,7 @@ class DeclarationHelper {
|
||||
// synthetic setter.
|
||||
if (accessor is GetterElement) {
|
||||
var variable = accessor.variable3;
|
||||
if (variable is FieldElement2) {
|
||||
if (variable is FieldElement) {
|
||||
var suggestion = FieldSuggestion(
|
||||
element: variable,
|
||||
matcherScore: matcherScore,
|
||||
@@ -2049,7 +2049,7 @@ class DeclarationHelper {
|
||||
|
||||
/// Adds a suggestion for the enum constant represented by the [element].
|
||||
/// The [importData] should be provided if the enum is imported.
|
||||
void _suggestStaticField(FieldElement2 element, ImportData? importData) {
|
||||
void _suggestStaticField(FieldElement element, ImportData? importData) {
|
||||
if (!element.isStatic ||
|
||||
(mustBeAssignable && !(element.isFinal || element.isConst)) ||
|
||||
(mustBeConstant && !element.isConst)) {
|
||||
@@ -2082,7 +2082,7 @@ class DeclarationHelper {
|
||||
if (getter != null) {
|
||||
if (getter.isSynthetic) {
|
||||
var variable = getter.variable3;
|
||||
if (variable is FieldElement2) {
|
||||
if (variable is FieldElement) {
|
||||
var suggestion = FieldSuggestion(
|
||||
element: variable,
|
||||
matcherScore: matcherScore,
|
||||
@@ -2116,10 +2116,7 @@ class DeclarationHelper {
|
||||
}
|
||||
|
||||
/// Adds a suggestion for each of the static fields in the list of [fields].
|
||||
void _suggestStaticFields(
|
||||
List<FieldElement2> fields,
|
||||
ImportData? importData,
|
||||
) {
|
||||
void _suggestStaticFields(List<FieldElement> fields, ImportData? importData) {
|
||||
for (var field in fields) {
|
||||
if (field.isVisibleIn(request.libraryElement)) {
|
||||
_suggestStaticField(field, importData);
|
||||
@@ -2164,7 +2161,7 @@ class DeclarationHelper {
|
||||
|
||||
/// Adds a suggestion for the getter or setter represented by the [element].
|
||||
void _suggestTopLevelProperty(
|
||||
PropertyAccessorElement2 element,
|
||||
PropertyAccessorElement element,
|
||||
ImportData? importData,
|
||||
) {
|
||||
if (visibilityTracker.isVisible(element: element, importData: importData)) {
|
||||
@@ -2192,7 +2189,7 @@ class DeclarationHelper {
|
||||
|
||||
/// Adds a suggestion for the getter or setter represented by the [element].
|
||||
void _suggestTopLevelVariable(
|
||||
TopLevelVariableElement2 element,
|
||||
TopLevelVariableElement element,
|
||||
ImportData? importData,
|
||||
) {
|
||||
if (visibilityTracker.isVisible(element: element, importData: importData)) {
|
||||
@@ -2214,7 +2211,7 @@ class DeclarationHelper {
|
||||
}
|
||||
|
||||
/// Adds a suggestion for the type alias represented by the [element].
|
||||
void _suggestTypeAlias(TypeAliasElement2 element, ImportData? importData) {
|
||||
void _suggestTypeAlias(TypeAliasElement element, ImportData? importData) {
|
||||
if (visibilityTracker.isVisible(element: element, importData: importData)) {
|
||||
var matcherScore = state.matcher.score(element.displayName);
|
||||
if (matcherScore != -1) {
|
||||
@@ -2232,7 +2229,7 @@ class DeclarationHelper {
|
||||
}
|
||||
|
||||
/// Adds a suggestion for the type parameter represented by the [element].
|
||||
void _suggestTypeParameter(TypeParameterElement2 element) {
|
||||
void _suggestTypeParameter(TypeParameterElement element) {
|
||||
if (visibilityTracker.isVisible(element: element, importData: null)) {
|
||||
var matcherScore = state.matcher.score(element.displayName);
|
||||
if (matcherScore != -1) {
|
||||
@@ -2246,7 +2243,7 @@ class DeclarationHelper {
|
||||
}
|
||||
|
||||
/// Adds a suggestion for each of the [typeParameters].
|
||||
void _suggestTypeParameters(List<TypeParameterElement2> typeParameters) {
|
||||
void _suggestTypeParameters(List<TypeParameterElement> typeParameters) {
|
||||
for (var parameter in typeParameters) {
|
||||
if (!_isWildcard(parameter.name3)) {
|
||||
_suggestTypeParameter(parameter);
|
||||
@@ -2255,7 +2252,7 @@ class DeclarationHelper {
|
||||
}
|
||||
|
||||
/// Adds a suggestion for the local variable represented by the [element].
|
||||
void _suggestVariable(LocalVariableElement2 element) {
|
||||
void _suggestVariable(LocalVariableElement element) {
|
||||
if (element.isWildcardVariable) return;
|
||||
if (visibilityTracker.isVisible(element: element, importData: null)) {
|
||||
if (mustBeConstant && !element.isConst) {
|
||||
@@ -2324,7 +2321,7 @@ class DeclarationHelper {
|
||||
var variables = node.variables;
|
||||
for (var variable in variables.variables) {
|
||||
var declaredElement = variable.declaredElement2;
|
||||
if (declaredElement is LocalVariableElement2) {
|
||||
if (declaredElement is LocalVariableElement) {
|
||||
_suggestVariable(declaredElement);
|
||||
}
|
||||
}
|
||||
@@ -2524,12 +2521,12 @@ class DeclarationHelper {
|
||||
}
|
||||
}
|
||||
|
||||
extension on Element2 {
|
||||
extension on Element {
|
||||
/// Whether this element is visible within the [referencingLibrary].
|
||||
///
|
||||
/// An element is visible if it's declared in the [referencingLibrary] or if
|
||||
/// the name is not private.
|
||||
bool isVisibleIn(LibraryElement2 referencingLibrary) {
|
||||
bool isVisibleIn(LibraryElement referencingLibrary) {
|
||||
if (library2 == referencingLibrary) {
|
||||
return true;
|
||||
}
|
||||
@@ -2538,13 +2535,13 @@ extension on Element2 {
|
||||
}
|
||||
}
|
||||
|
||||
extension on List<ExecutableElement2> {
|
||||
extension on List<ExecutableElement> {
|
||||
/// Returns the element in this list that is the best element to suggest.
|
||||
///
|
||||
/// Getters are preferred over setters, otherwise the first element in the
|
||||
/// list is returned under the assumption that it's lower in the hierarchy.
|
||||
ExecutableElement2 get bestMember {
|
||||
ExecutableElement2 bestMember = this[0];
|
||||
ExecutableElement get bestMember {
|
||||
ExecutableElement bestMember = this[0];
|
||||
if (bestMember is SetterElement) {
|
||||
for (var i = 1; i < length; i++) {
|
||||
var member = this[i];
|
||||
@@ -2557,7 +2554,7 @@ extension on List<ExecutableElement2> {
|
||||
}
|
||||
}
|
||||
|
||||
extension on PropertyAccessorElement2 {
|
||||
extension on PropertyAccessorElement {
|
||||
/// Whether this accessor is an accessor for a constant variable.
|
||||
bool get isConst {
|
||||
if (isSynthetic) {
|
||||
|
||||
@@ -188,18 +188,18 @@ class FeatureComputer {
|
||||
/// setters are always mapped into a different kind: FIELD for getters and
|
||||
/// setters declared in a class or extension, and TOP_LEVEL_VARIABLE for
|
||||
/// top-level getters and setters.
|
||||
protocol.ElementKind computeElementKind(Element2 element) {
|
||||
if (element is LibraryElement2) {
|
||||
protocol.ElementKind computeElementKind(Element element) {
|
||||
if (element is LibraryElement) {
|
||||
return protocol.ElementKind.PREFIX;
|
||||
} else if (element is EnumElement2) {
|
||||
} else if (element is EnumElement) {
|
||||
return protocol.ElementKind.ENUM;
|
||||
} else if (element is MixinElement2) {
|
||||
} else if (element is MixinElement) {
|
||||
return protocol.ElementKind.MIXIN;
|
||||
} else if (element is ClassElement2) {
|
||||
} else if (element is ClassElement) {
|
||||
return protocol.ElementKind.CLASS;
|
||||
} else if (element is FieldElement2 && element.isEnumConstant) {
|
||||
} else if (element is FieldElement && element.isEnumConstant) {
|
||||
return protocol.ElementKind.ENUM_CONSTANT;
|
||||
} else if (element is PropertyAccessorElement2) {
|
||||
} else if (element is PropertyAccessorElement) {
|
||||
var variable = element.variable3;
|
||||
if (variable == null) {
|
||||
return protocol.ElementKind.UNKNOWN;
|
||||
@@ -244,18 +244,18 @@ class FeatureComputer {
|
||||
/// setters are always mapped into a different kind: FIELD for getters and
|
||||
/// setters declared in a class or extension, and TOP_LEVEL_VARIABLE for
|
||||
/// top-level getters and setters.
|
||||
protocol.ElementKind computeElementKind2(Element2 element) {
|
||||
if (element is LibraryElement2) {
|
||||
protocol.ElementKind computeElementKind2(Element element) {
|
||||
if (element is LibraryElement) {
|
||||
return protocol.ElementKind.PREFIX;
|
||||
} else if (element is EnumElement2) {
|
||||
} else if (element is EnumElement) {
|
||||
return protocol.ElementKind.ENUM;
|
||||
} else if (element is MixinElement2) {
|
||||
} else if (element is MixinElement) {
|
||||
return protocol.ElementKind.MIXIN;
|
||||
} else if (element is ClassElement2) {
|
||||
} else if (element is ClassElement) {
|
||||
return protocol.ElementKind.CLASS;
|
||||
} else if (element is FieldElement2 && element.isEnumConstant) {
|
||||
} else if (element is FieldElement && element.isEnumConstant) {
|
||||
return protocol.ElementKind.ENUM_CONSTANT;
|
||||
} else if (element is PropertyAccessorElement2) {
|
||||
} else if (element is PropertyAccessorElement) {
|
||||
var variable = element.variable3;
|
||||
if (variable == null) {
|
||||
return protocol.ElementKind.UNKNOWN;
|
||||
@@ -331,7 +331,7 @@ class FeatureComputer {
|
||||
/// completing at the given [completionLocation]. If a [distance] is given it
|
||||
/// will be used to provide finer-grained relevance scores.
|
||||
double elementKindFeature(
|
||||
Element2 element,
|
||||
Element element,
|
||||
String? completionLocation, {
|
||||
double? distance,
|
||||
}) {
|
||||
@@ -353,7 +353,7 @@ class FeatureComputer {
|
||||
}
|
||||
|
||||
// Return the value of the _has deprecated_ feature for the given [element].
|
||||
double hasDeprecatedFeature(Element2 element) {
|
||||
double hasDeprecatedFeature(Element element) {
|
||||
return element.hasOrInheritsDeprecated ? -1.0 : 0.0;
|
||||
}
|
||||
|
||||
@@ -364,8 +364,8 @@ class FeatureComputer {
|
||||
/// supertype if the two types are not the same. Return `-1` if the [subclass]
|
||||
/// is not a subclass of the [superclass].
|
||||
int inheritanceDistance(
|
||||
InterfaceElement2 subclass,
|
||||
InterfaceElement2 superclass,
|
||||
InterfaceElement subclass,
|
||||
InterfaceElement superclass,
|
||||
) {
|
||||
// This method is only visible for the metrics computation and might be made
|
||||
// private at some future date.
|
||||
@@ -376,24 +376,22 @@ class FeatureComputer {
|
||||
/// defined in the [superclass] that is being accessed through an expression
|
||||
/// whose static type is the [subclass].
|
||||
double inheritanceDistanceFeature(
|
||||
InterfaceElement2 subclass,
|
||||
InterfaceElement2 superclass,
|
||||
InterfaceElement subclass,
|
||||
InterfaceElement superclass,
|
||||
) {
|
||||
var distance = _inheritanceDistance(subclass, superclass, {});
|
||||
return distanceToPercent(distance);
|
||||
}
|
||||
|
||||
/// Return the value of the _is constant_ feature for the given [element].
|
||||
double isConstantFeature(Element2 element) {
|
||||
if (element is ConstructorElement2 && element.isConst) {
|
||||
double isConstantFeature(Element element) {
|
||||
if (element is ConstructorElement && element.isConst) {
|
||||
return 1.0;
|
||||
} else if (element is FieldElement2 &&
|
||||
element.isStatic &&
|
||||
element.isConst) {
|
||||
} else if (element is FieldElement && element.isStatic && element.isConst) {
|
||||
return 1.0;
|
||||
} else if (element is TopLevelVariableElement2 && element.isConst) {
|
||||
} else if (element is TopLevelVariableElement && element.isConst) {
|
||||
return 1.0;
|
||||
} else if (element is PropertyAccessorElement2 && element.isSynthetic) {
|
||||
} else if (element is PropertyAccessorElement && element.isSynthetic) {
|
||||
var variable = element.variable3;
|
||||
if (variable != null && variable.isStatic && variable.isConst) {
|
||||
return 1.0;
|
||||
@@ -412,7 +410,7 @@ class FeatureComputer {
|
||||
// override of `noSuchMethod`.
|
||||
return 0.0;
|
||||
}
|
||||
return proposedMemberName == MethodElement2.NO_SUCH_METHOD_METHOD_NAME
|
||||
return proposedMemberName == MethodElement.NO_SUCH_METHOD_METHOD_NAME
|
||||
? -1.0
|
||||
: 0.0;
|
||||
}
|
||||
@@ -469,9 +467,9 @@ class FeatureComputer {
|
||||
///
|
||||
/// This is the implementation of [inheritanceDistance].
|
||||
int _inheritanceDistance(
|
||||
InterfaceElement2? subclass,
|
||||
InterfaceElement2 superclass,
|
||||
Set<InterfaceElement2> visited,
|
||||
InterfaceElement? subclass,
|
||||
InterfaceElement superclass,
|
||||
Set<InterfaceElement> visited,
|
||||
) {
|
||||
if (subclass == null) {
|
||||
return -1;
|
||||
@@ -495,7 +493,7 @@ class FeatureComputer {
|
||||
}
|
||||
}
|
||||
|
||||
if (subclass is MixinElement2) {
|
||||
if (subclass is MixinElement) {
|
||||
visitTypes(subclass.superclassConstraints);
|
||||
}
|
||||
visitTypes(subclass.mixins);
|
||||
@@ -664,7 +662,7 @@ class _ContextTypeVisitor extends SimpleAstVisitor<DartType> {
|
||||
DartType? visitConstructorFieldInitializer(ConstructorFieldInitializer node) {
|
||||
if (node.equals.end <= offset) {
|
||||
var element = node.fieldName.element;
|
||||
if (element is FieldElement2) {
|
||||
if (element is FieldElement) {
|
||||
return element.type;
|
||||
}
|
||||
}
|
||||
@@ -1226,7 +1224,7 @@ parent3: ${node.parent?.parent?.parent}
|
||||
// TODO(brianwilkerson): Replace with `patternTypeSchema` (on AST) where
|
||||
// possible.
|
||||
pattern = pattern.unParenthesized;
|
||||
Element2? element;
|
||||
Element? element;
|
||||
if (pattern is AssignedVariablePattern) {
|
||||
element = pattern.element2;
|
||||
} else if (pattern is DeclaredVariablePattern) {
|
||||
@@ -1236,7 +1234,7 @@ parent3: ${node.parent?.parent?.parent}
|
||||
} else if (pattern is ListPattern) {
|
||||
return pattern.requiredType;
|
||||
}
|
||||
if (element is VariableElement2) {
|
||||
if (element is VariableElement) {
|
||||
return element.type;
|
||||
}
|
||||
return null;
|
||||
@@ -1264,7 +1262,7 @@ parent3: ${node.parent?.parent?.parent}
|
||||
var member = manager.getMember3(type, Name(uri, name));
|
||||
if (member is GetterElement) {
|
||||
return member.returnType;
|
||||
} else if (member is MethodElement2) {
|
||||
} else if (member is MethodElement) {
|
||||
return member.returnType;
|
||||
}
|
||||
return null;
|
||||
|
||||
+26
-26
@@ -789,7 +789,7 @@ class InScopeCompletionPass extends SimpleAstVisitor<void> {
|
||||
void visitConstructorName(ConstructorName node) {
|
||||
if (node.parent is ConstructorReference) {
|
||||
var element = node.type.element2;
|
||||
if (element is InterfaceElement2) {
|
||||
if (element is InterfaceElement) {
|
||||
declarationHelper(
|
||||
preferNonInvocation: true,
|
||||
).addStaticMembersOfElement(element);
|
||||
@@ -1278,8 +1278,8 @@ class InScopeCompletionPass extends SimpleAstVisitor<void> {
|
||||
}
|
||||
if (constructor is ConstructorDeclaration) {
|
||||
var declaredElement = node.declaredFragment?.element;
|
||||
FieldElement2? field;
|
||||
if (declaredElement is FieldFormalParameterElement2) {
|
||||
FieldElement? field;
|
||||
if (declaredElement is FieldFormalParameterElement) {
|
||||
field = declaredElement.field2;
|
||||
}
|
||||
declarationHelper().addFieldsForInitializers(constructor, field);
|
||||
@@ -1679,13 +1679,13 @@ class InScopeCompletionPass extends SimpleAstVisitor<void> {
|
||||
var element = node.element2;
|
||||
DartType type;
|
||||
collector.completionLocation = 'PropertyAccess_propertyName';
|
||||
if (element is FunctionTypedElement2) {
|
||||
if (element is FunctionTypedElement) {
|
||||
if (element is GetterElement) {
|
||||
type = element.type.returnType;
|
||||
} else {
|
||||
type = element.type;
|
||||
}
|
||||
} else if (element is PrefixElement2) {
|
||||
} else if (element is PrefixElement) {
|
||||
var isInstanceCreation =
|
||||
node.parent?.parent?.parent is InstanceCreationExpression;
|
||||
declarationHelper(
|
||||
@@ -1694,10 +1694,10 @@ class InScopeCompletionPass extends SimpleAstVisitor<void> {
|
||||
mustBeNonVoid: isInstanceCreation,
|
||||
).addDeclarationsThroughImportPrefix(element);
|
||||
return;
|
||||
} else if (element is VariableElement2) {
|
||||
} else if (element is VariableElement) {
|
||||
type = element.type;
|
||||
} else {
|
||||
if (element is InterfaceElement2 || element is ExtensionElement2) {
|
||||
if (element is InterfaceElement || element is ExtensionElement) {
|
||||
declarationHelper().addStaticMembersOfElement(element!);
|
||||
}
|
||||
return;
|
||||
@@ -1944,10 +1944,10 @@ class InScopeCompletionPass extends SimpleAstVisitor<void> {
|
||||
target is Identifier &&
|
||||
(!node.isCascaded || offset == operator.offset + 1)) {
|
||||
var element = target.element;
|
||||
if (element is InterfaceElement2 || element is ExtensionTypeElement2) {
|
||||
if (element is InterfaceElement || element is ExtensionTypeElement) {
|
||||
declarationHelper().addStaticMembersOfElement(element!);
|
||||
}
|
||||
if (element is PrefixElement2) {
|
||||
if (element is PrefixElement) {
|
||||
declarationHelper().addDeclarationsThroughImportPrefix(element);
|
||||
}
|
||||
}
|
||||
@@ -2076,7 +2076,7 @@ class InScopeCompletionPass extends SimpleAstVisitor<void> {
|
||||
var prefixElement = importPrefix?.element2;
|
||||
|
||||
// `prefix.x^ print(0);` is recovered as `prefix.x print; (0);`.
|
||||
if (prefixElement is PrefixElement2) {
|
||||
if (prefixElement is PrefixElement) {
|
||||
if (node.parent case VariableDeclarationList variableList) {
|
||||
if (variableList.parent case VariableDeclarationStatement statement) {
|
||||
if (statement.semicolon.isSynthetic) {
|
||||
@@ -2265,7 +2265,7 @@ class InScopeCompletionPass extends SimpleAstVisitor<void> {
|
||||
var parent = node.parent;
|
||||
var mustBeAssignable =
|
||||
parent is AssignmentExpression && node == parent.leftHandSide;
|
||||
if (element is PrefixElement2) {
|
||||
if (element is PrefixElement) {
|
||||
declarationHelper(
|
||||
mustBeAssignable: mustBeAssignable,
|
||||
).addDeclarationsThroughImportPrefix(element);
|
||||
@@ -2274,13 +2274,13 @@ class InScopeCompletionPass extends SimpleAstVisitor<void> {
|
||||
mustBeAssignable: mustBeAssignable,
|
||||
preferNonInvocation:
|
||||
node.parent is CommentReference ||
|
||||
(element is InterfaceElement2 &&
|
||||
(element is InterfaceElement &&
|
||||
state.request.shouldSuggestTearOff(element)),
|
||||
);
|
||||
if (node.parent is CommentReference) {
|
||||
if (element is InterfaceElement2) {
|
||||
if (element is InterfaceElement) {
|
||||
helper.addInstanceMembersOfType(element.thisType);
|
||||
} else if (element is ExtensionElement2) {
|
||||
} else if (element is ExtensionElement) {
|
||||
helper.addMembersFromExtensionElement(
|
||||
element,
|
||||
excludedGetters: {},
|
||||
@@ -2333,10 +2333,10 @@ class InScopeCompletionPass extends SimpleAstVisitor<void> {
|
||||
target is Identifier &&
|
||||
(!node.isCascaded || offset == operator.offset + 1)) {
|
||||
var element = target.element;
|
||||
if (element is InterfaceElement2 || element is ExtensionTypeElement2) {
|
||||
if (element is InterfaceElement || element is ExtensionTypeElement) {
|
||||
declarationHelper().addStaticMembersOfElement(element!);
|
||||
}
|
||||
if (element is PrefixElement2) {
|
||||
if (element is PrefixElement) {
|
||||
declarationHelper().addDeclarationsThroughImportPrefix(element);
|
||||
}
|
||||
}
|
||||
@@ -2579,7 +2579,7 @@ class InScopeCompletionPass extends SimpleAstVisitor<void> {
|
||||
if (type is NamedType) {
|
||||
if (type.importPrefix case var importPrefix?) {
|
||||
var prefixElement = importPrefix.element2;
|
||||
if (prefixElement is PrefixElement2) {
|
||||
if (prefixElement is PrefixElement) {
|
||||
if (type.name2.coversOffset(offset)) {
|
||||
declarationHelper(
|
||||
mustBeType: true,
|
||||
@@ -3418,8 +3418,8 @@ class InScopeCompletionPass extends SimpleAstVisitor<void> {
|
||||
ConstructorFieldInitializer? initializer,
|
||||
) {
|
||||
var element = initializer?.fieldName.element;
|
||||
FieldElement2? field;
|
||||
if (element is FieldElement2) {
|
||||
FieldElement? field;
|
||||
if (element is FieldElement) {
|
||||
field = element;
|
||||
}
|
||||
keywordHelper.addConstructorInitializerKeywords(constructor, initializer);
|
||||
@@ -3740,7 +3740,7 @@ class InScopeCompletionPass extends SimpleAstVisitor<void> {
|
||||
if (node is NamedType) {
|
||||
if (node.importPrefix case var importPrefix?) {
|
||||
var prefixElement = importPrefix.element2;
|
||||
if (prefixElement is PrefixElement2) {
|
||||
if (prefixElement is PrefixElement) {
|
||||
declarationHelper(
|
||||
mustBeExtensible: mustBeExtensible,
|
||||
mustBeImplementable: mustBeImplementable,
|
||||
@@ -3923,7 +3923,7 @@ class InScopeCompletionPass extends SimpleAstVisitor<void> {
|
||||
/// If the budget has been exceeded, then the results are marked as incomplete
|
||||
/// and no suggestions are added.
|
||||
void _suggestOverridesFor({
|
||||
required InterfaceElement2? element,
|
||||
required InterfaceElement? element,
|
||||
bool skipAt = false,
|
||||
}) {
|
||||
if (state.budget.isEmpty) {
|
||||
@@ -4015,7 +4015,7 @@ class InScopeCompletionPass extends SimpleAstVisitor<void> {
|
||||
var lexeme = identifier.lexeme;
|
||||
if (lexeme.isNotEmpty && 'override'.startsWith(lexeme)) {
|
||||
var declaredElement = node.declaredFragment?.element;
|
||||
if (declaredElement is InterfaceElement2) {
|
||||
if (declaredElement is InterfaceElement) {
|
||||
_suggestOverridesFor(element: declaredElement, skipAt: true);
|
||||
}
|
||||
}
|
||||
@@ -4212,7 +4212,7 @@ extension on ClassMember {
|
||||
extension on ArgumentList {
|
||||
/// The element being invoked by the expression containing this argument list,
|
||||
/// or `null` if the element is not known.
|
||||
Element2? get invokedElement {
|
||||
Element? get invokedElement {
|
||||
switch (parent) {
|
||||
case Annotation invocation:
|
||||
return invocation.element2;
|
||||
@@ -4334,7 +4334,7 @@ extension on CompilationUnit {
|
||||
}
|
||||
}
|
||||
|
||||
extension on Element2? {
|
||||
extension on Element? {
|
||||
/// Returns the parameters associated with this element, or `null` if this
|
||||
/// element doesn't have any parameters associated with it.
|
||||
///
|
||||
@@ -4346,9 +4346,9 @@ extension on Element2? {
|
||||
var self = this;
|
||||
if (self is GetterElement) {
|
||||
return self.returnType.ifTypeOrNull<FunctionType>()?.formalParameters;
|
||||
} else if (self is ExecutableElement2) {
|
||||
} else if (self is ExecutableElement) {
|
||||
return self.formalParameters;
|
||||
} else if (self is VariableElement2) {
|
||||
} else if (self is VariableElement) {
|
||||
var type = self.type;
|
||||
if (type is FunctionType) {
|
||||
return type.formalParameters;
|
||||
|
||||
+8
-8
@@ -26,7 +26,7 @@ class ConstructorsOperation extends NotImportedOperation {
|
||||
: _declarationHelper = declarationHelper;
|
||||
|
||||
/// Compute any candidate suggestions for elements in the [library].
|
||||
void computeSuggestionsIn(LibraryElement2 library) {
|
||||
void computeSuggestionsIn(LibraryElement library) {
|
||||
_declarationHelper.addNotImportedConstructors(library);
|
||||
}
|
||||
}
|
||||
@@ -62,7 +62,7 @@ class InstanceExtensionMembersOperation extends NotImportedOperation {
|
||||
_includeSetters = includeSetters;
|
||||
|
||||
/// Compute any candidate suggestions for elements in the [library].
|
||||
void computeSuggestionsIn(LibraryElement2 library) {
|
||||
void computeSuggestionsIn(LibraryElement library) {
|
||||
_declarationHelper.addNotImportedExtensionMethods(
|
||||
library: library,
|
||||
type: _type,
|
||||
@@ -198,9 +198,9 @@ class StaticMembersOperation extends NotImportedOperation {
|
||||
|
||||
/// Compute any candidate suggestions for elements in the [library].
|
||||
void computeSuggestionsIn(
|
||||
LibraryElement2 library,
|
||||
List<Element2> exportElements,
|
||||
Set<Element2> importedElements,
|
||||
LibraryElement library,
|
||||
List<Element> exportElements,
|
||||
Set<Element> importedElements,
|
||||
) {
|
||||
// TODO(brianwilkerson): Determine whether we need the element parameters.
|
||||
_declarationHelper.addNotImportedTopLevelDeclarations(library);
|
||||
@@ -211,12 +211,12 @@ class StaticMembersOperation extends NotImportedOperation {
|
||||
class _ImportSummary {
|
||||
/// The elements that are imported from libraries that are only partially
|
||||
/// imported.
|
||||
Set<Element2> importedElements = Set<Element2>.identity();
|
||||
Set<Element> importedElements = Set<Element>.identity();
|
||||
|
||||
/// The libraries that are imported in their entirety.
|
||||
Set<LibraryElement2> importedLibraries = Set<LibraryElement2>.identity();
|
||||
Set<LibraryElement> importedLibraries = Set<LibraryElement>.identity();
|
||||
|
||||
_ImportSummary(LibraryElement2 library) {
|
||||
_ImportSummary(LibraryElement library) {
|
||||
for (var fragment in library.fragments) {
|
||||
for (var import in fragment.libraryImports2) {
|
||||
var importedLibrary = import.importedLibrary2;
|
||||
|
||||
@@ -29,7 +29,7 @@ class OverrideHelper {
|
||||
: inheritanceManager = state.request.inheritanceManager;
|
||||
|
||||
void computeOverridesFor({
|
||||
required InterfaceElement2 interfaceElement,
|
||||
required InterfaceElement interfaceElement,
|
||||
required SourceRange replacementRange,
|
||||
required bool skipAt,
|
||||
}) {
|
||||
@@ -73,7 +73,7 @@ class OverrideHelper {
|
||||
}
|
||||
|
||||
/// Checks if the [element] has the `@nonVirtual` annotation.
|
||||
bool _hasNonVirtualAnnotation(ExecutableElement2 element) {
|
||||
bool _hasNonVirtualAnnotation(ExecutableElement element) {
|
||||
if (element is GetterElement && element.isSynthetic) {
|
||||
var variable = element.variable3;
|
||||
if (variable != null && variable.metadata2.hasNonVirtual) {
|
||||
|
||||
@@ -65,9 +65,9 @@ class RelevanceComputer {
|
||||
return _cachedContainingMemberName;
|
||||
}
|
||||
|
||||
/// Compute the relevance for [FieldElement2] suggestion.
|
||||
/// Compute the relevance for [FieldElement] suggestion.
|
||||
int computeFieldElementRelevance(
|
||||
FieldElement2 element,
|
||||
FieldElement element,
|
||||
double inheritanceDistance,
|
||||
) {
|
||||
var contextType = featureComputer.contextTypeFeature(
|
||||
@@ -340,7 +340,7 @@ class RelevanceComputer {
|
||||
|
||||
/// Return the relevance score for a top-level [element].
|
||||
int computeTopLevelRelevance(
|
||||
Element2 element, {
|
||||
Element element, {
|
||||
required DartType elementType,
|
||||
required bool isNotImportedLibrary,
|
||||
}) {
|
||||
@@ -367,7 +367,7 @@ class RelevanceComputer {
|
||||
|
||||
/// Return the relevance score for a top-level [element].
|
||||
int computeTopLevelRelevance2(
|
||||
Element2 element, {
|
||||
Element element, {
|
||||
required DartType elementType,
|
||||
required bool isNotImportedLibrary,
|
||||
}) {
|
||||
@@ -395,7 +395,7 @@ class RelevanceComputer {
|
||||
/// Compute the relevance for an [accessor].
|
||||
int _computeAccessorRelevance(
|
||||
DartType? type,
|
||||
Element2 accessor,
|
||||
Element accessor,
|
||||
bool isNotImportedLibrary, {
|
||||
double startsWithDollar = 0.0,
|
||||
double superMatches = 0.0,
|
||||
@@ -420,9 +420,9 @@ class RelevanceComputer {
|
||||
);
|
||||
}
|
||||
|
||||
/// Compute the relevance for [ConstructorElement2].
|
||||
/// Compute the relevance for [ConstructorElement].
|
||||
int _computeConstructorRelevance(
|
||||
ConstructorElement2 element,
|
||||
ConstructorElement element,
|
||||
NeverType neverType,
|
||||
bool isNotImportedLibrary,
|
||||
) {
|
||||
@@ -437,7 +437,7 @@ class RelevanceComputer {
|
||||
|
||||
/// Compute the value of the _element kind_ feature for the given [element] in
|
||||
/// the completion context.
|
||||
double _computeElementKind(Element2 element, {double? distance}) {
|
||||
double _computeElementKind(Element element, {double? distance}) {
|
||||
var location = completionLocation;
|
||||
var elementKind = featureComputer.elementKindFeature(
|
||||
element,
|
||||
@@ -459,7 +459,7 @@ class RelevanceComputer {
|
||||
|
||||
/// Compute the value of the _element kind_ feature for the given [element] in
|
||||
/// the completion context.
|
||||
double _computeElementKind2(Element2 element, {double? distance}) {
|
||||
double _computeElementKind2(Element element, {double? distance}) {
|
||||
var location = completionLocation;
|
||||
var elementKind = featureComputer.elementKindFeature(
|
||||
element,
|
||||
@@ -564,9 +564,9 @@ class RelevanceComputer {
|
||||
);
|
||||
}
|
||||
|
||||
/// Compute the relevance for [MethodElement2].
|
||||
/// Compute the relevance for [MethodElement].
|
||||
int _computeMethodRelevance(
|
||||
MethodElement2 method,
|
||||
MethodElement method,
|
||||
double inheritanceDistance,
|
||||
bool isNotImportedLibrary,
|
||||
) {
|
||||
@@ -605,16 +605,16 @@ class RelevanceComputer {
|
||||
);
|
||||
}
|
||||
|
||||
/// Compute the relevance for [PropertyAccessorElement2].
|
||||
/// Compute the relevance for [PropertyAccessorElement].
|
||||
int _computePropertyAccessorRelevance(
|
||||
PropertyAccessorElement2 accessor,
|
||||
PropertyAccessorElement accessor,
|
||||
double inheritanceDistance,
|
||||
bool isNotImportedLibrary,
|
||||
) {
|
||||
if (accessor.isSynthetic) {
|
||||
if (accessor is GetterElement) {
|
||||
var variable = accessor.variable3;
|
||||
if (variable is FieldElement2) {
|
||||
if (variable is FieldElement) {
|
||||
return computeFieldElementRelevance(variable, inheritanceDistance);
|
||||
}
|
||||
}
|
||||
@@ -639,9 +639,9 @@ class RelevanceComputer {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// Compute the relevance for a static [FieldElement2].
|
||||
/// Compute the relevance for a static [FieldElement].
|
||||
int _computeStaticFieldRelevance(
|
||||
FieldElement2 element,
|
||||
FieldElement element,
|
||||
double inheritanceDistance,
|
||||
bool isNotImportedLibrary,
|
||||
) {
|
||||
@@ -649,7 +649,7 @@ class RelevanceComputer {
|
||||
var getter = element.getter2;
|
||||
if (getter != null) {
|
||||
var variable = getter.variable3;
|
||||
if (variable is FieldElement2) {
|
||||
if (variable is FieldElement) {
|
||||
return computeFieldElementRelevance(variable, inheritanceDistance);
|
||||
}
|
||||
}
|
||||
@@ -663,15 +663,15 @@ class RelevanceComputer {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// Compute the relevance for top level [PropertyAccessorElement2].
|
||||
/// Compute the relevance for top level [PropertyAccessorElement].
|
||||
int _computeTopLevelPropertyAccessorRelevance(
|
||||
PropertyAccessorElement2 accessor,
|
||||
PropertyAccessorElement accessor,
|
||||
bool isNotImportedLibrary,
|
||||
) {
|
||||
if (accessor.isSynthetic) {
|
||||
if (accessor is GetterElement) {
|
||||
var variable = accessor.variable3;
|
||||
if (variable is TopLevelVariableElement2) {
|
||||
if (variable is TopLevelVariableElement) {
|
||||
return computeTopLevelRelevance(
|
||||
variable,
|
||||
elementType: variable.type,
|
||||
@@ -694,8 +694,8 @@ class RelevanceComputer {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// Compute the relevance for [TypeParameterElement2].
|
||||
int _computeTypeParameterRelevance(TypeParameterElement2 parameter) {
|
||||
/// Compute the relevance for [TypeParameterElement].
|
||||
int _computeTypeParameterRelevance(TypeParameterElement parameter) {
|
||||
var elementKind = _computeElementKind(parameter);
|
||||
var isConstant =
|
||||
preferConstants ? featureComputer.isConstantFeature(parameter) : 0.0;
|
||||
@@ -704,7 +704,7 @@ class RelevanceComputer {
|
||||
|
||||
/// Return the type associated with the [accessor], maybe `null` if an
|
||||
/// invalid setter with no parameters at all.
|
||||
DartType? _getPropertyAccessorType(PropertyAccessorElement2 accessor) {
|
||||
DartType? _getPropertyAccessorType(PropertyAccessorElement accessor) {
|
||||
if (accessor is GetterElement) {
|
||||
return accessor.returnType;
|
||||
} else {
|
||||
@@ -718,7 +718,7 @@ class RelevanceComputer {
|
||||
}
|
||||
|
||||
/// Return the [DartType] for an instantiated [TypeAlias].
|
||||
DartType _instantiateTypeAlias(TypeAliasElement2 element) {
|
||||
DartType _instantiateTypeAlias(TypeAliasElement element) {
|
||||
var typeParameters = element.typeParameters2;
|
||||
var typeArguments = const <DartType>[];
|
||||
if (typeParameters.isNotEmpty) {
|
||||
|
||||
@@ -163,7 +163,7 @@ class SuggestionBuilder {
|
||||
/// can only be referenced using a prefix, and the class name is to be
|
||||
/// included in the completion, then the [prefix] should be provided.
|
||||
void suggestConstructor(
|
||||
ConstructorElement2 constructor, {
|
||||
ConstructorElement constructor, {
|
||||
CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION,
|
||||
bool suggestUnnamedAsNew = false,
|
||||
bool hasClassName = false,
|
||||
@@ -222,7 +222,7 @@ class SuggestionBuilder {
|
||||
/// Add a suggestion for an enum [constant]. If the enum can only be
|
||||
/// referenced using a prefix, then the [prefix] should be provided.
|
||||
void suggestEnumConstant(
|
||||
FieldElement2 constant,
|
||||
FieldElement constant,
|
||||
String completion, {
|
||||
String? prefix,
|
||||
int? relevance,
|
||||
@@ -248,7 +248,7 @@ class SuggestionBuilder {
|
||||
/// used as the kind for the suggestion. If the extension can only be
|
||||
/// referenced using a prefix, then the [prefix] should be provided.
|
||||
void suggestExtension(
|
||||
ExtensionElement2 extension, {
|
||||
ExtensionElement extension, {
|
||||
CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION,
|
||||
String? prefix,
|
||||
int? relevance,
|
||||
@@ -278,7 +278,7 @@ class SuggestionBuilder {
|
||||
/// The [inheritanceDistance] is the value of the inheritance distance feature
|
||||
/// computed for the field (or `-1.0` if the field is a static field).
|
||||
void suggestField(
|
||||
FieldElement2 field, {
|
||||
FieldElement field, {
|
||||
required double inheritanceDistance,
|
||||
int? relevance,
|
||||
}) {
|
||||
@@ -362,7 +362,7 @@ class SuggestionBuilder {
|
||||
void suggestFunctionCall() {
|
||||
var element = protocol.Element(
|
||||
protocol.ElementKind.METHOD,
|
||||
MethodElement2.CALL_METHOD_NAME,
|
||||
MethodElement.CALL_METHOD_NAME,
|
||||
protocol.Element.makeFlags(),
|
||||
parameters: '()',
|
||||
returnType: 'void',
|
||||
@@ -371,8 +371,8 @@ class SuggestionBuilder {
|
||||
CompletionSuggestion(
|
||||
CompletionSuggestionKind.INVOCATION,
|
||||
Relevance.callFunction,
|
||||
MethodElement2.CALL_METHOD_NAME,
|
||||
MethodElement2.CALL_METHOD_NAME.length,
|
||||
MethodElement.CALL_METHOD_NAME,
|
||||
MethodElement.CALL_METHOD_NAME.length,
|
||||
0,
|
||||
false,
|
||||
false,
|
||||
@@ -453,7 +453,7 @@ class SuggestionBuilder {
|
||||
/// Add a suggestion for an [element]. If the class can only be
|
||||
/// referenced using a prefix, then the [prefix] should be provided.
|
||||
void suggestInterface(
|
||||
InterfaceElement2 element, {
|
||||
InterfaceElement element, {
|
||||
String? prefix,
|
||||
int? relevance,
|
||||
}) {
|
||||
@@ -538,7 +538,7 @@ class SuggestionBuilder {
|
||||
/// Add a suggestion for the `loadLibrary` [function] associated with a
|
||||
/// prefix.
|
||||
void suggestLoadLibraryFunction(
|
||||
ExecutableElement2 function, {
|
||||
ExecutableElement function, {
|
||||
CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION,
|
||||
}) {
|
||||
// TODO(brianwilkerson): This might want to use the context type rather than
|
||||
@@ -584,7 +584,7 @@ class SuggestionBuilder {
|
||||
}
|
||||
|
||||
void suggestLocalVariable({
|
||||
required LocalVariableElement2 element,
|
||||
required LocalVariableElement element,
|
||||
required int distance,
|
||||
int? relevance,
|
||||
}) {
|
||||
@@ -624,7 +624,7 @@ class SuggestionBuilder {
|
||||
/// as the kind for the suggestion. The [inheritanceDistance] is the value of
|
||||
/// the inheritance distance feature computed for the method.
|
||||
void suggestMethod(
|
||||
MethodElement2 method, {
|
||||
MethodElement method, {
|
||||
required CompletionSuggestionKind kind,
|
||||
required double inheritanceDistance,
|
||||
int? relevance,
|
||||
@@ -726,7 +726,7 @@ class SuggestionBuilder {
|
||||
element: convertElement(parameter),
|
||||
);
|
||||
|
||||
if (parameter is FieldFormalParameterElement2) {
|
||||
if (parameter is FieldFormalParameterElement) {
|
||||
_setDocumentation(suggestion, parameter);
|
||||
}
|
||||
|
||||
@@ -776,7 +776,7 @@ class SuggestionBuilder {
|
||||
/// [element]. If [invokeSuper] is `true`, then the override will contain an
|
||||
/// invocation of an overridden member.
|
||||
Future<void> suggestOverride({
|
||||
required ExecutableElement2 element,
|
||||
required ExecutableElement element,
|
||||
required bool invokeSuper,
|
||||
required SourceRange replacementRange,
|
||||
required bool skipAt,
|
||||
@@ -855,7 +855,7 @@ class SuggestionBuilder {
|
||||
}
|
||||
|
||||
/// Add a suggestion for a [prefix] associated with a [library].
|
||||
void suggestPrefix(LibraryElement2 library, String prefix, {int? relevance}) {
|
||||
void suggestPrefix(LibraryElement library, String prefix, {int? relevance}) {
|
||||
var elementKind = _computeElementKind(library);
|
||||
// TODO(brianwilkerson): If we are in a constant context it would be nice
|
||||
// to promote prefixes for libraries that define constants, but that
|
||||
@@ -903,7 +903,7 @@ class SuggestionBuilder {
|
||||
|
||||
/// Add a suggestion for the Flutter's `setState` method.
|
||||
void suggestSetStateMethod(
|
||||
MethodElement2 method, {
|
||||
MethodElement method, {
|
||||
required CompletionSuggestionKind kind,
|
||||
required String completion,
|
||||
required String displayText,
|
||||
@@ -996,7 +996,7 @@ class SuggestionBuilder {
|
||||
/// If the enclosing element can only be referenced using a prefix, then
|
||||
/// the [prefix] should be provided.
|
||||
void suggestStaticField(
|
||||
FieldElement2 element, {
|
||||
FieldElement element, {
|
||||
String? prefix,
|
||||
int? relevance,
|
||||
String? completion,
|
||||
@@ -1076,7 +1076,7 @@ class SuggestionBuilder {
|
||||
int? relevance,
|
||||
}) {
|
||||
assert(
|
||||
getter.enclosingElement2 is LibraryElement2,
|
||||
getter.enclosingElement2 is LibraryElement,
|
||||
'Enclosing element of ${getter.runtimeType} is '
|
||||
'${getter.enclosingElement2.runtimeType}.',
|
||||
);
|
||||
@@ -1128,7 +1128,7 @@ class SuggestionBuilder {
|
||||
int? relevance,
|
||||
}) {
|
||||
assert(
|
||||
setter.enclosingElement2 is LibraryElement2,
|
||||
setter.enclosingElement2 is LibraryElement,
|
||||
'Enclosing element of ${setter.runtimeType} is '
|
||||
'${setter.enclosingElement2.runtimeType}.',
|
||||
);
|
||||
@@ -1175,14 +1175,14 @@ class SuggestionBuilder {
|
||||
/// Add a suggestion for a top-level [variable]. If the variable can only be
|
||||
/// referenced using a prefix, then the [prefix] should be provided.
|
||||
void suggestTopLevelVariable(
|
||||
TopLevelVariableElement2 variable, {
|
||||
TopLevelVariableElement variable, {
|
||||
String? prefix,
|
||||
int? relevance,
|
||||
}) {
|
||||
var completion = _getCompletionString(variable);
|
||||
if (completion == null) return;
|
||||
if (_couldMatch(completion, prefix)) {
|
||||
assert(variable.enclosingElement2 is LibraryElement2);
|
||||
assert(variable.enclosingElement2 is LibraryElement);
|
||||
relevance ??= relevanceComputer.computeTopLevelRelevance2(
|
||||
variable,
|
||||
elementType: variable.type,
|
||||
@@ -1203,7 +1203,7 @@ class SuggestionBuilder {
|
||||
/// Add a suggestion for a [typeAlias]. If the alias can only be referenced
|
||||
/// using a prefix, then the [prefix] should be provided.
|
||||
void suggestTypeAlias(
|
||||
TypeAliasElement2 typeAlias, {
|
||||
TypeAliasElement typeAlias, {
|
||||
String? prefix,
|
||||
int? relevance,
|
||||
}) {
|
||||
@@ -1228,7 +1228,7 @@ class SuggestionBuilder {
|
||||
}
|
||||
|
||||
/// Add a suggestion for a type [parameter].
|
||||
void suggestTypeParameter(TypeParameterElement2 parameter, {int? relevance}) {
|
||||
void suggestTypeParameter(TypeParameterElement parameter, {int? relevance}) {
|
||||
var elementKind = _computeElementKind(parameter);
|
||||
var isConstant =
|
||||
_preferConstants
|
||||
@@ -1278,11 +1278,11 @@ class SuggestionBuilder {
|
||||
// suggestions are added has been changed by the move to
|
||||
// `InScopeCompletionPass`.
|
||||
var suggestedElement = suggestion.orgElement;
|
||||
if (suggestedElement is ConstructorElement2) {
|
||||
if (suggestedElement is ConstructorElement) {
|
||||
var parentName = suggestedElement.enclosingElement2.displayName;
|
||||
var existingSuggestion = _suggestionMap[parentName];
|
||||
if (existingSuggestion is _CompletionSuggestionBuilderImpl &&
|
||||
existingSuggestion.orgElement is! ClassElement2) {
|
||||
existingSuggestion.orgElement is! ClassElement) {
|
||||
// We return when the current suggestion is not a class because that
|
||||
// means that the current suggestion shadows the one being added.
|
||||
return;
|
||||
@@ -1322,7 +1322,7 @@ class SuggestionBuilder {
|
||||
|
||||
/// Compute the value of the _element kind_ feature for the given [element] in
|
||||
/// the completion context.
|
||||
double _computeElementKind(Element2 element, {double? distance}) {
|
||||
double _computeElementKind(Element element, {double? distance}) {
|
||||
var location = request.opType.completionLocation;
|
||||
var elementKind = request.featureComputer.elementKindFeature(
|
||||
element,
|
||||
@@ -1367,7 +1367,7 @@ class SuggestionBuilder {
|
||||
/// element. If a [prefix] is provided, then the element name (or completion)
|
||||
/// will be prefixed. The [relevance] is the relevance of the suggestion.
|
||||
CompletionSuggestionBuilder? _createCompletionSuggestionBuilder(
|
||||
Element2 element, {
|
||||
Element element, {
|
||||
String? completion,
|
||||
required CompletionSuggestionKind kind,
|
||||
required int relevance,
|
||||
@@ -1395,7 +1395,7 @@ class SuggestionBuilder {
|
||||
);
|
||||
}
|
||||
|
||||
_ElementCompletionData _createElementCompletionData(Element2 element) {
|
||||
_ElementCompletionData _createElementCompletionData(Element element) {
|
||||
var documentation = _getDocumentation(element);
|
||||
|
||||
var suggestedElement = protocol.convertElement(element);
|
||||
@@ -1404,7 +1404,7 @@ class SuggestionBuilder {
|
||||
if (element is! FormalParameterElement) {
|
||||
var enclosingElement = element.enclosingElement2;
|
||||
|
||||
if (enclosingElement is InterfaceElement2) {
|
||||
if (enclosingElement is InterfaceElement) {
|
||||
declaringType = enclosingElement.displayName;
|
||||
}
|
||||
}
|
||||
@@ -1417,7 +1417,7 @@ class SuggestionBuilder {
|
||||
int? requiredParameterCount;
|
||||
bool? hasNamedParameters;
|
||||
CompletionDefaultArgumentList? defaultArgumentList;
|
||||
if (element is ExecutableElement2 && element is! PropertyAccessorElement2) {
|
||||
if (element is ExecutableElement && element is! PropertyAccessorElement) {
|
||||
parameterNames =
|
||||
element.formalParameters.map((parameter) {
|
||||
return parameter.displayName;
|
||||
@@ -1463,11 +1463,11 @@ class SuggestionBuilder {
|
||||
///
|
||||
/// The enclosing element must be either a class, or extension; otherwise
|
||||
/// we either fail with assertion, or return `null`.
|
||||
String? _enclosingClassOrExtensionName(Element2 element) {
|
||||
String? _enclosingClassOrExtensionName(Element element) {
|
||||
var enclosing = element.enclosingElement2;
|
||||
if (enclosing is InterfaceElement2) {
|
||||
if (enclosing is InterfaceElement) {
|
||||
return enclosing.displayName;
|
||||
} else if (enclosing is ExtensionElement2) {
|
||||
} else if (enclosing is ExtensionElement) {
|
||||
return enclosing.displayName;
|
||||
} else {
|
||||
assert(false, 'Expected ClassElement or ExtensionElement');
|
||||
@@ -1475,8 +1475,8 @@ class SuggestionBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
String? _getCompletionString(Element2 element) {
|
||||
if (element is MethodElement2 && element.isOperator) {
|
||||
String? _getCompletionString(Element element) {
|
||||
if (element is MethodElement && element.isOperator) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1484,7 +1484,7 @@ class SuggestionBuilder {
|
||||
}
|
||||
|
||||
/// If the [element] has a documentation comment, return it.
|
||||
_ElementDocumentation? _getDocumentation(Element2 element) {
|
||||
_ElementDocumentation? _getDocumentation(Element element) {
|
||||
var doc = request.documentationComputer.compute(
|
||||
element,
|
||||
includeSummary: true,
|
||||
@@ -1509,7 +1509,7 @@ class SuggestionBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
InterfaceType _instantiateInstanceElement(InterfaceElement2 element) {
|
||||
InterfaceType _instantiateInstanceElement(InterfaceElement element) {
|
||||
var typeParameters = element.typeParameters2;
|
||||
var typeArguments = const <DartType>[];
|
||||
if (typeParameters.isNotEmpty) {
|
||||
@@ -1522,7 +1522,7 @@ class SuggestionBuilder {
|
||||
);
|
||||
}
|
||||
|
||||
InterfaceType _instantiateInstanceElement2(InterfaceElement2 element) {
|
||||
InterfaceType _instantiateInstanceElement2(InterfaceElement element) {
|
||||
var typeParameters = element.typeParameters2;
|
||||
var typeArguments = const <DartType>[];
|
||||
if (typeParameters.isNotEmpty) {
|
||||
@@ -1535,7 +1535,7 @@ class SuggestionBuilder {
|
||||
);
|
||||
}
|
||||
|
||||
DartType _instantiateTypeAlias(TypeAliasElement2 element) {
|
||||
DartType _instantiateTypeAlias(TypeAliasElement element) {
|
||||
var typeParameters = element.typeParameters2;
|
||||
var typeArguments = const <DartType>[];
|
||||
if (typeParameters.isNotEmpty) {
|
||||
@@ -1550,7 +1550,7 @@ class SuggestionBuilder {
|
||||
|
||||
/// If the [element] has a documentation comment, fill the [suggestion]'s
|
||||
/// documentation fields.
|
||||
void _setDocumentation(CompletionSuggestion suggestion, Element2 element) {
|
||||
void _setDocumentation(CompletionSuggestion suggestion, Element element) {
|
||||
var doc = request.documentationComputer.compute(
|
||||
element,
|
||||
includeSummary: true,
|
||||
@@ -1561,8 +1561,8 @@ class SuggestionBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
static String _textToMatchOverride(ExecutableElement2 element) {
|
||||
if (element is MethodElement2 && element.isOperator) {
|
||||
static String _textToMatchOverride(ExecutableElement element) {
|
||||
if (element is MethodElement && element.isOperator) {
|
||||
return 'override_operator';
|
||||
}
|
||||
// Add "override" to match filter when `@override`.
|
||||
@@ -1642,7 +1642,7 @@ class ValueCompletionSuggestionBuilder implements CompletionSuggestionBuilder {
|
||||
/// The implementation of [CompletionSuggestionBuilder] that is based on
|
||||
/// [_ElementCompletionData] and location specific information.
|
||||
class _CompletionSuggestionBuilderImpl implements CompletionSuggestionBuilder {
|
||||
final Element2 orgElement;
|
||||
final Element orgElement;
|
||||
final SuggestionBuilder suggestionBuilder;
|
||||
|
||||
@override
|
||||
@@ -1714,7 +1714,7 @@ class _CompletionSuggestionBuilderImpl implements CompletionSuggestionBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
/// Information about an [Element2] that does not depend on the location where
|
||||
/// Information about an [Element] that does not depend on the location where
|
||||
/// this element is suggested. For some often used elements, such as classes,
|
||||
/// it might be cached, so created only once.
|
||||
class _ElementCompletionData {
|
||||
|
||||
@@ -88,7 +88,7 @@ String buildClosureParameters(
|
||||
/// Compute default argument list text and ranges based on the given
|
||||
/// [requiredParams] and [namedParams].
|
||||
CompletionDefaultArgumentList computeCompletionDefaultArgumentList(
|
||||
Element2 element,
|
||||
Element element,
|
||||
Iterable<FormalParameterElement> requiredParams,
|
||||
Iterable<FormalParameterElement> namedParams,
|
||||
) {
|
||||
@@ -213,9 +213,9 @@ String getTypeString(DartType type) {
|
||||
}
|
||||
}
|
||||
|
||||
/// Instantiates the given [InterfaceElement2]
|
||||
/// Instantiates the given [InterfaceElement]
|
||||
InterfaceType instantiateInstanceElement(
|
||||
InterfaceElement2 element,
|
||||
InterfaceElement element,
|
||||
NeverType neverType,
|
||||
) {
|
||||
var typeParameters = element.typeParameters2;
|
||||
@@ -233,7 +233,7 @@ InterfaceType instantiateInstanceElement(
|
||||
/// `Widget`.
|
||||
bool isFlutterWidgetParameter(FormalParameterElement parameter) {
|
||||
var element = parameter.enclosingElement2;
|
||||
if (element is ConstructorElement2 && element.enclosingElement2.isWidget) {
|
||||
if (element is ConstructorElement && element.enclosingElement2.isWidget) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -247,19 +247,19 @@ String? nameForType(SimpleIdentifier identifier, TypeAnnotation? declaredType) {
|
||||
var element = identifier.element;
|
||||
if (element == null) {
|
||||
return DYNAMIC;
|
||||
} else if (element is FunctionTypedElement2) {
|
||||
if (element is PropertyAccessorElement2 && element is SetterElement) {
|
||||
} else if (element is FunctionTypedElement) {
|
||||
if (element is PropertyAccessorElement && element is SetterElement) {
|
||||
return null;
|
||||
}
|
||||
type = element.returnType;
|
||||
} else if (element is TypeAliasElement2) {
|
||||
} else if (element is TypeAliasElement) {
|
||||
var aliasedType = element.aliasedType;
|
||||
if (aliasedType is FunctionType) {
|
||||
type = aliasedType.returnType;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} else if (element is VariableElement2) {
|
||||
} else if (element is VariableElement) {
|
||||
type = element.type;
|
||||
} else {
|
||||
return null;
|
||||
|
||||
@@ -21,10 +21,7 @@ class VisibilityTracker {
|
||||
/// by being `null` or by returning `false` from `isNotImported`) and the name
|
||||
/// is visible, it will be added to the list of [_declaredNames] so that it
|
||||
/// will shadow any elements of the same name further up the scope chain.
|
||||
bool isVisible({
|
||||
required Element2? element,
|
||||
required ImportData? importData,
|
||||
}) {
|
||||
bool isVisible({required Element? element, required ImportData? importData}) {
|
||||
var name = element?.displayName;
|
||||
if (name == null) {
|
||||
return false;
|
||||
|
||||
@@ -623,7 +623,7 @@ final class PostfixCompletionProcessor {
|
||||
}
|
||||
|
||||
Expression? _findOuterExpression(AstNode? start, InterfaceType builtInType) {
|
||||
if (start is SimpleIdentifier && start.element is PrefixElement2) {
|
||||
if (start is SimpleIdentifier && start.element is PrefixElement) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -417,7 +417,7 @@ class AddDiagnosticPropertyReference extends ResolvedCorrectionProducer {
|
||||
}
|
||||
case VariableDeclaration():
|
||||
var element = node.declaredFragment?.element;
|
||||
if (element is FieldElement2) {
|
||||
if (element is FieldElement) {
|
||||
return element.type;
|
||||
}
|
||||
}
|
||||
@@ -425,7 +425,7 @@ class AddDiagnosticPropertyReference extends ResolvedCorrectionProducer {
|
||||
}
|
||||
|
||||
bool _isEnum(DartType type) {
|
||||
return type is InterfaceType && type.element3 is EnumElement2;
|
||||
return type is InterfaceType && type.element3 is EnumElement;
|
||||
}
|
||||
|
||||
bool _isIterable(DartType type) {
|
||||
|
||||
@@ -37,7 +37,7 @@ class AddEnumConstant extends ResolvedCorrectionProducer {
|
||||
var target = parent.prefix;
|
||||
|
||||
var targetElement = target.element;
|
||||
if (targetElement is! EnumElement2) return;
|
||||
if (targetElement is! EnumElement) return;
|
||||
if (targetElement.library2.isInSdk) return;
|
||||
|
||||
var targetFragment = targetElement.firstFragment;
|
||||
|
||||
+2
-2
@@ -42,7 +42,7 @@ class AddFieldFormalParameters extends ResolvedCorrectionProducer {
|
||||
|
||||
// Compute uninitialized final fields.
|
||||
var fields = ErrorVerifier.computeNotInitializedFields(constructor);
|
||||
fields.retainWhere((FieldElement2 field) => field.isFinal);
|
||||
fields.retainWhere((FieldElement field) => field.isFinal);
|
||||
fields.sort(
|
||||
(a, b) => a.firstFragment.nameOffset2! - b.firstFragment.nameOffset2!,
|
||||
);
|
||||
@@ -51,7 +51,7 @@ class AddFieldFormalParameters extends ResolvedCorrectionProducer {
|
||||
if (superType.isExactlyStatelessWidgetType ||
|
||||
superType.isExactlyStatefulWidgetType) {
|
||||
if (parameters.isNotEmpty && parameters.last.isNamed) {
|
||||
String parameterForField(FieldElement2 field) {
|
||||
String parameterForField(FieldElement field) {
|
||||
var prefix = '';
|
||||
if (typeSystem.isPotentiallyNonNullable(field.type)) {
|
||||
prefix = 'required ';
|
||||
|
||||
@@ -45,7 +45,7 @@ class AddKeyToConstructors extends ResolvedCorrectionProducer {
|
||||
/// Return `true` if the [classDeclaration] can be instantiated as a `const`.
|
||||
bool _canBeConst(
|
||||
ClassDeclaration classDeclaration,
|
||||
List<ConstructorElement2> constructors,
|
||||
List<ConstructorElement> constructors,
|
||||
) {
|
||||
for (var constructor in constructors) {
|
||||
if (constructor.isDefaultConstructor && !constructor.isConst) {
|
||||
|
||||
@@ -61,7 +61,7 @@ class AddLate extends ResolvedCorrectionProducer {
|
||||
var getter = node.writeOrReadElement2;
|
||||
if (getter is GetterElement &&
|
||||
getter.isSynthetic &&
|
||||
getter.enclosingElement2 is InterfaceElement2) {
|
||||
getter.enclosingElement2 is InterfaceElement) {
|
||||
var variableElement = getter.variable3;
|
||||
if (variableElement != null &&
|
||||
!variableElement.isSynthetic &&
|
||||
|
||||
+2
-2
@@ -45,7 +45,7 @@ class AddMissingEnumCaseClauses extends ResolvedCorrectionProducer {
|
||||
var expressionType = statement.expression.staticType;
|
||||
if (expressionType is InterfaceType) {
|
||||
var enumElement = expressionType.element3;
|
||||
if (enumElement is EnumElement2) {
|
||||
if (enumElement is EnumElement) {
|
||||
enumName = enumElement.name3;
|
||||
for (var field in enumElement.fields2) {
|
||||
if (field.isEnumConstant) {
|
||||
@@ -122,7 +122,7 @@ class AddMissingEnumCaseClauses extends ResolvedCorrectionProducer {
|
||||
|
||||
/// Return the shortest prefix for the [element], or an empty String if not
|
||||
/// found.
|
||||
String _importPrefix(Element2 element) {
|
||||
String _importPrefix(Element element) {
|
||||
var shortestPrefix = '';
|
||||
for (var directive in unit.directives) {
|
||||
if (directive is ImportDirective) {
|
||||
|
||||
+1
-1
@@ -101,7 +101,7 @@ class AddMissingEnumLikeCaseClauses extends ResolvedCorrectionProducer {
|
||||
}
|
||||
|
||||
/// Return the names of the constants defined in [classElement].
|
||||
List<String> _constantNames(InterfaceElement2 classElement) {
|
||||
List<String> _constantNames(InterfaceElement classElement) {
|
||||
var type = classElement.thisType;
|
||||
var constantNames = <String>[];
|
||||
for (var field in classElement.fields2) {
|
||||
|
||||
+2
-2
@@ -47,7 +47,7 @@ class AddMissingRequiredArgument extends ResolvedCorrectionProducer {
|
||||
@override
|
||||
Future<void> compute(ChangeBuilder builder) async {
|
||||
InstanceCreationExpression? creation;
|
||||
Element2? targetElement;
|
||||
Element? targetElement;
|
||||
ArgumentList? argumentList;
|
||||
|
||||
if (node is SimpleIdentifier ||
|
||||
@@ -91,7 +91,7 @@ class AddMissingRequiredArgument extends ResolvedCorrectionProducer {
|
||||
_missingParameters = errors.length;
|
||||
|
||||
for (var (index, diagnostic) in errors.indexed) {
|
||||
if (targetElement is ExecutableElement2 && argumentList != null) {
|
||||
if (targetElement is ExecutableElement && argumentList != null) {
|
||||
// Format: "Missing required argument 'foo'."
|
||||
var messageParts = diagnostic.problemMessage
|
||||
.messageText(includeUrl: false)
|
||||
|
||||
+1
-1
@@ -60,7 +60,7 @@ class AddSuperConstructorInvocation extends MultiCorrectionProducer {
|
||||
/// the [AddSuperConstructorInvocation] producer.
|
||||
class _AddInvocation extends ResolvedCorrectionProducer {
|
||||
/// The constructor to be invoked.
|
||||
final ConstructorElement2 _constructor;
|
||||
final ConstructorElement _constructor;
|
||||
|
||||
/// The offset at which the initializer is to be inserted.
|
||||
final int _insertOffset;
|
||||
|
||||
@@ -243,7 +243,7 @@ class _AssignedTypeCollector extends RecursiveAstVisitor<void> {
|
||||
/// The type system used to compute the best type.
|
||||
final TypeSystem typeSystem;
|
||||
|
||||
final LocalVariableElement2 variable;
|
||||
final LocalVariableElement variable;
|
||||
|
||||
/// The types that are assigned to the variable.
|
||||
final Set<DartType> assignedTypes = {};
|
||||
|
||||
@@ -21,7 +21,7 @@ class AmbiguousImportFix extends MultiCorrectionProducer {
|
||||
@override
|
||||
Future<List<ResolvedCorrectionProducer>> get producers async {
|
||||
var node = this.node;
|
||||
Element2? element;
|
||||
Element? element;
|
||||
String? prefix;
|
||||
if (node is NamedType) {
|
||||
element = node.element2;
|
||||
@@ -34,7 +34,7 @@ class AmbiguousImportFix extends MultiCorrectionProducer {
|
||||
prefix = currentPrefix.name;
|
||||
}
|
||||
}
|
||||
if (element is! MultiplyDefinedElement2) {
|
||||
if (element is! MultiplyDefinedElement) {
|
||||
return const [];
|
||||
}
|
||||
var conflictingElements = element.conflictingElements2;
|
||||
@@ -99,7 +99,7 @@ class AmbiguousImportFix extends MultiCorrectionProducer {
|
||||
_getImportDirectives(
|
||||
ResolvedLibraryResult libraryResult,
|
||||
ResolvedUnitResult? unitResult,
|
||||
List<Element2> conflictingElements,
|
||||
List<Element> conflictingElements,
|
||||
String name,
|
||||
String? prefix,
|
||||
) {
|
||||
|
||||
@@ -16,7 +16,7 @@ import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
|
||||
import 'package:analyzer_plugin/utilities/range_factory.dart';
|
||||
|
||||
/// A predicate is a one-argument function that returns a boolean value.
|
||||
typedef _ElementPredicate = bool Function(Element2 argument);
|
||||
typedef _ElementPredicate = bool Function(Element argument);
|
||||
|
||||
class ChangeTo extends ResolvedCorrectionProducer {
|
||||
/// The kind of elements that should be proposed.
|
||||
@@ -84,7 +84,7 @@ class ChangeTo extends ResolvedCorrectionProducer {
|
||||
}
|
||||
|
||||
Iterable<FormalParameterElement> _formalParameterSuggestions(
|
||||
FunctionTypedElement2 element,
|
||||
FunctionTypedElement element,
|
||||
Iterable<FormalParameter> formalParameters,
|
||||
) {
|
||||
return element.formalParameters.where(
|
||||
@@ -117,7 +117,7 @@ class ChangeTo extends ResolvedCorrectionProducer {
|
||||
nameToken = node.name2;
|
||||
} else if (node is PrefixedIdentifier &&
|
||||
node.parent is NamedType &&
|
||||
node.prefix.element is PrefixElement2) {
|
||||
node.prefix.element is PrefixElement) {
|
||||
prefixName = node.prefix.name;
|
||||
nameToken = node.identifier.token;
|
||||
} else if (node is SimpleIdentifier) {
|
||||
@@ -128,7 +128,7 @@ class ChangeTo extends ResolvedCorrectionProducer {
|
||||
// Prepare for selecting the closest element.
|
||||
var finder = _ClosestElementFinder(
|
||||
nameToken.lexeme,
|
||||
(element) => element is InterfaceElement2,
|
||||
(element) => element is InterfaceElement,
|
||||
);
|
||||
// Check elements of this library.
|
||||
if (prefixName == null) {
|
||||
@@ -164,7 +164,7 @@ class ChangeTo extends ResolvedCorrectionProducer {
|
||||
}
|
||||
} else if (target is ExtensionOverride) {
|
||||
_updateFinderWithExtensionMembers(finder, target.element2);
|
||||
} else if (targetIdentifierElement is ExtensionElement2) {
|
||||
} else if (targetIdentifierElement is ExtensionElement) {
|
||||
_updateFinderWithExtensionMembers(finder, targetIdentifierElement);
|
||||
} else {
|
||||
var interfaceElement = getTargetInterfaceElement(target);
|
||||
@@ -203,7 +203,7 @@ class ChangeTo extends ResolvedCorrectionProducer {
|
||||
|
||||
var type = node.type?.type;
|
||||
await _proposeClassOrMixinMember(builder, node.name, null, (element) {
|
||||
return element is FieldElement2 &&
|
||||
return element is FieldElement &&
|
||||
!exclusions.contains(element.name3) &&
|
||||
!element.isSynthetic &&
|
||||
!element.isExternal &&
|
||||
@@ -225,7 +225,7 @@ class ChangeTo extends ResolvedCorrectionProducer {
|
||||
var invocation = node.parent;
|
||||
if (invocation is MethodInvocation && invocation.methodName == node) {
|
||||
var target = invocation.target;
|
||||
if (target is SimpleIdentifier && target.element is PrefixElement2) {
|
||||
if (target is SimpleIdentifier && target.element is PrefixElement) {
|
||||
prefixName = target.name;
|
||||
}
|
||||
}
|
||||
@@ -273,7 +273,7 @@ class ChangeTo extends ResolvedCorrectionProducer {
|
||||
return wantGetter;
|
||||
} else if (element is SetterElement) {
|
||||
return wantSetter;
|
||||
} else if (element is FieldElement2) {
|
||||
} else if (element is FieldElement) {
|
||||
return wantGetter && element.getter2 != null ||
|
||||
wantSetter && element.setter2 != null;
|
||||
}
|
||||
@@ -290,7 +290,7 @@ class ChangeTo extends ResolvedCorrectionProducer {
|
||||
builder,
|
||||
node.token,
|
||||
parent.realTarget,
|
||||
(element) => element is MethodElement2 && !element.isOperator,
|
||||
(element) => element is MethodElement && !element.isOperator,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -354,7 +354,7 @@ class ChangeTo extends ResolvedCorrectionProducer {
|
||||
|
||||
void _updateFinderWithClassMembers(
|
||||
_ClosestElementFinder finder,
|
||||
InterfaceElement2 clazz,
|
||||
InterfaceElement clazz,
|
||||
) {
|
||||
var members = getMembers(clazz);
|
||||
finder._updateList(members);
|
||||
@@ -362,7 +362,7 @@ class ChangeTo extends ResolvedCorrectionProducer {
|
||||
|
||||
void _updateFinderWithExtensionMembers(
|
||||
_ClosestElementFinder finder,
|
||||
ExtensionElement2? element,
|
||||
ExtensionElement? element,
|
||||
) {
|
||||
if (element != null) {
|
||||
finder._updateList(getExtensionMembers(element));
|
||||
@@ -370,7 +370,7 @@ class ChangeTo extends ResolvedCorrectionProducer {
|
||||
}
|
||||
}
|
||||
|
||||
/// Helper for finding [Element2] with name closest to the given.
|
||||
/// Helper for finding [Element] with name closest to the given.
|
||||
class _ClosestElementFinder {
|
||||
/// The maximum Levenshtein distance between the existing name and a possible
|
||||
/// replacement before the replacement is deemed to not be worth offering.
|
||||
@@ -385,11 +385,11 @@ class _ClosestElementFinder {
|
||||
|
||||
int _distance = _maxDistance;
|
||||
|
||||
Element2? _element;
|
||||
Element? _element;
|
||||
|
||||
_ClosestElementFinder(this._targetName, this._predicate);
|
||||
|
||||
void _update(Element2 element) {
|
||||
void _update(Element element) {
|
||||
if (_predicate(element)) {
|
||||
var name = element.name3;
|
||||
if (name != null) {
|
||||
@@ -402,7 +402,7 @@ class _ClosestElementFinder {
|
||||
}
|
||||
}
|
||||
|
||||
void _updateList(Iterable<Element2> elements) {
|
||||
void _updateList(Iterable<Element> elements) {
|
||||
for (var element in elements) {
|
||||
_update(element);
|
||||
}
|
||||
|
||||
@@ -50,13 +50,13 @@ class ChangeToStaticAccess extends ResolvedCorrectionProducer {
|
||||
}
|
||||
|
||||
var invokedElement = identifier.element;
|
||||
if (invokedElement is! ExecutableElement2) {
|
||||
if (invokedElement is! ExecutableElement) {
|
||||
return;
|
||||
}
|
||||
|
||||
var declaringElement = invokedElement.enclosingElement2;
|
||||
|
||||
if (declaringElement is InterfaceElement2) {
|
||||
if (declaringElement is InterfaceElement) {
|
||||
var declaringElementName = declaringElement.name3;
|
||||
if (declaringElementName != null) {
|
||||
_className = declaringElementName;
|
||||
@@ -66,7 +66,7 @@ class ChangeToStaticAccess extends ResolvedCorrectionProducer {
|
||||
});
|
||||
});
|
||||
}
|
||||
} else if (declaringElement is ExtensionElement2) {
|
||||
} else if (declaringElement is ExtensionElement) {
|
||||
var extensionName = declaringElement.name3;
|
||||
if (extensionName != null) {
|
||||
_className = extensionName;
|
||||
|
||||
@@ -71,7 +71,7 @@ class ConvertClassToEnum extends ResolvedCorrectionProducer {
|
||||
/// A superclass for the [_EnumVisitor] and [_NonEnumVisitor].
|
||||
class _BaseVisitor extends RecursiveAstVisitor<void> {
|
||||
/// The element representing the enum declaration that's being visited.
|
||||
final ClassElement2 classElement;
|
||||
final ClassElement classElement;
|
||||
|
||||
_BaseVisitor(this.classElement);
|
||||
|
||||
@@ -97,7 +97,7 @@ class _CannotConvertException implements Exception {
|
||||
/// replaced by an enum constant.
|
||||
class _ConstantField extends _Field {
|
||||
/// The element representing the constructor used to initialize the field.
|
||||
ConstructorElement2 constructorElement;
|
||||
ConstructorElement constructorElement;
|
||||
|
||||
/// The invocation of the constructor.
|
||||
final InstanceCreationExpression instanceCreation;
|
||||
@@ -122,7 +122,7 @@ class _Constructor {
|
||||
final ConstructorDeclaration declaration;
|
||||
|
||||
/// The element representing the constructor.
|
||||
final ConstructorElement2 element;
|
||||
final ConstructorElement element;
|
||||
|
||||
_Constructor(this.declaration, this.element);
|
||||
}
|
||||
@@ -130,7 +130,7 @@ class _Constructor {
|
||||
/// Information about the constructors in the class being converted.
|
||||
class _Constructors {
|
||||
/// A map from elements to constructors.
|
||||
final Map<ConstructorElement2, _Constructor> byElement = {};
|
||||
final Map<ConstructorElement, _Constructor> byElement = {};
|
||||
|
||||
_Constructors();
|
||||
|
||||
@@ -143,7 +143,7 @@ class _Constructors {
|
||||
}
|
||||
|
||||
/// Return the constructor with the given [element].
|
||||
_Constructor? forElement(ConstructorElement2 element) {
|
||||
_Constructor? forElement(ConstructorElement element) {
|
||||
return byElement[element];
|
||||
}
|
||||
}
|
||||
@@ -449,7 +449,7 @@ class _EnumDescription {
|
||||
_Constructors constructors,
|
||||
_Fields fields,
|
||||
) {
|
||||
var usedElements = <ConstructorElement2>{};
|
||||
var usedElements = <ConstructorElement>{};
|
||||
for (var field in fields.fieldsToConvert) {
|
||||
usedElements.add(field.constructorElement);
|
||||
}
|
||||
@@ -533,7 +533,7 @@ class _EnumDescription {
|
||||
var indexFieldElement = indexField.element;
|
||||
for (var i = 0; i < parameters.length; i++) {
|
||||
var element = parameters[i].declaredFragment!.element;
|
||||
if (element is FieldFormalParameterElement2) {
|
||||
if (element is FieldFormalParameterElement) {
|
||||
if (element.field2 == indexFieldElement) {
|
||||
if (element.isPositional) {
|
||||
return _Parameter(i, element);
|
||||
@@ -552,13 +552,13 @@ class _EnumDescription {
|
||||
/// The [classElement] must be the element declared by the [classDeclaration].
|
||||
static _Constructors? _validateConstructors(
|
||||
ClassDeclaration classDeclaration,
|
||||
ClassElement2 classElement,
|
||||
ClassElement classElement,
|
||||
) {
|
||||
var constructors = _Constructors();
|
||||
for (var member in classDeclaration.members) {
|
||||
if (member is ConstructorDeclaration) {
|
||||
var constructor = member.declaredFragment?.element;
|
||||
if (constructor is ConstructorElement2) {
|
||||
if (constructor is ConstructorElement) {
|
||||
if (!classElement.isPrivate && !constructor.isPrivate) {
|
||||
// Public constructor in public enum.
|
||||
return null;
|
||||
@@ -582,7 +582,7 @@ class _EnumDescription {
|
||||
/// The [classElement] must be the element declared by the [classDeclaration].
|
||||
static _Fields? _validateFields(
|
||||
ClassDeclaration classDeclaration,
|
||||
ClassElement2 classElement, {
|
||||
ClassElement classElement, {
|
||||
required bool strictCasts,
|
||||
}) {
|
||||
var potentialFieldsToConvert = <DartObject, List<_ConstantField>>{};
|
||||
@@ -595,7 +595,7 @@ class _EnumDescription {
|
||||
if (member.isStatic) {
|
||||
for (var field in fields) {
|
||||
var fieldElement = field.declaredFragment?.element;
|
||||
if (fieldElement is FieldElement2) {
|
||||
if (fieldElement is FieldElement) {
|
||||
var fieldType = fieldElement.type;
|
||||
// The field can be converted to be an enum constant if it
|
||||
// - is a const field,
|
||||
@@ -643,7 +643,7 @@ class _EnumDescription {
|
||||
return null;
|
||||
}
|
||||
var fieldElement = field.declaredFragment?.element;
|
||||
if (fieldElement is FieldElement2) {
|
||||
if (fieldElement is FieldElement) {
|
||||
var fieldType = fieldElement.type;
|
||||
if (fieldElement.name3 == 'index' && fieldType.isDartCoreInt) {
|
||||
indexField = _Field(fieldElement, field, fieldList, member);
|
||||
@@ -728,7 +728,7 @@ class _EnumVisitor extends _BaseVisitor {
|
||||
/// A representation of a field of interest in the class being converted.
|
||||
class _Field {
|
||||
/// The element representing the field.
|
||||
final FieldElement2 element;
|
||||
final FieldElement element;
|
||||
|
||||
/// The declaration of the field.
|
||||
final VariableDeclaration declaration;
|
||||
|
||||
@@ -91,7 +91,7 @@ class ConvertClassToMixin extends ResolvedCorrectionProducer {
|
||||
/// A visitor used to find all of the classes that define members referenced via
|
||||
/// `super`.
|
||||
class _SuperclassReferenceFinder extends RecursiveAstVisitor<void> {
|
||||
final List<ClassElement2> referencedClasses = [];
|
||||
final List<ClassElement> referencedClasses = [];
|
||||
|
||||
_SuperclassReferenceFinder();
|
||||
|
||||
@@ -112,10 +112,10 @@ class _SuperclassReferenceFinder extends RecursiveAstVisitor<void> {
|
||||
return super.visitSuperExpression(node);
|
||||
}
|
||||
|
||||
void _addElement(Element2? element) {
|
||||
if (element is ExecutableElement2) {
|
||||
void _addElement(Element? element) {
|
||||
if (element is ExecutableElement) {
|
||||
var enclosingElement = element.enclosingElement2;
|
||||
if (enclosingElement is ClassElement2) {
|
||||
if (enclosingElement is ClassElement) {
|
||||
referencedClasses.add(enclosingElement);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,7 +179,7 @@ class ConvertIntoBlockBody extends ResolvedCorrectionProducer {
|
||||
return [returnCode];
|
||||
}
|
||||
|
||||
ExecutableElement2? _getFunctionElement(AstNode? node) {
|
||||
ExecutableElement? _getFunctionElement(AstNode? node) {
|
||||
if (node is MethodDeclaration) {
|
||||
return node.declaredFragment?.element;
|
||||
} else if (node is ConstructorDeclaration) {
|
||||
|
||||
@@ -57,7 +57,7 @@ class ConvertIntoFinalField extends ResolvedCorrectionProducer {
|
||||
// static.
|
||||
if (!getterElement.isStatic) {
|
||||
switch (getterElement.enclosingElement2) {
|
||||
case ExtensionElement2() || ExtensionTypeElement2():
|
||||
case ExtensionElement() || ExtensionTypeElement():
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ class ConvertIntoForIndex extends ResolvedCorrectionProducer {
|
||||
// iterable should be VariableElement
|
||||
String listName;
|
||||
var iterable = forEachParts.iterable;
|
||||
if (iterable is SimpleIdentifier && iterable.element is VariableElement2) {
|
||||
if (iterable is SimpleIdentifier && iterable.element is VariableElement) {
|
||||
listName = iterable.name;
|
||||
} else {
|
||||
return;
|
||||
|
||||
+1
-1
@@ -143,7 +143,7 @@ class ConvertNullCheckToNullAwareElementOrEntry
|
||||
}
|
||||
|
||||
extension AstNodeNullableExtension on AstNode? {
|
||||
Element2? get canonicalElement {
|
||||
Element? get canonicalElement {
|
||||
var self = this;
|
||||
if (self is Expression) {
|
||||
var node = self.unParenthesized;
|
||||
|
||||
+3
-3
@@ -180,7 +180,7 @@ class ConvertToIfCaseStatement extends ResolvedCorrectionProducer {
|
||||
class _DeclaredVariable {
|
||||
final VariableDeclarationStatement statement;
|
||||
final VariableDeclaration declaration;
|
||||
final LocalVariableElement2 element;
|
||||
final LocalVariableElement element;
|
||||
final Expression initializer;
|
||||
|
||||
_DeclaredVariable({
|
||||
@@ -196,7 +196,7 @@ class _DeclaredVariable {
|
||||
}
|
||||
|
||||
class _ReferenceVisitor extends RecursiveAstVisitor<void> {
|
||||
final LocalVariableElement2 element;
|
||||
final LocalVariableElement element;
|
||||
bool hasReference = false;
|
||||
|
||||
_ReferenceVisitor(this.element);
|
||||
@@ -240,7 +240,7 @@ extension on Statement {
|
||||
}
|
||||
|
||||
var declaredElement = declaration.declaredElement2;
|
||||
if (declaredElement is! LocalVariableElement2) {
|
||||
if (declaredElement is! LocalVariableElement) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -82,7 +82,7 @@ class ConvertToInitializingFormal extends ResolvedCorrectionProducer {
|
||||
}
|
||||
|
||||
var fieldElement = node.fieldName.element;
|
||||
if (fieldElement is! VariableElement2) {
|
||||
if (fieldElement is! VariableElement) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ class ConvertToMapLiteral extends ResolvedCorrectionProducer {
|
||||
|
||||
/// Return `true` if the [element] represents either the class `Map` or
|
||||
/// `LinkedHashMap`.
|
||||
bool _isMapClass(InterfaceElement2 element) =>
|
||||
bool _isMapClass(InterfaceElement element) =>
|
||||
element == typeProvider.mapElement2 ||
|
||||
(element.name3 == 'LinkedHashMap' &&
|
||||
element.library2.name3 == 'dart.collection');
|
||||
|
||||
+2
-2
@@ -19,7 +19,7 @@ import 'package:analyzer_plugin/utilities/range_factory.dart';
|
||||
|
||||
class ConvertToSwitchExpression extends ResolvedCorrectionProducer {
|
||||
/// Local variable reference used in assignment switch expression generation.
|
||||
LocalVariableElement2? writeElement;
|
||||
LocalVariableElement? writeElement;
|
||||
|
||||
/// Assignment operator used in assignment switch expression generation.
|
||||
TokenType? assignmentOperator;
|
||||
@@ -488,7 +488,7 @@ class ConvertToSwitchExpression extends ResolvedCorrectionProducer {
|
||||
if (leftHandSide is! SimpleIdentifierImpl) return null;
|
||||
if (writeElement == null) {
|
||||
var element = leftHandSide.element;
|
||||
if (element is! LocalVariableElement2) return null;
|
||||
if (element is! LocalVariableElement) return null;
|
||||
writeElement = element;
|
||||
assignmentOperator = expression.operator.type;
|
||||
} else if (writeElement != leftHandSide.element ||
|
||||
|
||||
+1
-1
@@ -47,7 +47,7 @@ class ConvertToWildcardVariable extends ResolvedCorrectionProducer {
|
||||
|
||||
var nameToken = node.name;
|
||||
var element = node.declaredElement2;
|
||||
if (element is! LocalVariableElement2) {
|
||||
if (element is! LocalVariableElement) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ class CreateClass extends ResolvedCorrectionProducer {
|
||||
@override
|
||||
Future<void> compute(ChangeBuilder builder) async {
|
||||
var targetNode = node;
|
||||
Element2? prefixElement;
|
||||
Element? prefixElement;
|
||||
ArgumentList? arguments;
|
||||
|
||||
String? className;
|
||||
@@ -94,7 +94,7 @@ class CreateClass extends ResolvedCorrectionProducer {
|
||||
prefix = '$eol$eol';
|
||||
} else {
|
||||
for (var import in libraryElement2.firstFragment.libraryImports2) {
|
||||
if (prefixElement is PrefixElement2 &&
|
||||
if (prefixElement is PrefixElement &&
|
||||
import.prefix2?.element == prefixElement) {
|
||||
var library = import.importedLibrary2;
|
||||
if (library != null) {
|
||||
|
||||
@@ -176,7 +176,7 @@ class CreateConstructor extends ResolvedCorrectionProducer {
|
||||
}
|
||||
|
||||
var targetElement = constructorElement.enclosingElement2;
|
||||
var targetFragment = (targetElement as ClassElement2).firstFragment;
|
||||
var targetFragment = (targetElement as ClassElement).firstFragment;
|
||||
|
||||
var targetElementName = targetElement.name3;
|
||||
if (targetElementName == null) {
|
||||
|
||||
@@ -45,7 +45,7 @@ class CreateConstructorSuper extends MultiCorrectionProducer {
|
||||
/// the [CreateConstructorSuper] producer.
|
||||
class _CreateConstructor extends ResolvedCorrectionProducer {
|
||||
/// The constructor to be invoked.
|
||||
final ConstructorElement2 _constructor;
|
||||
final ConstructorElement _constructor;
|
||||
|
||||
/// The class in which the constructor will be added.
|
||||
final ClassDeclaration _targetClass;
|
||||
|
||||
@@ -418,7 +418,7 @@ abstract class _CreateExtensionMember extends ResolvedCorrectionProducer {
|
||||
return CorrectionApplicability.singleLocation;
|
||||
}
|
||||
|
||||
ExecutableElement2? get methodBeingCopied =>
|
||||
ExecutableElement? get methodBeingCopied =>
|
||||
_enclosingFunction?.declaredFragment?.element;
|
||||
|
||||
FunctionDeclaration? get _enclosingFunction => node.thisOrAncestorOfType();
|
||||
@@ -517,7 +517,7 @@ extension on List<DartType?> {
|
||||
/// it uses and get any type parameters they use by using this same getter.
|
||||
///
|
||||
/// These types are added internally to a set so that we don't add duplicates.
|
||||
List<TypeParameterElement2> get typeParameters =>
|
||||
List<TypeParameterElement> get typeParameters =>
|
||||
{
|
||||
for (var type in whereType<TypeParameterType>()) ...[
|
||||
type.element3,
|
||||
@@ -528,10 +528,10 @@ extension on List<DartType?> {
|
||||
}.toList();
|
||||
}
|
||||
|
||||
extension on Element2? {
|
||||
extension on Element? {
|
||||
bool get declaresIndex {
|
||||
var element = this;
|
||||
if (element is! InterfaceElement2) {
|
||||
if (element is! InterfaceElement) {
|
||||
return false;
|
||||
}
|
||||
var inheritanceManager3 = InheritanceManager3();
|
||||
|
||||
@@ -33,7 +33,7 @@ class CreateField extends CreateFieldOrGetter {
|
||||
@override
|
||||
Future<void> addForObjectPattern({
|
||||
required ChangeBuilder builder,
|
||||
required InterfaceElement2? targetElement,
|
||||
required InterfaceElement? targetElement,
|
||||
required String fieldName,
|
||||
required DartType? fieldType,
|
||||
}) async {
|
||||
@@ -64,7 +64,7 @@ class CreateField extends CreateFieldOrGetter {
|
||||
Future<void> _addDeclaration({
|
||||
required ChangeBuilder builder,
|
||||
required bool staticModifier,
|
||||
required InterfaceElement2? targetElement,
|
||||
required InterfaceElement? targetElement,
|
||||
required DartType? fieldType,
|
||||
}) async {
|
||||
if (targetElement == null) {
|
||||
@@ -153,7 +153,7 @@ class CreateField extends CreateFieldOrGetter {
|
||||
};
|
||||
// Prepare target `ClassElement`.
|
||||
var staticModifier = false;
|
||||
InterfaceElement2? targetClassElement;
|
||||
InterfaceElement? targetClassElement;
|
||||
if (target != null) {
|
||||
targetClassElement = getTargetInterfaceElement(target);
|
||||
// Maybe static.
|
||||
@@ -172,7 +172,7 @@ class CreateField extends CreateFieldOrGetter {
|
||||
|
||||
var fieldTypeNode = climbPropertyAccess(nameNode);
|
||||
var fieldTypeParent = fieldTypeNode.parent;
|
||||
if (targetClassElement is EnumElement2 &&
|
||||
if (targetClassElement is EnumElement &&
|
||||
fieldTypeParent is AssignmentExpression &&
|
||||
fieldTypeNode == fieldTypeParent.leftHandSide) {
|
||||
// Any field on an enum must be final; creating a final field does not
|
||||
|
||||
@@ -23,7 +23,7 @@ abstract class CreateFieldOrGetter extends ResolvedCorrectionProducer {
|
||||
/// Adds the declaration that makes a [fieldName] available.
|
||||
Future<void> addForObjectPattern({
|
||||
required ChangeBuilder builder,
|
||||
required InterfaceElement2? targetElement,
|
||||
required InterfaceElement? targetElement,
|
||||
required String fieldName,
|
||||
required DartType? fieldType,
|
||||
});
|
||||
@@ -103,7 +103,7 @@ class CreateGetter extends CreateFieldOrGetter {
|
||||
@override
|
||||
Future<void> addForObjectPattern({
|
||||
required ChangeBuilder builder,
|
||||
required InterfaceElement2? targetElement,
|
||||
required InterfaceElement? targetElement,
|
||||
required String fieldName,
|
||||
required DartType? fieldType,
|
||||
}) async {
|
||||
@@ -142,11 +142,11 @@ class CreateGetter extends CreateFieldOrGetter {
|
||||
}
|
||||
// prepare target element
|
||||
var staticModifier = false;
|
||||
InstanceElement2? targetElement;
|
||||
InstanceElement? targetElement;
|
||||
if (target is ExtensionOverride) {
|
||||
targetElement = target.element2;
|
||||
} else if (target is Identifier && target.element is ExtensionElement2) {
|
||||
targetElement = target.element as InstanceElement2?;
|
||||
} else if (target is Identifier && target.element is ExtensionElement) {
|
||||
targetElement = target.element as InstanceElement?;
|
||||
staticModifier = true;
|
||||
} else if (target != null) {
|
||||
// prepare target interface type
|
||||
@@ -185,7 +185,7 @@ class CreateGetter extends CreateFieldOrGetter {
|
||||
Future<void> _addDeclaration({
|
||||
required ChangeBuilder builder,
|
||||
required bool staticModifier,
|
||||
required InstanceElement2? targetElement,
|
||||
required InstanceElement? targetElement,
|
||||
required DartType? fieldType,
|
||||
}) async {
|
||||
if (targetElement == null) {
|
||||
|
||||
@@ -66,7 +66,7 @@ class CreateMethod extends ResolvedCorrectionProducer {
|
||||
|
||||
await builder.addDartFileEdit(file, (fileBuilder) {
|
||||
fileBuilder.insertIntoUnitMember(classDecl, (builder) {
|
||||
ExecutableElement2? element;
|
||||
ExecutableElement? element;
|
||||
if (missingEquals) {
|
||||
_memberName = '==';
|
||||
element = inheritanceManager.getInherited4(
|
||||
@@ -109,8 +109,8 @@ class CreateMethod extends ResolvedCorrectionProducer {
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else if (target is Identifier && target.element is ExtensionElement2) {
|
||||
targetFragment = (target.element as ExtensionElement2).firstFragment;
|
||||
} else if (target is Identifier && target.element is ExtensionElement) {
|
||||
targetFragment = (target.element as ExtensionElement).firstFragment;
|
||||
if (targetFragment is ExtensionFragment) {
|
||||
targetNode = await getExtensionDeclaration(targetFragment);
|
||||
if (targetNode == null) {
|
||||
@@ -141,16 +141,16 @@ class CreateMethod extends ResolvedCorrectionProducer {
|
||||
return;
|
||||
}
|
||||
// Prepare target ClassDeclaration.
|
||||
if (targetClassElement is MixinElement2) {
|
||||
if (targetClassElement is MixinElement) {
|
||||
var fragment = targetClassElement.firstFragment;
|
||||
targetNode = await getMixinDeclaration(fragment);
|
||||
} else if (targetClassElement is ClassElement2) {
|
||||
} else if (targetClassElement is ClassElement) {
|
||||
var fragment = targetClassElement.firstFragment;
|
||||
targetNode = await getClassDeclaration(fragment);
|
||||
} else if (targetClassElement is ExtensionTypeElement2) {
|
||||
} else if (targetClassElement is ExtensionTypeElement) {
|
||||
var fragment = targetClassElement.firstFragment;
|
||||
targetNode = await getExtensionTypeDeclaration(fragment);
|
||||
} else if (targetClassElement is EnumElement2) {
|
||||
} else if (targetClassElement is EnumElement) {
|
||||
var fragment = targetClassElement.firstFragment;
|
||||
targetNode = await getEnumDeclaration(fragment);
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ class CreateMethodOrFunction extends ResolvedCorrectionProducer {
|
||||
var nameNode = node;
|
||||
if (nameNode is SimpleIdentifier) {
|
||||
// prepare argument expression (to get parameter)
|
||||
InterfaceElement2? targetElement;
|
||||
InterfaceElement? targetElement;
|
||||
Expression argument;
|
||||
var target = getQualifiedPropertyTarget(node);
|
||||
if (target != null) {
|
||||
@@ -49,7 +49,7 @@ class CreateMethodOrFunction extends ResolvedCorrectionProducer {
|
||||
targetElement = targetType.element3;
|
||||
argument = target.parent as Expression;
|
||||
} else if (target case SimpleIdentifier(
|
||||
:InterfaceElement2? element,
|
||||
:InterfaceElement? element,
|
||||
:Expression parent,
|
||||
)) {
|
||||
isStatic = true;
|
||||
@@ -207,7 +207,7 @@ class CreateMethodOrFunction extends ResolvedCorrectionProducer {
|
||||
/// [FunctionType] inside the target element.
|
||||
Future<void> _createMethod(
|
||||
ChangeBuilder builder,
|
||||
InterfaceElement2 targetClassElement,
|
||||
InterfaceElement targetClassElement,
|
||||
FunctionType functionType, {
|
||||
required bool isStatic,
|
||||
}) async {
|
||||
@@ -217,19 +217,19 @@ class CreateMethodOrFunction extends ResolvedCorrectionProducer {
|
||||
// prepare insert offset
|
||||
CompilationUnitMember? targetNode;
|
||||
List<ClassMember>? classMembers;
|
||||
if (targetClassElement is MixinElement2) {
|
||||
if (targetClassElement is MixinElement) {
|
||||
var fragment = targetClassElement.firstFragment;
|
||||
var node = targetNode = await getMixinDeclaration(fragment);
|
||||
classMembers = node?.members;
|
||||
} else if (targetClassElement is ClassElement2) {
|
||||
} else if (targetClassElement is ClassElement) {
|
||||
var fragment = targetClassElement.firstFragment;
|
||||
var node = targetNode = await getClassDeclaration(fragment);
|
||||
classMembers = node?.members;
|
||||
} else if (targetClassElement is ExtensionTypeElement2) {
|
||||
} else if (targetClassElement is ExtensionTypeElement) {
|
||||
var fragment = targetClassElement.firstFragment;
|
||||
var node = targetNode = await getExtensionTypeDeclaration(fragment);
|
||||
classMembers = node?.members;
|
||||
} else if (targetClassElement is EnumElement2) {
|
||||
} else if (targetClassElement is EnumElement) {
|
||||
var fragment = targetClassElement.firstFragment;
|
||||
var node = targetNode = await getEnumDeclaration(fragment);
|
||||
classMembers = node?.members;
|
||||
|
||||
@@ -46,7 +46,7 @@ class CreateMissingOverrides extends ResolvedCorrectionProducer {
|
||||
...InheritanceOverrideVerifier.missingMustBeOverridden(targetDeclaration),
|
||||
];
|
||||
// Sort by name, getters before setters.
|
||||
signatures.sort((ExecutableElement2 a, ExecutableElement2 b) {
|
||||
signatures.sort((ExecutableElement a, ExecutableElement b) {
|
||||
var names = compareStrings(a.displayName, b.displayName);
|
||||
if (names != 0) {
|
||||
return names;
|
||||
|
||||
@@ -29,7 +29,7 @@ class CreateMixin extends ResolvedCorrectionProducer {
|
||||
|
||||
@override
|
||||
Future<void> compute(ChangeBuilder builder) async {
|
||||
Element2? prefixElement;
|
||||
Element? prefixElement;
|
||||
var node = this.node;
|
||||
if (node is NamedType) {
|
||||
var importPrefix = node.importPrefix;
|
||||
@@ -85,7 +85,7 @@ class CreateMixin extends ResolvedCorrectionProducer {
|
||||
prefix = '$eol$eol';
|
||||
} else {
|
||||
for (var import in libraryElement2.firstFragment.libraryImports2) {
|
||||
if (prefixElement is PrefixElement2 &&
|
||||
if (prefixElement is PrefixElement &&
|
||||
import.prefix2?.element == prefixElement) {
|
||||
var library = import.importedLibrary2;
|
||||
if (library != null) {
|
||||
|
||||
@@ -49,11 +49,11 @@ class CreateSetter extends ResolvedCorrectionProducer {
|
||||
}
|
||||
// prepare target element
|
||||
var staticModifier = false;
|
||||
InstanceElement2? targetElement;
|
||||
InstanceElement? targetElement;
|
||||
if (target is ExtensionOverride) {
|
||||
targetElement = target.element2;
|
||||
} else if (target is Identifier && target.element is ExtensionElement2) {
|
||||
targetElement = target.element as ExtensionElement2;
|
||||
} else if (target is Identifier && target.element is ExtensionElement) {
|
||||
targetElement = target.element as ExtensionElement;
|
||||
staticModifier = true;
|
||||
} else if (target != null) {
|
||||
// prepare target interface type
|
||||
|
||||
@@ -59,9 +59,7 @@ class DataDriven extends MultiCorrectionProducer {
|
||||
|
||||
/// Return the transform sets that are available for fixing issues in the
|
||||
/// given [library].
|
||||
List<TransformSet> _availableTransformSetsForLibrary(
|
||||
LibraryElement2 library,
|
||||
) {
|
||||
List<TransformSet> _availableTransformSetsForLibrary(LibraryElement library) {
|
||||
var setsForTests = transformSetsForTests;
|
||||
if (setsForTests != null) {
|
||||
return setsForTests;
|
||||
|
||||
+2
-2
@@ -253,7 +253,7 @@ abstract class RecordField {
|
||||
}
|
||||
|
||||
class _ReferenceFinder extends RecursiveAstVisitor<void> {
|
||||
final LocalVariableElement2? element;
|
||||
final LocalVariableElement? element;
|
||||
final objectReferences = <AstNode>[];
|
||||
final propertyReferences = <String, List<AstNode>>{};
|
||||
|
||||
@@ -288,7 +288,7 @@ class _ReferenceFinder extends RecursiveAstVisitor<void> {
|
||||
}
|
||||
}
|
||||
|
||||
extension on LocalVariableElement2 {
|
||||
extension on LocalVariableElement {
|
||||
({
|
||||
List<AstNode> objectReferences,
|
||||
Map<String, List<AstNode>> propertyReferences,
|
||||
|
||||
@@ -60,7 +60,7 @@ class EncapsulateField extends ResolvedCorrectionProducer {
|
||||
|
||||
// Should be in a class or mixin.
|
||||
List<ClassMember> classMembers;
|
||||
InterfaceElement2 parentElement;
|
||||
InterfaceElement parentElement;
|
||||
var parent = fieldDeclaration.parent;
|
||||
switch (parent) {
|
||||
case ClassDeclaration():
|
||||
@@ -170,7 +170,7 @@ class EncapsulateField extends ResolvedCorrectionProducer {
|
||||
void _updateReferencesInConstructor(
|
||||
DartFileEditBuilder builder,
|
||||
ConstructorDeclaration constructor,
|
||||
FieldElement2 fieldElement,
|
||||
FieldElement fieldElement,
|
||||
String name,
|
||||
String fieldTypeCode,
|
||||
) {
|
||||
@@ -178,7 +178,7 @@ class EncapsulateField extends ResolvedCorrectionProducer {
|
||||
var identifier = parameter.name;
|
||||
var parameterElement = parameter.declaredFragment?.element;
|
||||
if (identifier != null &&
|
||||
parameterElement is FieldFormalParameterElement2 &&
|
||||
parameterElement is FieldFormalParameterElement &&
|
||||
parameterElement.field2 == fieldElement) {
|
||||
if (parameter.isNamed && parameter is DefaultFormalParameter) {
|
||||
var normalParam = parameter.parameter;
|
||||
@@ -215,7 +215,7 @@ class EncapsulateField extends ResolvedCorrectionProducer {
|
||||
void _updateReferencesInConstructors(
|
||||
DartFileEditBuilder builder,
|
||||
List<ClassMember> classMembers,
|
||||
FieldElement2 fieldElement,
|
||||
FieldElement fieldElement,
|
||||
String name,
|
||||
String fieldTypeCode,
|
||||
) {
|
||||
|
||||
@@ -79,7 +79,7 @@ class ExtractLocalVariable extends ResolvedCorrectionProducer {
|
||||
Future<void> _rewriteProperty({
|
||||
required ChangeBuilder builder,
|
||||
required Expression target,
|
||||
required Element2? targetProperty,
|
||||
required Element? targetProperty,
|
||||
}) async {
|
||||
if (targetProperty is! GetterElement) {
|
||||
return;
|
||||
@@ -140,12 +140,12 @@ class ExtractLocalVariable extends ResolvedCorrectionProducer {
|
||||
}
|
||||
|
||||
class _ExpressionEncoder {
|
||||
final Map<Element2, int> _elementIds = {};
|
||||
final Map<Element, int> _elementIds = {};
|
||||
|
||||
String encode(Expression node) {
|
||||
var tokens = node.tokens;
|
||||
|
||||
var tokenToElementMap = Map<Token, Element2>.identity();
|
||||
var tokenToElementMap = Map<Token, Element>.identity();
|
||||
node.accept(
|
||||
_FunctionAstVisitor(
|
||||
simpleIdentifier: (node) {
|
||||
|
||||
+8
-8
@@ -71,7 +71,7 @@ class FlutterConvertToStatefulWidget extends ResolvedCorrectionProducer {
|
||||
|
||||
// Prepare nodes to move.
|
||||
var nodesToMove = <ClassMember>{};
|
||||
var elementsToMove = <Element2>{};
|
||||
var elementsToMove = <Element>{};
|
||||
for (var member in widgetClass.members) {
|
||||
if (member is FieldDeclaration && !member.isStatic) {
|
||||
for (var fieldNode in member.fields.variables) {
|
||||
@@ -273,12 +273,12 @@ class FlutterConvertToStatefulWidget extends ResolvedCorrectionProducer {
|
||||
}
|
||||
|
||||
class _FieldFinder extends RecursiveAstVisitor<void> {
|
||||
Set<FieldElement2> fieldsAssignedInConstructors = {};
|
||||
Set<FieldElement> fieldsAssignedInConstructors = {};
|
||||
|
||||
@override
|
||||
void visitFieldFormalParameter(FieldFormalParameter node) {
|
||||
var element = node.declaredFragment?.element;
|
||||
if (element is FieldFormalParameterElement2) {
|
||||
if (element is FieldFormalParameterElement) {
|
||||
var field = element.field2;
|
||||
if (field != null) {
|
||||
fieldsAssignedInConstructors.add(field);
|
||||
@@ -292,7 +292,7 @@ class _FieldFinder extends RecursiveAstVisitor<void> {
|
||||
void visitSimpleIdentifier(SimpleIdentifier node) {
|
||||
if (node.parent is ConstructorFieldInitializer) {
|
||||
var element = node.element;
|
||||
if (element is FieldElement2) {
|
||||
if (element is FieldElement) {
|
||||
fieldsAssignedInConstructors.add(element);
|
||||
}
|
||||
}
|
||||
@@ -300,7 +300,7 @@ class _FieldFinder extends RecursiveAstVisitor<void> {
|
||||
var element = node.writeOrReadElement2;
|
||||
if (element is SetterElement) {
|
||||
var field = element.variable3;
|
||||
if (field is FieldElement2) {
|
||||
if (field is FieldElement) {
|
||||
fieldsAssignedInConstructors.add(field);
|
||||
}
|
||||
}
|
||||
@@ -309,9 +309,9 @@ class _FieldFinder extends RecursiveAstVisitor<void> {
|
||||
}
|
||||
|
||||
class _ReplacementEditBuilder extends RecursiveAstVisitor<void> {
|
||||
final ClassElement2 widgetClassElement;
|
||||
final ClassElement widgetClassElement;
|
||||
|
||||
final Set<Element2> elementsToMove;
|
||||
final Set<Element> elementsToMove;
|
||||
|
||||
final SourceRange linesRange;
|
||||
|
||||
@@ -329,7 +329,7 @@ class _ReplacementEditBuilder extends RecursiveAstVisitor<void> {
|
||||
return;
|
||||
}
|
||||
var element = node.element;
|
||||
if (element is ExecutableElement2 &&
|
||||
if (element is ExecutableElement &&
|
||||
element.enclosingElement2 == widgetClassElement &&
|
||||
!elementsToMove.contains(element)) {
|
||||
var offset = node.offset - linesRange.offset;
|
||||
|
||||
+16
-16
@@ -86,7 +86,7 @@ class FlutterConvertToStatelessWidget extends ResolvedCorrectionProducer {
|
||||
|
||||
// Prepare nodes to move.
|
||||
var nodesToMove = <ClassMember>[];
|
||||
var elementsToMove = <Element2>{};
|
||||
var elementsToMove = <Element>{};
|
||||
for (var member in stateClass.members) {
|
||||
if (member is FieldDeclaration) {
|
||||
if (member.isStatic) {
|
||||
@@ -94,7 +94,7 @@ class FlutterConvertToStatelessWidget extends ResolvedCorrectionProducer {
|
||||
}
|
||||
for (var fieldNode in member.fields.variables) {
|
||||
var fieldElement =
|
||||
fieldNode.declaredFragment!.element as FieldElement2;
|
||||
fieldNode.declaredFragment!.element as FieldElement;
|
||||
if (!fieldsAssignedInConstructors.contains(fieldElement)) {
|
||||
nodesToMove.add(member);
|
||||
elementsToMove.add(fieldElement);
|
||||
@@ -195,7 +195,7 @@ class FlutterConvertToStatelessWidget extends ResolvedCorrectionProducer {
|
||||
return null;
|
||||
}
|
||||
|
||||
ClassDeclaration? _findStateClass(ClassElement2 widgetClassElement) {
|
||||
ClassDeclaration? _findStateClass(ClassElement widgetClassElement) {
|
||||
for (var declaration in unit.declarations) {
|
||||
if (declaration is ClassDeclaration) {
|
||||
var type = declaration.extendsClause?.superclass.type;
|
||||
@@ -265,7 +265,7 @@ class FlutterConvertToStatelessWidget extends ResolvedCorrectionProducer {
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool _isState(ClassElement2 widgetClassElement, DartType? type) {
|
||||
static bool _isState(ClassElement widgetClassElement, DartType? type) {
|
||||
if (type is! InterfaceType) return false;
|
||||
|
||||
var firstArgument = type.typeArguments.singleOrNull;
|
||||
@@ -275,18 +275,18 @@ class FlutterConvertToStatelessWidget extends ResolvedCorrectionProducer {
|
||||
}
|
||||
|
||||
var classElement = type.element3;
|
||||
return classElement is ClassElement2 && classElement.isExactState;
|
||||
return classElement is ClassElement && classElement.isExactState;
|
||||
}
|
||||
}
|
||||
|
||||
class _FieldFinder extends RecursiveAstVisitor<void> {
|
||||
Set<FieldElement2> fieldsAssignedInConstructors = {};
|
||||
Set<FieldElement> fieldsAssignedInConstructors = {};
|
||||
|
||||
@override
|
||||
void visitSimpleIdentifier(SimpleIdentifier node) {
|
||||
if (node.parent is FieldFormalParameter) {
|
||||
var element = node.element;
|
||||
if (element is FieldFormalParameterElement2) {
|
||||
if (element is FieldFormalParameterElement) {
|
||||
var field = element.field2;
|
||||
if (field != null) {
|
||||
fieldsAssignedInConstructors.add(field);
|
||||
@@ -295,17 +295,17 @@ class _FieldFinder extends RecursiveAstVisitor<void> {
|
||||
}
|
||||
if (node.parent is ConstructorFieldInitializer) {
|
||||
var element = node.element;
|
||||
if (element is FieldElement2) {
|
||||
if (element is FieldElement) {
|
||||
fieldsAssignedInConstructors.add(element);
|
||||
}
|
||||
}
|
||||
if (node.inSetterContext()) {
|
||||
var element = node.writeOrReadElement2;
|
||||
var field = switch (element) {
|
||||
PropertyAccessorElement2(:var variable3) => variable3,
|
||||
PropertyAccessorElement(:var variable3) => variable3,
|
||||
_ => null,
|
||||
};
|
||||
if (field is FieldElement2) {
|
||||
if (field is FieldElement) {
|
||||
fieldsAssignedInConstructors.add(field);
|
||||
}
|
||||
}
|
||||
@@ -313,9 +313,9 @@ class _FieldFinder extends RecursiveAstVisitor<void> {
|
||||
}
|
||||
|
||||
class _ReplacementEditBuilder extends RecursiveAstVisitor<void> {
|
||||
final ClassElement2 widgetClassElement;
|
||||
final ClassElement widgetClassElement;
|
||||
|
||||
final Set<Element2> elementsToMove;
|
||||
final Set<Element> elementsToMove;
|
||||
|
||||
final SourceRange linesRange;
|
||||
|
||||
@@ -333,7 +333,7 @@ class _ReplacementEditBuilder extends RecursiveAstVisitor<void> {
|
||||
return;
|
||||
}
|
||||
var element = node.element;
|
||||
if (element is ExecutableElement2 &&
|
||||
if (element is ExecutableElement &&
|
||||
element.enclosingElement2 == widgetClassElement &&
|
||||
!elementsToMove.contains(element)) {
|
||||
var parent = node.parent;
|
||||
@@ -390,7 +390,7 @@ class _StatelessVerifier extends RecursiveAstVisitor<void> {
|
||||
void visitMethodInvocation(MethodInvocation node) {
|
||||
var methodElement = node.methodName.element?.baseElement;
|
||||
var classElement = methodElement?.enclosingElement2;
|
||||
if (classElement is ClassElement2 &&
|
||||
if (classElement is ClassElement &&
|
||||
classElement.isExactState &&
|
||||
!FlutterConvertToStatelessWidget._isDefaultOverride(
|
||||
node.thisOrAncestorOfType<MethodDeclaration>(),
|
||||
@@ -404,8 +404,8 @@ class _StatelessVerifier extends RecursiveAstVisitor<void> {
|
||||
|
||||
class _StateUsageVisitor extends RecursiveAstVisitor<void> {
|
||||
bool used = false;
|
||||
ClassElement2 widgetClassElement;
|
||||
ClassElement2 stateClassElement;
|
||||
ClassElement widgetClassElement;
|
||||
ClassElement stateClassElement;
|
||||
|
||||
_StateUsageVisitor(this.widgetClassElement, this.stateClassElement);
|
||||
|
||||
|
||||
@@ -161,7 +161,7 @@ class FlutterRemoveWidget extends ResolvedCorrectionProducer {
|
||||
}
|
||||
|
||||
class _UsageFinder extends RecursiveAstVisitor<void> {
|
||||
final Element2 element;
|
||||
final Element element;
|
||||
bool used = false;
|
||||
|
||||
_UsageFinder(this.element);
|
||||
|
||||
@@ -337,7 +337,7 @@ abstract class _WrapSingleWidget extends ResolvedCorrectionProducer {
|
||||
// If the wrapper class is specified, find its element.
|
||||
var parentLibraryUri = _parentLibraryUri;
|
||||
var parentClassName = _parentClassName;
|
||||
ClassElement2? parentClassElement;
|
||||
ClassElement? parentClassElement;
|
||||
if (parentLibraryUri != null && parentClassName != null) {
|
||||
parentClassElement = await sessionHelper.getClass(
|
||||
parentLibraryUri,
|
||||
|
||||
@@ -59,7 +59,7 @@ class ImportAddShow extends ResolvedCorrectionProducer {
|
||||
}
|
||||
|
||||
class _ReferenceFinder extends RecursiveAstVisitor<void> {
|
||||
final Map<String, Element2> namespace;
|
||||
final Map<String, Element> namespace;
|
||||
|
||||
Set<String> referencedNames = SplayTreeSet<String>();
|
||||
|
||||
@@ -132,15 +132,15 @@ class _ReferenceFinder extends RecursiveAstVisitor<void> {
|
||||
_addName(node.token, element);
|
||||
}
|
||||
|
||||
void _addImplicitExtensionName(Element2? enclosingElement) {
|
||||
if (enclosingElement is ExtensionElement2) {
|
||||
void _addImplicitExtensionName(Element? enclosingElement) {
|
||||
if (enclosingElement is ExtensionElement) {
|
||||
if (namespace[enclosingElement.name3] == enclosingElement) {
|
||||
referencedNames.add(enclosingElement.displayName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void _addName(Token nameToken, Element2? element) {
|
||||
void _addName(Token nameToken, Element? element) {
|
||||
if (element != null) {
|
||||
var name = nameToken.lexeme;
|
||||
if (namespace[name] == element || namespace['$name='] == element) {
|
||||
|
||||
@@ -105,7 +105,7 @@ class ImportLibrary extends MultiCorrectionProducer {
|
||||
Future<(_ImportLibraryCombinator?, _ImportLibraryCombinatorMultiple?)>
|
||||
_importEditCombinators(
|
||||
LibraryImport import,
|
||||
LibraryElement2 libraryElement,
|
||||
LibraryElement libraryElement,
|
||||
String uri,
|
||||
String name, {
|
||||
String? prefix,
|
||||
@@ -234,7 +234,7 @@ class ImportLibrary extends MultiCorrectionProducer {
|
||||
var producers = <ResolvedCorrectionProducer>[];
|
||||
// Maybe there is an existing import, but it is with prefix and we don't use
|
||||
// this prefix.
|
||||
var alreadyImportedWithPrefix = <LibraryElement2>{};
|
||||
var alreadyImportedWithPrefix = <LibraryElement>{};
|
||||
for (var import in unitResult.libraryFragment.libraryImports2) {
|
||||
// Prepare the element.
|
||||
var libraryElement = import.importedLibrary2;
|
||||
@@ -245,7 +245,7 @@ class ImportLibrary extends MultiCorrectionProducer {
|
||||
if (element == null) {
|
||||
continue;
|
||||
}
|
||||
if (element is PropertyAccessorElement2) {
|
||||
if (element is PropertyAccessorElement) {
|
||||
element = element.variable3;
|
||||
if (element == null) {
|
||||
continue;
|
||||
@@ -390,7 +390,7 @@ class ImportLibrary extends MultiCorrectionProducer {
|
||||
}
|
||||
|
||||
List<_PrefixedName> _namesForExtensionInLibrary(
|
||||
LibraryElement2 libraryToImport,
|
||||
LibraryElement libraryToImport,
|
||||
DartType targetType,
|
||||
Name memberName,
|
||||
) {
|
||||
@@ -946,7 +946,7 @@ class _ImportLibraryCombinatorMultiple extends ResolvedCorrectionProducer {
|
||||
/// extension, but which does so only if the extension applies to a given type.
|
||||
class _ImportLibraryContainingExtension extends ResolvedCorrectionProducer {
|
||||
/// The library defining the extension.
|
||||
LibraryElement2 library;
|
||||
LibraryElement library;
|
||||
|
||||
/// The type of the target that the extension must apply to.
|
||||
DartType targetType;
|
||||
@@ -994,8 +994,8 @@ class _ImportLibraryContainingExtension extends ResolvedCorrectionProducer {
|
||||
/// A correction processor that can add a prefix to an identifier defined in a
|
||||
/// library that is already imported but that is imported with a prefix.
|
||||
class _ImportLibraryPrefix extends ResolvedCorrectionProducer {
|
||||
final LibraryElement2 _importedLibrary;
|
||||
final PrefixElement2 _importPrefix;
|
||||
final LibraryElement _importedLibrary;
|
||||
final PrefixElement _importPrefix;
|
||||
final String? _nodePrefix;
|
||||
final _ImportLibraryCombinator? _editCombinator;
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ class MakeFieldNotFinal extends ResolvedCorrectionProducer {
|
||||
}
|
||||
|
||||
// It must be a field declaration.
|
||||
if (getter.enclosingElement2 is! ClassElement2) {
|
||||
if (getter.enclosingElement2 is! ClassElement) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user