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

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

Issue 2962023002: Add SearchEngine.membersOfSubtypes(). (Closed)
Patch Set: Created 3 years, 6 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
Index: pkg/analysis_server/lib/src/services/search/search_engine_internal.dart
diff --git a/pkg/analysis_server/lib/src/services/search/search_engine_internal.dart b/pkg/analysis_server/lib/src/services/search/search_engine_internal.dart
index 2cd5cc4708bf1ceb2ab571b4616368507310f04b..b551b48123e7d993ff0966d38af10892d910a65b 100644
--- a/pkg/analysis_server/lib/src/services/search/search_engine_internal.dart
+++ b/pkg/analysis_server/lib/src/services/search/search_engine_internal.dart
@@ -20,6 +20,37 @@ class SearchEngineImpl implements SearchEngine {
SearchEngineImpl(this._drivers);
@override
+ Future<Set<String>> membersOfSubtypes(ClassElement type) async {
+ List<AnalysisDriver> drivers = _drivers.toList();
+
+ bool hasSubtypes = false;
+ Set<String> visitedIds = new Set<String>();
+ Set<String> members = new Set<String>();
+
+ Future<Null> addMembers(ClassElement type, SubtypeResult subtype) async {
+ if (subtype != null && !visitedIds.add(subtype.id)) {
+ return;
+ }
+ for (AnalysisDriver driver in drivers) {
+ List<SubtypeResult> subtypes =
+ await driver.search.subtypes(type: type, subtype: subtype);
+ for (var subtype in subtypes) {
+ hasSubtypes = true;
+ members.addAll(subtype.members);
+ await addMembers(null, subtype);
+ }
+ }
+ }
+
+ await addMembers(type, null);
+
+ if (!hasSubtypes) {
+ return null;
+ }
+ return members;
+ }
+
+ @override
Future<Set<ClassElement>> searchAllSubtypes(ClassElement type) async {
Set<ClassElement> allSubtypes = new Set<ClassElement>();

Powered by Google App Engine
This is Rietveld 408576698