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

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

Issue 2973673002: Fix a bug in inline method refactoring (Closed)
Patch Set: Created 3 years, 5 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/refactoring/inline_method_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/util.dart
diff --git a/pkg/analysis_server/lib/src/services/correction/util.dart b/pkg/analysis_server/lib/src/services/correction/util.dart
index 3ff5405bb4147157fda838eec4b7b09393672f04..2e73715e74333551b069e6ef61ec3a653912cef7 100644
--- a/pkg/analysis_server/lib/src/services/correction/util.dart
+++ b/pkg/analysis_server/lib/src/services/correction/util.dart
@@ -317,9 +317,17 @@ int getExpressionParentPrecedence(AstNode node) {
AstNode parent = node.parent;
if (parent is ParenthesizedExpression) {
return 0;
- }
- if (parent is IndexExpression && parent.index == node) {
+ } else if (parent is IndexExpression && parent.index == node) {
return 0;
+ } else if (parent is AssignmentExpression &&
+ node == parent.rightHandSide &&
+ parent.parent is CascadeExpression) {
+ // This is a hack to allow nesting of cascade expressions within other
+ // cascade expressions. The problem is that if the precedence of two
+ // expressions are equal it sometimes means that we don't need parentheses
+ // (such as replacing the `b` in `a + b` with `c + d`) and sometimes do
+ // (such as replacing the `v` in `..f = v` with `a..b`).
+ return 3;
}
return getExpressionPrecedence(parent);
}
« no previous file with comments | « no previous file | pkg/analysis_server/test/services/refactoring/inline_method_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698