groovy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Milles, Eric (TR Technology)" <>
Subject RE: Proposal: Change behavior of AST getMemberClassValue() and equivalents
Date Wed, 06 Jan 2021 15:29:53 GMT
I think it is implemented this way because it must support an unresolved annotation.  That
is, you may have a transform that runs before ResolveVisitor fills in all the type information.
 The transform can only ask for what is present in the AST.  If it wants to use the default
values of any annotation method, it can supply the annotation class.  You can get the default
value by reflection like this and that could be passed as the default to return or you could
use ?: logic.

// excerpt of void visit(ASTNode[] nodes, SourceUnit source)
AnnotationNode node = (AnnotationNode) nodes[0];
String value = getMemberStringValue(node, "name", AnnoType.class.getMethod("name").getDefaultValue());

View raw message