| 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_constructor; | 5 library services.src.refactoring.rename_constructor; |
| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 @override | 51 @override |
| 52 Future<SourceChange> createChange() { | 52 Future<SourceChange> createChange() { |
| 53 SourceChange change = new SourceChange(refactoringName); | 53 SourceChange change = new SourceChange(refactoringName); |
| 54 String replacement = newName.isEmpty ? '' : '.${newName}'; | 54 String replacement = newName.isEmpty ? '' : '.${newName}'; |
| 55 // update references | 55 // update references |
| 56 return searchEngine.searchReferences(element).then((refMatches) { | 56 return searchEngine.searchReferences(element).then((refMatches) { |
| 57 List<SourceReference> references = getSourceReferences(refMatches); | 57 List<SourceReference> references = getSourceReferences(refMatches); |
| 58 if (!element.isSynthetic) { | 58 if (!element.isSynthetic) { |
| 59 for (SourceReference reference in references) { | 59 for (SourceReference reference in references) { |
| 60 SourceEdit edit = createReferenceEdit(reference, replacement); | 60 SourceEdit edit = createReferenceEdit(reference, replacement); |
| 61 change.addEdit(reference.file, edit); | 61 addElementSourceChange(change, reference.element, edit); |
| 62 } | 62 } |
| 63 } | 63 } |
| 64 return change; | 64 return change; |
| 65 }); | 65 }); |
| 66 } | 66 } |
| 67 | 67 |
| 68 void _analyzePossibleConflicts(RefactoringStatus result) { | 68 void _analyzePossibleConflicts(RefactoringStatus result) { |
| 69 // check if there are members with "newName" in the same ClassElement | 69 // check if there are members with "newName" in the same ClassElement |
| 70 ClassElement parentClass = element.enclosingElement; | 70 ClassElement parentClass = element.enclosingElement; |
| 71 for (Element newNameMember in getChildren(parentClass, newName)) { | 71 for (Element newNameMember in getChildren(parentClass, newName)) { |
| 72 String message = | 72 String message = |
| 73 format( | 73 format( |
| 74 "Class '{0}' already declares {1} with name '{2}'.", | 74 "Class '{0}' already declares {1} with name '{2}'.", |
| 75 parentClass.displayName, | 75 parentClass.displayName, |
| 76 getElementKindName(newNameMember), | 76 getElementKindName(newNameMember), |
| 77 newName); | 77 newName); |
| 78 result.addError( | 78 result.addError( |
| 79 message, | 79 message, |
| 80 new Location.fromElement(newNameMember)); | 80 new Location.fromElement(newNameMember)); |
| 81 } | 81 } |
| 82 } | 82 } |
| 83 } | 83 } |
| OLD | NEW |