identify annotation

33 views
Skip to first unread message

Răzvan Rotaru

unread,
Apr 19, 2021, 10:47:10 AM4/19/21
to Dart Analyzer Discussion
Hi,

I am in a source_gen context and need to safely identify an annotation on a type. I tried comparing the type information I have from the analyzer with the various informations I get from reflection, but it didn't work. Probably because the information I have from reflection is in the execution context of the generator (i.e. it's obtained by running reflectType on the annotation class).

The code looks something like this:

//getter is a PropertyAccessorElement
getter.returnType.element?.metadata.any((element) =>
  //element is an ElementAnnotationImpl
  // how to compare it with the type of the annotation class?
);

Is this possible? built_value seems to be comparing the names of the annotation type.

Răzvan

Brian Wilkerson

unread,
Apr 19, 2021, 11:53:01 AM4/19/21
to Dart Analyzer Discussion, Jake Macdonald, Nate Bosch
--
You received this message because you are subscribed to the Google Groups "Dart Analyzer Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to analyzer-discu...@dartlang.org.
To view this discussion on the web visit https://groups.google.com/a/dartlang.org/d/msgid/analyzer-discuss/ddea8f9a-a178-4e42-8e82-17060f317da5n%40dartlang.org.
Reply all
Reply to author
Forward
0 new messages