Resolving annotation node from an annotated field using a code_transformer

52 views
Skip to first unread message

Adam Bender

unread,
Oct 1, 2015, 8:42:56 PM10/1/15
to Dart Misc
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?

Alexandre Ardhuin

unread,
Oct 2, 2015, 11:23:18 AM10/2/15
to General Dart Discussion, analyzer...@dartlang.org
+analyzer-discuss


--
For other discussions, see https://groups.google.com/a/dartlang.org/
 
For HOWTO questions, visit http://stackoverflow.com/tags/dart
 
To file a bug report or feature request, go to http://www.dartbug.com/new

To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.

Reply all
Reply to author
Forward
0 new messages