gen reflectClass method

This commit is contained in:
Tobe O 2018-11-08 11:31:46 -05:00
parent ccdffe7901
commit 5ca37494cf
2 changed files with 19 additions and 4 deletions

View file

@ -48,6 +48,18 @@ class ReflectorLibraryGenerator {
clazz.constructors.add(new Constructor((b) {
b..constant = true;
}));
// Add a reflectClass that just forwards to reflectType
clazz.methods.add(new Method((b) {
b
..name = 'reflectClass'
..returns = refer('ReflectedClass')
..annotations.add(refer('override'))
..requiredParameters.add(new Parameter((b) => b
..name = 'type'
..type = refer('Type')))
..body = new Code('return reflectType(type) as ReflectedClass;');
}));
});
}

View file

@ -8,11 +8,14 @@ part of angel_container_generator_test;
class AngelContainerGeneratorTestReflector implements Reflector {
const AngelContainerGeneratorTestReflector();
@override
ReflectedClass reflectClass(Type type) {
return reflectType(type) as ReflectedClass;
}
}
ReflectedClass _reflectedArtistClass = const _ReflectedArtistClass._();
class _ReflectedArtistClass extends ReflectedClass {
const _ReflectedArtistClass._()
class _ReflectedArtist extends ReflectedClass {
const _ReflectedArtist._()
: super('Artist', const [], const [], const [], const [], Artist);
}