Parser<O> class
Owner class parser. It looks UiField anotations of fields and collect them in variables. It keeps instance mirror of owner in ownerInstance.
class Parser<O> { Map<String, VariableMirror> variables = new Map<String, VariableMirror>(); InstanceMirror ownerInstance; /** * Parse owner class to find UiFields. */ void parse(O owner) { ownerInstance = reflect(owner); _findVariables(); } /** * Find all UiField variables. */ void _findVariables() { _uiFieldVariables(ownerInstance.type).forEach((VariableMirror variable){ variables[_symbolAsString(variable.simpleName)] = variable; }); } /** * Returns ui field variables from [clazz]. */ Iterable<VariableMirror> _uiFieldVariables(ClassMirror clazz) => clazz.variables.values.where(_testUiField); /** * Test method returns true if the declared [element] is UiField */ bool _testUiField(DeclarationMirror element) => element.metadata.any((InstanceMirror im) => im.reflectee is _UiField); //******** // Utility //******** String _symbolAsString(Symbol symbol) => MirrorSystem.getName(symbol); }