| 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 6bb75be6fc6449924891d740760ccd1920aef659..c669fae9a7661523b4b41dfb74464cd1699bdcd1 100644
|
| --- a/pkg/analyzer/lib/src/dart/analysis/search.dart
|
| +++ b/pkg/analyzer/lib/src/dart/analysis/search.dart
|
| @@ -120,6 +120,47 @@ class Search {
|
| }
|
|
|
| /**
|
| + * Return direct [SubtypeResult]s for either the [type] or [subtype].
|
| + */
|
| + Future<List<SubtypeResult>> subtypes(
|
| + {ClassElement type, SubtypeResult subtype}) async {
|
| + String name;
|
| + String id;
|
| + if (type != null) {
|
| + name = type.name;
|
| + id = type.librarySource.uri.toString() +
|
| + ';' +
|
| + type.source.uri.toString() +
|
| + ';' +
|
| + name;
|
| + } else {
|
| + name = subtype.name;
|
| + id = subtype.id;
|
| + }
|
| +
|
| + List<SubtypeResult> results = [];
|
| + for (String path in _driver.addedFiles) {
|
| + FileState file = _driver.fsState.getFileForPath(path);
|
| + if (file.subtypedNames.contains(name)) {
|
| + AnalysisDriverResolvedUnit unit = _driver.getResolvedUnitObject(file);
|
| + if (unit != null) {
|
| + for (AnalysisDriverSubtype subtype in unit.index.subtypes) {
|
| + if (subtype.supertypes.contains(id)) {
|
| + FileState library = file.isPart ? file.library : file;
|
| + results.add(new SubtypeResult(
|
| + library.uriStr + ';' + file.uriStr + ';' + subtype.name,
|
| + subtype.name,
|
| + subtype.members));
|
| + }
|
| + }
|
| + }
|
| + }
|
| + }
|
| +
|
| + return results;
|
| + }
|
| +
|
| + /**
|
| * Returns top-level elements with names matching the given [regExp].
|
| */
|
| Future<List<Element>> topLevelElements(RegExp regExp) async {
|
| @@ -499,6 +540,28 @@ class SearchResult {
|
| enum SearchResultKind { READ, READ_WRITE, WRITE, INVOCATION, REFERENCE }
|
|
|
| /**
|
| + * A single subtype of a type.
|
| + */
|
| +class SubtypeResult {
|
| + /**
|
| + * The identifier of the subtype.
|
| + */
|
| + final String id;
|
| +
|
| + /**
|
| + * The name of the subtype.
|
| + */
|
| + final String name;
|
| +
|
| + /**
|
| + * The names of members declared in the class.
|
| + */
|
| + final List<String> members;
|
| +
|
| + SubtypeResult(this.id, this.name, this.members);
|
| +}
|
| +
|
| +/**
|
| * A visitor that finds the deep-most [Element] that contains the [offset].
|
| */
|
| class _ContainingElementFinder extends GeneralizingElementVisitor {
|
|
|