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

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

Issue 1278033006: tests for keyword/identifier replacementOffset - asserts fixes #23906 and fixes #23947 (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: address comments Created 5 years, 4 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/test/domain_completion_test.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/keyword_contributor_test.dart
diff --git a/pkg/analysis_server/test/services/completion/keyword_contributor_test.dart b/pkg/analysis_server/test/services/completion/keyword_contributor_test.dart
index 900062c9c1e2b7c92baa279c992c9657b26fd4a2..c41cee72c535dc284650132793b5ee4f53329b87 100644
--- a/pkg/analysis_server/test/services/completion/keyword_contributor_test.dart
+++ b/pkg/analysis_server/test/services/completion/keyword_contributor_test.dart
@@ -229,6 +229,35 @@ class KeywordContributorTest extends AbstractCompletionTest {
}
}
+ fail_import_partial() {
+ addTestSource('imp^ import "package:foo/foo.dart"; import "bar.dart";');
+ expect(computeFast(), isTrue);
+ // TODO(danrubel) should not suggest declaration keywords
+ assertNotSuggested('class');
+ }
+
+ fail_import_partial4() {
+ addTestSource('^ imp import "package:foo/foo.dart";');
+ expect(computeFast(), isTrue);
+ // TODO(danrubel) should not suggest declaration keywords
+ assertNotSuggested('class');
+ }
+
+ fail_import_partial5() {
+ addTestSource('library libA; imp^ import "package:foo/foo.dart";');
+ expect(computeFast(), isTrue);
+ // TODO(danrubel) should not suggest declaration keywords
+ assertNotSuggested('class');
+ }
+
+ fail_import_partial6() {
+ addTestSource(
+ 'library bar; import "zoo.dart"; imp^ import "package:foo/foo.dart";');
+ expect(computeFast(), isTrue);
+ // TODO(danrubel) should not suggest declaration keywords
+ assertNotSuggested('class');
+ }
+
@override
void setUpContributor() {
contributor = new KeywordContributor();
@@ -841,6 +870,14 @@ class A {
relevance: DART_RELEVANCE_HIGH);
}
+ test_import_deferred_as5() {
+ addTestSource('import "foo" sh^ import "bar"; import "baz";');
+ expect(computeFast(), isTrue);
+ assertSuggestKeywords([Keyword.AS],
+ pseudoKeywords: ['deferred as', 'show', 'hide'],
+ relevance: DART_RELEVANCE_HIGH);
+ }
+
test_import_deferred_not() {
addTestSource('import "foo" as foo ^;');
expect(computeFast(), isTrue);
@@ -848,11 +885,79 @@ class A {
pseudoKeywords: ['show', 'hide'], relevance: DART_RELEVANCE_HIGH);
}
+ test_import_deferred_partial() {
+ addTestSource('import "package:foo/foo.dart" def^ as foo;');
+ expect(computeFast(), isTrue);
+ assertSuggestKeywords([Keyword.DEFERRED], relevance: DART_RELEVANCE_HIGH);
+ expect(request.replacementOffset, 30);
+ expect(request.replacementLength, 3);
+ }
+
test_import_incomplete() {
addTestSource('import "^"');
expect(computeFast(), isTrue);
assertNoSuggestions();
- assertSuggestKeywords([]);
+ }
+
+ test_import_partial() {
+ addTestSource('imp^ import "package:foo/foo.dart"; import "bar.dart";');
+ expect(computeFast(), isTrue);
+ // TODO(danrubel) should not suggest declaration keywords
+ assertSuggestKeywords(DIRECTIVE_DECLARATION_AND_LIBRARY_KEYWORDS,
+ relevance: DART_RELEVANCE_HIGH);
+ expect(request.replacementOffset, 0);
+ expect(request.replacementLength, 3);
+ }
+
+ test_import_partial2() {
+ addTestSource('^imp import "package:foo/foo.dart";');
+ expect(computeFast(), isTrue);
+ // TODO(danrubel) should not suggest declaration keywords
+ assertSuggestKeywords(DIRECTIVE_DECLARATION_AND_LIBRARY_KEYWORDS,
+ relevance: DART_RELEVANCE_HIGH);
+ expect(request.replacementOffset, 0);
+ expect(request.replacementLength, 3);
+ }
+
+ test_import_partial3() {
+ addTestSource(' ^imp import "package:foo/foo.dart"; import "bar.dart";');
+ expect(computeFast(), isTrue);
+ // TODO(danrubel) should not suggest declaration keywords
+ assertSuggestKeywords(DIRECTIVE_DECLARATION_AND_LIBRARY_KEYWORDS,
+ relevance: DART_RELEVANCE_HIGH);
+ expect(request.replacementOffset, 1);
+ expect(request.replacementLength, 3);
+ }
+
+ test_import_partial4() {
+ addTestSource('^ imp import "package:foo/foo.dart";');
+ expect(computeFast(), isTrue);
+ // TODO(danrubel) should not suggest declaration keywords
+ assertSuggestKeywords(DIRECTIVE_DECLARATION_AND_LIBRARY_KEYWORDS,
+ relevance: DART_RELEVANCE_HIGH);
+ expect(request.replacementOffset, 0);
+ expect(request.replacementLength, 0);
+ }
+
+ test_import_partial5() {
+ addTestSource('library libA; imp^ import "package:foo/foo.dart";');
+ expect(computeFast(), isTrue);
+ // TODO(danrubel) should not suggest declaration keywords
+ assertSuggestKeywords(DIRECTIVE_AND_DECLARATION_KEYWORDS,
+ relevance: DART_RELEVANCE_HIGH);
+ expect(request.replacementOffset, 14);
+ expect(request.replacementLength, 3);
+ }
+
+ test_import_partial6() {
+ addTestSource(
+ 'library bar; import "zoo.dart"; imp^ import "package:foo/foo.dart";');
+ expect(computeFast(), isTrue);
+ // TODO(danrubel) should not suggest declaration keywords
+ assertSuggestKeywords(DIRECTIVE_AND_DECLARATION_KEYWORDS,
+ relevance: DART_RELEVANCE_HIGH);
+ expect(request.replacementOffset, 32);
+ expect(request.replacementLength, 3);
}
test_library() {
« no previous file with comments | « pkg/analysis_server/test/domain_completion_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698