mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 08:41:10 +00:00
Stop using available suggestions for already imported libraries
This is a re-do of https://dart-review.googlesource.com/c/sdk/+/197880 that removes the support for Cider. We might try using this for Cider at some future date, but I didn't want that support to prevent us from getting this to users sooner. Change-Id: Ia5c06a8a3d7366770dedb4f51153c2f4004bb89e Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/201021 Reviewed-by: Konstantin Shcheglov <scheglov@google.com> Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
parent
e1393eb589
commit
3cc518b3cc
|
@ -99,6 +99,7 @@ class CiderCompletionComputer {
|
|||
return await manager.computeSuggestions(
|
||||
performance,
|
||||
completionRequest,
|
||||
enableImportedReferenceContributor: false,
|
||||
enableOverrideContributor: false,
|
||||
enableUriContributor: false,
|
||||
);
|
||||
|
|
|
@ -38,8 +38,9 @@ void computeIncludedSetList(
|
|||
) {
|
||||
int relevance;
|
||||
if (importedUriSet.contains(library.uri)) {
|
||||
relevance = importedRelevance;
|
||||
} else if (library.isDeprecated) {
|
||||
return;
|
||||
}
|
||||
if (library.isDeprecated) {
|
||||
relevance = deprecatedRelevance;
|
||||
} else {
|
||||
relevance = otherwiseRelevance;
|
||||
|
|
|
@ -91,6 +91,7 @@ class DartCompletionManager {
|
|||
Future<List<CompletionSuggestion>> computeSuggestions(
|
||||
OperationPerformanceImpl performance,
|
||||
CompletionRequest request, {
|
||||
bool enableImportedReferenceContributor = true,
|
||||
bool enableOverrideContributor = true,
|
||||
bool enableUriContributor = true,
|
||||
CompletionPreference? completionPreference,
|
||||
|
@ -129,6 +130,7 @@ class DartCompletionManager {
|
|||
CombinatorContributor(),
|
||||
ExtensionMemberContributor(),
|
||||
FieldFormalContributor(),
|
||||
if (enableImportedReferenceContributor) ImportedReferenceContributor(),
|
||||
KeywordContributor(),
|
||||
LabelContributor(),
|
||||
LibraryMemberContributor(),
|
||||
|
@ -146,8 +148,6 @@ class DartCompletionManager {
|
|||
if (includedElementKinds != null) {
|
||||
_addIncludedElementKinds(dartRequest);
|
||||
_addIncludedSuggestionRelevanceTags(dartRequest);
|
||||
} else {
|
||||
contributors.add(ImportedReferenceContributor());
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
|
@ -71,6 +71,7 @@ abstract class AbstractCompletionDriverTest with ResourceProviderMixin {
|
|||
}
|
||||
|
||||
void assertSuggestion({
|
||||
bool allowMultiple = false,
|
||||
required String completion,
|
||||
ElementKind? element,
|
||||
CompletionSuggestionKind? kind,
|
||||
|
@ -78,6 +79,7 @@ abstract class AbstractCompletionDriverTest with ResourceProviderMixin {
|
|||
}) {
|
||||
expect(
|
||||
suggestionWith(
|
||||
allowMultiple: allowMultiple,
|
||||
completion: completion,
|
||||
element: element,
|
||||
kind: kind,
|
||||
|
@ -182,6 +184,7 @@ project:${toUri('$projectPath/lib')}
|
|||
completion: completion, element: element, kind: kind, file: file));
|
||||
|
||||
CompletionSuggestion suggestionWith({
|
||||
bool allowMultiple = false,
|
||||
required String completion,
|
||||
ElementKind? element,
|
||||
CompletionSuggestionKind? kind,
|
||||
|
@ -189,7 +192,9 @@ project:${toUri('$projectPath/lib')}
|
|||
}) {
|
||||
final matches = suggestionsWith(
|
||||
completion: completion, element: element, kind: kind, file: file);
|
||||
expect(matches, hasLength(1));
|
||||
if (!allowMultiple) {
|
||||
expect(matches, hasLength(1));
|
||||
}
|
||||
return matches.first;
|
||||
}
|
||||
|
||||
|
@ -264,7 +269,10 @@ void main() {
|
|||
}
|
||||
''');
|
||||
|
||||
// TODO(brianwilkerson) There should be a single suggestion here after we
|
||||
// figure out how to stop the duplication.
|
||||
assertSuggestion(
|
||||
allowMultiple: true,
|
||||
completion: 'A',
|
||||
element: ElementKind.CONSTRUCTOR,
|
||||
kind: CompletionSuggestionKind.INVOCATION);
|
||||
|
@ -288,7 +296,11 @@ void main() {
|
|||
^
|
||||
}
|
||||
''');
|
||||
|
||||
// TODO(brianwilkerson) There should be a single suggestion here after we
|
||||
// figure out how to stop the duplication.
|
||||
assertSuggestion(
|
||||
allowMultiple: true,
|
||||
completion: 'E.e',
|
||||
element: ElementKind.ENUM_CONSTANT,
|
||||
kind: CompletionSuggestionKind.INVOCATION);
|
||||
|
@ -313,7 +325,10 @@ void main() {
|
|||
}
|
||||
''');
|
||||
|
||||
// TODO(brianwilkerson) There should be a single suggestion here after we
|
||||
// figure out how to stop the duplication.
|
||||
assertSuggestion(
|
||||
allowMultiple: true,
|
||||
completion: 'A.a',
|
||||
element: ElementKind.CONSTRUCTOR,
|
||||
kind: CompletionSuggestionKind.INVOCATION);
|
||||
|
@ -641,13 +656,15 @@ void main() {
|
|||
}
|
||||
''');
|
||||
|
||||
// TODO(brianwilkerson) There should be a single suggestion here after we
|
||||
// figure out how to stop the duplication.
|
||||
expect(
|
||||
suggestionsWith(
|
||||
completion: 'Future.value',
|
||||
file: '/sdk/lib/async/async.dart',
|
||||
element: ElementKind.CONSTRUCTOR,
|
||||
kind: CompletionSuggestionKind.INVOCATION),
|
||||
hasLength(1));
|
||||
hasLength(2));
|
||||
}
|
||||
|
||||
Future<void> test_sdk_lib_suggestions() async {
|
||||
|
|
|
@ -1544,7 +1544,7 @@ main() {
|
|||
expect(completions, hasLength(1));
|
||||
final resolved = await resolveCompletion(completions.first);
|
||||
// It should not include auto-import text since it's already imported.
|
||||
expect(resolved.detail, isNull);
|
||||
expect(resolved.detail, isNot(contains('Auto import from')));
|
||||
}
|
||||
|
||||
Future<void> test_suggestionSets_filtersOutAlreadyImportedSymbols() async {
|
||||
|
|
|
@ -15,7 +15,13 @@ void main() {
|
|||
|
||||
@reflectiveTest
|
||||
class BoolAssignmentTest extends CompletionRelevanceTest {
|
||||
@failingTest
|
||||
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('''
|
||||
foo() {
|
||||
bool b;
|
||||
|
|
Loading…
Reference in a new issue