Package org.codenarc.util
Class AstUtil
- java.lang.Object
-
- org.codenarc.util.AstUtil
-
public class AstUtil extends Object
Contains static utility methods and constants related to Groovy AST. This is an internal class and its API is subject to change.- Author:
- Chris Mair, Hamlet D'Arcy
-
-
Field Summary
Fields Modifier and Type Field Description static List<String>
AUTO_IMPORTED_CLASSES
static List<String>
AUTO_IMPORTED_PACKAGES
static List<String>
COMPARISON_OPERATORS
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
classNodeHasProperty(org.codehaus.groovy.ast.ClassNode classNode, String propertyName)
static boolean
classNodeImplementsType(org.codehaus.groovy.ast.ClassNode node, Class target)
This method tells you if a ClassNode implements or extends a certain class.static String
createPrettyExpression(org.codehaus.groovy.ast.ASTNode expression)
static boolean
expressionIsAssignment(org.codehaus.groovy.ast.ASTNode node, String variableName)
static boolean
expressionIsNullCheck(org.codehaus.groovy.ast.ASTNode node)
static int
findFirstNonAnnotationLine(org.codehaus.groovy.ast.ASTNode node, SourceCode sourceCode)
gets the first non annotation line number of a node, taking into account annotations.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<String>
getArgumentNames(org.codehaus.groovy.ast.expr.MethodCallExpression methodCall)
Gets the argument names of a method call.static String
getDeclaration(org.codehaus.groovy.ast.ASTNode node, SourceCode sourceCode)
static org.codehaus.groovy.ast.ASTNode
getEmptyBlock(org.codehaus.groovy.ast.stmt.Statement origStatement)
static Class
getFieldType(org.codehaus.groovy.ast.ClassNode node, String fieldName)
Supports discovering many common JDK types, but not all.static Class
getFieldType(org.codehaus.groovy.ast.FieldNode field)
Supports discovering many common JDK types, but not all.static String
getInstanceOfTarget(Object expression)
static String
getLastLineOfNodeText(org.codehaus.groovy.ast.ASTNode expression, SourceCode sourceCode)
static List<? extends org.codehaus.groovy.ast.expr.Expression>
getMethodArguments(org.codehaus.groovy.ast.ASTNode methodCall)
Return the List of Arguments for the specified MethodCallExpression or a ConstructorCallExpression.static String
getNodeText(org.codehaus.groovy.ast.ASTNode expression, SourceCode sourceCode)
static String
getNullComparisonTarget(Object expression)
static List<String>
getParameterNames(org.codehaus.groovy.ast.MethodNode node)
Gets the parameter names of a method node.static String
getRawLine(SourceCode sourceCode, int lineNumber)
static List<org.codehaus.groovy.ast.expr.Expression>
getVariableExpressions(org.codehaus.groovy.ast.expr.DeclarationExpression declarationExpression)
Return the List of VariableExpression objects referenced by the specified DeclarationExpression.static boolean
hasAnnotation(org.codehaus.groovy.ast.AnnotatedNode node, String name)
Return true only if the node has the named annotationstatic boolean
hasAnyAnnotation(org.codehaus.groovy.ast.AnnotatedNode node, String... names)
Return true only if the node has any of the named annotationsstatic boolean
isBinaryExpressionType(org.codehaus.groovy.ast.expr.Expression expression, String token)
Returns true if the expression is a binary expression with the specified token.static boolean
isBinaryExpressionType(org.codehaus.groovy.ast.expr.Expression expression, List<String> tokens)
Returns true if the expression is a binary expression with the specified token.static boolean
isBlock(org.codehaus.groovy.ast.stmt.Statement statement)
Return true if the Statement is a blockstatic boolean
isBoolean(org.codehaus.groovy.ast.expr.Expression expression)
Tells you if the expression is either the true or false literal.static boolean
isClosureDeclaration(org.codehaus.groovy.ast.ASTNode expression)
Returns true if the ASTNode is a declaration of a closure, either as a declaration or a field.static boolean
isConstant(org.codehaus.groovy.ast.expr.Expression expression, Object expected)
Tells you if an expression is the expected constant.static boolean
isConstantOrConstantLiteral(org.codehaus.groovy.ast.expr.Expression expression)
Returns true if an expression is a constant or else a literal that contains only constant values.static boolean
isConstantOrLiteral(org.codehaus.groovy.ast.expr.Expression expression)
Tells you if an expression is a constant or literal.static boolean
isConstructorCall(org.codehaus.groovy.ast.expr.Expression expression, String classNamePattern)
Return true if the expression is a constructor call on a class that matches the supplied.static boolean
isConstructorCall(org.codehaus.groovy.ast.expr.Expression expression, List<String> classNames)
Return true if the expression is a constructor call on any of the named classes, with any number of parameters.static boolean
isEmptyBlock(org.codehaus.groovy.ast.stmt.Statement origStatement)
Return true if the Statement is a block and it is empty (contains no "meaningful" statements).static boolean
isFalse(org.codehaus.groovy.ast.expr.Expression expression)
Tells you if the expression is the false expression, either literal or constant.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)
static boolean
isInstanceOfCheck(Object expression)
static boolean
isListLiteralWithOnlyConstantValues(org.codehaus.groovy.ast.expr.Expression expression)
Returns true if a List literal that contains only entries that are constants.static boolean
isMapLiteralWithOnlyConstantValues(org.codehaus.groovy.ast.expr.Expression expression)
Returns true if a Map literal that contains only entries where both key and value are constants.static boolean
isMethodCall(org.codehaus.groovy.ast.expr.Expression expression, String methodName, int numArguments)
Tells you if the expression is a method call for a certain method name with a certain number of arguments.static boolean
isMethodCall(org.codehaus.groovy.ast.expr.Expression expression, String methodName, groovy.lang.Range numArguments)
Tells you if the expression is a method call for a certain method name with a certain number of arguments.static boolean
isMethodCall(org.codehaus.groovy.ast.expr.Expression expression, String methodObjectPattern, String methodNamePattern)
Return true only if the expression represents a method call (MethodCallExpression) for the specified method object (receiver) and method name.static boolean
isMethodCall(org.codehaus.groovy.ast.expr.Expression expression, String methodObject, String methodName, int numArguments)
Return true only if the expression is a MethodCallExpression representing 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 methodObjectPattern, String methodPattern, 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, List<String> methodObjects, List<String> methodNames)
static boolean
isMethodCall(org.codehaus.groovy.ast.expr.MethodCallExpression methodCall, List<String> methodObjects, List<String> methodNames, Integer numArguments)
Return true only if the MethodCallExpression represents a method call for any one of the specified method objects (receivers) and any one of the method names.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
isMethodCallOnObject(org.codehaus.groovy.ast.expr.Expression expression, String methodObjectPattern)
Tells you if the expression is a method call on a particular object (which is represented as a String).static boolean
isMethodNamed(org.codehaus.groovy.ast.expr.MethodCallExpression methodCall, String methodNamePattern)
static boolean
isMethodNamed(org.codehaus.groovy.ast.expr.MethodCallExpression methodCall, String methodNamePattern, Integer numArguments)
Return true only if the MethodCallExpression represents a method call for the specified method namestatic boolean
isMethodNode(org.codehaus.groovy.ast.ASTNode node, String methodNamePattern)
static boolean
isMethodNode(org.codehaus.groovy.ast.ASTNode node, String methodNamePattern, Integer numArguments)
static boolean
isMethodNode(org.codehaus.groovy.ast.ASTNode node, String methodNamePattern, Integer numArguments, Class returnType)
Tells you if the ASTNode is a method node for the given name, arity, and return type.static boolean
isNotNullCheck(Object expression)
static boolean
isNull(org.codehaus.groovy.ast.ASTNode expression)
Tells you if the expression is the null literal.static boolean
isNullCheck(Object expression)
static boolean
isOneLiner(Object statement)
static boolean
isPropertyNamed(org.codehaus.groovy.ast.expr.Expression property, Object expectedName)
static boolean
isPublic(org.codehaus.groovy.ast.ASTNode node)
Tells you if the ASTNode has a public modifier on it.static boolean
isSafe(org.codehaus.groovy.ast.expr.Expression expression)
Tells you if the expression is a null safe dereference.static boolean
isSpreadSafe(org.codehaus.groovy.ast.expr.Expression expression)
Tells you if the expression is a spread operator callstatic boolean
isSuperReference(org.codehaus.groovy.ast.expr.Expression expression)
static boolean
isThisReference(org.codehaus.groovy.ast.expr.Expression expression)
static boolean
isTrue(org.codehaus.groovy.ast.expr.Expression expression)
Tells you if the expression is true, which can be true or Boolean.TRUE.static boolean
isVariable(org.codehaus.groovy.ast.ASTNode expression, String pattern)
Tells you if the given ASTNode is a VariableExpression with the given name.static boolean
respondsTo(Object object, String methodName)
Return true only if the specified object responds to the named method
-
-
-
Method Detail
-
isConstantOrLiteral
public static boolean isConstantOrLiteral(org.codehaus.groovy.ast.expr.Expression expression)
Tells you if an expression is a constant or literal. Basically, is it a map, list, constant, or a predefined constant like true/false.- Parameters:
expression
- any expression- Returns:
- as described
-
isConstantOrConstantLiteral
public static boolean isConstantOrConstantLiteral(org.codehaus.groovy.ast.expr.Expression expression)
Returns true if an expression is a constant or else a literal that contains only constant values. Basically, is it a constant, or else a map like [a:1, b:99, c:true], or a list like ['abc', 99.0, false]- Parameters:
expression
- - any expression
-
isMapLiteralWithOnlyConstantValues
public static boolean isMapLiteralWithOnlyConstantValues(org.codehaus.groovy.ast.expr.Expression expression)
Returns true if a Map literal that contains only entries where both key and value are constants.- Parameters:
expression
- - any expression
-
isListLiteralWithOnlyConstantValues
public static boolean isListLiteralWithOnlyConstantValues(org.codehaus.groovy.ast.expr.Expression expression)
Returns true if a List literal that contains only entries that are constants.- Parameters:
expression
- - any expression
-
isConstant
public static boolean isConstant(org.codehaus.groovy.ast.expr.Expression expression, Object expected)
Tells you if an expression is the expected constant.- Parameters:
expression
- any expressionexpected
- the expected int or String- Returns:
- as described
-
isPropertyNamed
public static boolean isPropertyNamed(org.codehaus.groovy.ast.expr.Expression property, Object expectedName)
-
isBlock
public static boolean isBlock(org.codehaus.groovy.ast.stmt.Statement statement)
Return true if the Statement is a block- Parameters:
statement
- - the Statement to check- Returns:
- true if the Statement is a block
-
isEmptyBlock
public static boolean isEmptyBlock(org.codehaus.groovy.ast.stmt.Statement origStatement)
Return 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.- Parameters:
origStatement
- - the Statement to check- Returns:
- true if the BlockStatement is empty
-
getEmptyBlock
public static org.codehaus.groovy.ast.ASTNode getEmptyBlock(org.codehaus.groovy.ast.stmt.Statement origStatement)
-
getMethodArguments
public static List<? extends org.codehaus.groovy.ast.expr.Expression> getMethodArguments(org.codehaus.groovy.ast.ASTNode methodCall)
Return the List of Arguments for the specified MethodCallExpression or a ConstructorCallExpression. The returned List contains either ConstantExpression or MapEntryExpression objects.- Parameters:
methodCall
- - the AST MethodCallExpression or ConstructorCalLExpression- Returns:
- the List of argument objects
-
isMethodCallOnObject
public static boolean isMethodCallOnObject(org.codehaus.groovy.ast.expr.Expression expression, String methodObjectPattern)
Tells you if the expression is a method call on a particular object (which is represented as a String). For instance, you may ask isMethodCallOnObject(e, 'this') to find a this reference.- Parameters:
expression
- - the expressionmethodObjectPattern
- - the name of the method object (receiver) such as 'this'- Returns:
- as described
-
isMethodCall
public 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.- Parameters:
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 method- Returns:
- true only if the Statement is a method call matching the specified criteria
-
isMethodCall
public static boolean isMethodCall(org.codehaus.groovy.ast.expr.MethodCallExpression methodCall, String methodObjectPattern, String methodPattern, 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.- Parameters:
methodCall
- - the AST MethodCallExpressionmethodObjectPattern
- - the name of the method object (receiver)methodPattern
- - the name of the method being callednumArguments
- - the number of arguments passed into the method- Returns:
- true only if the method call matches the specified criteria
-
isMethodCall
public static boolean isMethodCall(org.codehaus.groovy.ast.expr.Expression expression, String methodObject, String methodName, int numArguments)
Return true only if the expression is a MethodCallExpression representing a method call for the specified method object (receiver), method name, and with the specified number of arguments.- Parameters:
expression
- - the AST expressionmethodObject
- - the name of the method object (receiver)methodName
- - the name of the method being callednumArguments
- - the number of arguments passed into the method- Returns:
- true only if the method call matches the specified criteria
-
isMethodCall
public static boolean isMethodCall(org.codehaus.groovy.ast.expr.Expression expression, String methodObjectPattern, String methodNamePattern)
Return true only if the expression represents a method call (MethodCallExpression) for the specified method object (receiver) and method name.- Parameters:
expression
- - the AST expression to be checkedmethodObjectPattern
- - the name of the method object (receiver)methodNamePattern
- - the name of the method being called- Returns:
- true only if the expression is a method call that matches the specified criteria
-
isMethodCall
public static boolean isMethodCall(org.codehaus.groovy.ast.expr.MethodCallExpression methodCall, List<String> methodObjects, List<String> methodNames, Integer numArguments)
Return true only if the MethodCallExpression represents a method call for any one of the specified method objects (receivers) and any one of the method names. Optionally, you can restrict it to a method call with a certain number of arguments.- Parameters:
methodCall
- the method call objectmethodObjects
- a list of receivers, such as ['this', 'super']methodNames
- a list of method namesnumArguments
- optionally, require a certain number of arguments- Returns:
- as described
-
isMethodCall
public static boolean isMethodCall(org.codehaus.groovy.ast.expr.MethodCallExpression methodCall, List<String> methodObjects, List<String> methodNames)
-
isMethodCall
public static boolean isMethodCall(org.codehaus.groovy.ast.expr.Expression expression, String methodName, int numArguments)
Tells you if the expression is a method call for a certain method name with a certain number of arguments.- Parameters:
expression
- the (potentially) method callmethodName
- the name of the method expectednumArguments
- number of expected arguments- Returns:
- as described
-
isMethodCall
public static boolean isMethodCall(org.codehaus.groovy.ast.expr.Expression expression, String methodName, groovy.lang.Range numArguments)
Tells you if the expression is a method call for a certain method name with a certain number of arguments.- Parameters:
expression
- the (potentially) method callmethodName
- the name of the method expectednumArguments
- number of expected arguments- Returns:
- as described
-
isMethodNamed
public static boolean isMethodNamed(org.codehaus.groovy.ast.expr.MethodCallExpression methodCall, String methodNamePattern, Integer numArguments)
Return true only if the MethodCallExpression represents a method call for the specified method name- Parameters:
methodCall
- - the AST MethodCallExpressionmethodNamePattern
- - the expected name of the method being callednumArguments
- - The number of expected arguments- Returns:
- true only if the method call name matches
-
isMethodNamed
public static boolean isMethodNamed(org.codehaus.groovy.ast.expr.MethodCallExpression methodCall, String methodNamePattern)
-
isConstructorCall
public static boolean isConstructorCall(org.codehaus.groovy.ast.expr.Expression expression, List<String> classNames)
Return true if the expression is a constructor call on any of the named classes, with any number of parameters.- Parameters:
expression
- - the expressionclassNames
- - the possible List of class names- Returns:
- as described
-
isConstructorCall
public static boolean isConstructorCall(org.codehaus.groovy.ast.expr.Expression expression, String classNamePattern)
Return true if the expression is a constructor call on a class that matches the supplied.- Parameters:
expression
- - the expressionclassNamePattern
- - the possible List of class names- Returns:
- as described
-
getAnnotation
public 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. Supports Groovy 1.5 and Groovy 1.6.- Parameters:
node
- - the AnnotatedNodename
- - the name of the annotation- Returns:
- the AnnotationNode or else null
-
hasAnnotation
public static boolean hasAnnotation(org.codehaus.groovy.ast.AnnotatedNode node, String name)
Return true only if the node has the named annotation- Parameters:
node
- - the AST Node to checkname
- - the name of the annotation- Returns:
- true only if the node has the named annotation
-
hasAnyAnnotation
public static boolean hasAnyAnnotation(org.codehaus.groovy.ast.AnnotatedNode node, String... names)
Return true only if the node has any of the named annotations- Parameters:
node
- - the AST Node to checknames
- - the names of the annotations- Returns:
- true only if the node has any of the named annotations
-
getVariableExpressions
public static List<org.codehaus.groovy.ast.expr.Expression> getVariableExpressions(org.codehaus.groovy.ast.expr.DeclarationExpression declarationExpression)
Return the List of VariableExpression objects referenced by the specified DeclarationExpression.- Parameters:
declarationExpression
- - the DeclarationExpression- Returns:
- the List of VariableExpression objects
-
isFinalVariable
public static boolean isFinalVariable(org.codehaus.groovy.ast.expr.DeclarationExpression declarationExpression, SourceCode sourceCode)
Return 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.
-
isFromGeneratedSourceCode
public static boolean isFromGeneratedSourceCode(org.codehaus.groovy.ast.ASTNode node)
- Returns:
- true if the ASTNode was generated (synthetic) rather than from the "real" input source code.
-
isTrue
public static boolean isTrue(org.codehaus.groovy.ast.expr.Expression expression)
Tells you if the expression is true, which can be true or Boolean.TRUE.- Parameters:
expression
- expression- Returns:
- as described
-
isBoolean
public static boolean isBoolean(org.codehaus.groovy.ast.expr.Expression expression)
Tells you if the expression is either the true or false literal.- Parameters:
expression
- expression- Returns:
- as described
-
isNull
public static boolean isNull(org.codehaus.groovy.ast.ASTNode expression)
Tells you if the expression is the null literal.- Parameters:
expression
- expression.- Returns:
- as described
-
isFalse
public static boolean isFalse(org.codehaus.groovy.ast.expr.Expression expression)
Tells you if the expression is the false expression, either literal or constant.- Parameters:
expression
- expression- Returns:
- as described
-
respondsTo
public static boolean respondsTo(Object object, String methodName)
Return true only if the specified object responds to the named method- Parameters:
object
- - the object to checkmethodName
- - the name of the method- Returns:
- true if the object responds to the named method
-
classNodeImplementsType
public static boolean classNodeImplementsType(org.codehaus.groovy.ast.ClassNode node, Class target)
This method tells you if a ClassNode implements or extends a certain class.- Parameters:
node
- the nodetarget
- the class- Returns:
- true if the class node 'is a' target
-
isClosureDeclaration
public static boolean isClosureDeclaration(org.codehaus.groovy.ast.ASTNode expression)
Returns true if the ASTNode is a declaration of a closure, either as a declaration or a field.- Parameters:
expression
- the target expression- Returns:
- as described
-
getParameterNames
public static List<String> getParameterNames(org.codehaus.groovy.ast.MethodNode node)
Gets the parameter names of a method node.- Parameters:
node
- the node to search parameter names on- Returns:
- argument names, never null
-
getArgumentNames
public static List<String> getArgumentNames(org.codehaus.groovy.ast.expr.MethodCallExpression methodCall)
Gets the argument names of a method call. If the arguments are not VariableExpressions then a null will be returned.- Parameters:
methodCall
- the method call to search- Returns:
- a list of strings, never null, but some elements may be null
-
isBinaryExpressionType
public static boolean isBinaryExpressionType(org.codehaus.groovy.ast.expr.Expression expression, String token)
Returns true if the expression is a binary expression with the specified token.- Parameters:
expression
- expressiontoken
- token- Returns:
- as described
-
isBinaryExpressionType
public static boolean isBinaryExpressionType(org.codehaus.groovy.ast.expr.Expression expression, List<String> tokens)
Returns true if the expression is a binary expression with the specified token.- Parameters:
expression
- - the expression nodetokens
- - the List of allowable (operator) tokens- Returns:
- as described
-
isSafe
public static boolean isSafe(org.codehaus.groovy.ast.expr.Expression expression)
Tells you if the expression is a null safe dereference.- Parameters:
expression
- expression- Returns:
- true if is null safe dereference.
-
isSpreadSafe
public static boolean isSpreadSafe(org.codehaus.groovy.ast.expr.Expression expression)
Tells you if the expression is a spread operator call- Parameters:
expression
- expression- Returns:
- true if is spread expression
-
isMethodNode
public static boolean isMethodNode(org.codehaus.groovy.ast.ASTNode node, String methodNamePattern, Integer numArguments, Class returnType)
Tells you if the ASTNode is a method node for the given name, arity, and return type.- Parameters:
node
- the node to inspectmethodNamePattern
- the expected name of the methodnumArguments
- the expected number of arguments, optionalreturnType
- the expected return type, optional- Returns:
- true if this node is a MethodNode meeting the parameters. false otherwise
-
isMethodNode
public static boolean isMethodNode(org.codehaus.groovy.ast.ASTNode node, String methodNamePattern, Integer numArguments)
-
isMethodNode
public static boolean isMethodNode(org.codehaus.groovy.ast.ASTNode node, String methodNamePattern)
-
isVariable
public static boolean isVariable(org.codehaus.groovy.ast.ASTNode expression, String pattern)
Tells you if the given ASTNode is a VariableExpression with the given name.- Parameters:
expression
- any AST Nodepattern
- a string pattern to match- Returns:
- true if the node is a variable with the specified name
-
isPublic
public static boolean isPublic(org.codehaus.groovy.ast.ASTNode node)
Tells you if the ASTNode has a public modifier on it. If the node does not have modifiers at all (like a variable expression) then false is returned.- Parameters:
node
- node to query- Returns:
- true if definitely public, false if not public or unknown
-
isNotNullCheck
public static boolean isNotNullCheck(Object expression)
-
isNullCheck
public static boolean isNullCheck(Object expression)
-
isInstanceOfCheck
public static boolean isInstanceOfCheck(Object expression)
-
getFieldType
public static Class getFieldType(org.codehaus.groovy.ast.ClassNode node, String fieldName)
Supports discovering many common JDK types, but not all.
-
getFieldType
public static Class getFieldType(org.codehaus.groovy.ast.FieldNode field)
Supports discovering many common JDK types, but not all.
-
isThisReference
public static boolean isThisReference(org.codehaus.groovy.ast.expr.Expression expression)
-
isSuperReference
public static boolean isSuperReference(org.codehaus.groovy.ast.expr.Expression expression)
-
classNodeHasProperty
public static boolean classNodeHasProperty(org.codehaus.groovy.ast.ClassNode classNode, String propertyName)
-
findFirstNonAnnotationLine
public static int findFirstNonAnnotationLine(org.codehaus.groovy.ast.ASTNode node, SourceCode sourceCode)
gets the first non annotation line number of a node, taking into account annotations.
-
getRawLine
public static String getRawLine(SourceCode sourceCode, int lineNumber)
-
isOneLiner
public static boolean isOneLiner(Object statement)
-
expressionIsNullCheck
public static boolean expressionIsNullCheck(org.codehaus.groovy.ast.ASTNode node)
-
expressionIsAssignment
public static boolean expressionIsAssignment(org.codehaus.groovy.ast.ASTNode node, String variableName)
-
getNodeText
public static String getNodeText(org.codehaus.groovy.ast.ASTNode expression, SourceCode sourceCode)
-
getLastLineOfNodeText
public static String getLastLineOfNodeText(org.codehaus.groovy.ast.ASTNode expression, SourceCode sourceCode)
-
getDeclaration
public static String getDeclaration(org.codehaus.groovy.ast.ASTNode node, SourceCode sourceCode)
-
createPrettyExpression
public static String createPrettyExpression(org.codehaus.groovy.ast.ASTNode expression)
-
-