| 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 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 doSourceChange_addElementEdit( | 268 doSourceChange_addElementEdit( |
| 269 change, | 269 change, |
| 270 _methodElement, | 270 _methodElement, |
| 271 newSourceEdit_range(linesRange, '')); | 271 newSourceEdit_range(linesRange, '')); |
| 272 } | 272 } |
| 273 // done | 273 // done |
| 274 return new Future.value(result); | 274 return new Future.value(result); |
| 275 } | 275 } |
| 276 | 276 |
| 277 @override | 277 @override |
| 278 Future<RefactoringStatus> checkInitialConditions() { | 278 Future<RefactoringStatus> checkInitialConditions() async { |
| 279 RefactoringStatus result = new RefactoringStatus(); | 279 RefactoringStatus result = new RefactoringStatus(); |
| 280 // prepare method information | 280 // prepare method information |
| 281 result.addStatus(_prepareMethod()); | 281 result.addStatus(_prepareMethod()); |
| 282 if (result.hasFatalError) { | 282 if (result.hasFatalError) { |
| 283 return new Future.value(result); | 283 return new Future.value(result); |
| 284 } | 284 } |
| 285 // maybe operator | 285 // maybe operator |
| 286 if (_methodElement.isOperator) { | 286 if (_methodElement.isOperator) { |
| 287 result = new RefactoringStatus.fatal('Cannot inline operator.'); | 287 result = new RefactoringStatus.fatal('Cannot inline operator.'); |
| 288 return new Future.value(result); | 288 return new Future.value(result); |
| 289 } | 289 } |
| 290 // analyze method body | 290 // analyze method body |
| 291 result.addStatus(_prepareMethodParts()); | 291 result.addStatus(_prepareMethodParts()); |
| 292 // process references | 292 // process references |
| 293 return searchEngine.searchReferences(_methodElement).then((references) { | 293 List<SearchMatch> references = |
| 294 _referenceProcessors.clear(); | 294 await searchEngine.searchReferences(_methodElement); |
| 295 for (SearchMatch reference in references) { | 295 _referenceProcessors.clear(); |
| 296 _ReferenceProcessor processor = | 296 for (SearchMatch reference in references) { |
| 297 new _ReferenceProcessor(this, reference); | 297 _ReferenceProcessor processor = new _ReferenceProcessor(this, reference); |
| 298 _referenceProcessors.add(processor); | 298 _referenceProcessors.add(processor); |
| 299 } | 299 } |
| 300 }).then((_) { | 300 return result; |
| 301 return result; | |
| 302 }); | |
| 303 } | 301 } |
| 304 | 302 |
| 305 @override | 303 @override |
| 306 Future<SourceChange> createChange() { | 304 Future<SourceChange> createChange() { |
| 307 return new Future.value(change); | 305 return new Future.value(change); |
| 308 } | 306 } |
| 309 | 307 |
| 310 @override | 308 @override |
| 311 bool requiresPreview() => false; | 309 bool requiresPreview() => false; |
| 312 | 310 |
| (...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 840 } | 838 } |
| 841 | 839 |
| 842 void _addVariable(SimpleIdentifier node) { | 840 void _addVariable(SimpleIdentifier node) { |
| 843 VariableElement variableElement = getLocalVariableElement(node); | 841 VariableElement variableElement = getLocalVariableElement(node); |
| 844 if (variableElement != null) { | 842 if (variableElement != null) { |
| 845 SourceRange nodeRange = rangeNode(node); | 843 SourceRange nodeRange = rangeNode(node); |
| 846 result.addVariable(variableElement, nodeRange); | 844 result.addVariable(variableElement, nodeRange); |
| 847 } | 845 } |
| 848 } | 846 } |
| 849 } | 847 } |
| OLD | NEW |