Contains static utility methods related to Groovy AST.
This is an internal class and its API is subject to change.Type Params | Return Type | Name and description |
---|---|---|
|
static org.codehaus.groovy.ast.AnnotationNode |
getAnnotation(org.codehaus.groovy.ast.AnnotatedNode node, String name) Return the AnnotationNode for the named annotation, or else null. |
|
static List |
getMethodArguments(org.codehaus.groovy.ast.expr.MethodCallExpression methodCall) Return the List of Arguments for the specified MethodCallExpression. |
|
static List |
getVariableExpressions(org.codehaus.groovy.ast.expr.DeclarationExpression declarationExpression) Return the List of VariableExpression objects referenced by the specified DeclarationExpression. |
|
static boolean |
isBlock(org.codehaus.groovy.ast.stmt.Statement statement) Return true if the Statement is a block |
|
static boolean |
isClosureField(org.codehaus.groovy.ast.FieldNode fieldNode) Return true only if the specified FieldNode has an initial expression that is a Closure |
|
static boolean |
isEmptyBlock(org.codehaus.groovy.ast.stmt.Statement statement) Return true if the Statement is a block and it is empty (contains no "meaningful" statements). |
|
static boolean |
isEmptyMethod(org.codehaus.groovy.ast.MethodNode methodNode) |
|
static boolean |
isFinalVariable(org.codehaus.groovy.ast.expr.DeclarationExpression declarationExpression, SourceCode sourceCode) Return true if the DeclarationExpression represents a 'final' variable declaration. |
|
static boolean |
isFromGeneratedSourceCode(org.codehaus.groovy.ast.ASTNode node) @return true if the ASTNode was generated (synthetic) rather than from the "real" input source code. |
|
static boolean |
isMethodCall(org.codehaus.groovy.ast.stmt.Statement stmt, String methodObject, String methodName, int numArguments) Return true only if the Statement represents a method call for the specified method object (receiver), method name, and with the specified number of arguments. |
|
static boolean |
isMethodCall(org.codehaus.groovy.ast.expr.MethodCallExpression methodCall, String methodObject, String methodName, int numArguments) Return true only if the MethodCallExpression represents a method call for the specified method object (receiver), method name, and with the specified number of arguments. |
|
static boolean |
isMethodCall(org.codehaus.groovy.ast.expr.MethodCallExpression methodCall, String methodObject, String methodName) Return true only if the MethodCallExpression represents a method call for the specified method object (receiver) and method name. |
|
static boolean |
isMethodNamed(org.codehaus.groovy.ast.expr.MethodCallExpression methodCall, String methodName) Return true only if the MethodCallExpression represents a method call for the specified method name |
Return the AnnotationNode for the named annotation, or else null. Supports Groovy 1.5 and Groovy 1.6.
node
- - the AnnotatedNodename
- - the name of the annotationReturn the List of Arguments for the specified MethodCallExpression. The returned List contains either ConstantExpression or MapEntryExpression objects.
methodCall
- - the AST MethodCallExpressionReturn the List of VariableExpression objects referenced by the specified DeclarationExpression.
declarationExpression
- - the DeclarationExpressionReturn true if the Statement is a block
statement
- - the Statement to checkReturn true only if the specified FieldNode has an initial expression that is a Closure
fieldNode
- - the FieldNodeReturn true if the Statement is a block and it is empty (contains no "meaningful" statements). This implementation also addresses some "weirdness" around some statement types (specifically finally) where the BlockStatement answered false to isEmpty() even if it was.
statement
- - the Statement to checkReturn true if the DeclarationExpression represents a 'final' variable declaration. NOTE: THIS IS A WORKAROUND. There does not seem to be an easy way to determine whether the 'final' modifier has been specified for a variable declaration. Return true if the 'final' is present before the variable name.
Return true only if the Statement represents a method call for the specified method object (receiver), method name, and with the specified number of arguments.
stmt
- - the AST StatementmethodObject
- - the name of the method object (receiver)methodName
- - the name of the method being callednumArguments
- - the number of arguments passed into the methodReturn true only if the MethodCallExpression represents a method call for the specified method object (receiver), method name, and with the specified number of arguments.
methodCall
- - the AST MethodCallExpressionmethodObject
- - the name of the method object (receiver)methodName
- - the name of the method being callednumArguments
- - the number of arguments passed into the methodReturn true only if the MethodCallExpression represents a method call for the specified method object (receiver) and method name.
methodCall
- - the AST MethodCallExpressionmethodObject
- - the name of the method object (receiver)methodName
- - the name of the method being calledReturn true only if the MethodCallExpression represents a method call for the specified method name
methodCall
- - the AST MethodCallExpressionmethodName
- - the expected name of the method being called