Revert "Stop using available suggestions for already imported libraries"

This reverts commit 3cc518b3cc.
Initial CL: https://dart-review.googlesource.com/c/sdk/+/201021

Bug: https://github.com/flutter/flutter-intellij/issues/5761
Change-Id: I62e57deef819f78f1d08934ad924585eaa52223b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/214225
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Jacob Richman <jacobr@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
Konstantin Shcheglov 2021-09-23 18:39:07 +00:00 committed by commit-bot@chromium.org
parent 57e71e33c5
commit 6207d1da35
6 changed files with 7 additions and 32 deletions

View file

@ -99,7 +99,6 @@ class CiderCompletionComputer {
return await manager.computeSuggestions( return await manager.computeSuggestions(
performance, performance,
completionRequest, completionRequest,
enableImportedReferenceContributor: false,
enableOverrideContributor: false, enableOverrideContributor: false,
enableUriContributor: false, enableUriContributor: false,
); );

View file

@ -37,9 +37,8 @@ void computeIncludedSetList(
) { ) {
int relevance; int relevance;
if (importedUriSet.contains(library.uri)) { if (importedUriSet.contains(library.uri)) {
return; relevance = importedRelevance;
} } else if (library.isDeprecated) {
if (library.isDeprecated) {
relevance = deprecatedRelevance; relevance = deprecatedRelevance;
} else { } else {
relevance = otherwiseRelevance; relevance = otherwiseRelevance;

View file

@ -92,7 +92,6 @@ class DartCompletionManager {
Future<List<CompletionSuggestion>> computeSuggestions( Future<List<CompletionSuggestion>> computeSuggestions(
OperationPerformanceImpl performance, OperationPerformanceImpl performance,
CompletionRequest request, { CompletionRequest request, {
bool enableImportedReferenceContributor = true,
bool enableOverrideContributor = true, bool enableOverrideContributor = true,
bool enableUriContributor = true, bool enableUriContributor = true,
CompletionPreference? completionPreference, CompletionPreference? completionPreference,
@ -131,7 +130,6 @@ class DartCompletionManager {
CombinatorContributor(), CombinatorContributor(),
ExtensionMemberContributor(), ExtensionMemberContributor(),
FieldFormalContributor(), FieldFormalContributor(),
if (enableImportedReferenceContributor) ImportedReferenceContributor(),
KeywordContributor(), KeywordContributor(),
LabelContributor(), LabelContributor(),
LibraryMemberContributor(), LibraryMemberContributor(),
@ -150,6 +148,8 @@ class DartCompletionManager {
if (includedElementKinds != null) { if (includedElementKinds != null) {
_addIncludedElementKinds(dartRequest); _addIncludedElementKinds(dartRequest);
_addIncludedSuggestionRelevanceTags(dartRequest); _addIncludedSuggestionRelevanceTags(dartRequest);
} else {
contributors.add(ImportedReferenceContributor());
} }
try { try {

View file

@ -71,7 +71,6 @@ abstract class AbstractCompletionDriverTest with ResourceProviderMixin {
} }
void assertSuggestion({ void assertSuggestion({
bool allowMultiple = false,
required String completion, required String completion,
ElementKind? element, ElementKind? element,
CompletionSuggestionKind? kind, CompletionSuggestionKind? kind,
@ -79,7 +78,6 @@ abstract class AbstractCompletionDriverTest with ResourceProviderMixin {
}) { }) {
expect( expect(
suggestionWith( suggestionWith(
allowMultiple: allowMultiple,
completion: completion, completion: completion,
element: element, element: element,
kind: kind, kind: kind,
@ -184,7 +182,6 @@ project:${toUri('$projectPath/lib')}
completion: completion, element: element, kind: kind, file: file)); completion: completion, element: element, kind: kind, file: file));
CompletionSuggestion suggestionWith({ CompletionSuggestion suggestionWith({
bool allowMultiple = false,
required String completion, required String completion,
ElementKind? element, ElementKind? element,
CompletionSuggestionKind? kind, CompletionSuggestionKind? kind,
@ -192,9 +189,7 @@ project:${toUri('$projectPath/lib')}
}) { }) {
final matches = suggestionsWith( final matches = suggestionsWith(
completion: completion, element: element, kind: kind, file: file); completion: completion, element: element, kind: kind, file: file);
if (!allowMultiple) { expect(matches, hasLength(1));
expect(matches, hasLength(1));
}
return matches.first; return matches.first;
} }
@ -269,10 +264,7 @@ void f() {
} }
'''); ''');
// TODO(brianwilkerson) There should be a single suggestion here after we
// figure out how to stop the duplication.
assertSuggestion( assertSuggestion(
allowMultiple: true,
completion: 'A', completion: 'A',
element: ElementKind.CONSTRUCTOR, element: ElementKind.CONSTRUCTOR,
kind: CompletionSuggestionKind.INVOCATION); kind: CompletionSuggestionKind.INVOCATION);
@ -296,11 +288,7 @@ void f() {
^ ^
} }
'''); ''');
// TODO(brianwilkerson) There should be a single suggestion here after we
// figure out how to stop the duplication.
assertSuggestion( assertSuggestion(
allowMultiple: true,
completion: 'E.e', completion: 'E.e',
element: ElementKind.ENUM_CONSTANT, element: ElementKind.ENUM_CONSTANT,
kind: CompletionSuggestionKind.INVOCATION); kind: CompletionSuggestionKind.INVOCATION);
@ -325,10 +313,7 @@ void f() {
} }
'''); ''');
// TODO(brianwilkerson) There should be a single suggestion here after we
// figure out how to stop the duplication.
assertSuggestion( assertSuggestion(
allowMultiple: true,
completion: 'A.a', completion: 'A.a',
element: ElementKind.CONSTRUCTOR, element: ElementKind.CONSTRUCTOR,
kind: CompletionSuggestionKind.INVOCATION); kind: CompletionSuggestionKind.INVOCATION);
@ -661,15 +646,13 @@ void f() {
} }
'''); ''');
// TODO(brianwilkerson) There should be a single suggestion here after we
// figure out how to stop the duplication.
expect( expect(
suggestionsWith( suggestionsWith(
completion: 'Future.value', completion: 'Future.value',
file: '/sdk/lib/async/async.dart', file: '/sdk/lib/async/async.dart',
element: ElementKind.CONSTRUCTOR, element: ElementKind.CONSTRUCTOR,
kind: CompletionSuggestionKind.INVOCATION), kind: CompletionSuggestionKind.INVOCATION),
hasLength(2)); hasLength(1));
} }
Future<void> test_sdk_lib_suggestions() async { Future<void> test_sdk_lib_suggestions() async {

View file

@ -1560,7 +1560,7 @@ void f() {
expect(completions, hasLength(1)); expect(completions, hasLength(1));
final resolved = await resolveCompletion(completions.first); final resolved = await resolveCompletion(completions.first);
// It should not include auto-import text since it's already imported. // It should not include auto-import text since it's already imported.
expect(resolved.detail, isNot(contains('Auto import from'))); expect(resolved.detail, isNull);
} }
Future<void> test_suggestionSets_filtersOutAlreadyImportedSymbols() async { Future<void> test_suggestionSets_filtersOutAlreadyImportedSymbols() async {

View file

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