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

Unified Diff: pkg/analysis_server/lib/src/services/correction/assist_internal.dart

Issue 1415253002: Fix for 'Assign to Local Variable' in closures. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 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 | « no previous file | pkg/analysis_server/test/services/correction/assist_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/correction/assist_internal.dart
diff --git a/pkg/analysis_server/lib/src/services/correction/assist_internal.dart b/pkg/analysis_server/lib/src/services/correction/assist_internal.dart
index e287c45c32c5b2bbf28b7d12af3dbe0315d2bb4e..d83ca2f2073bcd7094fca5db80be04f236344255 100644
--- a/pkg/analysis_server/lib/src/services/correction/assist_internal.dart
+++ b/pkg/analysis_server/lib/src/services/correction/assist_internal.dart
@@ -331,30 +331,27 @@ class AssistProcessor {
void _addProposal_assignToLocalVariable() {
// prepare enclosing ExpressionStatement
- Statement statement = node.getAncestor((node) => node is Statement);
- if (statement is! ExpressionStatement) {
+ ExpressionStatement expressionStatement;
+ for (AstNode node = this.node; node != null; node = node.parent) {
+ if (node is ExpressionStatement) {
+ expressionStatement = node;
+ break;
+ }
+ if (node is ArgumentList ||
+ node is AssignmentExpression ||
+ node is Statement ||
+ node is ThrowExpression) {
+ _coverageMarker();
+ return;
+ }
+ }
+ if (expressionStatement == null) {
_coverageMarker();
return;
}
- ExpressionStatement expressionStatement = statement as ExpressionStatement;
// prepare expression
Expression expression = expressionStatement.expression;
int offset = expression.offset;
- // ignore if in arguments
- if (node.getAncestor((node) => node is ArgumentList) != null) {
- _coverageMarker();
- return;
- }
- // ignore if already assignment
- if (expression is AssignmentExpression) {
- _coverageMarker();
- return;
- }
- // ignore "throw"
- if (expression is ThrowExpression) {
- _coverageMarker();
- return;
- }
// prepare expression type
DartType type = expression.bestType;
if (type.isVoid) {
« no previous file with comments | « no previous file | pkg/analysis_server/test/services/correction/assist_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698