Class GrailsASTUtils


  • public class GrailsASTUtils
    extends java.lang.Object
    Helper methods for working with Groovy AST trees.
    Since:
    0.3
    • Constructor Summary

      Constructors 
      Constructor Description
      GrailsASTUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void addAnnotationIfNecessary​(org.codehaus.groovy.ast.ClassNode classNode, java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)
      Adds an annotation to the give nclass node if it doesn't already exist
      static org.codehaus.groovy.ast.AnnotationNode addAnnotationOrGetExisting​(org.codehaus.groovy.ast.ClassNode classNode, java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)
      Adds an annotation to the given class node or returns the existing annotation
      static org.codehaus.groovy.ast.AnnotationNode addAnnotationOrGetExisting​(org.codehaus.groovy.ast.ClassNode classNode, java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass, java.util.Map<java.lang.String,​java.lang.Object> members)
      Adds an annotation to the given class node or returns the existing annotation
      static org.codehaus.groovy.ast.AnnotationNode addAnnotationOrGetExisting​(org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.ast.ClassNode annotationClassNode)  
      static org.codehaus.groovy.ast.AnnotationNode addAnnotationOrGetExisting​(org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.ast.ClassNode annotationClassNode, java.util.Map<java.lang.String,​java.lang.Object> members)  
      static org.codehaus.groovy.ast.AnnotatedNode addCompileStaticAnnotation​(org.codehaus.groovy.ast.AnnotatedNode annotatedNode)
      Marks a method to be staticly compiled
      static org.codehaus.groovy.ast.AnnotatedNode addCompileStaticAnnotation​(org.codehaus.groovy.ast.AnnotatedNode annotatedNode, boolean skip)
      Adds @CompileStatic annotation to method
      static org.codehaus.groovy.ast.ConstructorNode addDelegateConstructor​(org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.ast.MethodNode constructorMethod, java.util.Map<java.lang.String,​org.codehaus.groovy.ast.ClassNode> genericsPlaceholders)
      Adds or modifies an existing constructor to delegate to the given static constructor method for initialization logic.
      static org.codehaus.groovy.ast.MethodNode addDelegateInstanceMethod​(org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.ast.expr.Expression delegate, org.codehaus.groovy.ast.MethodNode declaredMethod)
      Adds a delegate method to the target class node where the first argument is to the delegate method is 'this'.
      static org.codehaus.groovy.ast.MethodNode addDelegateInstanceMethod​(org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.ast.expr.Expression delegate, org.codehaus.groovy.ast.MethodNode declaredMethod, boolean thisAsFirstArgument)  
      static org.codehaus.groovy.ast.MethodNode addDelegateInstanceMethod​(org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.ast.expr.Expression delegate, org.codehaus.groovy.ast.MethodNode declaredMethod, org.codehaus.groovy.ast.AnnotationNode markerAnnotation)  
      static org.codehaus.groovy.ast.MethodNode addDelegateInstanceMethod​(org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.ast.expr.Expression delegate, org.codehaus.groovy.ast.MethodNode declaredMethod, org.codehaus.groovy.ast.AnnotationNode markerAnnotation, boolean thisAsFirstArgument)  
      static org.codehaus.groovy.ast.MethodNode addDelegateInstanceMethod​(org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.ast.expr.Expression delegate, org.codehaus.groovy.ast.MethodNode declaredMethod, org.codehaus.groovy.ast.AnnotationNode markerAnnotation, boolean thisAsFirstArgument, java.util.Map<java.lang.String,​org.codehaus.groovy.ast.ClassNode> genericsPlaceholders)  
      static org.codehaus.groovy.ast.MethodNode addDelegateInstanceMethod​(org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.ast.expr.Expression delegate, org.codehaus.groovy.ast.MethodNode declaredMethod, org.codehaus.groovy.ast.AnnotationNode markerAnnotation, boolean thisAsFirstArgument, java.util.Map<java.lang.String,​org.codehaus.groovy.ast.ClassNode> genericsPlaceholders, boolean noNullCheck)
      Adds a delegate method to the target class node where the first argument is to the delegate method is 'this'.
      static void addDelegateInstanceMethods​(org.codehaus.groovy.ast.ClassNode supportedSuperType, org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.ast.ClassNode delegateNode, org.codehaus.groovy.ast.expr.Expression delegateInstance)  
      static void addDelegateInstanceMethods​(org.codehaus.groovy.ast.ClassNode supportedSuperType, org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.ast.ClassNode delegateNode, org.codehaus.groovy.ast.expr.Expression delegateInstance, java.util.Map<java.lang.String,​org.codehaus.groovy.ast.ClassNode> genericsPlaceholders, boolean noNullCheck, boolean addCompileStatic)  
      static void addDelegateInstanceMethods​(org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.ast.ClassNode delegateNode, org.codehaus.groovy.ast.expr.Expression delegateInstance)  
      static void addDelegateInstanceMethods​(org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.ast.ClassNode delegateNode, org.codehaus.groovy.ast.expr.Expression delegateInstance, java.util.Map<java.lang.String,​org.codehaus.groovy.ast.ClassNode> genericsPlaceholders)  
      static org.codehaus.groovy.ast.MethodNode addDelegateStaticMethod​(org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.ast.MethodNode delegateMethod)
      Adds a static method call to given class node that delegates to the given method
      static org.codehaus.groovy.ast.MethodNode addDelegateStaticMethod​(org.codehaus.groovy.ast.expr.Expression expression, org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.ast.MethodNode delegateMethod)
      Adds a static method to the given class node that delegates to the given method and resolves the object to invoke the method on from the given expression.
      static org.codehaus.groovy.ast.MethodNode addDelegateStaticMethod​(org.codehaus.groovy.ast.expr.Expression delegate, org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.ast.MethodNode delegateMethod, org.codehaus.groovy.ast.AnnotationNode markerAnnotation, java.util.Map<java.lang.String,​org.codehaus.groovy.ast.ClassNode> genericsPlaceholders, boolean noNullCheck)
      Adds a static method to the given class node that delegates to the given method and resolves the object to invoke the method on from the given expression.
      static org.codehaus.groovy.ast.AnnotationNode addEnhancedAnnotation​(org.codehaus.groovy.ast.ClassNode classNode, java.lang.String... enhancedFor)
      Add the grails.artefact.Enhanced annotation to classNode if it does not already exist and ensure that all of the features in the enhancedFor array are represented in the enhancedFor attribute of the Enhanced annnotation
      static void addExpressionToAnnotationMember​(org.codehaus.groovy.ast.AnnotationNode annotationNode, java.lang.String memberName, org.codehaus.groovy.ast.expr.Expression expression)
      Adds the given expression as a member of the given annotation
      static org.codehaus.groovy.ast.FieldNode addFieldIfNonExistent​(org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.ast.ClassNode fieldType, java.lang.String fieldName)  
      static void addMethodIfNotPresent​(org.codehaus.groovy.ast.ClassNode controllerClassNode, org.codehaus.groovy.ast.MethodNode methodNode)  
      static org.codehaus.groovy.ast.expr.MethodCallExpression applyDefaultMethodTarget​(org.codehaus.groovy.ast.expr.MethodCallExpression methodCallExpression, java.lang.Class<?> targetClass)
      Set the method target of a MethodCallExpression to the first matching method with same number of arguments.
      static org.codehaus.groovy.ast.expr.MethodCallExpression applyDefaultMethodTarget​(org.codehaus.groovy.ast.expr.MethodCallExpression methodCallExpression, org.codehaus.groovy.ast.ClassNode targetClassNode)
      Set the method target of a MethodCallExpression to the first matching method with same number of arguments.
      static org.codehaus.groovy.ast.expr.MethodCallExpression applyImplicitThis​(org.codehaus.groovy.ast.expr.MethodCallExpression methodCallExpression, boolean useImplicitThis)  
      static org.codehaus.groovy.ast.expr.MethodCallExpression applyMethodTarget​(org.codehaus.groovy.ast.expr.MethodCallExpression methodCallExpression, java.lang.Class<?> targetClass, java.lang.Class<?>... targetParameterClassTypes)
      Set the method target of a MethodCallExpression to the first matching method with same number and type of arguments.
      static org.codehaus.groovy.ast.expr.MethodCallExpression applyMethodTarget​(org.codehaus.groovy.ast.expr.MethodCallExpression methodCallExpression, org.codehaus.groovy.ast.ClassNode targetClassNode, java.lang.Class<?>... targetParameterClassTypes)
      Set the method target of a MethodCallExpression to the first matching method with same number and type of arguments.
      static org.codehaus.groovy.ast.expr.MethodCallExpression applyMethodTarget​(org.codehaus.groovy.ast.expr.MethodCallExpression methodCallExpression, org.codehaus.groovy.ast.ClassNode targetClassNode, org.codehaus.groovy.ast.ClassNode... targetParameterTypes)
      Set the method target of a MethodCallExpression to the first matching method with same number and type of arguments.
      static org.codehaus.groovy.ast.expr.MethodCallExpression buildGetMapExpression​(org.codehaus.groovy.ast.expr.Expression objectExpression, java.lang.String keyName)
      Build static direct call to get entry from Map
      static org.codehaus.groovy.ast.expr.MethodCallExpression buildGetPropertyExpression​(org.codehaus.groovy.ast.expr.Expression objectExpression, java.lang.String propertyName, org.codehaus.groovy.ast.ClassNode targetClassNode)
      Build static direct call to getter of a property
      static org.codehaus.groovy.ast.expr.MethodCallExpression buildGetPropertyExpression​(org.codehaus.groovy.ast.expr.Expression objectExpression, java.lang.String propertyName, org.codehaus.groovy.ast.ClassNode targetClassNode, boolean useBooleanGetter)
      Build static direct call to getter of a property
      static org.codehaus.groovy.ast.expr.Expression buildGetThisObjectExpression​(boolean inClosureBlock)  
      static org.codehaus.groovy.ast.expr.MethodCallExpression buildPutMapExpression​(org.codehaus.groovy.ast.expr.Expression objectExpression, java.lang.String keyName, org.codehaus.groovy.ast.expr.Expression valueExpression)
      Build static direct call to put entry in Map
      static org.codehaus.groovy.ast.expr.MethodCallExpression buildSetPropertyExpression​(org.codehaus.groovy.ast.expr.Expression objectExpression, java.lang.String propertyName, org.codehaus.groovy.ast.ClassNode targetClassNode, org.codehaus.groovy.ast.expr.Expression valueExpression)
      Build static direct call to setter of a property
      static org.codehaus.groovy.ast.expr.Expression buildThisExpression()  
      static org.codehaus.groovy.ast.AnnotationNode cloneAnnotation​(org.codehaus.groovy.ast.AnnotationNode node)  
      static void copyAnnotations​(org.codehaus.groovy.ast.AnnotatedNode from, org.codehaus.groovy.ast.AnnotatedNode to)  
      static void copyAnnotations​(org.codehaus.groovy.ast.AnnotatedNode from, org.codehaus.groovy.ast.AnnotatedNode to, java.util.Set<java.lang.String> included, java.util.Set<java.lang.String> excluded)  
      static org.codehaus.groovy.ast.Parameter[] copyParameters​(org.codehaus.groovy.ast.Parameter[] parameterTypes)  
      static org.codehaus.groovy.ast.Parameter[] copyParameters​(org.codehaus.groovy.ast.Parameter[] parameterTypes, java.util.Map<java.lang.String,​org.codehaus.groovy.ast.ClassNode> genericsPlaceholders)  
      static org.codehaus.groovy.ast.expr.ArgumentListExpression createArgumentListFromParameters​(org.codehaus.groovy.ast.Parameter[] parameterTypes, boolean thisAsFirstArgument, java.util.Map<java.lang.String,​org.codehaus.groovy.ast.ClassNode> genericsPlaceholders)
      Creates an argument list from the given parameter types.
      static org.codehaus.groovy.ast.stmt.ExpressionStatement createPrintlnStatement​(java.lang.String message)  
      static org.codehaus.groovy.ast.stmt.ExpressionStatement createPrintlnStatement​(java.lang.String message, java.lang.String variable)  
      static void error​(org.codehaus.groovy.control.SourceUnit sourceUnit, org.codehaus.groovy.ast.ASTNode astNode, java.lang.String message)
      Generates a fatal compilation error.
      static void error​(org.codehaus.groovy.control.SourceUnit sourceUnit, org.codehaus.groovy.ast.ASTNode astNode, java.lang.String message, boolean fatal)
      Generates a fatal compilation error.
      static void filterAnnotations​(org.codehaus.groovy.ast.AnnotatedNode annotatedNode, java.util.Set<java.lang.String> classNamesToRetain, java.util.Set<java.lang.String> classNamesToRemove)  
      static org.codehaus.groovy.ast.AnnotationNode findAnnotation​(org.codehaus.groovy.ast.ClassNode classNode, java.lang.Class<?> type)  
      static org.codehaus.groovy.ast.AnnotationNode findAnnotation​(org.codehaus.groovy.ast.ClassNode annotationClassNode, java.util.List<org.codehaus.groovy.ast.AnnotationNode> annotations)  
      static org.codehaus.groovy.ast.ConstructorNode findConstructor​(org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.ast.Parameter[] constructorParams)
      Finds a constructor for the given class node and parameter types
      static org.codehaus.groovy.ast.ClassNode findInterface​(org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.ast.ClassNode interfaceNode)  
      static java.util.Map<java.lang.String,​org.codehaus.groovy.ast.ClassNode> getAllAssociationMap​(org.codehaus.groovy.ast.ClassNode classNode)  
      static java.util.Map<java.lang.String,​org.codehaus.groovy.ast.ClassNode> getAssocationMap​(org.codehaus.groovy.ast.ClassNode classNode, java.lang.String associationType)
      Returns a map containing the names and types of the given association type.
      static java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​org.codehaus.groovy.ast.expr.Expression>> getConstraintMetadata​(org.codehaus.groovy.ast.expr.ClosureExpression closureExpression)
      Evaluates a constraints closure and returns metadata about the constraints configured in the closure.
      static org.codehaus.groovy.ast.ConstructorNode getDefaultConstructor​(org.codehaus.groovy.ast.ClassNode classNode)
      Obtains the default constructor for the given class node.
      static java.lang.String getFullName​(org.codehaus.groovy.ast.ClassNode classNode)
      Gets the full name of a ClassNode.
      static org.codehaus.groovy.ast.ClassNode getFurthestParent​(org.codehaus.groovy.ast.ClassNode classNode)  
      static org.codehaus.groovy.ast.ClassNode getFurthestUnresolvedParent​(org.codehaus.groovy.ast.ClassNode classNode)  
      static org.codehaus.groovy.ast.Parameter[] getRemainingParameterTypes​(org.codehaus.groovy.ast.Parameter[] parameters)
      Gets the remaining parameters excluding the first parameter in the given list
      static java.net.URL getSourceUrl​(org.codehaus.groovy.ast.ClassNode classNode)  
      static java.net.URL getSourceUrl​(org.codehaus.groovy.control.SourceUnit source)
      Find URL of SourceUnit source.getSource().getURI() fails in Groovy-Eclipse compiler
      static boolean hasAnnotation​(org.codehaus.groovy.ast.ClassNode classNode, java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)
      Returns true if classNode is marked with annotationClass
      static boolean hasAnnotation​(org.codehaus.groovy.ast.MethodNode methodNode, java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)
      Returns true if MethodNode is marked with annotationClass
      static boolean hasAnyAnnotations​(org.codehaus.groovy.ast.ClassNode classNode, java.lang.Class<? extends java.lang.annotation.Annotation>... annotationsToLookFor)  
      static boolean hasOrInheritsProperty​(org.codehaus.groovy.ast.ClassNode classNode, java.lang.String propertyName)  
      static boolean hasParameters​(org.codehaus.groovy.ast.MethodNode methodNode)  
      static boolean hasProperty​(org.codehaus.groovy.ast.ClassNode classNode, java.lang.String propertyName)
      Returns whether a classNode has the specified property or not
      static boolean hasZeroArgsConstructor​(org.codehaus.groovy.ast.ClassNode implementationNode)  
      static boolean implementsOrInheritsZeroArgMethod​(org.codehaus.groovy.ast.ClassNode classNode, java.lang.String methodName, java.util.List ignoreClasses)  
      static boolean implementsZeroArgMethod​(org.codehaus.groovy.ast.ClassNode classNode, java.lang.String methodName)
      Tests whether the ClasNode implements the specified method name.
      static boolean isApplied​(org.codehaus.groovy.ast.ASTNode astNode, java.lang.Class<?> transformationClass)  
      static boolean isAssignableFrom​(org.codehaus.groovy.ast.ClassNode superClass, org.codehaus.groovy.ast.ClassNode childClass)
      Determines if the class or interface represented by the superClass argument is either the same as, or is a superclass or superinterface of, the class or interface represented by the specified subClass parameter.
      static boolean isCandidateInstanceMethod​(org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.ast.MethodNode declaredMethod)  
      static boolean isCandidateMethod​(org.codehaus.groovy.ast.MethodNode declaredMethod)  
      static boolean isConstructorMethod​(org.codehaus.groovy.ast.MethodNode declaredMethod)  
      static boolean isDomainClass​(org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.control.SourceUnit sourceNode)  
      static boolean isGetterMethod​(org.codehaus.groovy.ast.MethodNode md)  
      static boolean isInheritedFromTrait​(org.codehaus.groovy.ast.MethodNode methodNode)  
      static boolean isInnerClassNode​(org.codehaus.groovy.ast.ClassNode classNode)
      Whether the given class node is an inner class
      static boolean isSetterMethod​(org.codehaus.groovy.ast.MethodNode md)  
      static boolean isSetterOrGetterMethod​(org.codehaus.groovy.ast.MethodNode md)  
      static boolean isSubclassOf​(org.codehaus.groovy.ast.ClassNode classNode, java.lang.String parentClassName)
      Returns true if the given class name is a parent class of the given class
      static boolean isSubclassOfOrImplementsInterface​(org.codehaus.groovy.ast.ClassNode childClass, java.lang.String superClassName)  
      static boolean isSubclassOfOrImplementsInterface​(org.codehaus.groovy.ast.ClassNode childClass, org.codehaus.groovy.ast.ClassNode superClass)  
      static void markApplied​(org.codehaus.groovy.ast.ASTNode astNode, java.lang.Class<?> transformationClass)  
      static org.codehaus.groovy.ast.expr.MethodCallExpression noImplicitThis​(org.codehaus.groovy.ast.expr.MethodCallExpression methodCallExpression)  
      static org.codehaus.groovy.ast.ClassNode nonGeneric​(org.codehaus.groovy.ast.ClassNode type)  
      static org.codehaus.groovy.ast.ClassNode nonGeneric​(org.codehaus.groovy.ast.ClassNode type, org.codehaus.groovy.ast.ClassNode wildcardReplacement)  
      static boolean parametersEqual​(org.codehaus.groovy.ast.Parameter[] a, org.codehaus.groovy.ast.Parameter[] b)  
      static void processVariableScopes​(org.codehaus.groovy.control.SourceUnit source, org.codehaus.groovy.ast.ClassNode classNode)  
      static void processVariableScopes​(org.codehaus.groovy.control.SourceUnit source, org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.ast.MethodNode methodNode)  
      static boolean removeAnnotation​(org.codehaus.groovy.ast.MethodNode methodNode, java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)  
      static void removeCompileStaticAnnotations​(org.codehaus.groovy.ast.AnnotatedNode annotatedNode)  
      static org.codehaus.groovy.ast.ClassNode replaceGenericsPlaceholders​(org.codehaus.groovy.ast.ClassNode type, java.util.Map<java.lang.String,​org.codehaus.groovy.ast.ClassNode> genericsPlaceholders)  
      static org.codehaus.groovy.ast.ClassNode replaceGenericsPlaceholders​(org.codehaus.groovy.ast.ClassNode type, java.util.Map<java.lang.String,​org.codehaus.groovy.ast.ClassNode> genericsPlaceholders, org.codehaus.groovy.ast.ClassNode defaultPlaceholder)  
      static void warning​(org.codehaus.groovy.control.SourceUnit sourceUnit, org.codehaus.groovy.ast.ASTNode node, java.lang.String warningMessage)  
      static void wrapMethodBodyInTryCatchDebugStatements​(org.codehaus.groovy.ast.MethodNode methodNode)
      Wraps a method body in try / catch logic that catches any errors and logs an error, but does not rethrow!
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • METHOD_MISSING_METHOD_NAME

        public static final java.lang.String METHOD_MISSING_METHOD_NAME
        See Also:
        Constant Field Values
      • STATIC_METHOD_MISSING_METHOD_NAME

        public static final java.lang.String STATIC_METHOD_MISSING_METHOD_NAME
        See Also:
        Constant Field Values
      • EQUALS_OPERATOR

        public static final org.codehaus.groovy.syntax.Token EQUALS_OPERATOR
      • LOGICAL_AND_OPERATOR

        public static final org.codehaus.groovy.syntax.Token LOGICAL_AND_OPERATOR
      • NOT_EQUALS_OPERATOR

        public static final org.codehaus.groovy.syntax.Token NOT_EQUALS_OPERATOR
      • MISSING_METHOD_EXCEPTION

        public static final org.codehaus.groovy.ast.ClassNode MISSING_METHOD_EXCEPTION
      • NULL_EXPRESSION

        public static final org.codehaus.groovy.ast.expr.ConstantExpression NULL_EXPRESSION
      • ASSIGNMENT_OPERATOR

        public static final org.codehaus.groovy.syntax.Token ASSIGNMENT_OPERATOR
      • OBJECT_CLASS_NODE

        public static final org.codehaus.groovy.ast.ClassNode OBJECT_CLASS_NODE
      • VOID_CLASS_NODE

        public static final org.codehaus.groovy.ast.ClassNode VOID_CLASS_NODE
      • INTEGER_CLASS_NODE

        public static final org.codehaus.groovy.ast.ClassNode INTEGER_CLASS_NODE
      • ZERO_PARAMETERS

        public static final org.codehaus.groovy.ast.Parameter[] ZERO_PARAMETERS
      • ZERO_ARGUMENTS

        public static final org.codehaus.groovy.ast.expr.ArgumentListExpression ZERO_ARGUMENTS
    • Constructor Detail

      • GrailsASTUtils

        public GrailsASTUtils()
    • Method Detail

      • warning

        public static void warning​(org.codehaus.groovy.control.SourceUnit sourceUnit,
                                   org.codehaus.groovy.ast.ASTNode node,
                                   java.lang.String warningMessage)
      • error

        public static void error​(org.codehaus.groovy.control.SourceUnit sourceUnit,
                                 org.codehaus.groovy.ast.ASTNode astNode,
                                 java.lang.String message)
        Generates a fatal compilation error.
        Parameters:
        sourceUnit - the SourceUnit
        astNode - the ASTNode which caused the error
        message - The error message
      • error

        public static void error​(org.codehaus.groovy.control.SourceUnit sourceUnit,
                                 org.codehaus.groovy.ast.ASTNode astNode,
                                 java.lang.String message,
                                 boolean fatal)
        Generates a fatal compilation error.
        Parameters:
        sourceUnit - the SourceUnit
        astNode - the ASTNode which caused the error
        message - The error message
        fatal - indicates if this is a fatal error
      • hasProperty

        public static boolean hasProperty​(org.codehaus.groovy.ast.ClassNode classNode,
                                          java.lang.String propertyName)
        Returns whether a classNode has the specified property or not
        Parameters:
        classNode - The ClassNode
        propertyName - The name of the property
        Returns:
        true if the property exists in the ClassNode
      • hasOrInheritsProperty

        public static boolean hasOrInheritsProperty​(org.codehaus.groovy.ast.ClassNode classNode,
                                                    java.lang.String propertyName)
      • implementsZeroArgMethod

        public static boolean implementsZeroArgMethod​(org.codehaus.groovy.ast.ClassNode classNode,
                                                      java.lang.String methodName)
        Tests whether the ClasNode implements the specified method name.
        Parameters:
        classNode - The ClassNode
        methodName - The method name
        Returns:
        true if it does implement the method
      • implementsOrInheritsZeroArgMethod

        public static boolean implementsOrInheritsZeroArgMethod​(org.codehaus.groovy.ast.ClassNode classNode,
                                                                java.lang.String methodName,
                                                                java.util.List ignoreClasses)
      • getFullName

        public static java.lang.String getFullName​(org.codehaus.groovy.ast.ClassNode classNode)
        Gets the full name of a ClassNode.
        Parameters:
        classNode - The class node
        Returns:
        The full name
      • getFurthestParent

        public static org.codehaus.groovy.ast.ClassNode getFurthestParent​(org.codehaus.groovy.ast.ClassNode classNode)
      • getFurthestUnresolvedParent

        public static org.codehaus.groovy.ast.ClassNode getFurthestUnresolvedParent​(org.codehaus.groovy.ast.ClassNode classNode)
      • addDelegateInstanceMethod

        public static org.codehaus.groovy.ast.MethodNode addDelegateInstanceMethod​(org.codehaus.groovy.ast.ClassNode classNode,
                                                                                   org.codehaus.groovy.ast.expr.Expression delegate,
                                                                                   org.codehaus.groovy.ast.MethodNode declaredMethod)
        Adds a delegate method to the target class node where the first argument is to the delegate method is 'this'. In other words a method such as foo(Object instance, String bar) would be added with a signature of foo(String) and 'this' is passed to the delegate instance
        Parameters:
        classNode - The class node
        delegate - The expression that looks up the delegate
        declaredMethod - The declared method
        Returns:
        The added method node or null if it couldn't be added
      • addDelegateInstanceMethod

        public static org.codehaus.groovy.ast.MethodNode addDelegateInstanceMethod​(org.codehaus.groovy.ast.ClassNode classNode,
                                                                                   org.codehaus.groovy.ast.expr.Expression delegate,
                                                                                   org.codehaus.groovy.ast.MethodNode declaredMethod,
                                                                                   org.codehaus.groovy.ast.AnnotationNode markerAnnotation)
      • addDelegateInstanceMethod

        public static org.codehaus.groovy.ast.MethodNode addDelegateInstanceMethod​(org.codehaus.groovy.ast.ClassNode classNode,
                                                                                   org.codehaus.groovy.ast.expr.Expression delegate,
                                                                                   org.codehaus.groovy.ast.MethodNode declaredMethod,
                                                                                   boolean thisAsFirstArgument)
      • addDelegateInstanceMethod

        public static org.codehaus.groovy.ast.MethodNode addDelegateInstanceMethod​(org.codehaus.groovy.ast.ClassNode classNode,
                                                                                   org.codehaus.groovy.ast.expr.Expression delegate,
                                                                                   org.codehaus.groovy.ast.MethodNode declaredMethod,
                                                                                   org.codehaus.groovy.ast.AnnotationNode markerAnnotation,
                                                                                   boolean thisAsFirstArgument)
      • addDelegateInstanceMethod

        public static org.codehaus.groovy.ast.MethodNode addDelegateInstanceMethod​(org.codehaus.groovy.ast.ClassNode classNode,
                                                                                   org.codehaus.groovy.ast.expr.Expression delegate,
                                                                                   org.codehaus.groovy.ast.MethodNode declaredMethod,
                                                                                   org.codehaus.groovy.ast.AnnotationNode markerAnnotation,
                                                                                   boolean thisAsFirstArgument,
                                                                                   java.util.Map<java.lang.String,​org.codehaus.groovy.ast.ClassNode> genericsPlaceholders)
      • addDelegateInstanceMethod

        public static org.codehaus.groovy.ast.MethodNode addDelegateInstanceMethod​(org.codehaus.groovy.ast.ClassNode classNode,
                                                                                   org.codehaus.groovy.ast.expr.Expression delegate,
                                                                                   org.codehaus.groovy.ast.MethodNode declaredMethod,
                                                                                   org.codehaus.groovy.ast.AnnotationNode markerAnnotation,
                                                                                   boolean thisAsFirstArgument,
                                                                                   java.util.Map<java.lang.String,​org.codehaus.groovy.ast.ClassNode> genericsPlaceholders,
                                                                                   boolean noNullCheck)
        Adds a delegate method to the target class node where the first argument is to the delegate method is 'this'. In other words a method such as foo(Object instance, String bar) would be added with a signature of foo(String) and 'this' is passed to the delegate instance
        Parameters:
        classNode - The class node
        delegate - The expression that looks up the delegate
        declaredMethod - The declared method
        thisAsFirstArgument - Whether 'this' should be passed as the first argument to the method
        Returns:
        The added method node or null if it couldn't be added
      • createArgumentListFromParameters

        public static org.codehaus.groovy.ast.expr.ArgumentListExpression createArgumentListFromParameters​(org.codehaus.groovy.ast.Parameter[] parameterTypes,
                                                                                                           boolean thisAsFirstArgument,
                                                                                                           java.util.Map<java.lang.String,​org.codehaus.groovy.ast.ClassNode> genericsPlaceholders)
        Creates an argument list from the given parameter types.
        Parameters:
        parameterTypes - The parameter types
        thisAsFirstArgument - Whether to include a reference to 'this' as the first argument
        genericsPlaceholders -
        Returns:
        the arguments
      • getRemainingParameterTypes

        public static org.codehaus.groovy.ast.Parameter[] getRemainingParameterTypes​(org.codehaus.groovy.ast.Parameter[] parameters)
        Gets the remaining parameters excluding the first parameter in the given list
        Parameters:
        parameters - The parameters
        Returns:
        A new array with the first parameter removed
      • addDelegateStaticMethod

        public static org.codehaus.groovy.ast.MethodNode addDelegateStaticMethod​(org.codehaus.groovy.ast.ClassNode classNode,
                                                                                 org.codehaus.groovy.ast.MethodNode delegateMethod)
        Adds a static method call to given class node that delegates to the given method
        Parameters:
        classNode - The class node
        delegateMethod - The delegate method
        Returns:
        The added method node or null if it couldn't be added
      • addDelegateStaticMethod

        public static org.codehaus.groovy.ast.MethodNode addDelegateStaticMethod​(org.codehaus.groovy.ast.expr.Expression expression,
                                                                                 org.codehaus.groovy.ast.ClassNode classNode,
                                                                                 org.codehaus.groovy.ast.MethodNode delegateMethod)
        Adds a static method to the given class node that delegates to the given method and resolves the object to invoke the method on from the given expression.
        Parameters:
        expression - The expression
        classNode - The class node
        delegateMethod - The delegate method
        Returns:
        The added method node or null if it couldn't be added
      • addDelegateStaticMethod

        public static org.codehaus.groovy.ast.MethodNode addDelegateStaticMethod​(org.codehaus.groovy.ast.expr.Expression delegate,
                                                                                 org.codehaus.groovy.ast.ClassNode classNode,
                                                                                 org.codehaus.groovy.ast.MethodNode delegateMethod,
                                                                                 org.codehaus.groovy.ast.AnnotationNode markerAnnotation,
                                                                                 java.util.Map<java.lang.String,​org.codehaus.groovy.ast.ClassNode> genericsPlaceholders,
                                                                                 boolean noNullCheck)
        Adds a static method to the given class node that delegates to the given method and resolves the object to invoke the method on from the given expression.
        Parameters:
        delegate - The expression
        classNode - The class node
        delegateMethod - The delegate method
        markerAnnotation - A marker annotation to be added to all methods
        Returns:
        The added method node or null if it couldn't be added
      • addDelegateConstructor

        public static org.codehaus.groovy.ast.ConstructorNode addDelegateConstructor​(org.codehaus.groovy.ast.ClassNode classNode,
                                                                                     org.codehaus.groovy.ast.MethodNode constructorMethod,
                                                                                     java.util.Map<java.lang.String,​org.codehaus.groovy.ast.ClassNode> genericsPlaceholders)
        Adds or modifies an existing constructor to delegate to the given static constructor method for initialization logic.
        Parameters:
        classNode - The class node
        constructorMethod - The constructor static method
      • findConstructor

        public static org.codehaus.groovy.ast.ConstructorNode findConstructor​(org.codehaus.groovy.ast.ClassNode classNode,
                                                                              org.codehaus.groovy.ast.Parameter[] constructorParams)
        Finds a constructor for the given class node and parameter types
        Parameters:
        classNode - The class node
        constructorParams - The parameter types
        Returns:
        The located constructor or null
      • parametersEqual

        public static boolean parametersEqual​(org.codehaus.groovy.ast.Parameter[] a,
                                              org.codehaus.groovy.ast.Parameter[] b)
        Returns:
        true if the two arrays are of the same size and have the same contents
      • getDefaultConstructor

        public static org.codehaus.groovy.ast.ConstructorNode getDefaultConstructor​(org.codehaus.groovy.ast.ClassNode classNode)
        Obtains the default constructor for the given class node.
        Parameters:
        classNode - The class node
        Returns:
        The default constructor or null if there isn't one
      • copyParameters

        public static org.codehaus.groovy.ast.Parameter[] copyParameters​(org.codehaus.groovy.ast.Parameter[] parameterTypes)
      • copyParameters

        public static org.codehaus.groovy.ast.Parameter[] copyParameters​(org.codehaus.groovy.ast.Parameter[] parameterTypes,
                                                                         java.util.Map<java.lang.String,​org.codehaus.groovy.ast.ClassNode> genericsPlaceholders)
      • nonGeneric

        public static org.codehaus.groovy.ast.ClassNode nonGeneric​(org.codehaus.groovy.ast.ClassNode type)
      • nonGeneric

        public static org.codehaus.groovy.ast.ClassNode nonGeneric​(org.codehaus.groovy.ast.ClassNode type,
                                                                   org.codehaus.groovy.ast.ClassNode wildcardReplacement)
      • replaceGenericsPlaceholders

        public static org.codehaus.groovy.ast.ClassNode replaceGenericsPlaceholders​(org.codehaus.groovy.ast.ClassNode type,
                                                                                    java.util.Map<java.lang.String,​org.codehaus.groovy.ast.ClassNode> genericsPlaceholders)
      • replaceGenericsPlaceholders

        public static org.codehaus.groovy.ast.ClassNode replaceGenericsPlaceholders​(org.codehaus.groovy.ast.ClassNode type,
                                                                                    java.util.Map<java.lang.String,​org.codehaus.groovy.ast.ClassNode> genericsPlaceholders,
                                                                                    org.codehaus.groovy.ast.ClassNode defaultPlaceholder)
      • isCandidateInstanceMethod

        public static boolean isCandidateInstanceMethod​(org.codehaus.groovy.ast.ClassNode classNode,
                                                        org.codehaus.groovy.ast.MethodNode declaredMethod)
      • isAssignableFrom

        public static boolean isAssignableFrom​(org.codehaus.groovy.ast.ClassNode superClass,
                                               org.codehaus.groovy.ast.ClassNode childClass)
        Determines if the class or interface represented by the superClass argument is either the same as, or is a superclass or superinterface of, the class or interface represented by the specified subClass parameter.
        Parameters:
        superClass - The super class to check
        childClass - The sub class the check
        Returns:
        true if the childClass is either equal to or a sub class of the specified superClass
      • isSubclassOfOrImplementsInterface

        public static boolean isSubclassOfOrImplementsInterface​(org.codehaus.groovy.ast.ClassNode childClass,
                                                                org.codehaus.groovy.ast.ClassNode superClass)
      • isSubclassOfOrImplementsInterface

        public static boolean isSubclassOfOrImplementsInterface​(org.codehaus.groovy.ast.ClassNode childClass,
                                                                java.lang.String superClassName)
      • isCandidateMethod

        public static boolean isCandidateMethod​(org.codehaus.groovy.ast.MethodNode declaredMethod)
      • isConstructorMethod

        public static boolean isConstructorMethod​(org.codehaus.groovy.ast.MethodNode declaredMethod)
      • isDomainClass

        public static boolean isDomainClass​(org.codehaus.groovy.ast.ClassNode classNode,
                                            org.codehaus.groovy.control.SourceUnit sourceNode)
      • addDelegateInstanceMethods

        public static void addDelegateInstanceMethods​(org.codehaus.groovy.ast.ClassNode classNode,
                                                      org.codehaus.groovy.ast.ClassNode delegateNode,
                                                      org.codehaus.groovy.ast.expr.Expression delegateInstance)
      • addDelegateInstanceMethods

        public static void addDelegateInstanceMethods​(org.codehaus.groovy.ast.ClassNode classNode,
                                                      org.codehaus.groovy.ast.ClassNode delegateNode,
                                                      org.codehaus.groovy.ast.expr.Expression delegateInstance,
                                                      java.util.Map<java.lang.String,​org.codehaus.groovy.ast.ClassNode> genericsPlaceholders)
      • addDelegateInstanceMethods

        public static void addDelegateInstanceMethods​(org.codehaus.groovy.ast.ClassNode supportedSuperType,
                                                      org.codehaus.groovy.ast.ClassNode classNode,
                                                      org.codehaus.groovy.ast.ClassNode delegateNode,
                                                      org.codehaus.groovy.ast.expr.Expression delegateInstance)
      • addDelegateInstanceMethods

        public static void addDelegateInstanceMethods​(org.codehaus.groovy.ast.ClassNode supportedSuperType,
                                                      org.codehaus.groovy.ast.ClassNode classNode,
                                                      org.codehaus.groovy.ast.ClassNode delegateNode,
                                                      org.codehaus.groovy.ast.expr.Expression delegateInstance,
                                                      java.util.Map<java.lang.String,​org.codehaus.groovy.ast.ClassNode> genericsPlaceholders,
                                                      boolean noNullCheck,
                                                      boolean addCompileStatic)
      • addFieldIfNonExistent

        public static org.codehaus.groovy.ast.FieldNode addFieldIfNonExistent​(org.codehaus.groovy.ast.ClassNode classNode,
                                                                              org.codehaus.groovy.ast.ClassNode fieldType,
                                                                              java.lang.String fieldName)
      • addExpressionToAnnotationMember

        public static void addExpressionToAnnotationMember​(org.codehaus.groovy.ast.AnnotationNode annotationNode,
                                                           java.lang.String memberName,
                                                           org.codehaus.groovy.ast.expr.Expression expression)
        Adds the given expression as a member of the given annotation
        Parameters:
        annotationNode - The annotation node
        memberName - The name of the member
        expression - The expression
      • addAnnotationIfNecessary

        public static void addAnnotationIfNecessary​(org.codehaus.groovy.ast.ClassNode classNode,
                                                    java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)
        Adds an annotation to the give nclass node if it doesn't already exist
        Parameters:
        classNode - The class node
        annotationClass - The annotation class
      • addAnnotationOrGetExisting

        public static org.codehaus.groovy.ast.AnnotationNode addAnnotationOrGetExisting​(org.codehaus.groovy.ast.ClassNode classNode,
                                                                                        java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)
        Adds an annotation to the given class node or returns the existing annotation
        Parameters:
        classNode - The class node
        annotationClass - The annotation class
      • addAnnotationOrGetExisting

        public static org.codehaus.groovy.ast.AnnotationNode addAnnotationOrGetExisting​(org.codehaus.groovy.ast.ClassNode classNode,
                                                                                        java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass,
                                                                                        java.util.Map<java.lang.String,​java.lang.Object> members)
        Adds an annotation to the given class node or returns the existing annotation
        Parameters:
        classNode - The class node
        annotationClass - The annotation class
      • addAnnotationOrGetExisting

        public static org.codehaus.groovy.ast.AnnotationNode addAnnotationOrGetExisting​(org.codehaus.groovy.ast.ClassNode classNode,
                                                                                        org.codehaus.groovy.ast.ClassNode annotationClassNode)
      • addAnnotationOrGetExisting

        public static org.codehaus.groovy.ast.AnnotationNode addAnnotationOrGetExisting​(org.codehaus.groovy.ast.ClassNode classNode,
                                                                                        org.codehaus.groovy.ast.ClassNode annotationClassNode,
                                                                                        java.util.Map<java.lang.String,​java.lang.Object> members)
      • addEnhancedAnnotation

        public static org.codehaus.groovy.ast.AnnotationNode addEnhancedAnnotation​(org.codehaus.groovy.ast.ClassNode classNode,
                                                                                   java.lang.String... enhancedFor)
        Add the grails.artefact.Enhanced annotation to classNode if it does not already exist and ensure that all of the features in the enhancedFor array are represented in the enhancedFor attribute of the Enhanced annnotation
        Parameters:
        classNode - the class to add the Enhanced annotation to
        enhancedFor - an array of feature names to include in the enhancedFor attribute of the annotation
        Returns:
        the AnnotationNode associated with the Enhanced annotation for classNode
        See Also:
        Enhanced
      • findAnnotation

        public static org.codehaus.groovy.ast.AnnotationNode findAnnotation​(org.codehaus.groovy.ast.ClassNode annotationClassNode,
                                                                            java.util.List<org.codehaus.groovy.ast.AnnotationNode> annotations)
      • findAnnotation

        public static org.codehaus.groovy.ast.AnnotationNode findAnnotation​(org.codehaus.groovy.ast.ClassNode classNode,
                                                                            java.lang.Class<?> type)
      • hasAnnotation

        public static boolean hasAnnotation​(org.codehaus.groovy.ast.ClassNode classNode,
                                            java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)
        Returns true if classNode is marked with annotationClass
        Parameters:
        classNode - A ClassNode to inspect
        annotationClass - an annotation to look for
        Returns:
        true if classNode is marked with annotationClass, otherwise false
      • hasAnnotation

        public static boolean hasAnnotation​(org.codehaus.groovy.ast.MethodNode methodNode,
                                            java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)
        Returns true if MethodNode is marked with annotationClass
        Parameters:
        methodNode - A MethodNode to inspect
        annotationClass - an annotation to look for
        Returns:
        true if classNode is marked with annotationClass, otherwise false
      • hasAnyAnnotations

        public static boolean hasAnyAnnotations​(org.codehaus.groovy.ast.ClassNode classNode,
                                                java.lang.Class<? extends java.lang.annotation.Annotation>... annotationsToLookFor)
        Parameters:
        classNode - a ClassNode to search
        annotationsToLookFor - Annotations to look for
        Returns:
        true if classNode is marked with any of the annotations in annotationsToLookFor
      • removeAnnotation

        public static boolean removeAnnotation​(org.codehaus.groovy.ast.MethodNode methodNode,
                                               java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)
      • addMethodIfNotPresent

        public static void addMethodIfNotPresent​(org.codehaus.groovy.ast.ClassNode controllerClassNode,
                                                 org.codehaus.groovy.ast.MethodNode methodNode)
      • createPrintlnStatement

        public static org.codehaus.groovy.ast.stmt.ExpressionStatement createPrintlnStatement​(java.lang.String message)
      • createPrintlnStatement

        public static org.codehaus.groovy.ast.stmt.ExpressionStatement createPrintlnStatement​(java.lang.String message,
                                                                                              java.lang.String variable)
      • wrapMethodBodyInTryCatchDebugStatements

        public static void wrapMethodBodyInTryCatchDebugStatements​(org.codehaus.groovy.ast.MethodNode methodNode)
        Wraps a method body in try / catch logic that catches any errors and logs an error, but does not rethrow!
        Parameters:
        methodNode - The method node
      • getConstraintMetadata

        public static java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​org.codehaus.groovy.ast.expr.Expression>> getConstraintMetadata​(org.codehaus.groovy.ast.expr.ClosureExpression closureExpression)
        Evaluates a constraints closure and returns metadata about the constraints configured in the closure. The Map returned has property names as keys and the value associated with each of those property names is a Map which has constraint names as keys and the Expression associated with that constraint as values.
        Parameters:
        closureExpression - the closure expression to evaluate
        Returns:
        the Map as described above
      • getAssocationMap

        public static java.util.Map<java.lang.String,​org.codehaus.groovy.ast.ClassNode> getAssocationMap​(org.codehaus.groovy.ast.ClassNode classNode,
                                                                                                               java.lang.String associationType)
        Returns a map containing the names and types of the given association type. eg. GrailsDomainClassProperty.HAS_MANY
        Parameters:
        classNode - The target class ndoe
        associationType - The associationType
        Returns:
        A map
      • getAllAssociationMap

        public static java.util.Map<java.lang.String,​org.codehaus.groovy.ast.ClassNode> getAllAssociationMap​(org.codehaus.groovy.ast.ClassNode classNode)
      • findInterface

        public static org.codehaus.groovy.ast.ClassNode findInterface​(org.codehaus.groovy.ast.ClassNode classNode,
                                                                      org.codehaus.groovy.ast.ClassNode interfaceNode)
      • hasZeroArgsConstructor

        public static boolean hasZeroArgsConstructor​(org.codehaus.groovy.ast.ClassNode implementationNode)
      • isInnerClassNode

        public static boolean isInnerClassNode​(org.codehaus.groovy.ast.ClassNode classNode)
        Whether the given class node is an inner class
        Parameters:
        classNode - The class node
        Returns:
        True if it is
      • isSubclassOf

        public static boolean isSubclassOf​(org.codehaus.groovy.ast.ClassNode classNode,
                                           java.lang.String parentClassName)
        Returns true if the given class name is a parent class of the given class
        Parameters:
        classNode - The class node
        parentClassName - the parent class name
        Returns:
        True if it is a subclass
      • addCompileStaticAnnotation

        public static org.codehaus.groovy.ast.AnnotatedNode addCompileStaticAnnotation​(org.codehaus.groovy.ast.AnnotatedNode annotatedNode)
        Marks a method to be staticly compiled
        Parameters:
        annotatedNode -
        Returns:
        The annotated method
      • addCompileStaticAnnotation

        public static org.codehaus.groovy.ast.AnnotatedNode addCompileStaticAnnotation​(org.codehaus.groovy.ast.AnnotatedNode annotatedNode,
                                                                                       boolean skip)
        Adds @CompileStatic annotation to method
        Parameters:
        annotatedNode -
        skip -
        Returns:
        The annotated method
      • applyDefaultMethodTarget

        public static org.codehaus.groovy.ast.expr.MethodCallExpression applyDefaultMethodTarget​(org.codehaus.groovy.ast.expr.MethodCallExpression methodCallExpression,
                                                                                                 org.codehaus.groovy.ast.ClassNode targetClassNode)
        Set the method target of a MethodCallExpression to the first matching method with same number of arguments. This doesn't check argument types.
        Parameters:
        methodCallExpression -
        targetClassNode -
      • applyDefaultMethodTarget

        public static org.codehaus.groovy.ast.expr.MethodCallExpression applyDefaultMethodTarget​(org.codehaus.groovy.ast.expr.MethodCallExpression methodCallExpression,
                                                                                                 java.lang.Class<?> targetClass)
        Set the method target of a MethodCallExpression to the first matching method with same number of arguments. This doesn't check argument types.
        Parameters:
        methodCallExpression -
        targetClass -
        Returns:
        The method call expression
      • applyMethodTarget

        public static org.codehaus.groovy.ast.expr.MethodCallExpression applyMethodTarget​(org.codehaus.groovy.ast.expr.MethodCallExpression methodCallExpression,
                                                                                          org.codehaus.groovy.ast.ClassNode targetClassNode,
                                                                                          org.codehaus.groovy.ast.ClassNode... targetParameterTypes)
        Set the method target of a MethodCallExpression to the first matching method with same number and type of arguments. A null parameter type will match any type
        Parameters:
        methodCallExpression -
        targetClassNode -
        targetParameterTypes -
        Returns:
        The method call expression
      • applyMethodTarget

        public static org.codehaus.groovy.ast.expr.MethodCallExpression applyMethodTarget​(org.codehaus.groovy.ast.expr.MethodCallExpression methodCallExpression,
                                                                                          java.lang.Class<?> targetClass,
                                                                                          java.lang.Class<?>... targetParameterClassTypes)
        Set the method target of a MethodCallExpression to the first matching method with same number and type of arguments.
        Parameters:
        methodCallExpression -
        targetClass -
        targetParameterClassTypes -
        Returns:
        The method call expression
      • applyMethodTarget

        public static org.codehaus.groovy.ast.expr.MethodCallExpression applyMethodTarget​(org.codehaus.groovy.ast.expr.MethodCallExpression methodCallExpression,
                                                                                          org.codehaus.groovy.ast.ClassNode targetClassNode,
                                                                                          java.lang.Class<?>... targetParameterClassTypes)
        Set the method target of a MethodCallExpression to the first matching method with same number and type of arguments.
        Parameters:
        methodCallExpression -
        targetClassNode -
        targetParameterClassTypes -
        Returns:
        The method call expression
      • buildGetPropertyExpression

        public static org.codehaus.groovy.ast.expr.MethodCallExpression buildGetPropertyExpression​(org.codehaus.groovy.ast.expr.Expression objectExpression,
                                                                                                   java.lang.String propertyName,
                                                                                                   org.codehaus.groovy.ast.ClassNode targetClassNode)
        Build static direct call to getter of a property
        Parameters:
        objectExpression -
        propertyName -
        targetClassNode -
        Returns:
        The method call expression
      • buildGetPropertyExpression

        public static org.codehaus.groovy.ast.expr.MethodCallExpression buildGetPropertyExpression​(org.codehaus.groovy.ast.expr.Expression objectExpression,
                                                                                                   java.lang.String propertyName,
                                                                                                   org.codehaus.groovy.ast.ClassNode targetClassNode,
                                                                                                   boolean useBooleanGetter)
        Build static direct call to getter of a property
        Parameters:
        objectExpression -
        propertyName -
        targetClassNode -
        useBooleanGetter -
        Returns:
        The method call expression
      • buildSetPropertyExpression

        public static org.codehaus.groovy.ast.expr.MethodCallExpression buildSetPropertyExpression​(org.codehaus.groovy.ast.expr.Expression objectExpression,
                                                                                                   java.lang.String propertyName,
                                                                                                   org.codehaus.groovy.ast.ClassNode targetClassNode,
                                                                                                   org.codehaus.groovy.ast.expr.Expression valueExpression)
        Build static direct call to setter of a property
        Parameters:
        objectExpression -
        propertyName -
        targetClassNode -
        valueExpression -
        Returns:
        The method call expression
      • buildPutMapExpression

        public static org.codehaus.groovy.ast.expr.MethodCallExpression buildPutMapExpression​(org.codehaus.groovy.ast.expr.Expression objectExpression,
                                                                                              java.lang.String keyName,
                                                                                              org.codehaus.groovy.ast.expr.Expression valueExpression)
        Build static direct call to put entry in Map
        Parameters:
        objectExpression -
        keyName -
        valueExpression -
        Returns:
        The method call expression
      • buildGetMapExpression

        public static org.codehaus.groovy.ast.expr.MethodCallExpression buildGetMapExpression​(org.codehaus.groovy.ast.expr.Expression objectExpression,
                                                                                              java.lang.String keyName)
        Build static direct call to get entry from Map
        Parameters:
        objectExpression -
        keyName -
        Returns:
        The method call expression
      • buildGetThisObjectExpression

        public static org.codehaus.groovy.ast.expr.Expression buildGetThisObjectExpression​(boolean inClosureBlock)
      • buildThisExpression

        public static org.codehaus.groovy.ast.expr.Expression buildThisExpression()
      • noImplicitThis

        public static org.codehaus.groovy.ast.expr.MethodCallExpression noImplicitThis​(org.codehaus.groovy.ast.expr.MethodCallExpression methodCallExpression)
      • applyImplicitThis

        public static org.codehaus.groovy.ast.expr.MethodCallExpression applyImplicitThis​(org.codehaus.groovy.ast.expr.MethodCallExpression methodCallExpression,
                                                                                          boolean useImplicitThis)
      • copyAnnotations

        public static void copyAnnotations​(org.codehaus.groovy.ast.AnnotatedNode from,
                                           org.codehaus.groovy.ast.AnnotatedNode to)
      • copyAnnotations

        public static void copyAnnotations​(org.codehaus.groovy.ast.AnnotatedNode from,
                                           org.codehaus.groovy.ast.AnnotatedNode to,
                                           java.util.Set<java.lang.String> included,
                                           java.util.Set<java.lang.String> excluded)
      • cloneAnnotation

        public static org.codehaus.groovy.ast.AnnotationNode cloneAnnotation​(org.codehaus.groovy.ast.AnnotationNode node)
      • filterAnnotations

        public static void filterAnnotations​(org.codehaus.groovy.ast.AnnotatedNode annotatedNode,
                                             java.util.Set<java.lang.String> classNamesToRetain,
                                             java.util.Set<java.lang.String> classNamesToRemove)
      • removeCompileStaticAnnotations

        public static void removeCompileStaticAnnotations​(org.codehaus.groovy.ast.AnnotatedNode annotatedNode)
      • markApplied

        public static void markApplied​(org.codehaus.groovy.ast.ASTNode astNode,
                                       java.lang.Class<?> transformationClass)
      • isApplied

        public static boolean isApplied​(org.codehaus.groovy.ast.ASTNode astNode,
                                        java.lang.Class<?> transformationClass)
      • processVariableScopes

        public static void processVariableScopes​(org.codehaus.groovy.control.SourceUnit source,
                                                 org.codehaus.groovy.ast.ClassNode classNode)
      • processVariableScopes

        public static void processVariableScopes​(org.codehaus.groovy.control.SourceUnit source,
                                                 org.codehaus.groovy.ast.ClassNode classNode,
                                                 org.codehaus.groovy.ast.MethodNode methodNode)
      • isGetterMethod

        public static boolean isGetterMethod​(org.codehaus.groovy.ast.MethodNode md)
      • isSetterMethod

        public static boolean isSetterMethod​(org.codehaus.groovy.ast.MethodNode md)
      • isSetterOrGetterMethod

        public static boolean isSetterOrGetterMethod​(org.codehaus.groovy.ast.MethodNode md)
      • getSourceUrl

        public static java.net.URL getSourceUrl​(org.codehaus.groovy.control.SourceUnit source)
        Find URL of SourceUnit source.getSource().getURI() fails in Groovy-Eclipse compiler
        Parameters:
        source -
        Returns:
        URL of SourceUnit
      • getSourceUrl

        public static java.net.URL getSourceUrl​(org.codehaus.groovy.ast.ClassNode classNode)
      • hasParameters

        public static boolean hasParameters​(org.codehaus.groovy.ast.MethodNode methodNode)
      • isInheritedFromTrait

        public static boolean isInheritedFromTrait​(org.codehaus.groovy.ast.MethodNode methodNode)