getDeclarationsAnnotatedBy function
Finds and returns all declarations within a compilation unit
that are
annotated with the given annotation
class.
If this is being leveraged within a transformer, you can associate the
returned DeclarationWithMeta
instance with the asset in which it is
located by passing in an assetId
.
Implementation
Iterable<CompilationUnitMember> getDeclarationsAnnotatedBy(
CompilationUnit unit, Type annotation) {
var annotationName = _getReflectedName(annotation);
return unit.declarations.where((member) {
return member.metadata.any((meta) => meta.name.name == annotationName);
});
}