| 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.refactoring.inline_method; | 5 library services.src.refactoring.inline_method; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/src/protocol_server.dart' hide Element; | 9 import 'package:analysis_server/src/protocol_server.dart' hide Element; |
| 10 import 'package:analysis_server/src/services/correction/source_range.dart'; | 10 import 'package:analysis_server/src/services/correction/source_range.dart'; |
| (...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 SourceEdit edit = newSourceEdit_range(range, source); | 516 SourceEdit edit = newSourceEdit_range(range, source); |
| 517 _addRefEdit(edit); | 517 _addRefEdit(edit); |
| 518 } | 518 } |
| 519 // replace invocation with return expression | 519 // replace invocation with return expression |
| 520 if (ref._methodExpressionPart != null) { | 520 if (ref._methodExpressionPart != null) { |
| 521 // prepare expression source for invocation | 521 // prepare expression source for invocation |
| 522 String source = _getMethodSourceForInvocation(status, | 522 String source = _getMethodSourceForInvocation(status, |
| 523 ref._methodExpressionPart, _refUtils, usage, target, arguments); | 523 ref._methodExpressionPart, _refUtils, usage, target, arguments); |
| 524 if (getExpressionPrecedence(ref._methodExpression) < | 524 if (getExpressionPrecedence(ref._methodExpression) < |
| 525 getExpressionParentPrecedence(usage)) { | 525 getExpressionParentPrecedence(usage)) { |
| 526 source = "(${source})"; | 526 source = "($source)"; |
| 527 } | 527 } |
| 528 // do replace | 528 // do replace |
| 529 SourceRange methodUsageRange = rangeNode(usage); | 529 SourceRange methodUsageRange = rangeNode(usage); |
| 530 SourceEdit edit = newSourceEdit_range(methodUsageRange, source); | 530 SourceEdit edit = newSourceEdit_range(methodUsageRange, source); |
| 531 _addRefEdit(edit); | 531 _addRefEdit(edit); |
| 532 } else { | 532 } else { |
| 533 SourceEdit edit = newSourceEdit_range(_refLineRange, ""); | 533 SourceEdit edit = newSourceEdit_range(_refLineRange, ""); |
| 534 _addRefEdit(edit); | 534 _addRefEdit(edit); |
| 535 } | 535 } |
| 536 return; | 536 return; |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 813 } | 813 } |
| 814 | 814 |
| 815 void _addVariable(SimpleIdentifier node) { | 815 void _addVariable(SimpleIdentifier node) { |
| 816 VariableElement variableElement = getLocalVariableElement(node); | 816 VariableElement variableElement = getLocalVariableElement(node); |
| 817 if (variableElement != null) { | 817 if (variableElement != null) { |
| 818 SourceRange nodeRange = rangeNode(node); | 818 SourceRange nodeRange = rangeNode(node); |
| 819 result.addVariable(variableElement, nodeRange); | 819 result.addVariable(variableElement, nodeRange); |
| 820 } | 820 } |
| 821 } | 821 } |
| 822 } | 822 } |
| OLD | NEW |