Skip to content

Commit f6e4b3e

Browse files
keertipCommit Queue
authored andcommitted
[Element.migrate] Migrate CompletionState
Change-Id: I08bb8ffc4fa079d1f5b126af5de3101673f1be55 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/396520 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Keerti Parthasarathy <[email protected]>
1 parent 1af77fa commit f6e4b3e

File tree

4 files changed

+8
-11
lines changed

4 files changed

+8
-11
lines changed

pkg/analysis_server/analyzer_use_new_elements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ lib/src/protocol_server.dart
2828
lib/src/search/element_references.dart
2929
lib/src/search/type_hierarchy.dart
3030
lib/src/services/completion/dart/completion_manager.dart
31-
lib/src/services/completion/dart/completion_state.dart
3231
lib/src/services/completion/dart/declaration_helper.dart
3332
lib/src/services/completion/dart/feature_computer.dart
3433
lib/src/services/completion/dart/identifier_helper.dart

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import 'package:analysis_server_plugin/src/utilities/selection.dart';
88
import 'package:analyzer/dart/analysis/code_style_options.dart';
99
import 'package:analyzer/dart/analysis/features.dart';
1010
import 'package:analyzer/dart/ast/ast.dart';
11-
import 'package:analyzer/dart/element/element.dart';
11+
import 'package:analyzer/dart/element/element2.dart';
1212
import 'package:analyzer/dart/element/type.dart';
1313
import 'package:analyzer/src/utilities/completion_matcher.dart';
1414

@@ -58,7 +58,7 @@ class CompletionState {
5858
}
5959

6060
/// The element of the library containing the completion location.
61-
LibraryElement get libraryElement => request.libraryElement;
61+
LibraryElement2 get libraryElement => request.libraryElement2;
6262

6363
/// The type of quotes preferred for [String]s as specified in [CodeStyleOptions].
6464
String get preferredQuoteForStrings =>
@@ -75,19 +75,19 @@ class CompletionState {
7575
while (node != null) {
7676
switch (node) {
7777
case ClassDeclaration():
78-
var element = node.declaredElement;
78+
var element = node.declaredFragment?.element;
7979
if (element != null) {
8080
return element.thisType;
8181
}
8282
case EnumDeclaration():
83-
var element = node.declaredElement;
83+
var element = node.declaredFragment?.element;
8484
if (element != null) {
8585
return element.thisType;
8686
}
8787
case ExtensionDeclaration():
8888
return node.onClause?.extendedType.type;
8989
case MixinDeclaration():
90-
var element = node.declaredElement;
90+
var element = node.declaredFragment?.element;
9191
if (element != null) {
9292
return element.thisType;
9393
}

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,10 @@ class IdentifierHelper {
5959
if (candidateName == null) {
6060
return;
6161
}
62-
for (var unit in state.libraryElement.units) {
63-
for (var childElement in unit.children) {
64-
if (childElement.name == candidateName) {
62+
for (var childElement in state.libraryElement.children2) {
63+
if (childElement.name3 == candidateName) {
6564
// Don't suggest a name that's already declared in the library.
6665
return;
67-
}
6866
}
6967
}
7068
var matcherScore = state.matcher.score(candidateName);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,7 @@ class InScopeCompletionPass extends SimpleAstVisitor<void> {
742742
if (constructorElement == null) {
743743
return;
744744
}
745-
var libraryElement = state.libraryElement;
745+
var libraryElement = state.libraryElement.asElement as LibraryElement;
746746
declarationHelper(
747747
mustBeConstant: constructorElement.isConst,
748748
).addPossibleRedirectionsInLibrary(constructorElement, libraryElement);

0 commit comments

Comments
 (0)