| 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.dart' hide Element; | 9 import 'package:analysis_server/src/protocol.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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 result.addError('All references must be inlined to remove the source.'); | 232 result.addError('All references must be inlined to remove the source.'); |
| 233 } | 233 } |
| 234 // prepare changes | 234 // prepare changes |
| 235 for (_ReferenceProcessor processor in _referenceProcessors) { | 235 for (_ReferenceProcessor processor in _referenceProcessors) { |
| 236 processor._process(result); | 236 processor._process(result); |
| 237 } | 237 } |
| 238 // delete method | 238 // delete method |
| 239 if (deleteSource && inlineAll) { | 239 if (deleteSource && inlineAll) { |
| 240 SourceRange methodRange = rangeNode(_methodNode); | 240 SourceRange methodRange = rangeNode(_methodNode); |
| 241 SourceRange linesRange = _methodUtils.getLinesRange(methodRange); | 241 SourceRange linesRange = _methodUtils.getLinesRange(methodRange); |
| 242 addElementSourceChange( | 242 change.addElementEdit( |
| 243 change, | |
| 244 _methodElement, | 243 _methodElement, |
| 245 new SourceEdit.range(linesRange, '')); | 244 new SourceEdit.range(linesRange, '')); |
| 246 } | 245 } |
| 247 // done | 246 // done |
| 248 return new Future.value(result); | 247 return new Future.value(result); |
| 249 } | 248 } |
| 250 | 249 |
| 251 @override | 250 @override |
| 252 Future<RefactoringStatus> checkInitialConditions() { | 251 Future<RefactoringStatus> checkInitialConditions() { |
| 253 RefactoringStatus result = new RefactoringStatus(); | 252 RefactoringStatus result = new RefactoringStatus(); |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 source = removeEnd(source, ';'); | 602 source = removeEnd(source, ';'); |
| 604 } | 603 } |
| 605 // do insert | 604 // do insert |
| 606 SourceRange range = rangeNode(_node); | 605 SourceRange range = rangeNode(_node); |
| 607 SourceEdit edit = new SourceEdit.range(range, source); | 606 SourceEdit edit = new SourceEdit.range(range, source); |
| 608 _addRefEdit(edit); | 607 _addRefEdit(edit); |
| 609 } | 608 } |
| 610 } | 609 } |
| 611 | 610 |
| 612 void _addRefEdit(SourceEdit edit) { | 611 void _addRefEdit(SourceEdit edit) { |
| 613 addElementSourceChange(ref.change, refElement, edit); | 612 ref.change.addElementEdit(refElement, edit); |
| 614 } | 613 } |
| 615 | 614 |
| 616 bool _shouldProcess() { | 615 bool _shouldProcess() { |
| 617 if (!ref.inlineAll) { | 616 if (!ref.inlineAll) { |
| 618 SourceRange parentRange = rangeNode(_node); | 617 SourceRange parentRange = rangeNode(_node); |
| 619 return parentRange.contains(ref.offset); | 618 return parentRange.contains(ref.offset); |
| 620 } | 619 } |
| 621 return true; | 620 return true; |
| 622 } | 621 } |
| 623 } | 622 } |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 803 } | 802 } |
| 804 | 803 |
| 805 void _addVariable(SimpleIdentifier node) { | 804 void _addVariable(SimpleIdentifier node) { |
| 806 VariableElement variableElement = getLocalVariableElement(node); | 805 VariableElement variableElement = getLocalVariableElement(node); |
| 807 if (variableElement != null) { | 806 if (variableElement != null) { |
| 808 SourceRange nodeRange = rangeNode(node); | 807 SourceRange nodeRange = rangeNode(node); |
| 809 result.addVariable(variableElement, nodeRange); | 808 result.addVariable(variableElement, nodeRange); |
| 810 } | 809 } |
| 811 } | 810 } |
| 812 } | 811 } |
| OLD | NEW |