Utility methods for dealing with Groovy ASTs
Modifiers | Name | Description |
---|---|---|
static org.codehaus.groovy.syntax.Token |
ASSIGNMENT_OPERATOR |
|
static org.codehaus.groovy.ast.ClassNode |
COMPILE_STATIC_TYPE |
|
static java.util.regex.Pattern |
DOMAIN_PATH_PATTERN |
|
static java.lang.String |
DOMAIN_TYPE |
|
static org.codehaus.groovy.ast.ClassNode[] |
EMPTY_CLASS_ARRAY |
|
static java.lang.String |
GRAILS_APP_DIR |
The name of the Grails application directory |
static org.codehaus.groovy.ast.ClassNode |
OBJECT_CLASS_NODE |
|
static java.lang.String |
REGEX_FILE_SEPARATOR |
|
static java.lang.Object |
TRANSFORM_APPLIED_MARKER |
|
static org.codehaus.groovy.ast.ClassNode |
TYPE_CHECKED_TYPE |
|
static org.codehaus.groovy.ast.expr.ArgumentListExpression |
ZERO_ARGUMENTS |
|
static org.codehaus.groovy.ast.Parameter[] |
ZERO_PARAMETERS |
Type Params | Return Type | Name and description |
---|---|---|
|
static void |
addAnnotationIfNecessary(org.codehaus.groovy.ast.AnnotatedNode 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.AnnotatedNode 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.AnnotatedNode annotatedNode, 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.AnnotatedNode annotatedNode, org.codehaus.groovy.ast.ClassNode annotationClassNode) |
|
static org.codehaus.groovy.ast.AnnotationNode |
addAnnotationOrGetExisting(org.codehaus.groovy.ast.AnnotatedNode annotatedNode, org.codehaus.groovy.ast.ClassNode annotationClassNode, java.util.Map<java.lang.String, java.lang.Object> members) |
|
static void |
addTransformedEntityName(java.lang.String name) @param name Adds the name of a transformed entity |
|
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.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.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.Parameter[] |
copyParameters(java.util.Map<java.lang.String, org.codehaus.groovy.ast.ClassNode> genericsSpec, org.codehaus.groovy.ast.Parameter[] parameterTypes, java.util.List<java.lang.String> currentMethodGenPlaceholders) |
|
static void |
error(org.codehaus.groovy.control.SourceUnit sourceUnit, org.codehaus.groovy.ast.ASTNode expr, java.lang.String errorMessage) |
|
protected static void |
findAbstractMethodsInternal(org.codehaus.groovy.ast.ClassNode classNode, java.util.List<org.codehaus.groovy.ast.MethodNode> methods, boolean includeProtected) |
|
static java.util.List<org.codehaus.groovy.ast.MethodNode> |
findAllAbstractMethods(org.codehaus.groovy.ast.ClassNode classNode) Finds all the abstract methods for the give class node |
|
static java.util.List<org.codehaus.groovy.ast.MethodNode> |
findAllUnimplementedAbstractMethods(org.codehaus.groovy.ast.ClassNode classNode) Finds all the abstract methods for the give class node |
|
static org.codehaus.groovy.ast.AnnotationNode |
findAnnotation(org.codehaus.groovy.ast.AnnotatedNode classNode, java.lang.Class<?> type) |
|
static org.codehaus.groovy.ast.AnnotationNode |
findAnnotation(org.codehaus.groovy.ast.AnnotatedNode annotationClassNode, java.util.List<org.codehaus.groovy.ast.AnnotationNode> annotations) |
|
static org.codehaus.groovy.ast.ClassNode |
findInterface(org.codehaus.groovy.ast.ClassNode classNode, java.lang.String interfaceName) |
|
static java.util.List<org.codehaus.groovy.ast.MethodNode> |
findPublicAbstractMethods(org.codehaus.groovy.ast.ClassNode classNode) Finds all the abstract methods for the give class node |
|
static org.codehaus.groovy.ast.ClassNode |
getFurthestUnresolvedParent(org.codehaus.groovy.ast.ClassNode classNode) |
|
static java.util.Collection<java.lang.String> |
getKnownEntityNames() @return The names of the transformed entities for this context |
|
static org.codehaus.groovy.ast.PropertyNode |
getPropertyFromHierarchy(org.codehaus.groovy.ast.ClassNode cn, java.lang.String name) Obtains a property from the class hierarchy |
|
static org.codehaus.groovy.ast.ClassNode |
getPropertyType(org.codehaus.groovy.ast.ClassNode classNode, java.lang.String propertyName) Returns the property type if it exists |
|
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 |
hasAnnotation(org.codehaus.groovy.ast.MethodNode methodNode, org.codehaus.groovy.ast.ClassNode annotationClassNode) |
|
static boolean |
hasAnnotation(org.codehaus.groovy.ast.MethodNode methodNode, java.lang.String annotationClassName) Returns true if MethodNode is marked with annotationClass |
|
static boolean |
hasAnnotation(java.util.List<org.codehaus.groovy.ast.AnnotationNode> annotationNodes, org.codehaus.groovy.ast.AnnotationNode annotationNode) |
|
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 |
hasAnyAnnotations(org.codehaus.groovy.ast.ClassNode classNode, java.lang.Class<? extends java.lang.annotation.Annotation>... annotationsToLookFor) @param classNode a ClassNode to search |
|
static boolean |
hasJunitAnnotation(org.codehaus.groovy.ast.MethodNode md) Whether the method node has any JUnit annotations |
|
static boolean |
hasOrInheritsProperty(org.codehaus.groovy.ast.ClassNode classNode, java.lang.String propertyName) |
|
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 |
implementsInterface(org.codehaus.groovy.ast.ClassNode classNode, java.lang.String interfaceName) Whether the given class node implements the given interface name |
|
static boolean |
implementsInterface(org.codehaus.groovy.ast.ClassNode classNode, java.lang.Class itfc) Whether the given class node implements the given interface node |
|
static boolean |
implementsInterface(org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.ast.ClassNode interfaceNode) Whether the given class node implements the given interface node |
|
static boolean |
implementsOrInheritsZeroArgMethod(org.codehaus.groovy.ast.ClassNode classNode, java.lang.String methodName) |
|
static boolean |
implementsZeroArgMethod(org.codehaus.groovy.ast.ClassNode classNode, java.lang.String methodName) Tests whether the ClasNode implements the specified method name. |
|
static void |
injectTrait(org.codehaus.groovy.ast.ClassNode classNode, java.lang.Class traitClass) |
|
static boolean |
isDomainClass(java.net.URL url) Checks whether the file referenced by the given url is a domain class |
|
static boolean |
isDomainClass(org.codehaus.groovy.ast.ClassNode classNode) |
|
static boolean |
isEnum(org.codehaus.groovy.ast.ClassNode classNode) Is the class an enum |
|
static boolean |
isGetter(org.codehaus.groovy.ast.MethodNode declaredMethod) |
|
static boolean |
isGroovyType(org.codehaus.groovy.ast.ClassNode type) Whether the given type is a Groovy object |
|
static boolean |
isIterableOrArrayOfDomainClasses(org.codehaus.groovy.ast.ClassNode type) |
|
static boolean |
isNumberType(org.codehaus.groovy.ast.ClassNode classNode) Is the class a number |
|
static boolean |
isSetter(org.codehaus.groovy.ast.MethodNode declaredMethod) |
|
static boolean |
isSpockTest(org.codehaus.groovy.ast.ClassNode classNode) Whether the class is a Spock test |
|
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, org.codehaus.groovy.ast.ClassNode superClass) |
|
static boolean |
isSubclassOfOrImplementsInterface(org.codehaus.groovy.ast.ClassNode childClass, java.lang.String superClassName) |
|
static org.codehaus.groovy.ast.expr.ClosureExpression |
makeClosureAwareOfArguments(org.codehaus.groovy.ast.MethodNode methodNode, org.codehaus.groovy.ast.expr.ClosureExpression closure) Makes a closure aware of the given methods arguments |
|
static org.codehaus.groovy.ast.expr.MapExpression |
mapX(java.util.Map<java.lang.String, ? extends org.codehaus.groovy.ast.expr.Expression> map) Builds a map |
|
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 void |
processVariableScopes(org.codehaus.groovy.control.SourceUnit source, org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.ast.MethodNode methodNode) |
|
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 org.codehaus.groovy.ast.expr.VariableExpression |
varThis() @return A new this variable |
|
static void |
warning(org.codehaus.groovy.control.SourceUnit sourceUnit, org.codehaus.groovy.ast.ASTNode node, java.lang.String warningMessage) |
Methods inherited from class | Name |
---|---|
class java.lang.Object |
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
The name of the Grails application directory
Adds an annotation to the give nclass node if it doesn't already exist
classNode
- The class nodeannotationClass
- The annotation classAdds an annotation to the given class node or returns the existing annotation
classNode
- The class nodeannotationClass
- The annotation classAdds an annotation to the given class node or returns the existing annotation
annotatedNode
- The class nodeannotationClass
- The annotation class
name
- Adds the name of a transformed entityBuild static direct call to getter of a property
Build static direct call to getter of a property
Build static direct call to setter of a property
Finds all the abstract methods for the give class node
classNode
- The class nodeFinds all the abstract methods for the give class node
classNode
- The class nodeFinds all the abstract methods for the give class node
classNode
- The class node
Obtains a property from the class hierarchy
cn
- The class nodename
- The property nameReturns the property type if it exists
classNode
- The ClassNodepropertyName
- The name of the propertyReturns true if MethodNode is marked with annotationClass
methodNode
- A MethodNode to inspectannotationClass
- an annotation to look forReturns true if MethodNode is marked with annotationClass
methodNode
- A MethodNode to inspectannotationClass
- an annotation to look forReturns true if classNode is marked with annotationClass
classNode
- A ClassNode to inspectannotationClass
- an annotation to look for
classNode
- a ClassNode to searchannotationsToLookFor
- Annotations to look forWhether the method node has any JUnit annotations
md
- The method nodeReturns whether a classNode has the specified property or not
classNode
- The ClassNodepropertyName
- The name of the propertyWhether the given class node implements the given interface name
classNode
- The class nodeinterfaceName
- The interface nameWhether the given class node implements the given interface node
classNode
- The class nodeitfc
- The interfaceWhether the given class node implements the given interface node
classNode
- The class nodeinterfaceName
- The interface nodeTests whether the ClasNode implements the specified method name.
classNode
- The ClassNodemethodName
- The method nameChecks whether the file referenced by the given url is a domain class
url
- The URL instanceIs the class an enum
classNode
- The class nodeWhether the given type is a Groovy object
type
- The typeIs the class a number
classNode
- The class nodeWhether the class is a Spock test
classNode
- The class nodeReturns true if the given class name is a parent class of the given class
classNode
- The class nodeparentClassName
- the parent class nameMakes a closure aware of the given methods arguments
methodNode
- The methodclosure
- The existing closureBuilds a map
map
- The map