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

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

Issue 2566393003: Implement SearchEngine.searchMemberDeclarations() for the new 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/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 59a1a63dda8b575b6f202e4d218a06e5a377066b..3ec8f884804ee69cb6d48adabcb6f68d6285b1e8 100644
--- a/pkg/analyzer/lib/src/dart/analysis/search.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/search.dart
@@ -34,6 +34,30 @@ class Search {
Search(this._driver);
/**
+ * Returns class members with names matching the given [regExp].
+ */
+ Future<List<Element>> classMembers(RegExp regExp) async {
+ List<Element> elements = <Element>[];
+
+ void addElement(Element element) {
+ if (!element.isSynthetic && regExp.hasMatch(element.displayName)) {
+ elements.add(element);
+ }
+ }
+
+ for (FileState file in _driver.fsState.knownFiles) {
+ CompilationUnitElement unitElement =
+ await _driver.getUnitElement(file.path);
+ for (ClassElement clazz in unitElement.types) {
+ clazz.accessors.forEach(addElement);
+ clazz.fields.forEach(addElement);
+ clazz.methods.forEach(addElement);
+ }
+ }
+ return elements;
+ }
+
+ /**
* Returns references to the [element].
*/
Future<List<SearchResult>> references(Element element) async {

Powered by Google App Engine
This is Rietveld 408576698