Index: pkg/analysis_server/lib/src/computer/computer_navigation.dart |
diff --git a/pkg/analysis_server/lib/src/computer/computer_navigation.dart b/pkg/analysis_server/lib/src/computer/computer_navigation.dart |
index c3081ba43d7a7208fd3fd6aa2317812a1c2728ca..fa0b12ed2ed8f8b80cc3b2f6f9467e614d9b2442 100644 |
--- a/pkg/analysis_server/lib/src/computer/computer_navigation.dart |
+++ b/pkg/analysis_server/lib/src/computer/computer_navigation.dart |
@@ -150,6 +150,18 @@ class _DartUnitNavigationComputerVisitor extends RecursiveAstVisitor { |
} |
@override |
+ visitConstructorName(ConstructorName node) { |
+ AstNode parent = node.parent; |
+ if (parent is InstanceCreationExpression && |
+ parent.constructorName == node) { |
+ _addConstructorName(parent, node); |
+ } else if (parent is ConstructorDeclaration && |
+ parent.redirectedConstructor == node) { |
+ _addConstructorName(node, node); |
+ } |
+ } |
+ |
+ @override |
visitExportDirective(ExportDirective node) { |
ExportElement exportElement = node.element; |
if (exportElement != null) { |
@@ -176,37 +188,6 @@ class _DartUnitNavigationComputerVisitor extends RecursiveAstVisitor { |
} |
@override |
- visitInstanceCreationExpression(InstanceCreationExpression node) { |
- Element element = node.staticElement; |
- ConstructorName constructorName = node.constructorName; |
- if (element != null && constructorName != null) { |
- // if a synthetic constructor, navigate to the class |
- if (element.isSynthetic) { |
- ClassElement classElement = element.enclosingElement; |
- element = classElement; |
- } |
- // add regions |
- TypeName typeName = constructorName.type; |
- TypeArgumentList typeArguments = typeName.typeArguments; |
- if (typeArguments == null) { |
- computer._addRegion_nodeStart_nodeEnd(node, constructorName, element); |
- } else { |
- computer._addRegion_nodeStart_nodeEnd(node, typeName.name, element); |
- // <TypeA, TypeB> |
- typeArguments.accept(this); |
- // optional ".name" |
- if (constructorName.period != null) { |
- computer._addRegion_tokenStart_nodeEnd( |
- constructorName.period, |
- constructorName, |
- element); |
- } |
- } |
- } |
- _safelyVisit(node.argumentList); |
- } |
- |
- @override |
visitPartDirective(PartDirective node) { |
computer._addRegion_tokenStart_nodeEnd( |
node.keyword, |
@@ -262,6 +243,32 @@ class _DartUnitNavigationComputerVisitor extends RecursiveAstVisitor { |
_safelyVisit(node.argumentList); |
} |
+ void _addConstructorName(AstNode parent, ConstructorName node) { |
+ Element element = node.staticElement; |
+ if (element == null) { |
+ return; |
+ } |
+ // if a synthetic constructor, navigate to the class |
+ if (element.isSynthetic) { |
+ ClassElement classElement = element.enclosingElement; |
+ element = classElement; |
Brian Wilkerson
2015/02/12 17:56:19
Why the temporary variable? Why not just:
elemen
|
+ } |
+ // add regions |
+ TypeName typeName = node.type; |
+ TypeArgumentList typeArguments = typeName.typeArguments; |
+ if (typeArguments == null) { |
+ computer._addRegion_nodeStart_nodeEnd(parent, node, element); |
+ } else { |
+ computer._addRegion_nodeStart_nodeEnd(parent, typeName.name, element); |
+ // <TypeA, TypeB> |
+ typeArguments.accept(this); |
+ // optional ".name" |
+ if (node.period != null) { |
+ computer._addRegion_tokenStart_nodeEnd(node.period, node, element); |
+ } |
+ } |
+ } |
+ |
void _safelyVisit(AstNode node) { |
if (node != null) { |
node.accept(this); |