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

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

Issue 628293004: Remove references to Engine classes from protocol.dart (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 2 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 | Annotate | Revision Log
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.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';
11 import 'package:analysis_server/src/services/correction/util.dart'; 11 import 'package:analysis_server/src/services/correction/util.dart';
12 import 'package:analysis_server/src/services/refactoring/naming_conventions.dart '; 12 import 'package:analysis_server/src/services/refactoring/naming_conventions.dart ';
13 import 'package:analysis_server/src/services/refactoring/refactoring.dart'; 13 import 'package:analysis_server/src/services/refactoring/refactoring.dart';
14 import 'package:analysis_server/src/services/refactoring/rename.dart'; 14 import 'package:analysis_server/src/services/refactoring/rename.dart';
15 import 'package:analysis_server/src/services/search/hierarchy.dart'; 15 import 'package:analysis_server/src/services/search/hierarchy.dart';
16 import 'package:analysis_server/src/services/search/search_engine.dart'; 16 import 'package:analysis_server/src/services/search/search_engine.dart';
17 import 'package:analyzer/src/generated/ast.dart'; 17 import 'package:analyzer/src/generated/ast.dart';
18 import 'package:analyzer/src/generated/element.dart'; 18 import 'package:analyzer/src/generated/element.dart';
19 import 'package:analyzer/src/generated/source.dart'; 19 import 'package:analyzer/src/generated/source.dart';
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 visitSimpleIdentifier(SimpleIdentifier node) { 106 visitSimpleIdentifier(SimpleIdentifier node) {
107 Element nodeElement = node.bestElement; 107 Element nodeElement = node.bestElement;
108 String newName = refactoring.newName; 108 String newName = refactoring.newName;
109 if (nodeElement != null && nodeElement.name == newName) { 109 if (nodeElement != null && nodeElement.name == newName) {
110 // duplicate declaration 110 // duplicate declaration
111 if (node.inDeclarationContext() && 111 if (node.inDeclarationContext() &&
112 haveIntersectingRanges(refactoring.element, nodeElement)) { 112 haveIntersectingRanges(refactoring.element, nodeElement)) {
113 conflictingLocals.add(nodeElement); 113 conflictingLocals.add(nodeElement);
114 String nodeKind = nodeElement.kind.displayName; 114 String nodeKind = nodeElement.kind.displayName;
115 String message = "Duplicate ${nodeKind} '$newName'."; 115 String message = "Duplicate ${nodeKind} '$newName'.";
116 result.addError(message, new Location.fromElement(nodeElement)); 116 result.addError(message, newLocation_fromElement(nodeElement));
117 return; 117 return;
118 } 118 }
119 if (conflictingLocals.contains(nodeElement)) { 119 if (conflictingLocals.contains(nodeElement)) {
120 return; 120 return;
121 } 121 }
122 // shadowing referenced element 122 // shadowing referenced element
123 if (elementRange.contains(node.offset) && 123 if (elementRange.contains(node.offset) &&
124 !node.isQualified && 124 !node.isQualified &&
125 !_isNamedExpressionName(node)) { 125 !_isNamedExpressionName(node)) {
126 nodeElement = getSyntheticAccessorVariable(nodeElement); 126 nodeElement = getSyntheticAccessorVariable(nodeElement);
127 String nodeKind = nodeElement.kind.displayName; 127 String nodeKind = nodeElement.kind.displayName;
128 String nodeName = getElementQualifiedName(nodeElement); 128 String nodeName = getElementQualifiedName(nodeElement);
129 String nameElementSourceName = nodeElement.source.shortName; 129 String nameElementSourceName = nodeElement.source.shortName;
130 String refKind = refactoring.element.kind.displayName; 130 String refKind = refactoring.element.kind.displayName;
131 String message = 131 String message =
132 'Usage of $nodeKind "$nodeName" declared in ' 132 'Usage of $nodeKind "$nodeName" declared in '
133 '"$nameElementSourceName" will be shadowed by renamed $refKind.' ; 133 '"$nameElementSourceName" will be shadowed by renamed $refKind.' ;
134 result.addError(message, new Location.fromNode(node)); 134 result.addError(message, newLocation_fromNode(node));
135 } 135 }
136 } 136 }
137 } 137 }
138 138
139 static bool _isNamedExpressionName(SimpleIdentifier node) { 139 static bool _isNamedExpressionName(SimpleIdentifier node) {
140 return node.parent is Label && node.parent.parent is NamedExpression; 140 return node.parent is Label && node.parent.parent is NamedExpression;
141 } 141 }
142 } 142 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698