Skip to content

Commit 3557eb4

Browse files
DanTupscheglov
authored andcommitted
[analyzer] Remove Element2.location
The completion code was no longer using this (we use `ElementLocation2` directly in the completion handler now), and the navigation check was just to ensure we didn't include MultiplyDefinedElements in navigation results. Change-Id: I8412ec60d3d56386a7ced3d78c3a7428313df5d3 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/402101 Reviewed-by: Konstantin Shcheglov <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]>
1 parent 354c64f commit 3557eb4

File tree

5 files changed

+2
-29
lines changed

5 files changed

+2
-29
lines changed

pkg/analysis_server/lib/src/services/completion/dart/dart_completion_suggestion.dart

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@
44

55
import 'package:analysis_server/src/protocol_server.dart'
66
show CompletionSuggestion;
7-
import 'package:analyzer/dart/element/element2.dart';
87

98
/// An extension of [CompletionSuggestion] that includes additional
109
/// Dart-specific fields that are not part of the JSON protocol.
1110
class DartCompletionSuggestion extends CompletionSuggestion {
12-
final ElementLocation? elementLocation;
1311
final List<Uri> requiredImports;
1412
final String? colorHex;
1513

@@ -39,7 +37,6 @@ class DartCompletionSuggestion extends CompletionSuggestion {
3937
super.parameterType,
4038
super.libraryUri,
4139
super.isNotImported,
42-
required this.elementLocation,
4340
this.requiredImports = const [],
4441
this.colorHex,
4542
});

pkg/analysis_server/lib/src/services/completion/dart/suggestion_builder.dart

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ class SuggestionBuilder {
152152
false,
153153
false,
154154
displayText: displayText,
155-
elementLocation: null, // type.element is Null for FunctionType.
156155
),
157156
);
158157
}
@@ -728,7 +727,6 @@ class SuggestionBuilder {
728727
parameterType: type,
729728
replacementLength: replacementLength,
730729
element: convertElement2(parameter),
731-
elementLocation: parameter.location,
732730
);
733731

734732
if (parameter is FieldFormalParameterElement2) {
@@ -850,7 +848,6 @@ class SuggestionBuilder {
850848
element.metadata2.hasDeprecated,
851849
false,
852850
displayText: displayText,
853-
elementLocation: element.location,
854851
requiredImports: overrideImports.toList(),
855852
);
856853
suggestion.element = protocol.convertElement2(element);
@@ -928,7 +925,6 @@ class SuggestionBuilder {
928925
false,
929926
// Let the user know that we are going to insert a complete statement.
930927
displayText: displayText,
931-
elementLocation: method.location,
932928
),
933929
textToMatchOverride: 'setState',
934930
);
@@ -1522,9 +1518,7 @@ class SuggestionBuilder {
15221518
ElementLocation? elementLocation;
15231519
if (element is! LocalVariableElement2 ||
15241520
(element is FormalParameterElement &&
1525-
element.enclosingElement2 != null)) {
1526-
elementLocation = element.location;
1527-
}
1521+
element.enclosingElement2 != null)) {}
15281522

15291523
return _ElementCompletionData(
15301524
isDeprecated: element.hasOrInheritsDeprecated,
@@ -1799,7 +1793,6 @@ class _CompletionSuggestionBuilderImpl implements CompletionSuggestionBuilder {
17991793
defaultArgumentListTextRanges: element.defaultArgumentList?.ranges,
18001794
libraryUri: libraryUriStr,
18011795
isNotImported: isNotImported ? true : null,
1802-
elementLocation: element.elementLocation,
18031796
requiredImports: requiredImports,
18041797
colorHex: element.colorHex,
18051798
);

pkg/analyzer/lib/dart/element/element2.dart

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ import 'package:analyzer/dart/element/element.dart'
5454
DirectiveUri,
5555
ElementAnnotation,
5656
ElementKind,
57-
ElementLocation,
5857
LibraryLanguageVersion,
5958
NamespaceCombinator;
6059
import 'package:analyzer/dart/element/nullability_suffix.dart';
@@ -436,11 +435,6 @@ abstract class Element2 {
436435
/// in a single library.
437436
LibraryElement2? get library2;
438437

439-
/// The location of this element in the element model.
440-
///
441-
/// The object can be used to locate this element at a later time.
442-
ElementLocation? get location;
443-
444438
/// The name to use for lookup in maps.
445439
///
446440
/// It is usually the same as [name3], with a few special cases.

pkg/analyzer/lib/src/dart/element/element.dart

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3337,11 +3337,6 @@ abstract class ElementImpl2 implements Element2 {
33373337
@override
33383338
bool get isPublic => !isPrivate;
33393339

3340-
@override
3341-
ElementLocation? get location {
3342-
return ElementLocationImpl.fromElement(this);
3343-
}
3344-
33453340
@override
33463341
String? get lookupName {
33473342
return name3;
@@ -5576,9 +5571,6 @@ abstract class InstanceElementImpl2 extends ElementImpl2
55765571
@override
55775572
LibraryElement2 get library2 => firstFragment.library2!;
55785573

5579-
@override
5580-
ElementLocation? get location => firstFragment.location;
5581-
55825574
@override
55835575
List<ElementAnnotation> get metadata => firstFragment.metadata;
55845576

@@ -8700,9 +8692,6 @@ class MultiplyDefinedElementImpl2 extends ElementImpl2
87008692
@override
87018693
LibraryElement2 get library2 => libraryFragment.element;
87028694

8703-
@override
8704-
ElementLocation? get location => null;
8705-
87068695
@override
87078696
Element2 get nonSynthetic2 => this;
87088697

pkg/analyzer_plugin/lib/src/utilities/navigation/navigation_dart.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ class _DartNavigationCollector {
145145
if (fragment.element == DynamicElementImpl.instance) {
146146
return;
147147
}
148-
if (fragment.element.location == null) {
148+
if (fragment.element is MultiplyDefinedElement2) {
149149
return;
150150
}
151151

0 commit comments

Comments
 (0)