Top Description Inners Constructors Methods
org.codehaus.groovy.transform

public Class AnnotationCollectorTransform

extends Object
Class Inheritance
Known Direct Subclasses
org.codehaus.groovy.transform.CompileDynamicProcessor
Imports
groovy.lang.GroovyRuntimeException, groovy.transform.AnnotationCollector, org.apache.groovy.ast.tools.ClassNodeUtils, org.codehaus.groovy.GroovyBugError, org.codehaus.groovy.ast.ASTNode, .AnnotatedNode, .AnnotationNode, .ClassHelper, .ClassNode, .InnerClassNode, .Parameter, org.codehaus.groovy.ast.expr.AnnotationConstantExpression, .ArrayExpression, .ClassExpression, .ConstantExpression, .Expression, .ListExpression, .MapExpression, org.codehaus.groovy.ast.stmt.ReturnStatement, .Statement, org.codehaus.groovy.control.SourceUnit, java.lang.reflect.Method, .Modifier, java.util.ArrayList, .Arrays, .Collections, .HashMap, .HashSet, .List, .ListIterator, .Map, .Set

This class is the base for any annotation alias processor.
See Also
AnnotationCollector, AnnotationCollectorTransform#visit(AnnotationNode, AnnotationNode, AnnotatedNode, SourceUnit)

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
AnnotationCollectorTransform.ClassChanger

Class used by org.codehaus.groovy.control.CompilationUnit to transform the alias class into what is needed by the compiler.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected void
addError(String
the message
message
,
ASTNode
the node for the error report
node
,
SourceUnit
the source unit for the error report
source
)

Adds a new syntax error to the source unit and then continues.

private static List<AnnotationNode>
copy(List<AnnotationNode> orig, AnnotationNode aliasAnnotationUsage)

private static void
private static void
copyMembers(final Map<String, Expression> members, final AnnotationNode to)

private static List<AnnotationNode>
private static ClassNode
private static List<AnnotationNode>
getStoredTargetList(AnnotationNode aliasAnnotationUsage, SourceUnit source)

protected List<AnnotationNode>

Returns:

a list of string constants
getTargetAnnotationList
(AnnotationNode
the node containing the value member with the list
collector
,
AnnotationNode aliasAnnotationUsage, SourceUnit
the source unit for error reporting
source
)

Returns a list of AnnotationNodes for the value attribute of the given AnnotationNode.

private static List<AnnotationNode>
private static List<AnnotationNode>
private List<AnnotationNode>
getTargetListFromValue(AnnotationNode collector, AnnotationNode aliasAnnotationUsage, SourceUnit source)

private static Expression
private static List<AnnotationNode>
makeListOfAnnotations(final Object[][] data)

public List<AnnotationNode>

Returns:

list of the new AnnotationNodes
visit
(AnnotationNode
reference to the annotation with AnnotationCollector
collector
,
AnnotationNode
reference to the place of usage of the alias
aliasAnnotationUsage
,
AnnotatedNode
reference to the node that has been annotated by the alias
aliasAnnotated
,
SourceUnit
source unit for error reporting
source
)

Implementation method of the alias annotation processor.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

AnnotationCollectorTransformback to summary
public AnnotationCollectorTransform()

Method Detail

addErrorback to summary
protected void addError(String message, ASTNode node, SourceUnit source)

Adds a new syntax error to the source unit and then continues.

Parameters
message:String

the message

node:ASTNode

the node for the error report

source:SourceUnit

the source unit for the error report

copyback to summary
private static List<AnnotationNode> copy(List<AnnotationNode> orig, AnnotationNode aliasAnnotationUsage)
copyMembersback to summary
private static void copyMembers(final AnnotationNode from, final AnnotationNode to)
copyMembersback to summary
private static void copyMembers(final Map<String, Expression> members, final AnnotationNode to)
getMetaback to summary
private static List<AnnotationNode> getMeta(ClassNode cn)
getSerializeClassback to summary
private static ClassNode getSerializeClass(final ClassNode alias)
getStoredTargetListback to summary
private static List<AnnotationNode> getStoredTargetList(AnnotationNode aliasAnnotationUsage, SourceUnit source)
getTargetAnnotationListback to summary
protected List<AnnotationNode> getTargetAnnotationList(AnnotationNode collector, AnnotationNode aliasAnnotationUsage, SourceUnit source)

Returns a list of AnnotationNodes for the value attribute of the given AnnotationNode.

Parameters
collector:AnnotationNode

the node containing the value member with the list

source:SourceUnit

the source unit for error reporting

Returns:List<AnnotationNode>

a list of string constants

getTargetListFromAnnotationsback to summary
private static List<AnnotationNode> getTargetListFromAnnotations(ClassNode alias)
getTargetListFromClassback to summary
private static List<AnnotationNode> getTargetListFromClass(final ClassNode alias)
getTargetListFromValueback to summary
private List<AnnotationNode> getTargetListFromValue(AnnotationNode collector, AnnotationNode aliasAnnotationUsage, SourceUnit source)
makeExpressionback to summary
private static Expression makeExpression(final Object o)
makeListOfAnnotationsback to summary
private static List<AnnotationNode> makeListOfAnnotations(final Object[][] data)
visitback to summary
public List<AnnotationNode> visit(AnnotationNode collector, AnnotationNode aliasAnnotationUsage, AnnotatedNode aliasAnnotated, SourceUnit source)

Implementation method of the alias annotation processor. This method will get the list of annotations we aliased from the collector and adds it to aliasAnnotationUsage. The method will also map all members from aliasAnnotationUsage to the aliased nodes. Should a member stay unmapped, we will ad an error. Further processing of those members is done by the annotations.

Parameters
collector:AnnotationNode

reference to the annotation with AnnotationCollector

aliasAnnotationUsage:AnnotationNode

reference to the place of usage of the alias

aliasAnnotated:AnnotatedNode

reference to the node that has been annotated by the alias

source:SourceUnit

source unit for error reporting

Returns:List<AnnotationNode>

list of the new AnnotationNodes

org.codehaus.groovy.transform back to summary

public Class AnnotationCollectorTransform.ClassChanger

extends Object
Class Inheritance
  • java.lang.Object
  • org.codehaus.groovy.transform.AnnotationCollectorTransform.ClassChanger

Class used by org.codehaus.groovy.control.CompilationUnit to transform the alias class into what is needed by the compiler. This means removing invalid modifiers, interfaces and superclasses, as well as adding a static value method returning our serialized version of the data for processing from a pre-compiled state. By doing this the old annotations will be removed as well

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private Expression
private Expression
public void
transformClass(ClassNode cn)

Method to transform the given ClassNode, if it is annotated with AnnotationCollector.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

ClassChangerback to summary
public ClassChanger()

Method Detail

serializeback to summary
private Expression serialize(Expression e)
serializeback to summary
private Expression serialize(AnnotationNode an)
transformClassback to summary
public void transformClass(ClassNode cn)

Method to transform the given ClassNode, if it is annotated with AnnotationCollector. See class description for what the transformation includes.