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

Unified Diff: pkg/analysis_server/lib/src/services/index/index_contributor.dart

Issue 1407863004: Index library/part file references from import/export/part containing files. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: tweaks Created 5 years, 2 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/services/index/indexable_file.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/src/services/index/index_contributor.dart
diff --git a/pkg/analysis_server/lib/src/services/index/index_contributor.dart b/pkg/analysis_server/lib/src/services/index/index_contributor.dart
index 34aec15cd47e211db0410d950296d5cafa84debe..6fcd9343f4a00104eaef7567eedddc465c27f6b5 100644
--- a/pkg/analysis_server/lib/src/services/index/index_contributor.dart
+++ b/pkg/analysis_server/lib/src/services/index/index_contributor.dart
@@ -11,6 +11,7 @@ import 'package:analysis_server/src/services/correction/namespace.dart';
import 'package:analysis_server/src/services/index/index.dart';
import 'package:analysis_server/src/services/index/index_store.dart';
import 'package:analysis_server/src/services/index/indexable_element.dart';
+import 'package:analysis_server/src/services/index/indexable_file.dart';
import 'package:analyzer/src/generated/ast.dart';
import 'package:analyzer/src/generated/element.dart';
import 'package:analyzer/src/generated/engine.dart';
@@ -37,6 +38,7 @@ class DartIndexContributor extends IndexContributor {
class _IndexContributor extends GeneralizingAstVisitor {
final InternalIndexStore _store;
+ CompilationUnitElement _unitElement;
LibraryElement _libraryElement;
Map<ImportElement, Set<Element>> _importElementsMap = {};
@@ -186,10 +188,10 @@ class _IndexContributor extends GeneralizingAstVisitor {
@override
visitCompilationUnit(CompilationUnit node) {
- CompilationUnitElement unitElement = node.element;
- if (unitElement != null) {
- _elementStack.add(unitElement);
- _libraryElement = unitElement.enclosingElement;
+ _unitElement = node.element;
+ if (_unitElement != null) {
+ _elementStack.add(_unitElement);
+ _libraryElement = _unitElement.enclosingElement;
if (_libraryElement != null) {
super.visitCompilationUnit(node);
}
@@ -279,6 +281,7 @@ class _IndexContributor extends GeneralizingAstVisitor {
LibraryElement expLibrary = element.exportedLibrary;
_recordLibraryReference(node, expLibrary);
}
+ _recordUriFileReference(node);
super.visitExportDirective(node);
}
@@ -319,6 +322,7 @@ class _IndexContributor extends GeneralizingAstVisitor {
LibraryElement impLibrary = element.importedLibrary;
_recordLibraryReference(node, impLibrary);
}
+ _recordUriFileReference(node);
super.visitImportDirective(node);
}
@@ -375,6 +379,7 @@ class _IndexContributor extends GeneralizingAstVisitor {
LocationImpl location = _createLocationForNode(node.uri);
recordRelationshipElement(
element, IndexConstants.IS_REFERENCED_BY, location);
+ _recordUriFileReference(node);
super.visitPartDirective(node);
}
@@ -790,6 +795,18 @@ class _IndexContributor extends GeneralizingAstVisitor {
}
}
+ void _recordUriFileReference(UriBasedDirective directive) {
+ Source source = directive.source;
+ if (source != null) {
+ LocationImpl location = new LocationImpl(
+ new IndexableFile(_unitElement.source.fullName),
+ directive.uri.offset,
+ directive.uri.length);
+ _store.recordRelationship(new IndexableFile(source.fullName),
+ IndexConstants.IS_REFERENCED_BY, location);
+ }
+ }
+
/**
* If the given expression has resolved type, returns the new location with this type.
*
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/services/index/indexable_file.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698