Index: pkg/analysis_server/lib/src/domains/analysis/navigation_dart.dart |
diff --git a/pkg/analysis_server/lib/src/domains/analysis/navigation_dart.dart b/pkg/analysis_server/lib/src/domains/analysis/navigation_dart.dart |
index 671e752564a5d2a66a5aa6a4f55485a4587736b5..8b87629949fc819391227faa702bb83315cd2440 100644 |
--- a/pkg/analysis_server/lib/src/domains/analysis/navigation_dart.dart |
+++ b/pkg/analysis_server/lib/src/domains/analysis/navigation_dart.dart |
@@ -40,6 +40,52 @@ class DartNavigationComputer implements NavigationContributor { |
} |
} |
+/** |
+ * A Dart specific wrapper around [NavigationCollector]. |
+ */ |
+class _DartNavigationCollector { |
+ final NavigationCollector collector; |
+ |
+ _DartNavigationCollector(this.collector); |
+ |
+ void _addRegion(int offset, int length, Element element) { |
+ if (element is FieldFormalParameterElement) { |
+ element = (element as FieldFormalParameterElement).field; |
+ } |
+ if (element == null || element == DynamicElementImpl.instance) { |
+ return; |
+ } |
+ if (element.location == null) { |
+ return; |
+ } |
+ protocol.ElementKind kind = |
+ protocol.newElementKind_fromEngine(element.kind); |
+ protocol.Location location = protocol.newLocation_fromElement(element); |
+ if (location == null) { |
+ return; |
+ } |
+ collector.addRegion(offset, length, kind, location); |
+ } |
+ |
+ void _addRegion_nodeStart_nodeEnd(AstNode a, AstNode b, Element element) { |
+ int offset = a.offset; |
+ int length = b.end - offset; |
+ _addRegion(offset, length, element); |
+ } |
+ |
+ void _addRegionForNode(AstNode node, Element element) { |
+ int offset = node.offset; |
+ int length = node.length; |
+ _addRegion(offset, length, element); |
+ } |
+ |
+ void _addRegionForToken(Token token, Element element) { |
+ int offset = token.offset; |
+ int length = token.length; |
+ _addRegion(offset, length, element); |
+ } |
+} |
+ |
class _DartNavigationComputerVisitor extends RecursiveAstVisitor { |
final _DartNavigationCollector computer; |
@@ -130,6 +176,11 @@ class _DartNavigationComputerVisitor extends RecursiveAstVisitor { |
} |
@override |
+ visitLibraryDirective(LibraryDirective node) { |
+ computer._addRegionForNode(node.name, node.element); |
+ } |
+ |
+ @override |
visitPartDirective(PartDirective node) { |
_addUriDirectiveRegion(node, node.element); |
super.visitPartDirective(node); |
@@ -223,52 +274,6 @@ class _DartNavigationComputerVisitor extends RecursiveAstVisitor { |
} |
/** |
- * A Dart specific wrapper around [NavigationCollector]. |
- */ |
-class _DartNavigationCollector { |
- final NavigationCollector collector; |
- |
- _DartNavigationCollector(this.collector); |
- |
- void _addRegion(int offset, int length, Element element) { |
- if (element is FieldFormalParameterElement) { |
- element = (element as FieldFormalParameterElement).field; |
- } |
- if (element == null || element == DynamicElementImpl.instance) { |
- return; |
- } |
- if (element.location == null) { |
- return; |
- } |
- protocol.ElementKind kind = |
- protocol.newElementKind_fromEngine(element.kind); |
- protocol.Location location = protocol.newLocation_fromElement(element); |
- if (location == null) { |
- return; |
- } |
- collector.addRegion(offset, length, kind, location); |
- } |
- |
- void _addRegion_nodeStart_nodeEnd(AstNode a, AstNode b, Element element) { |
- int offset = a.offset; |
- int length = b.end - offset; |
- _addRegion(offset, length, element); |
- } |
- |
- void _addRegionForNode(AstNode node, Element element) { |
- int offset = node.offset; |
- int length = node.length; |
- _addRegion(offset, length, element); |
- } |
- |
- void _addRegionForToken(Token token, Element element) { |
- int offset = token.offset; |
- int length = token.length; |
- _addRegion(offset, length, element); |
- } |
-} |
- |
-/** |
* An AST visitor that forwards nodes intersecting with the range from |
* [start] to [end] to the given [visitor]. |
*/ |