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

Unified Diff: pkg/analysis_server/lib/src/computer/computer_navigation.dart

Issue 921833002: Issue 22381. Fix for navigating to constructor from redirecting factory constructor. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/edit/edit_domain.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/edit/edit_domain.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698