| 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/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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 Object visitSimpleIdentifier(SimpleIdentifier node) { | 114 Object visitSimpleIdentifier(SimpleIdentifier node) { |
| 115 Element nodeElement = node.bestElement; | 115 Element nodeElement = node.bestElement; |
| 116 String newName = refactoring.newName; | 116 String newName = refactoring.newName; |
| 117 if (nodeElement != null && nodeElement.name == newName) { | 117 if (nodeElement != null && nodeElement.name == newName) { |
| 118 // duplicate declaration | 118 // duplicate declaration |
| 119 if (haveIntersectingRanges(refactoring.element, nodeElement)) { | 119 if (haveIntersectingRanges(refactoring.element, nodeElement)) { |
| 120 String nodeKind = nodeElement.kind.displayName; | 120 String nodeKind = nodeElement.kind.displayName; |
| 121 String message = "Duplicate ${nodeKind} '$newName'."; | 121 String message = "Duplicate ${nodeKind} '$newName'."; |
| 122 result.addError( | 122 result.addError( |
| 123 message, | 123 message, |
| 124 new RefactoringStatusContext.forElement(nodeElement)); | 124 createLocation_forElement(nodeElement)); |
| 125 return null; | 125 return null; |
| 126 } | 126 } |
| 127 // shadowing referenced element | 127 // shadowing referenced element |
| 128 if (elementRange.contains(node.offset) && !node.isQualified) { | 128 if (elementRange.contains(node.offset) && !node.isQualified) { |
| 129 nodeElement = getSyntheticAccessorVariable(nodeElement); | 129 nodeElement = getSyntheticAccessorVariable(nodeElement); |
| 130 String nodeKind = nodeElement.kind.displayName; | 130 String nodeKind = nodeElement.kind.displayName; |
| 131 String nodeName = getElementQualifiedName(nodeElement); | 131 String nodeName = getElementQualifiedName(nodeElement); |
| 132 String nameElementSourceName = nodeElement.source.shortName; | 132 String nameElementSourceName = nodeElement.source.shortName; |
| 133 String refKind = refactoring.element.kind.displayName; | 133 String refKind = refactoring.element.kind.displayName; |
| 134 String message = | 134 String message = |
| 135 'Usage of $nodeKind "$nodeName" declared in ' | 135 'Usage of $nodeKind "$nodeName" declared in ' |
| 136 '"$nameElementSourceName" will be shadowed by renamed $refKind.'
; | 136 '"$nameElementSourceName" will be shadowed by renamed $refKind.'
; |
| 137 result.addError(message, new RefactoringStatusContext.forNode(node)); | 137 result.addError(message, createLocation_forNode(node)); |
| 138 } | 138 } |
| 139 } | 139 } |
| 140 return null; | 140 return null; |
| 141 } | 141 } |
| 142 } | 142 } |
| OLD | NEW |