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

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

Issue 1271723002: fix completion replacement offset/length for invalid token in switch statement (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 c9666b16e0451b28de1e8c6c6587d0e93224580b..6db5b894e068a4aef769380914143ef75cdf41f3 100644
--- a/pkg/analysis_server/test/services/completion/keyword_contributor_test.dart
+++ b/pkg/analysis_server/test/services/completion/keyword_contributor_test.dart
@@ -1128,6 +1128,33 @@ class A {
relevance: DART_RELEVANCE_HIGH);
}
+ test_switch_start5() {
+ addTestSource('main() {switch(1) {c^ default:}}');
+ expect(computeFast(), isTrue);
+ assertSuggestKeywords([Keyword.CASE, Keyword.DEFAULT],
+ relevance: DART_RELEVANCE_HIGH);
+ expect(request.replacementOffset, 19);
+ expect(request.replacementLength, 1);
+ }
+
+ test_switch_start6() {
+ addTestSource('main() {switch(1) {c^}}');
+ expect(computeFast(), isTrue);
+ assertSuggestKeywords([Keyword.CASE, Keyword.DEFAULT],
+ relevance: DART_RELEVANCE_HIGH);
+ expect(request.replacementOffset, 19);
+ expect(request.replacementLength, 1);
+ }
+
+ test_switch_start7() {
+ addTestSource('main() {switch(1) { c^ }}');
+ expect(computeFast(), isTrue);
+ assertSuggestKeywords([Keyword.CASE, Keyword.DEFAULT],
+ relevance: DART_RELEVANCE_HIGH);
+ expect(request.replacementOffset, 20);
+ expect(request.replacementLength, 1);
+ }
+
test_switch_statement() {
addTestSource('main() {switch(1) {case 1:^}}');
expect(computeFast(), isTrue);

Powered by Google App Engine
This is Rietveld 408576698