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

Side by Side Diff: pkg/analysis_server/lib/src/computer/computer_navigation.dart

Issue 717513003: Issue 21552. Fixes for navigation, hover and rename in instance creation expressions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month 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 computer.navigation; 5 library computer.navigation;
6 6
7 import 'package:analysis_server/src/protocol_server.dart' as protocol; 7 import 'package:analysis_server/src/protocol_server.dart' as protocol;
8 import 'package:analyzer/src/generated/ast.dart'; 8 import 'package:analyzer/src/generated/ast.dart';
9 import 'package:analyzer/src/generated/element.dart'; 9 import 'package:analyzer/src/generated/element.dart';
10 import 'package:analyzer/src/generated/scanner.dart'; 10 import 'package:analyzer/src/generated/scanner.dart';
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 @override 161 @override
162 visitInstanceCreationExpression(InstanceCreationExpression node) { 162 visitInstanceCreationExpression(InstanceCreationExpression node) {
163 Element element = node.staticElement; 163 Element element = node.staticElement;
164 ConstructorName constructorName = node.constructorName; 164 ConstructorName constructorName = node.constructorName;
165 if (element != null && constructorName != null) { 165 if (element != null && constructorName != null) {
166 // if a synthetic constructor, navigate to the class 166 // if a synthetic constructor, navigate to the class
167 if (element.isSynthetic) { 167 if (element.isSynthetic) {
168 ClassElement classElement = element.enclosingElement; 168 ClassElement classElement = element.enclosingElement;
169 element = classElement; 169 element = classElement;
170 } 170 }
171 // "new ", excluding last character 171 // add regions
172 computer._addRegion_nodeStart_nodeStart( 172 TypeName typeName = constructorName.type;
173 node, 173 TypeArgumentList typeArguments = typeName.typeArguments;
174 constructorName.type, 174 if (typeArguments == null) {
175 element, 175 computer._addRegion_nodeStart_nodeEnd(node, constructorName, element);
176 excludeLastChar: true); 176 } else {
177 // "ClassName<TypeA, TypeB>" 177 computer._addRegion_nodeStart_nodeEnd(node, typeName.name, element);
178 _safelyVisit(constructorName.type); 178 // <TypeA, TypeB>
179 // optional ".name" 179 typeArguments.accept(this);
180 if (constructorName.period != null) { 180 // optional ".name"
181 computer._addRegion_tokenStart_nodeEnd( 181 if (constructorName.period != null) {
182 constructorName.period, 182 computer._addRegion_tokenStart_nodeEnd(
183 constructorName, 183 constructorName.period,
184 element); 184 constructorName,
185 element);
186 }
185 } 187 }
186 } 188 }
187 _safelyVisit(node.argumentList); 189 _safelyVisit(node.argumentList);
188 } 190 }
189 191
190 @override 192 @override
191 visitPartDirective(PartDirective node) { 193 visitPartDirective(PartDirective node) {
192 computer._addRegion_tokenStart_nodeEnd( 194 computer._addRegion_tokenStart_nodeEnd(
193 node.keyword, 195 node.keyword,
194 node.uri, 196 node.uri,
(...skipping 30 matching lines...) Expand all
225 Element element = node.bestElement; 227 Element element = node.bestElement;
226 computer._addRegionForNode(node, element); 228 computer._addRegionForNode(node, element);
227 } 229 }
228 230
229 void _safelyVisit(AstNode node) { 231 void _safelyVisit(AstNode node) {
230 if (node != null) { 232 if (node != null) {
231 node.accept(this); 233 node.accept(this);
232 } 234 }
233 } 235 }
234 } 236 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698