| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library services.src.correction.util; | 5 library services.src.correction.util; |
| 6 | 6 |
| 7 import 'dart:math'; | 7 import 'dart:math'; |
| 8 | 8 |
| 9 import 'package:analysis_server/src/protocol.dart' | 9 import 'package:analysis_server/src/protocol.dart' |
| 10 show SourceChange, SourceEdit; | 10 show SourceChange, SourceEdit; |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 * Returns [getExpressionPrecedence] for the parent of [node], | 254 * Returns [getExpressionPrecedence] for the parent of [node], |
| 255 * or `0` if the parent node is [ParenthesizedExpression]. | 255 * or `0` if the parent node is [ParenthesizedExpression]. |
| 256 * | 256 * |
| 257 * The reason is that `(expr)` is always executed after `expr`. | 257 * The reason is that `(expr)` is always executed after `expr`. |
| 258 */ | 258 */ |
| 259 int getExpressionParentPrecedence(AstNode node) { | 259 int getExpressionParentPrecedence(AstNode node) { |
| 260 AstNode parent = node.parent; | 260 AstNode parent = node.parent; |
| 261 if (parent is ParenthesizedExpression) { | 261 if (parent is ParenthesizedExpression) { |
| 262 return 0; | 262 return 0; |
| 263 } | 263 } |
| 264 if (parent is IndexExpression && parent.index == node) { |
| 265 return 0; |
| 266 } |
| 264 return getExpressionPrecedence(parent); | 267 return getExpressionPrecedence(parent); |
| 265 } | 268 } |
| 266 | 269 |
| 267 /** | 270 /** |
| 268 * Returns the precedence of [node] it is an [Expression], negative otherwise. | 271 * Returns the precedence of [node] it is an [Expression], negative otherwise. |
| 269 */ | 272 */ |
| 270 int getExpressionPrecedence(AstNode node) { | 273 int getExpressionPrecedence(AstNode node) { |
| 271 if (node is Expression) { | 274 if (node is Expression) { |
| 272 return node.precedence; | 275 return node.precedence; |
| 273 } | 276 } |
| (...skipping 1282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1556 | 1559 |
| 1557 @override | 1560 @override |
| 1558 Object visitExpression(Expression node) { | 1561 Object visitExpression(Expression node) { |
| 1559 if (node is BinaryExpression && node.operator.type == groupOperatorType) { | 1562 if (node is BinaryExpression && node.operator.type == groupOperatorType) { |
| 1560 return super.visitNode(node); | 1563 return super.visitNode(node); |
| 1561 } | 1564 } |
| 1562 operands.add(node); | 1565 operands.add(node); |
| 1563 return null; | 1566 return null; |
| 1564 } | 1567 } |
| 1565 } | 1568 } |
| OLD | NEW |