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

Unified Diff: pkg/analyzer/lib/src/dart/analysis/search.dart

Issue 2619013003: Implement search for LibraryElement in its parts. (Closed)
Patch Set: Created 3 years, 11 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/analyzer/test/src/dart/analysis/search_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/dart/analysis/search.dart
diff --git a/pkg/analyzer/lib/src/dart/analysis/search.dart b/pkg/analyzer/lib/src/dart/analysis/search.dart
index 3ec8f884804ee69cb6d48adabcb6f68d6285b1e8..d9e81188767a150b68e307582a869b792be30e70 100644
--- a/pkg/analyzer/lib/src/dart/analysis/search.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/search.dart
@@ -88,6 +88,8 @@ class Search {
} else if (kind == ElementKind.LABEL ||
kind == ElementKind.LOCAL_VARIABLE) {
return _searchReferences_Local(element, (n) => n is Block);
+ } else if (kind == ElementKind.LIBRARY) {
+ return _searchReferences_Library(element);
} else if (kind == ElementKind.PARAMETER) {
return _searchReferences_Parameter(element);
} else if (kind == ElementKind.PREFIX) {
@@ -294,6 +296,34 @@ class Search {
return results;
}
+ Future<List<SearchResult>> _searchReferences_Library(
+ LibraryElement element) async {
+ // Search only in drivers to which the library with the prefix was added.
+ String path = element.source.fullName;
+ if (!_driver.addedFiles.contains(path)) {
+ return const <SearchResult>[];
+ }
+
+ List<SearchResult> results = <SearchResult>[];
+ for (CompilationUnitElement unitElement in element.units) {
+ String unitPath = unitElement.source.fullName;
+ AnalysisResult unitAnalysisResult = await _driver.getResult(unitPath);
+ CompilationUnit unit = unitAnalysisResult.unit;
+ for (Directive directive in unit.directives) {
+ if (directive is PartOfDirective && directive.element == element) {
+ results.add(new SearchResult._(
+ unit.element,
+ SearchResultKind.REFERENCE,
+ directive.libraryName.offset,
+ directive.libraryName.length,
+ true,
+ false));
+ }
+ }
+ }
+ return results;
+ }
+
Future<List<SearchResult>> _searchReferences_Local(
Element element, bool isRootNode(AstNode n)) async {
String path = element.source.fullName;
« no previous file with comments | « no previous file | pkg/analyzer/test/src/dart/analysis/search_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698