Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1345)

Unified Diff: pkg/analysis_server/test/services/completion/dart/local_library_contributor_test.dart

Issue 1908703002: Code completion improvement, use type information when suggesting constructors, part 2. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Rebase with master, comments from danrubel Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analysis_server/lib/src/services/completion/dart/local_library_contributor.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/test/services/completion/dart/local_library_contributor_test.dart
diff --git a/pkg/analysis_server/test/services/completion/dart/local_library_contributor_test.dart b/pkg/analysis_server/test/services/completion/dart/local_library_contributor_test.dart
index eeab8d7be89e5922a6081ecaf625c938f5a16378..a53e433514e2a9394d521318c2e4c0a1e5fa8938 100644
--- a/pkg/analysis_server/test/services/completion/dart/local_library_contributor_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/local_library_contributor_test.dart
@@ -103,6 +103,114 @@ class LocalLibraryContributorTest extends DartCompletionContributorTest {
assertNotSuggested('m');
}
+ test_partFile_InstanceCreationExpression_variable_declaration_filter() async {
+ // ConstructorName InstanceCreationExpression VariableDeclarationList
+ addSource(
+ '/testB.dart',
+ '''
+ lib B;
+ int T1;
+ F1() { }
+ class X {X.c(); X._d(); z() {}}''');
+ addSource(
+ '/testA.dart',
+ '''
+ part of libA;
+ class A {} class B extends A {} class C implements A {} class D {}
+ ''');
+ addTestSource('''
+ library libA;
+ import "/testB.dart";
+ part "/testA.dart";
+ class Local { }
+ main() {
+ A a = new ^
+ }
+ var m;''');
+ await computeLibrariesContaining();
+ await computeSuggestions();
+ expect(replacementOffset, completionOffset);
+ expect(replacementLength, 0);
+ // A is suggested with a higher relevance
+ assertSuggestConstructor('A',
+ elemOffset: -1,
+ relevance: DART_RELEVANCE_DEFAULT + DART_RELEVANCE_INCREMENT);
+ assertSuggestConstructor('B',
+ elemOffset: -1, relevance: DART_RELEVANCE_DEFAULT);
+ assertSuggestConstructor('C',
+ elemOffset: -1, relevance: DART_RELEVANCE_DEFAULT);
+ // D is sorted out
+ assertNotSuggested('D');
+
+ // Suggested by ConstructorContributor
+ assertNotSuggested('Local');
+
+ // Suggested by ImportedReferenceContributor
+ assertNotSuggested('Object');
+ assertNotSuggested('X.c');
+ assertNotSuggested('X._d');
+ assertNotSuggested('F1');
+ assertNotSuggested('T1');
+ assertNotSuggested('_d');
+ assertNotSuggested('z');
+ assertNotSuggested('m');
+ }
+
+ test_partFile_InstanceCreationExpression_assignment_filter() async {
+ // ConstructorName InstanceCreationExpression VariableDeclarationList
+ addSource(
+ '/testB.dart',
+ '''
+ lib B;
+ int T1;
+ F1() { }
+ class X {X.c(); X._d(); z() {}}''');
+ addSource(
+ '/testA.dart',
+ '''
+ part of libA;
+ class A {} class B extends A {} class C implements A {} class D {}
+ ''');
+ addTestSource('''
+ library libA;
+ import "/testB.dart";
+ part "/testA.dart";
+ class Local { }
+ main() {
+ A a;
+ // FAIL:
+ a = new ^
+ }
+ var m;''');
+ await computeLibrariesContaining();
+ await computeSuggestions();
+ expect(replacementOffset, completionOffset);
+ expect(replacementLength, 0);
+ // A is suggested with a higher relevance
+ assertSuggestConstructor('A',
+ elemOffset: -1,
+ relevance: DART_RELEVANCE_DEFAULT + DART_RELEVANCE_INCREMENT);
+ assertSuggestConstructor('B',
+ elemOffset: -1, relevance: DART_RELEVANCE_DEFAULT);
+ assertSuggestConstructor('C',
+ elemOffset: -1, relevance: DART_RELEVANCE_DEFAULT);
+ // D is sorted out
+ assertNotSuggested('D');
+
+ // Suggested by ConstructorContributor
+ assertNotSuggested('Local');
+
+ // Suggested by ImportedReferenceContributor
+ assertNotSuggested('Object');
+ assertNotSuggested('X.c');
+ assertNotSuggested('X._d');
+ assertNotSuggested('F1');
+ assertNotSuggested('T1');
+ assertNotSuggested('_d');
+ assertNotSuggested('z');
+ assertNotSuggested('m');
+ }
+
test_partFile_TypeName() async {
addSource(
'/testB.dart',
« no previous file with comments | « pkg/analysis_server/lib/src/services/completion/dart/local_library_contributor.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698