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

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

Issue 551143003: Issue 20894. Improve navigation regions for 'new Class.named()' expression. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 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/test/analysis_notification_navigation_test.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 ac2cfec2782b20eeb0242382a452369149bede4d..bce017c7bceeef3ec02d74b5ec1a1c13d44ee5e5 100644
--- a/pkg/analysis_server/lib/src/computer/computer_navigation.dart
+++ b/pkg/analysis_server/lib/src/computer/computer_navigation.dart
@@ -16,7 +16,8 @@ import 'package:analyzer/src/generated/scanner.dart';
class DartUnitNavigationComputer {
final CompilationUnit _unit;
- final List<protocol.NavigationRegion> _regions = <protocol.NavigationRegion>[];
+ final List<protocol.NavigationRegion> _regions = <protocol.NavigationRegion>[
+ ];
DartUnitNavigationComputer(this._unit);
@@ -136,10 +137,32 @@ class _DartUnitNavigationComputerVisitor extends RecursiveAstVisitor {
@override
visitInstanceCreationExpression(InstanceCreationExpression node) {
Element element = node.staticElement;
- if (element != null && element.isSynthetic) {
- element = element.enclosingElement;
+ ConstructorName constructorName = node.constructorName;
+ if (element != null && constructorName != null) {
+ ClassElement classElement = element.enclosingElement;
+ if (element.isSynthetic) {
+ element = classElement;
+ computer._addRegion_nodeStart_nodeStart(
+ node,
+ node.argumentList,
+ element);
+ } else {
+ // add region for "type" first, so that it is found before "new "
+ computer._addRegionForNode(constructorName.type, classElement);
+ // "new "
+ computer._addRegion_nodeStart_nodeStart(
+ node,
+ constructorName.type,
+ element);
+ // optional ".name"
+ if (constructorName.period != null) {
+ computer._addRegion_tokenStart_nodeEnd(
+ constructorName.period,
+ constructorName,
+ element);
+ }
+ }
}
- computer._addRegion_nodeStart_nodeStart(node, node.argumentList, element);
return super.visitInstanceCreationExpression(node);
}
« no previous file with comments | « no previous file | pkg/analysis_server/test/analysis_notification_navigation_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698