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

Unified Diff: pkg/analysis_server/lib/src/services/search/search_engine_internal2.dart

Issue 2564913002: Implement SearchEngine.searchAllSubtypes() with the analysis driver. (Closed)
Patch Set: Created 4 years 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
Index: pkg/analysis_server/lib/src/services/search/search_engine_internal2.dart
diff --git a/pkg/analysis_server/lib/src/services/search/search_engine_internal2.dart b/pkg/analysis_server/lib/src/services/search/search_engine_internal2.dart
index 04dd6c59e9220d1eea6ce397ff65b3cae2b1cc8b..71b1f297063883b485648ae119faada1bb663c45 100644
--- a/pkg/analysis_server/lib/src/services/search/search_engine_internal2.dart
+++ b/pkg/analysis_server/lib/src/services/search/search_engine_internal2.dart
@@ -19,9 +19,21 @@ class SearchEngineImpl2 implements SearchEngine {
SearchEngineImpl2(this._drivers);
@override
- Future<List<SearchMatch>> searchAllSubtypes(ClassElement type) async {
- // TODO(scheglov) implement
- return [];
+ Future<Set<ClassElement>> searchAllSubtypes(ClassElement type) async {
+ Set<ClassElement> allSubtypes = new Set<ClassElement>();
+
+ Future<Null> addSubtypes(ClassElement type) async {
+ List<SearchResult> directResults = await _searchDirectSubtypes(type);
+ for (SearchResult directResult in directResults) {
+ var directSubtype = directResult.enclosingElement as ClassElement;
+ if (allSubtypes.add(directSubtype)) {
+ await addSubtypes(directSubtype);
+ }
+ }
+ }
+
+ await addSubtypes(type);
+ return allSubtypes;
}
@override
@@ -48,12 +60,8 @@ class SearchEngineImpl2 implements SearchEngine {
@override
Future<List<SearchMatch>> searchSubtypes(ClassElement type) async {
- List<SearchResult> allResults = [];
- for (AnalysisDriver driver in _drivers) {
- List<SearchResult> results = await driver.search.subTypes(type);
- allResults.addAll(results);
- }
- return allResults.map(_SearchMatch.forSearchResult).toList();
+ List<SearchResult> results = await _searchDirectSubtypes(type);
+ return results.map(_SearchMatch.forSearchResult).toList();
}
@override
@@ -61,6 +69,15 @@ class SearchEngineImpl2 implements SearchEngine {
// TODO(scheglov) implement
return [];
}
+
+ Future<List<SearchResult>> _searchDirectSubtypes(ClassElement type) async {
+ List<SearchResult> allResults = [];
+ for (AnalysisDriver driver in _drivers) {
+ List<SearchResult> results = await driver.search.subTypes(type);
+ allResults.addAll(results);
+ }
+ return allResults;
+ }
}
class _SearchMatch implements SearchMatch {

Powered by Google App Engine
This is Rietveld 408576698