Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(31)

Side by Side Diff: pkg/analysis_server/lib/src/services/refactoring/rename_local.dart

Issue 1776743006: Fix NPE in rename local (issue 25933) (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/protocol_server.dart' hide Element; 9 import 'package:analysis_server/src/protocol_server.dart' hide Element;
10 import 'package:analysis_server/src/services/correction/status.dart'; 10 import 'package:analysis_server/src/services/correction/status.dart';
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 conflictingLocals.add(nodeElement); 143 conflictingLocals.add(nodeElement);
144 String nodeKind = nodeElement.kind.displayName; 144 String nodeKind = nodeElement.kind.displayName;
145 String message = "Duplicate $nodeKind '$newName'."; 145 String message = "Duplicate $nodeKind '$newName'.";
146 result.addError(message, newLocation_fromElement(nodeElement)); 146 result.addError(message, newLocation_fromElement(nodeElement));
147 return; 147 return;
148 } 148 }
149 if (conflictingLocals.contains(nodeElement)) { 149 if (conflictingLocals.contains(nodeElement)) {
150 return; 150 return;
151 } 151 }
152 // shadowing referenced element 152 // shadowing referenced element
153 if (elementRange.contains(node.offset) && 153 if (elementRange != null &&
154 elementRange.contains(node.offset) &&
154 !node.isQualified && 155 !node.isQualified &&
155 !_isNamedExpressionName(node)) { 156 !_isNamedExpressionName(node)) {
156 nodeElement = getSyntheticAccessorVariable(nodeElement); 157 nodeElement = getSyntheticAccessorVariable(nodeElement);
157 String nodeKind = nodeElement.kind.displayName; 158 String nodeKind = nodeElement.kind.displayName;
158 String nodeName = getElementQualifiedName(nodeElement); 159 String nodeName = getElementQualifiedName(nodeElement);
159 String nameElementSourceName = nodeElement.source.shortName; 160 String nameElementSourceName = nodeElement.source.shortName;
160 String refKind = refactoring.element.kind.displayName; 161 String refKind = refactoring.element.kind.displayName;
161 String message = 'Usage of $nodeKind "$nodeName" declared in ' 162 String message = 'Usage of $nodeKind "$nodeName" declared in '
162 '"$nameElementSourceName" will be shadowed by renamed $refKind.'; 163 '"$nameElementSourceName" will be shadowed by renamed $refKind.';
163 result.addError(message, newLocation_fromNode(node)); 164 result.addError(message, newLocation_fromNode(node));
164 } 165 }
165 } 166 }
166 } 167 }
167 168
168 static bool _isNamedExpressionName(SimpleIdentifier node) { 169 static bool _isNamedExpressionName(SimpleIdentifier node) {
169 return node.parent is Label && node.parent.parent is NamedExpression; 170 return node.parent is Label && node.parent.parent is NamedExpression;
170 } 171 }
171 } 172 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698