| 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.rename_local; | 5 library services.src.refactoring.rename_local; |
| 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/status.dart'; | 10 import 'package:analysis_server/src/services/correction/status.dart'; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 } | 64 } |
| 65 } else if (element is ParameterElement) { | 65 } else if (element is ParameterElement) { |
| 66 result.addStatus(validateParameterName(newName)); | 66 result.addStatus(validateParameterName(newName)); |
| 67 } else if (element is FunctionElement) { | 67 } else if (element is FunctionElement) { |
| 68 result.addStatus(validateFunctionName(newName)); | 68 result.addStatus(validateFunctionName(newName)); |
| 69 } | 69 } |
| 70 return result; | 70 return result; |
| 71 } | 71 } |
| 72 | 72 |
| 73 @override | 73 @override |
| 74 Future<SourceChange> createChange() { | 74 Future fillChange() { |
| 75 SourceChange change = new SourceChange(refactoringName); | 75 addDeclarationEdit(element); |
| 76 // update declaration | 76 return searchEngine.searchReferences(element).then(addReferenceEdits); |
| 77 addDeclarationEdit(change, element); | |
| 78 // update references | |
| 79 return searchEngine.searchReferences(element).then((refMatches) { | |
| 80 List<SourceReference> references = getSourceReferences(refMatches); | |
| 81 for (SourceReference reference in references) { | |
| 82 addReferenceEdit(change, reference); | |
| 83 } | |
| 84 return change; | |
| 85 }); | |
| 86 } | 77 } |
| 87 | 78 |
| 88 void _analyzePossibleConflicts_inLibrary(RefactoringStatus result, | 79 void _analyzePossibleConflicts_inLibrary(RefactoringStatus result, |
| 89 Source unitSource, Source librarySource) { | 80 Source unitSource, Source librarySource) { |
| 90 // prepare resolved unit | 81 // prepare resolved unit |
| 91 CompilationUnit unit = null; | 82 CompilationUnit unit = null; |
| 92 try { | 83 try { |
| 93 unit = context.resolveCompilationUnit2(unitSource, librarySource); | 84 unit = context.resolveCompilationUnit2(unitSource, librarySource); |
| 94 } catch (e) { | 85 } catch (e) { |
| 95 } | 86 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 '"$nameElementSourceName" will be shadowed by renamed $refKind.'
; | 133 '"$nameElementSourceName" will be shadowed by renamed $refKind.'
; |
| 143 result.addError(message, new Location.fromNode(node)); | 134 result.addError(message, new Location.fromNode(node)); |
| 144 } | 135 } |
| 145 } | 136 } |
| 146 } | 137 } |
| 147 | 138 |
| 148 static bool _isNamedExpressionName(SimpleIdentifier node) { | 139 static bool _isNamedExpressionName(SimpleIdentifier node) { |
| 149 return node.parent is Label && node.parent.parent is NamedExpression; | 140 return node.parent is Label && node.parent.parent is NamedExpression; |
| 150 } | 141 } |
| 151 } | 142 } |
| OLD | NEW |