Package org.codehaus.groovy.transform
Class TupleConstructorASTTransformation
java.lang.Object
org.codehaus.groovy.transform.AbstractASTTransformation
org.codehaus.groovy.transform.TupleConstructorASTTransformation
- All Implemented Interfaces:
CompilationUnitAware,ASTTransformation,ErrorCollecting,TransformWithPriority
public class TupleConstructorASTTransformation
extends AbstractASTTransformation
implements CompilationUnitAware, TransformWithPriority
Handles generation of code for the @TupleConstructor annotation.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordResult ofselectTupleProperties(org.codehaus.groovy.transform.AbstractASTTransformation, org.codehaus.groovy.ast.ClassNode, org.codehaus.groovy.ast.AnnotationNode): the super-class properties and self properties that pass the annotation's filters (includes / excludes / allNames / includeProperties / includeFields / includeSuperProperties / includeSuperFields / allProperties). -
Field Summary
Fields inherited from class org.codehaus.groovy.transform.AbstractASTTransformation
RETENTION_CLASSNODE, sourceUnit -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddSpecialMapConstructors(int modifiers, ClassNode cNode, String message, boolean addNoArg) Adds a generated constructor that takes aLinkedHashMapnamed__namedArgs.If the transform is associated with a single annotation, returns a name suitable for displaying in error messages.intpriority()Returns the order of this transform among others in the same phase.selectTupleProperties(AbstractASTTransformation xform, ClassNode cNode, AnnotationNode anno) Resolves the property nodes the@TupleConstructorruntime transform would use as constructor parameters.voidSets the compilation unit currently applying this transformation.voidvisit(ASTNode[] nodes, SourceUnit source) The method is invoked when an AST Transformation is active.Methods inherited from class org.codehaus.groovy.transform.AbstractASTTransformation
addError, checkIncludeExcludeUndefinedAware, checkIncludeExcludeUndefinedAware, checkNotInterface, checkPropertyList, checkPropertyList, checkPropertyList, copyAnnotatedNodeAnnotations, copyAnnotatedNodeAnnotations, deemedInternal, deemedInternalName, getMemberClassList, getMemberClassValue, getMemberClassValue, getMemberIntValue, getMemberStringList, getMemberStringValue, getMemberStringValue, getMemberValue, hasAnnotation, init, markAsInternal, memberHasValue, shouldSkip, shouldSkip, shouldSkip, shouldSkipOnDescriptorUndefinedAware, shouldSkipUndefinedAware, shouldSkipUndefinedAware, shouldSkipUndefinedAware, tokenize
-
Constructor Details
-
TupleConstructorASTTransformation
public TupleConstructorASTTransformation()
-
-
Method Details
-
priority
public int priority()Description copied from interface:TransformWithPriorityReturns the order of this transform among others in the same phase. Higher values run first. The default used by transforms that do not implement this interface is zero.- Specified by:
priorityin interfaceTransformWithPriority- Returns:
- the priority
-
getAnnotationName
Description copied from class:AbstractASTTransformationIf the transform is associated with a single annotation, returns a name suitable for displaying in error messages.- Overrides:
getAnnotationNamein classAbstractASTTransformation- Returns:
- The simple name of the annotation including the "@" or null if no such name is defined
-
setCompilationUnit
Description copied from interface:CompilationUnitAwareSets the compilation unit currently applying this transformation.- Specified by:
setCompilationUnitin interfaceCompilationUnitAware- Parameters:
unit- the active compilation unit
-
visit
Description copied from interface:ASTTransformationThe method is invoked when an AST Transformation is active. For local transformations, it is invoked once each time the local annotation is encountered. For global transformations, it is invoked once for every source unit, which is typically a source file.- Specified by:
visitin interfaceASTTransformation- Parameters:
nodes- The ASTnodes when the call was triggered. Element 0 is the AnnotationNode that triggered this annotation to be activated. Element 1 is the AnnotatedNode decorated, such as a MethodNode or ClassNode. For global transformations it is usually safe to ignore this parameter.source- The source unit being compiled. The source unit may contain several classes. For global transformations, information about the AST can be retrieved from this object.
-
selectTupleProperties
public static TupleConstructorASTTransformation.SelectedTupleProperties selectTupleProperties(AbstractASTTransformation xform, ClassNode cNode, AnnotationNode anno) Resolves the property nodes the@TupleConstructorruntime transform would use as constructor parameters. Honoursincludes,excludes,allNames,includeProperties,includeFields,includeSuperProperties,includeSuperFields, andallPropertiesattributes the same way the full transform does so the joint-compilation stubber stays in lockstep.- Since:
- 6.0.0
-
addSpecialMapConstructors
public static void addSpecialMapConstructors(int modifiers, ClassNode cNode, String message, boolean addNoArg) Adds a generated constructor that takes aLinkedHashMapnamed__namedArgs. A null map throwsIllegalArgumentExceptionwithmessagefrom that constructor. Otherwise each instance property whose name is a key of the map is assigned from that entry, and the keys are checked against the property names. WhenaddNoArgis true, a no-arg constructor that callsthis(new LinkedHashMap())is added as well.- Parameters:
modifiers- access flags of the generated constructorscNode- class that receives the constructorsmessage- exception text used when the map is nulladdNoArg- whether to also add the no-arg constructor
-