OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 domains.analysis.navigation_dart; | 5 library domains.analysis.navigation_dart; |
6 | 6 |
7 import 'package:analysis_server/plugin/analysis/navigation/navigation_core.dart'
; | 7 import 'package:analysis_server/plugin/analysis/navigation/navigation_core.dart'
; |
8 import 'package:analysis_server/src/protocol_server.dart' as protocol; | 8 import 'package:analysis_server/src/protocol_server.dart' as protocol; |
9 import 'package:analyzer/src/generated/ast.dart'; | 9 import 'package:analyzer/src/generated/ast.dart'; |
10 import 'package:analyzer/src/generated/element.dart'; | 10 import 'package:analyzer/src/generated/element.dart'; |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 computer._addRegionForToken(node.operator, node.bestElement); | 236 computer._addRegionForToken(node.operator, node.bestElement); |
237 } | 237 } |
238 | 238 |
239 @override | 239 @override |
240 visitPrefixExpression(PrefixExpression node) { | 240 visitPrefixExpression(PrefixExpression node) { |
241 computer._addRegionForToken(node.operator, node.bestElement); | 241 computer._addRegionForToken(node.operator, node.bestElement); |
242 super.visitPrefixExpression(node); | 242 super.visitPrefixExpression(node); |
243 } | 243 } |
244 | 244 |
245 @override | 245 @override |
| 246 visitRedirectingConstructorInvocation(RedirectingConstructorInvocation node) { |
| 247 Element element = node.staticElement; |
| 248 if (element != null && element.isSynthetic) { |
| 249 element = element.enclosingElement; |
| 250 } |
| 251 // add region |
| 252 computer._addRegionForToken(node.thisKeyword, element); |
| 253 computer._addRegionForNode(node.constructorName, element); |
| 254 // process arguments |
| 255 _safelyVisit(node.argumentList); |
| 256 } |
| 257 |
| 258 @override |
246 visitSimpleIdentifier(SimpleIdentifier node) { | 259 visitSimpleIdentifier(SimpleIdentifier node) { |
247 if (node.parent is ConstructorDeclaration) { | 260 if (node.parent is ConstructorDeclaration) { |
248 return; | 261 return; |
249 } | 262 } |
250 Element element = node.bestElement; | 263 Element element = node.bestElement; |
251 computer._addRegionForNode(node, element); | 264 computer._addRegionForNode(node, element); |
252 } | 265 } |
253 | 266 |
254 @override | 267 @override |
255 visitSuperConstructorInvocation(SuperConstructorInvocation node) { | 268 visitSuperConstructorInvocation(SuperConstructorInvocation node) { |
256 Element element = node.staticElement; | 269 Element element = node.staticElement; |
257 if (element != null && element.isSynthetic) { | 270 if (element != null && element.isSynthetic) { |
258 element = element.enclosingElement; | 271 element = element.enclosingElement; |
259 } | 272 } |
260 // add region | 273 // add region |
261 SimpleIdentifier name = node.constructorName; | 274 computer._addRegionForToken(node.superKeyword, element); |
262 if (name != null) { | 275 computer._addRegionForNode(node.constructorName, element); |
263 computer._addRegion_nodeStart_nodeEnd(node, name, element); | |
264 } else { | |
265 computer._addRegionForToken(node.superKeyword, element); | |
266 } | |
267 // process arguments | 276 // process arguments |
268 _safelyVisit(node.argumentList); | 277 _safelyVisit(node.argumentList); |
269 } | 278 } |
270 | 279 |
271 void _addConstructorName(AstNode parent, ConstructorName node) { | 280 void _addConstructorName(AstNode parent, ConstructorName node) { |
272 Element element = node.staticElement; | 281 Element element = node.staticElement; |
273 if (element == null) { | 282 if (element == null) { |
274 return; | 283 return; |
275 } | 284 } |
276 // if a synthetic constructor, navigate to the class | 285 // if a synthetic constructor, navigate to the class |
(...skipping 26 matching lines...) Expand all Loading... |
303 } | 312 } |
304 } | 313 } |
305 } | 314 } |
306 | 315 |
307 void _safelyVisit(AstNode node) { | 316 void _safelyVisit(AstNode node) { |
308 if (node != null) { | 317 if (node != null) { |
309 node.accept(this); | 318 node.accept(this); |
310 } | 319 } |
311 } | 320 } |
312 } | 321 } |
OLD | NEW |