Skip to content

Commit 6207d1d

Browse files
scheglovcommit-bot@chromium.org
authored andcommitted
Revert "Stop using available suggestions for already imported libraries"
This reverts commit 3cc518b. Initial CL: https://dart-review.googlesource.com/c/sdk/+/201021 Bug: flutter/flutter-intellij#5761 Change-Id: I62e57deef819f78f1d08934ad924585eaa52223b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/214225 Reviewed-by: Brian Wilkerson <[email protected]> Reviewed-by: Jacob Richman <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
1 parent 57e71e3 commit 6207d1d

File tree

6 files changed

+7
-32
lines changed

6 files changed

+7
-32
lines changed

pkg/analysis_server/lib/src/cider/completion.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ class CiderCompletionComputer {
9999
return await manager.computeSuggestions(
100100
performance,
101101
completionRequest,
102-
enableImportedReferenceContributor: false,
103102
enableOverrideContributor: false,
104103
enableUriContributor: false,
105104
);

pkg/analysis_server/lib/src/domains/completion/available_suggestions.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,8 @@ void computeIncludedSetList(
3737
) {
3838
int relevance;
3939
if (importedUriSet.contains(library.uri)) {
40-
return;
41-
}
42-
if (library.isDeprecated) {
40+
relevance = importedRelevance;
41+
} else if (library.isDeprecated) {
4342
relevance = deprecatedRelevance;
4443
} else {
4544
relevance = otherwiseRelevance;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ class DartCompletionManager {
9292
Future<List<CompletionSuggestion>> computeSuggestions(
9393
OperationPerformanceImpl performance,
9494
CompletionRequest request, {
95-
bool enableImportedReferenceContributor = true,
9695
bool enableOverrideContributor = true,
9796
bool enableUriContributor = true,
9897
CompletionPreference? completionPreference,
@@ -131,7 +130,6 @@ class DartCompletionManager {
131130
CombinatorContributor(),
132131
ExtensionMemberContributor(),
133132
FieldFormalContributor(),
134-
if (enableImportedReferenceContributor) ImportedReferenceContributor(),
135133
KeywordContributor(),
136134
LabelContributor(),
137135
LibraryMemberContributor(),
@@ -150,6 +148,8 @@ class DartCompletionManager {
150148
if (includedElementKinds != null) {
151149
_addIncludedElementKinds(dartRequest);
152150
_addIncludedSuggestionRelevanceTags(dartRequest);
151+
} else {
152+
contributors.add(ImportedReferenceContributor());
153153
}
154154

155155
try {

pkg/analysis_server/test/client/completion_driver_test.dart

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,13 @@ abstract class AbstractCompletionDriverTest with ResourceProviderMixin {
7171
}
7272

7373
void assertSuggestion({
74-
bool allowMultiple = false,
7574
required String completion,
7675
ElementKind? element,
7776
CompletionSuggestionKind? kind,
7877
String? file,
7978
}) {
8079
expect(
8180
suggestionWith(
82-
allowMultiple: allowMultiple,
8381
completion: completion,
8482
element: element,
8583
kind: kind,
@@ -184,17 +182,14 @@ project:${toUri('$projectPath/lib')}
184182
completion: completion, element: element, kind: kind, file: file));
185183

186184
CompletionSuggestion suggestionWith({
187-
bool allowMultiple = false,
188185
required String completion,
189186
ElementKind? element,
190187
CompletionSuggestionKind? kind,
191188
String? file,
192189
}) {
193190
final matches = suggestionsWith(
194191
completion: completion, element: element, kind: kind, file: file);
195-
if (!allowMultiple) {
196-
expect(matches, hasLength(1));
197-
}
192+
expect(matches, hasLength(1));
198193
return matches.first;
199194
}
200195

@@ -269,10 +264,7 @@ void f() {
269264
}
270265
''');
271266

272-
// TODO(brianwilkerson) There should be a single suggestion here after we
273-
// figure out how to stop the duplication.
274267
assertSuggestion(
275-
allowMultiple: true,
276268
completion: 'A',
277269
element: ElementKind.CONSTRUCTOR,
278270
kind: CompletionSuggestionKind.INVOCATION);
@@ -296,11 +288,7 @@ void f() {
296288
^
297289
}
298290
''');
299-
300-
// TODO(brianwilkerson) There should be a single suggestion here after we
301-
// figure out how to stop the duplication.
302291
assertSuggestion(
303-
allowMultiple: true,
304292
completion: 'E.e',
305293
element: ElementKind.ENUM_CONSTANT,
306294
kind: CompletionSuggestionKind.INVOCATION);
@@ -325,10 +313,7 @@ void f() {
325313
}
326314
''');
327315

328-
// TODO(brianwilkerson) There should be a single suggestion here after we
329-
// figure out how to stop the duplication.
330316
assertSuggestion(
331-
allowMultiple: true,
332317
completion: 'A.a',
333318
element: ElementKind.CONSTRUCTOR,
334319
kind: CompletionSuggestionKind.INVOCATION);
@@ -661,15 +646,13 @@ void f() {
661646
}
662647
''');
663648

664-
// TODO(brianwilkerson) There should be a single suggestion here after we
665-
// figure out how to stop the duplication.
666649
expect(
667650
suggestionsWith(
668651
completion: 'Future.value',
669652
file: '/sdk/lib/async/async.dart',
670653
element: ElementKind.CONSTRUCTOR,
671654
kind: CompletionSuggestionKind.INVOCATION),
672-
hasLength(2));
655+
hasLength(1));
673656
}
674657

675658
Future<void> test_sdk_lib_suggestions() async {

pkg/analysis_server/test/lsp/completion_dart_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1560,7 +1560,7 @@ void f() {
15601560
expect(completions, hasLength(1));
15611561
final resolved = await resolveCompletion(completions.first);
15621562
// It should not include auto-import text since it's already imported.
1563-
expect(resolved.detail, isNot(contains('Auto import from')));
1563+
expect(resolved.detail, isNull);
15641564
}
15651565

15661566
Future<void> test_suggestionSets_filtersOutAlreadyImportedSymbols() async {

pkg/analysis_server/test/services/completion/dart/relevance/bool_assignment_test.dart

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,7 @@ void main() {
1515

1616
@reflectiveTest
1717
class BoolAssignmentTest extends CompletionRelevanceTest {
18-
@failingTest
1918
Future<void> test_boolLiterals_imported() async {
20-
// TODO(brianwilkerson) This test is arguably invalid given that there's no
21-
// data to suggest that the boolean keywords should appear before a
22-
// constructor in the list, but it does seem likely to be valid in this
23-
// case, so we should investigate features that might cause this test to
24-
// start passing again.
2519
await addTestFile('''
2620
foo() {
2721
bool b;

0 commit comments

Comments
 (0)