I was doing some fiddling with a code_transformer the other day and I ran into a problem I couldnt figure out how to solve. Given a class like this:
class MyClass {
@somethingSpecial
Foo foo;
@somethingSpecial
Foo get aDifferentFoo => new Foo();
}
static const somethingSpecial = const _SomethingSpecial();
class _SomethingSpecial{
const _SomethingSpecial();
}
When running the transformer across this class I see that I am able to resolve the actual Annotation node from the getter but I can only access the AnnotationElement for the field. I have tried looking around the FieldElement API including the implied getter and setter but I dont see anyway to resolve the actual Annotation AST node starting from a field and that just seems weird. No matter where I looked I ended up with the null node or not a node lacking metadata. Im sure I am missing something obvious but I cant quite crack it. Any AST experts have any pointers for how I sort this out?