Discussion:
[dart-misc] Resolving annotation node from an annotated field using a code_transformer
Adam Bender
2015-10-02 00:42:56 UTC
Permalink
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?
--
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+***@dartlang.org.
Alexandre Ardhuin
2015-10-02 15:23:13 UTC
Permalink
+analyzer-discuss
Post by Adam Bender
I was doing some fiddling with a code_transformer the other day and I ran
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?
--
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
--
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+***@dartlang.org.
Loading...