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

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

Issue 694383003: Issue 21498. Fix for navigation from instance creation with type arguments. (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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 visitIndexExpression(IndexExpression node) { 156 visitIndexExpression(IndexExpression node) {
157 super.visitIndexExpression(node); 157 super.visitIndexExpression(node);
158 computer._addRegionForToken(node.rightBracket, node.bestElement); 158 computer._addRegionForToken(node.rightBracket, node.bestElement);
159 } 159 }
160 160
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 ClassElement classElement = element.enclosingElement; 166 // if a synthetic constructor, navigate to the class
167 if (element.isSynthetic) { 167 if (element.isSynthetic) {
168 ClassElement classElement = element.enclosingElement;
168 element = classElement; 169 element = classElement;
169 computer._addRegion_nodeStart_nodeStart( 170 }
170 node, 171 // "new ", excluding last character
171 node.argumentList, 172 computer._addRegion_nodeStart_nodeStart(
173 node,
174 constructorName.type,
175 element,
176 excludeLastChar: true);
177 // "ClassName<TypeA, TypeB>"
178 _safelyVisit(constructorName.type);
179 // optional ".name"
180 if (constructorName.period != null) {
181 computer._addRegion_tokenStart_nodeEnd(
182 constructorName.period,
183 constructorName,
172 element); 184 element);
173 } else {
174 // "new ", excluding last character
175 computer._addRegion_nodeStart_nodeStart(
176 node,
177 constructorName.type,
178 element,
179 excludeLastChar: true);
180 // "ClassName"
181 computer._addRegionForNode(constructorName.type, classElement);
182 // optional ".name"
183 if (constructorName.period != null) {
184 computer._addRegion_tokenStart_nodeEnd(
185 constructorName.period,
186 constructorName,
187 element);
188 }
189 } 185 }
190 } 186 }
191 _safelyVisit(node.argumentList); 187 _safelyVisit(node.argumentList);
192 } 188 }
193 189
194 @override 190 @override
195 visitPartDirective(PartDirective node) { 191 visitPartDirective(PartDirective node) {
196 computer._addRegion_tokenStart_nodeEnd( 192 computer._addRegion_tokenStart_nodeEnd(
197 node.keyword, 193 node.keyword,
198 node.uri, 194 node.uri,
(...skipping 30 matching lines...) Expand all
229 Element element = node.bestElement; 225 Element element = node.bestElement;
230 computer._addRegionForNode(node, element); 226 computer._addRegionForNode(node, element);
231 } 227 }
232 228
233 void _safelyVisit(AstNode node) { 229 void _safelyVisit(AstNode node) {
234 if (node != null) { 230 if (node != null) {
235 node.accept(this); 231 node.accept(this);
236 } 232 }
237 } 233 }
238 } 234 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698