| 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 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 if (deleteSource && !inlineAll) { | 256 if (deleteSource && !inlineAll) { |
| 257 result.addError('All references must be inlined to remove the source.'); | 257 result.addError('All references must be inlined to remove the source.'); |
| 258 } | 258 } |
| 259 // prepare changes | 259 // prepare changes |
| 260 for (_ReferenceProcessor processor in _referenceProcessors) { | 260 for (_ReferenceProcessor processor in _referenceProcessors) { |
| 261 processor._process(result); | 261 processor._process(result); |
| 262 } | 262 } |
| 263 // delete method | 263 // delete method |
| 264 if (deleteSource && inlineAll) { | 264 if (deleteSource && inlineAll) { |
| 265 SourceRange methodRange = rangeNode(_methodNode); | 265 SourceRange methodRange = rangeNode(_methodNode); |
| 266 SourceRange linesRange = _methodUtils.getLinesRange(methodRange); | 266 SourceRange linesRange = |
| 267 _methodUtils.getLinesRange(methodRange, skipLeadingEmptyLines: true); |
| 267 doSourceChange_addElementEdit( | 268 doSourceChange_addElementEdit( |
| 268 change, _methodElement, newSourceEdit_range(linesRange, '')); | 269 change, _methodElement, newSourceEdit_range(linesRange, '')); |
| 269 } | 270 } |
| 270 // done | 271 // done |
| 271 return new Future.value(result); | 272 return new Future.value(result); |
| 272 } | 273 } |
| 273 | 274 |
| 274 @override | 275 @override |
| 275 Future<RefactoringStatus> checkInitialConditions() async { | 276 Future<RefactoringStatus> checkInitialConditions() async { |
| 276 RefactoringStatus result = new RefactoringStatus(); | 277 RefactoringStatus result = new RefactoringStatus(); |
| (...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 822 } | 823 } |
| 823 | 824 |
| 824 void _addVariable(SimpleIdentifier node) { | 825 void _addVariable(SimpleIdentifier node) { |
| 825 VariableElement variableElement = getLocalVariableElement(node); | 826 VariableElement variableElement = getLocalVariableElement(node); |
| 826 if (variableElement != null) { | 827 if (variableElement != null) { |
| 827 SourceRange nodeRange = rangeNode(node); | 828 SourceRange nodeRange = rangeNode(node); |
| 828 result.addVariable(variableElement, nodeRange); | 829 result.addVariable(variableElement, nodeRange); |
| 829 } | 830 } |
| 830 } | 831 } |
| 831 } | 832 } |
| OLD | NEW |