@groovy.transform.CompileStatic abstract class AbstractMethodDecoratingTransformation extends AbstractGormASTTransformation
An abstract implementation for transformations that decorate a method invocation such that the method invocation is wrapped in the execution of a closure that delegates to the original logic. Examples of such transformations are Transactional and CurrentTenant
Modifiers | Name | Description |
---|---|---|
private static java.util.Set<java.lang.String> |
ANNOTATION_NAME_EXCLUDES |
|
static java.lang.String |
DECORATED_METHODS |
Key used to store within the original method node metadata, all previous decorated methods |
private static java.util.Set<java.lang.String> |
METHOD_NAME_EXCLUDES |
Fields inherited from class | Fields |
---|---|
class AbstractGormASTTransformation |
compilationUnit |
Constructor and description |
---|
AbstractMethodDecoratingTransformation
() |
Type Params | Return Type | Name and description |
---|---|---|
|
protected org.codehaus.groovy.ast.expr.MethodCallExpression |
buildCallToOriginalMethod(org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.ast.MethodNode renamedMethodNode) |
|
protected abstract org.codehaus.groovy.ast.expr.Expression |
buildDelegatingMethodCall(org.codehaus.groovy.control.SourceUnit sourceUnit, org.codehaus.groovy.ast.AnnotationNode annotationNode, org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.ast.MethodNode methodNode, org.codehaus.groovy.ast.expr.MethodCallExpression originalMethodCallExpr, org.codehaus.groovy.ast.stmt.BlockStatement newMethodBody) Builds the delegating method call for the given class node |
|
protected void |
compileMethodStatically(org.codehaus.groovy.control.SourceUnit sourceUnit, org.codehaus.groovy.ast.MethodNode methodNode) |
|
protected org.codehaus.groovy.ast.stmt.Statement |
createDelegingMethodBody(org.codehaus.groovy.ast.Parameter[] parameters, org.codehaus.groovy.ast.expr.MethodCallExpression originalMethodCall) |
|
protected void |
enhanceClassNode(org.codehaus.groovy.control.SourceUnit sourceUnit, org.codehaus.groovy.ast.AnnotationNode annotationNode, org.codehaus.groovy.ast.ClassNode classNode) Add any additional logic to enhance the class node |
|
protected abstract java.lang.String |
getRenamedMethodPrefix() |
|
protected boolean |
hasExcludedAnnotation(org.codehaus.groovy.ast.MethodNode md) |
|
protected boolean |
hasExcludedAnnotation(org.codehaus.groovy.ast.MethodNode md, java.util.Set<java.lang.String> excludes) |
|
protected boolean |
isTestSetupOrCleanup(org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.ast.MethodNode md) |
|
protected org.codehaus.groovy.ast.expr.MethodCallExpression |
makeDelegatingClosureCall(org.codehaus.groovy.ast.expr.Expression targetObject, java.lang.String executeMethodName, org.codehaus.groovy.ast.Parameter[] closureParameters, org.codehaus.groovy.ast.expr.MethodCallExpression originalMethodCall, org.codehaus.groovy.ast.VariableScope variableScope) Construct a method call that wraps an original call with a closure invocation |
|
protected org.codehaus.groovy.ast.expr.MethodCallExpression |
makeDelegatingClosureCall(org.codehaus.groovy.ast.expr.Expression targetObject, java.lang.String executeMethodName, org.codehaus.groovy.ast.expr.ArgumentListExpression arguments, org.codehaus.groovy.ast.Parameter[] closureParameters, org.codehaus.groovy.ast.expr.MethodCallExpression originalMethodCall, org.codehaus.groovy.ast.VariableScope variableScope) Construct a method call that wraps an original call with a closure invocation |
|
protected org.codehaus.groovy.ast.MethodNode |
moveOriginalCodeToNewMethod(org.codehaus.groovy.ast.MethodNode methodNode, java.lang.String renamedMethodName, org.codehaus.groovy.ast.Parameter[] newParameters, org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.control.SourceUnit source, java.util.Map<java.lang.String, org.codehaus.groovy.ast.ClassNode> genericsSpec) |
|
protected org.codehaus.groovy.ast.Parameter[] |
prepareNewMethodParameters(org.codehaus.groovy.ast.MethodNode methodNode, java.util.Map<java.lang.String, org.codehaus.groovy.ast.ClassNode> genericsSpec, org.codehaus.groovy.ast.ClassNode classNode) |
|
protected org.codehaus.groovy.ast.ClassNode |
resolveReturnTypeForNewMethod(org.codehaus.groovy.ast.MethodNode methodNode) |
|
void |
visit(org.codehaus.groovy.control.SourceUnit source, org.codehaus.groovy.ast.AnnotationNode annotationNode, org.codehaus.groovy.ast.AnnotatedNode annotatedNode) |
|
protected void |
weaveClassNode(org.codehaus.groovy.control.SourceUnit source, org.codehaus.groovy.ast.AnnotationNode annotationNode, org.codehaus.groovy.ast.ClassNode classNode) |
|
protected org.codehaus.groovy.ast.MethodNode |
weaveNewMethod(org.codehaus.groovy.control.SourceUnit sourceUnit, org.codehaus.groovy.ast.AnnotationNode annotationNode, org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.ast.MethodNode methodNode, java.util.Map<java.lang.String, org.codehaus.groovy.ast.ClassNode> genericsSpec) Weaves a new method |
|
protected void |
weaveTestSetupMethod(org.codehaus.groovy.control.SourceUnit sourceUnit, org.codehaus.groovy.ast.AnnotationNode annotationNode, org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.ast.MethodNode methodNode, java.util.Map<java.lang.String, org.codehaus.groovy.ast.ClassNode> genericsSpec) |
Methods inherited from class | Name |
---|---|
class AbstractGormASTTransformation |
getAnnotationType, getAppliedMarker, isValidAnnotation, visit, visit |
Key used to store within the original method node metadata, all previous decorated methods
Builds the delegating method call for the given class node
sourceUnit
- The source unitannotationNode
- The annotation nodeclassNode
- The class nodemethodNode
- The original method nodeoriginalMethodCallExpr
- The method call expression that invokes the original logicnewMethodBody
- The new method bodyAdd any additional logic to enhance the class node
sourceUnit
- The source unitannotationNode
- The annotation nodeclassNode
- The class nodeConstruct a method call that wraps an original call with a closure invocation
targetObject
- The target objectexecuteMethodName
- The method that accepts a closureclosureParameters
- The parameters for the closureoriginalMethodCall
- The original method call to delegate toConstruct a method call that wraps an original call with a closure invocation
targetObject
- The target objectexecuteMethodName
- The method that accepts a closureclosureParameters
- The parameters for the closureoriginalMethodCall
- The original method call to delegate toWeaves a new method
sourceUnit
- The source unitannotationNode
- The annotation nodeclassNode
- The class nodemethodNode
- The original method that will delete to the new method