| 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/protocol_server.dart' | 9 import 'package:analysis_server/src/protocol_server.dart' |
| 10 show newLocation_fromElement, newLocation_fromMatch; | 10 show newLocation_fromElement, newLocation_fromMatch; |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 */ | 191 */ |
| 192 void _validateWillBeShadowed() { | 192 void _validateWillBeShadowed() { |
| 193 for (SearchMatch reference in references) { | 193 for (SearchMatch reference in references) { |
| 194 Element refElement = reference.element; | 194 Element refElement = reference.element; |
| 195 ClassElement refClass = refElement.getAncestor((e) => e is ClassElement); | 195 ClassElement refClass = refElement.getAncestor((e) => e is ClassElement); |
| 196 if (refClass != null) { | 196 if (refClass != null) { |
| 197 visitChildren(refClass, (shadow) { | 197 visitChildren(refClass, (shadow) { |
| 198 if (hasDisplayName(shadow, name)) { | 198 if (hasDisplayName(shadow, name)) { |
| 199 String message = format( | 199 String message = format( |
| 200 "Reference to renamed {0} will be shadowed by {1} '{2}'.", | 200 "Reference to renamed {0} will be shadowed by {1} '{2}'.", |
| 201 getElementKindName(element), getElementKindName(shadow), | 201 getElementKindName(element), |
| 202 getElementKindName(shadow), |
| 202 getElementQualifiedName(shadow)); | 203 getElementQualifiedName(shadow)); |
| 203 result.addError(message, newLocation_fromElement(shadow)); | 204 result.addError(message, newLocation_fromElement(shadow)); |
| 204 } | 205 } |
| 205 }); | 206 }); |
| 206 } | 207 } |
| 207 } | 208 } |
| 208 } | 209 } |
| 209 | 210 |
| 210 /** | 211 /** |
| 211 * Validates if [element] renamed to [name] will conflict with another | 212 * Validates if [element] renamed to [name] will conflict with another |
| (...skipping 30 matching lines...) Expand all Loading... |
| 242 ClassElement refClass = | 243 ClassElement refClass = |
| 243 refElement.getAncestor((e) => e is ClassElement); | 244 refElement.getAncestor((e) => e is ClassElement); |
| 244 if (refClass == declaringClass) { | 245 if (refClass == declaringClass) { |
| 245 continue; | 246 continue; |
| 246 } | 247 } |
| 247 // ignore if not visible | 248 // ignore if not visible |
| 248 if (!_isVisibleAt(element, memberReference)) { | 249 if (!_isVisibleAt(element, memberReference)) { |
| 249 continue; | 250 continue; |
| 250 } | 251 } |
| 251 // OK, reference will be shadowed be the element being renamed | 252 // OK, reference will be shadowed be the element being renamed |
| 252 String message = format(isRename | 253 String message = format( |
| 254 isRename |
| 253 ? "Renamed {0} will shadow {1} '{2}'." | 255 ? "Renamed {0} will shadow {1} '{2}'." |
| 254 : "Created {0} will shadow {1} '{2}'.", elementKind.displayName, | 256 : "Created {0} will shadow {1} '{2}'.", |
| 255 getElementKindName(member), getElementQualifiedName(member)); | 257 elementKind.displayName, |
| 258 getElementKindName(member), |
| 259 getElementQualifiedName(member)); |
| 256 result.addError(message, newLocation_fromMatch(memberReference)); | 260 result.addError(message, newLocation_fromMatch(memberReference)); |
| 257 } | 261 } |
| 258 } | 262 } |
| 259 } | 263 } |
| 260 } | 264 } |
| OLD | NEW |