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

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: 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
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..4a50fb0a04b2526d809581e48cf9265583998d11 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,26 @@ class KeywordContributorTest extends AbstractCompletionTest {
static const List<Keyword> STMT_START_IN_CLASS = const [
Keyword.ASSERT,
+ 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.CONTINUE,
Keyword.DO,
Keyword.FINAL,
@@ -99,8 +119,8 @@ class KeywordContributorTest extends AbstractCompletionTest {
static const List<Keyword> STMT_START_IN_SWITCH_IN_CLASS = const [
Keyword.ASSERT,
+ Keyword.BREAK,
Keyword.CASE,
- Keyword.CONTINUE,
Keyword.DEFAULT,
Keyword.DO,
Keyword.FINAL,
@@ -121,8 +141,8 @@ class KeywordContributorTest extends AbstractCompletionTest {
static const List<Keyword> STMT_START_IN_SWITCH_OUTSIDE_CLASS = const [
Keyword.ASSERT,
+ Keyword.BREAK,
Keyword.CASE,
- Keyword.CONTINUE,
Keyword.DEFAULT,
Keyword.DO,
Keyword.FINAL,
@@ -141,6 +161,24 @@ class KeywordContributorTest extends AbstractCompletionTest {
static const List<Keyword> STMT_START_OUTSIDE_CLASS = const [
Keyword.ASSERT,
+ 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.CONTINUE,
Keyword.DO,
Keyword.FINAL,
@@ -539,6 +577,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 +598,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);
@@ -960,6 +1026,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 +1363,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();

Powered by Google App Engine
This is Rietveld 408576698