| 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/plugin/protocol/protocol.dart' | 9 import 'package:analysis_server/plugin/protocol/protocol.dart' |
| 10 show SourceChange, SourceEdit; | 10 show SourceChange, SourceEdit; |
| (...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 } | 389 } |
| 390 return parents[0][i - 1]; | 390 return parents[0][i - 1]; |
| 391 } | 391 } |
| 392 | 392 |
| 393 /** | 393 /** |
| 394 * Returns the [Expression] qualifier if given node is the name part of a | 394 * Returns the [Expression] qualifier if given node is the name part of a |
| 395 * [PropertyAccess] or a [PrefixedIdentifier]. Maybe `null`. | 395 * [PropertyAccess] or a [PrefixedIdentifier]. Maybe `null`. |
| 396 */ | 396 */ |
| 397 Expression getNodeQualifier(SimpleIdentifier node) { | 397 Expression getNodeQualifier(SimpleIdentifier node) { |
| 398 AstNode parent = node.parent; | 398 AstNode parent = node.parent; |
| 399 if (parent is PropertyAccess) { | 399 if (parent is MethodInvocation && identical(parent.methodName, node)) { |
| 400 PropertyAccess propertyAccess = parent; | 400 return parent.target; |
| 401 if (identical(propertyAccess.propertyName, node)) { | |
| 402 return propertyAccess.target; | |
| 403 } | |
| 404 } | 401 } |
| 405 if (parent is PrefixedIdentifier) { | 402 if (parent is PropertyAccess && identical(parent.propertyName, node)) { |
| 406 PrefixedIdentifier prefixed = parent; | 403 return parent.target; |
| 407 if (identical(prefixed.identifier, node)) { | 404 } |
| 408 return prefixed.prefix; | 405 if (parent is PrefixedIdentifier && identical(parent.identifier, node)) { |
| 409 } | 406 return parent.prefix; |
| 410 } | 407 } |
| 411 return null; | 408 return null; |
| 412 } | 409 } |
| 413 | 410 |
| 414 /** | 411 /** |
| 415 * Returns the [ParameterElement] if the given [SimpleIdentifier] is a reference | 412 * Returns the [ParameterElement] if the given [SimpleIdentifier] is a reference |
| 416 * to a parameter, or `null` in the other case. | 413 * to a parameter, or `null` in the other case. |
| 417 */ | 414 */ |
| 418 ParameterElement getParameterElement(SimpleIdentifier node) { | 415 ParameterElement getParameterElement(SimpleIdentifier node) { |
| 419 Element element = node.staticElement; | 416 Element element = node.staticElement; |
| (...skipping 1058 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1478 _InvertedCondition expr, int newOperatorPrecedence) { | 1475 _InvertedCondition expr, int newOperatorPrecedence) { |
| 1479 if (expr._precedence < newOperatorPrecedence) { | 1476 if (expr._precedence < newOperatorPrecedence) { |
| 1480 return "(${expr._source})"; | 1477 return "(${expr._source})"; |
| 1481 } | 1478 } |
| 1482 return expr._source; | 1479 return expr._source; |
| 1483 } | 1480 } |
| 1484 | 1481 |
| 1485 static _InvertedCondition _simple(String source) => | 1482 static _InvertedCondition _simple(String source) => |
| 1486 new _InvertedCondition(2147483647, source); | 1483 new _InvertedCondition(2147483647, source); |
| 1487 } | 1484 } |
| OLD | NEW |