| 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_unit_member; | 5 library services.src.refactoring.rename_unit_member; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/src/services/correction/change.dart'; | 9 import 'package:analysis_server/src/services/correction/change.dart'; |
| 10 import 'package:analysis_server/src/services/correction/status.dart'; | 10 import 'package:analysis_server/src/services/correction/status.dart'; |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 visitChildren(refClass, (shadow) { | 172 visitChildren(refClass, (shadow) { |
| 173 if (hasDisplayName(shadow, newName)) { | 173 if (hasDisplayName(shadow, newName)) { |
| 174 String message = | 174 String message = |
| 175 format( | 175 format( |
| 176 "Reference to renamed {0} will be shadowed by {1} '{2}'.", | 176 "Reference to renamed {0} will be shadowed by {1} '{2}'.", |
| 177 getElementKindName(element), | 177 getElementKindName(element), |
| 178 getElementKindName(shadow), | 178 getElementKindName(shadow), |
| 179 getElementQualifiedName(shadow)); | 179 getElementQualifiedName(shadow)); |
| 180 result.addError( | 180 result.addError( |
| 181 message, | 181 message, |
| 182 new RefactoringStatusContext.forElement(shadow)); | 182 createLocation_forElement(shadow)); |
| 183 } | 183 } |
| 184 }); | 184 }); |
| 185 } | 185 } |
| 186 } | 186 } |
| 187 }); | 187 }); |
| 188 } | 188 } |
| 189 | 189 |
| 190 /** | 190 /** |
| 191 * Validates if [element] renamed to [newName] will conflict with another | 191 * Validates if [element] renamed to [newName] will conflict with another |
| 192 * top-level [Element] in the same library. | 192 * top-level [Element] in the same library. |
| 193 */ | 193 */ |
| 194 void _validateWillConflict() { | 194 void _validateWillConflict() { |
| 195 LibraryElement library = element.getAncestor((e) => e is LibraryElement); | 195 LibraryElement library = element.getAncestor((e) => e is LibraryElement); |
| 196 visitLibraryTopLevelElements(library, (element) { | 196 visitLibraryTopLevelElements(library, (element) { |
| 197 if (hasDisplayName(element, newName)) { | 197 if (hasDisplayName(element, newName)) { |
| 198 String message = | 198 String message = |
| 199 format( | 199 format( |
| 200 "Library already declares {0} with name '{1}'.", | 200 "Library already declares {0} with name '{1}'.", |
| 201 getElementKindName(element), | 201 getElementKindName(element), |
| 202 newName); | 202 newName); |
| 203 result.addError( | 203 result.addError( |
| 204 message, | 204 message, |
| 205 new RefactoringStatusContext.forElement(element)); | 205 createLocation_forElement(element)); |
| 206 } | 206 } |
| 207 }); | 207 }); |
| 208 } | 208 } |
| 209 | 209 |
| 210 /** | 210 /** |
| 211 * Validates if renamed [element] will shadow any [Element] named [newName]. | 211 * Validates if renamed [element] will shadow any [Element] named [newName]. |
| 212 */ | 212 */ |
| 213 Future _validateWillShadow() { | 213 Future _validateWillShadow() { |
| 214 return searchEngine.searchMemberDeclarations(newName).then((declarations) { | 214 return searchEngine.searchMemberDeclarations(newName).then((declarations) { |
| 215 return Future.forEach(declarations, (SearchMatch declaration) { | 215 return Future.forEach(declarations, (SearchMatch declaration) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 236 String message = | 236 String message = |
| 237 format( | 237 format( |
| 238 forRename ? | 238 forRename ? |
| 239 "Renamed {0} will shadow {1} '{2}'." : | 239 "Renamed {0} will shadow {1} '{2}'." : |
| 240 "Created {0} will shadow {1} '{2}'.", | 240 "Created {0} will shadow {1} '{2}'.", |
| 241 getElementKindName(element), | 241 getElementKindName(element), |
| 242 getElementKindName(member), | 242 getElementKindName(member), |
| 243 getElementQualifiedName(member)); | 243 getElementQualifiedName(member)); |
| 244 result.addError( | 244 result.addError( |
| 245 message, | 245 message, |
| 246 new RefactoringStatusContext.forMatch(memberReference)); | 246 createLocation_forMatch(memberReference)); |
| 247 } | 247 } |
| 248 }); | 248 }); |
| 249 }); | 249 }); |
| 250 }); | 250 }); |
| 251 } | 251 } |
| 252 } | 252 } |
| OLD | NEW |