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_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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 | 52 |
53 @override | 53 @override |
54 Future fillChange() async { | 54 Future fillChange() async { |
55 if (!element.isSynthetic) { | 55 if (!element.isSynthetic) { |
56 // prepare references | 56 // prepare references |
57 List<SearchMatch> matches = await searchEngine.searchReferences(element); | 57 List<SearchMatch> matches = await searchEngine.searchReferences(element); |
58 List<SourceReference> references = getSourceReferences(matches); | 58 List<SourceReference> references = getSourceReferences(matches); |
59 // append declaration | 59 // append declaration |
60 references.add(_createDeclarationReference()); | 60 references.add(_createDeclarationReference()); |
61 // update references | 61 // update references |
62 String replacement = newName.isEmpty ? '' : '.${newName}'; | 62 String replacement = newName.isEmpty ? '' : '.$newName'; |
63 for (SourceReference reference in references) { | 63 for (SourceReference reference in references) { |
64 reference.addEdit(change, replacement); | 64 reference.addEdit(change, replacement); |
65 } | 65 } |
66 } | 66 } |
67 } | 67 } |
68 | 68 |
69 void _analyzePossibleConflicts(RefactoringStatus result) { | 69 void _analyzePossibleConflicts(RefactoringStatus result) { |
70 // check if there are members with "newName" in the same ClassElement | 70 // check if there are members with "newName" in the same ClassElement |
71 ClassElement parentClass = element.enclosingElement; | 71 ClassElement parentClass = element.enclosingElement; |
72 for (Element newNameMember in getChildren(parentClass, newName)) { | 72 for (Element newNameMember in getChildren(parentClass, newName)) { |
(...skipping 10 matching lines...) Expand all Loading... |
83 SourceRange sourceRange; | 83 SourceRange sourceRange; |
84 if (element.periodOffset != null) { | 84 if (element.periodOffset != null) { |
85 sourceRange = rangeStartEnd(element.periodOffset, element.nameEnd); | 85 sourceRange = rangeStartEnd(element.periodOffset, element.nameEnd); |
86 } else { | 86 } else { |
87 sourceRange = rangeStartLength(element.nameEnd, 0); | 87 sourceRange = rangeStartLength(element.nameEnd, 0); |
88 } | 88 } |
89 String file = element.source.fullName; | 89 String file = element.source.fullName; |
90 return new SourceReference(file, sourceRange, element, true, true); | 90 return new SourceReference(file, sourceRange, element, true, true); |
91 } | 91 } |
92 } | 92 } |
OLD | NEW |