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

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

Issue 1534793002: Do not suggest loop variable when completing expression in ForEachStatement (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: merge Created 5 years 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_reference_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_reference_contributor_test.dart
diff --git a/pkg/analysis_server/test/services/completion/dart/local_reference_contributor_test.dart b/pkg/analysis_server/test/services/completion/dart/local_reference_contributor_test.dart
index f892bb19be24c74911f780e3712361a72307c9bd..8e72635c53cb398b1ceec61dcc88823293afe3cc 100644
--- a/pkg/analysis_server/test/services/completion/dart/local_reference_contributor_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/local_reference_contributor_test.dart
@@ -2324,6 +2324,39 @@ class A {a(^) { }}''');
assertNotSuggested('bar');
}
+ test_ForEachStatement() async {
+ // SimpleIdentifier ForEachStatement
+ addTestSource('main() {List<int> values; for (int index in ^)}');
+ await computeSuggestions();
+
+ expect(replacementOffset, completionOffset);
+ expect(replacementLength, 0);
+ assertSuggestLocalVariable('values', 'List');
+ assertNotSuggested('index');
+ }
+
+ test_ForEachStatement2() async {
+ // SimpleIdentifier ForEachStatement
+ addTestSource('main() {List<int> values; for (int index in i^)}');
+ await computeSuggestions();
+
+ expect(replacementOffset, completionOffset - 1);
+ expect(replacementLength, 1);
+ assertSuggestLocalVariable('values', 'List');
+ assertNotSuggested('index');
+ }
+
+ test_ForEachStatement3() async {
+ // SimpleIdentifier ParenthesizedExpression ForEachStatement
+ addTestSource('main() {List<int> values; for (int index in (i^))}');
+ await computeSuggestions();
+
+ expect(replacementOffset, completionOffset - 1);
+ expect(replacementLength, 1);
+ assertSuggestLocalVariable('values', 'List');
+ assertNotSuggested('index');
+ }
+
test_ForStatement_body() async {
// Block ForStatement
addTestSource('main(args) {for (int i; i < 10; ++i) {^}}');
« no previous file with comments | « pkg/analysis_server/lib/src/services/completion/dart/local_reference_contributor.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698