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

Unified Diff: pkg/analysis_server/lib/src/services/completion/dart/local_reference_contributor.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 | « no previous file | pkg/analysis_server/test/services/completion/dart/local_reference_contributor_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/src/services/completion/dart/local_reference_contributor.dart
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/local_reference_contributor.dart b/pkg/analysis_server/lib/src/services/completion/dart/local_reference_contributor.dart
index 9199091a64b36e570f34386420a8f23112a61bf3..9d14fda53cbe1282b455ed2792de43cae6de7561 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/local_reference_contributor.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/local_reference_contributor.dart
@@ -46,7 +46,20 @@ class LocalReferenceContributor extends DartCompletionContributor {
optype.includeVoidReturnSuggestions) {
_LocalVisitor visitor =
new _LocalVisitor(request, request.offset, optype);
- visitor.visit(request.target.containingNode);
+ AstNode node = request.target.containingNode;
+
+ // Do not suggest local vars within the current expression
+ while (node is Expression) {
+ node = node.parent;
+ }
+
+ // Do not suggest loop variable of a ForEachStatement
+ // when completing the expression of the ForEachStatement
+ if (node is ForEachStatement) {
+ node = node.parent;
+ }
+
+ visitor.visit(node);
return visitor.suggestions;
}
}
« no previous file with comments | « no previous file | pkg/analysis_server/test/services/completion/dart/local_reference_contributor_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698