Skip to content

Commit e43f086

Browse files
scheglovCommit Queue
authored and
Commit Queue
committed
Macro. Return ClassDeclaration(s) from typesOf().
Just as much as to allow me work on 'test_reflective_loader' rewrite. Change-Id: I6010b649beac1942a00d6da858bbae61556c7bbc Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/375084 Reviewed-by: Johnni Winther <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
1 parent b2eec8b commit e43f086

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

pkg/front_end/lib/src/kernel/macro/introspectors.dart

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -839,8 +839,28 @@ class _DeclarationPhaseIntrospector extends _TypePhaseIntrospector
839839

840840
@override
841841
Future<List<macro.TypeDeclaration>> typesOf(covariant macro.Library library) {
842-
// TODO: implement typesOf
843-
throw new UnimplementedError();
842+
Uri uri = library.uri;
843+
LibraryBuilder? libraryBuilder =
844+
sourceLoader.lookupLoadedLibraryBuilder(uri);
845+
if (libraryBuilder == null) {
846+
return new Future.error(
847+
new macro.MacroImplementationExceptionImpl(
848+
'Library at uri $uri could not be resolved.'),
849+
StackTrace.current);
850+
}
851+
852+
List<macro.TypeDeclaration> result = [];
853+
Iterator<Builder> iterator = libraryBuilder.localMembersIterator;
854+
while (iterator.moveNext()) {
855+
Builder builder = iterator.current;
856+
// TODO(scheglov): This switch is not complete.
857+
switch (builder) {
858+
case ClassBuilder():
859+
result.add(_introspection.getClassDeclaration(builder));
860+
}
861+
}
862+
863+
return new Future.value(result);
844864
}
845865

846866
@override

0 commit comments

Comments
 (0)