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

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

Issue 1303233008: improve keyword suggestions - fixes #24016 (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: merge 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/services/completion/completion_test_util.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 c41cee72c535dc284650132793b5ee4f53329b87..bf3c027f3d80f27ce01b6075a8666663dbec6aee 100644
--- a/pkg/analysis_server/test/services/completion/keyword_contributor_test.dart
+++ b/pkg/analysis_server/test/services/completion/keyword_contributor_test.dart
@@ -79,6 +79,28 @@ class KeywordContributorTest extends AbstractCompletionTest {
static const List<Keyword> STMT_START_IN_CLASS = const [
Keyword.ASSERT,
+ Keyword.CONST,
+ Keyword.DO,
+ Keyword.FINAL,
+ Keyword.FOR,
+ Keyword.IF,
+ Keyword.NEW,
+ Keyword.RETHROW,
+ Keyword.RETURN,
+ Keyword.SUPER,
+ Keyword.SWITCH,
+ Keyword.THIS,
+ Keyword.THROW,
+ Keyword.TRY,
+ Keyword.VAR,
+ Keyword.VOID,
+ Keyword.WHILE
+ ];
+
+ static const List<Keyword> STMT_START_IN_LOOP_IN_CLASS = const [
+ Keyword.ASSERT,
+ Keyword.BREAK,
+ Keyword.CONST,
Keyword.CONTINUE,
Keyword.DO,
Keyword.FINAL,
@@ -99,8 +121,9 @@ class KeywordContributorTest extends AbstractCompletionTest {
static const List<Keyword> STMT_START_IN_SWITCH_IN_CLASS = const [
Keyword.ASSERT,
+ Keyword.BREAK,
Keyword.CASE,
- Keyword.CONTINUE,
+ Keyword.CONST,
Keyword.DEFAULT,
Keyword.DO,
Keyword.FINAL,
@@ -121,8 +144,9 @@ class KeywordContributorTest extends AbstractCompletionTest {
static const List<Keyword> STMT_START_IN_SWITCH_OUTSIDE_CLASS = const [
Keyword.ASSERT,
+ Keyword.BREAK,
Keyword.CASE,
- Keyword.CONTINUE,
+ Keyword.CONST,
Keyword.DEFAULT,
Keyword.DO,
Keyword.FINAL,
@@ -141,6 +165,26 @@ class KeywordContributorTest extends AbstractCompletionTest {
static const List<Keyword> STMT_START_OUTSIDE_CLASS = const [
Keyword.ASSERT,
+ Keyword.CONST,
+ Keyword.DO,
+ Keyword.FINAL,
+ Keyword.FOR,
+ Keyword.IF,
+ Keyword.NEW,
+ Keyword.RETHROW,
+ Keyword.RETURN,
+ Keyword.SWITCH,
+ Keyword.THROW,
+ Keyword.TRY,
+ Keyword.VAR,
+ Keyword.VOID,
+ Keyword.WHILE
+ ];
+
+ static const List<Keyword> STMT_START_IN_LOOP_OUTSIDE_CLASS = const [
+ Keyword.ASSERT,
+ Keyword.BREAK,
+ Keyword.CONST,
Keyword.CONTINUE,
Keyword.DO,
Keyword.FINAL,
@@ -158,6 +202,7 @@ class KeywordContributorTest extends AbstractCompletionTest {
];
static const List<Keyword> EXPRESSION_START_INSTANCE = const [
+ Keyword.CONST,
Keyword.FALSE,
Keyword.NEW,
Keyword.NULL,
@@ -167,6 +212,7 @@ class KeywordContributorTest extends AbstractCompletionTest {
];
static const List<Keyword> EXPRESSION_START_NO_INSTANCE = const [
+ Keyword.CONST,
Keyword.FALSE,
Keyword.NEW,
Keyword.NULL,
@@ -539,6 +585,20 @@ class KeywordContributorTest extends AbstractCompletionTest {
assertSuggestKeywords([Keyword.THIS]);
}
+ test_do_break_continue() {
+ addTestSource('main() {do {^} while (true);}');
+ expect(computeFast(), isTrue);
+ assertSuggestKeywords(STMT_START_IN_LOOP_OUTSIDE_CLASS,
+ relevance: DART_RELEVANCE_KEYWORD);
+ }
+
+ test_do_break_continue2() {
+ addTestSource('class A {foo() {do {^} while (true);}}');
+ expect(computeFast(), isTrue);
+ assertSuggestKeywords(STMT_START_IN_LOOP_IN_CLASS,
+ relevance: DART_RELEVANCE_KEYWORD);
+ }
+
test_empty() {
addTestSource('^');
expect(computeFast(), isTrue);
@@ -546,6 +606,20 @@ class KeywordContributorTest extends AbstractCompletionTest {
relevance: DART_RELEVANCE_HIGH);
}
+ test_for_break_continue() {
+ addTestSource('main() {for (int x in myList) {^}}');
+ expect(computeFast(), isTrue);
+ assertSuggestKeywords(STMT_START_IN_LOOP_OUTSIDE_CLASS,
+ relevance: DART_RELEVANCE_KEYWORD);
+ }
+
+ test_for_break_continue2() {
+ addTestSource('class A {foo() {for (int x in myList) {^}}}');
+ expect(computeFast(), isTrue);
+ assertSuggestKeywords(STMT_START_IN_LOOP_IN_CLASS,
+ relevance: DART_RELEVANCE_KEYWORD);
+ }
+
test_for_expression_in() {
addTestSource('main() {for (int x i^)}');
expect(computeFast(), isTrue);
@@ -561,15 +635,13 @@ class KeywordContributorTest extends AbstractCompletionTest {
test_for_expression_init() {
addTestSource('main() {for (int x = i^)}');
expect(computeFast(), isTrue);
- assertSuggestKeywords(
- [Keyword.FALSE, Keyword.NEW, Keyword.NULL, Keyword.TRUE]);
+ assertSuggestKeywords(EXPRESSION_START_NO_INSTANCE);
}
test_for_expression_init2() {
addTestSource('main() {for (int x = in^)}');
expect(computeFast(), isTrue);
- assertSuggestKeywords(
- [Keyword.FALSE, Keyword.NEW, Keyword.NULL, Keyword.TRUE]);
+ assertSuggestKeywords(EXPRESSION_START_NO_INSTANCE);
}
test_function_async() {
@@ -960,6 +1032,12 @@ class A {
expect(request.replacementLength, 3);
}
+ test_is_expression() {
+ addTestSource('main() {if (x is^)}');
+ expect(computeFast(), isTrue);
+ assertSuggestKeywords([Keyword.IS], relevance: DART_RELEVANCE_HIGH);
+ }
+
test_library() {
addTestSource('library foo;^');
expect(computeFast(), isTrue);
@@ -1291,6 +1369,20 @@ class A {
assertSuggestKeywords(STMT_START_IN_SWITCH_IN_CLASS);
}
+ test_while_break_continue() {
+ addTestSource('main() {while (true) {^}}');
+ expect(computeFast(), isTrue);
+ assertSuggestKeywords(STMT_START_IN_LOOP_OUTSIDE_CLASS,
+ relevance: DART_RELEVANCE_KEYWORD);
+ }
+
+ test_while_break_continue2() {
+ addTestSource('class A {foo() {while (true) {^}}}');
+ expect(computeFast(), isTrue);
+ assertSuggestKeywords(STMT_START_IN_LOOP_IN_CLASS,
+ relevance: DART_RELEVANCE_KEYWORD);
+ }
+
void _appendCompletions(
StringBuffer msg, Iterable<String> completions, Iterable<String> other) {
List<String> sorted = completions.toList();
« no previous file with comments | « pkg/analysis_server/test/services/completion/completion_test_util.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698