public class GeneralUtils
extends Object
Handy methods when working with the Groovy AST. Provides factory methods for creating common AST nodes and utility methods for expression and statement construction.
This utility class offers shorthand methods (often with abbreviated names) for building AST structures:
block(), expr(), assign(), ret(), etc.var(), constX(), classX(), cast(), etc.binX(), andX(), orX(), cmp(), etc.list(), map(), tuple(), array(), etc.call(), invokeMethod(), staticCall(), etc.Common patterns use abbreviated names like X suffix for expression factories
(e.g., varX() for VariableExpression) and S suffix for statement factories
(e.g., blockS() for BlockStatement).
Null Handling: Most methods handle null gracefully, often returning empty or no-op structures rather than throwing exceptions.
| Modifiers | Name | Description |
|---|---|---|
enum |
GeneralUtils.ConditionValue |
Represents the compile-time constant value of a boolean loop-condition or branch expression. |
| Modifiers | Name | Description |
|---|---|---|
static Token |
AND |
AST logical AND operator token ("&&"). |
static Token |
ASSIGN |
AST assignment operator token ("="). |
static Token |
CMP |
AST compare-to operator token ("<=>"). |
static Token |
EQ |
AST equality operator token ("=="). |
static Token |
GE |
AST greater-than-or-equal operator token (">="). |
static Token |
GT |
AST greater-than operator token (">"). |
static Token |
INSTANCEOF |
AST instanceof keyword token. |
static Token |
LE |
AST less-than-or-equal operator token ("<="). |
static Token |
LT |
AST less-than operator token ("<"). |
static Token |
MINUS |
AST subtraction operator token ("-"). |
static Token |
NE |
AST inequality operator token ("! |
static Token |
NOT_IDENTICAL |
AST non-identity operator token ("! |
static Token |
OR |
AST logical OR operator token ("||"). |
static Token |
PLUS |
AST addition operator token ("+"). |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public static BinaryExpression |
andX(Expression lhv, Expression rhv)Creates a binary expression with the AND operator joining two expressions. |
|
public static ArgumentListExpression |
args(Expression expressions)Creates an ArgumentListExpression from individual expression arguments. |
|
public static ArgumentListExpression |
args(List<Expression> expressions)Creates an ArgumentListExpression from a list of expressions. |
|
public static ArgumentListExpression |
args(Parameter parameters)Creates an ArgumentListExpression from parameter nodes, extracting their names as variable references. |
|
public static ArgumentListExpression |
args(String names)Creates an ArgumentListExpression from variable names, converting each to a VariableExpression. |
|
public static ArrayExpression |
arrayX(ClassNode elementType, List<Expression> initExpressions)Creates an ArrayExpression for the given element type and initial value expressions. |
|
public static ArrayExpression |
arrayX(ClassNode elementType, List<Expression> initExpressions, List<Expression> sizeExpressions)Creates an ArrayExpression for the given element type, dimensions, and initial values. |
|
public static CastExpression |
asX(ClassNode type, Expression expression)Creates a CastExpression converting the given expression to the specified type. |
|
public static Statement |
assignNullS(Expression target)Creates a statement that assigns a null/empty value to the target expression. |
|
public static Statement |
assignS(Expression target, Expression value)Creates an assignment statement for the supplied target and value. |
|
public static Expression |
assignX(Expression target, Expression value)Creates an assignment expression using ASSIGN. |
|
public static AttributeExpression |
attrX(Expression owner, String attribute)
|
|
public static AttributeExpression |
attrX(Expression owner, Expression attribute)Creates an attribute access expression. |
|
public static BinaryExpression |
binX(Expression left, Token token, Expression right)Creates a binary expression from operands and an operator token. |
|
public static BlockStatement |
block(VariableScope scope, Statement stmts)Creates a block statement from statements and optional scope. |
|
public static BlockStatement |
block(VariableScope scope, List<Statement> stmts)Creates a block statement from statements and optional scope. |
|
public static BlockStatement |
block(Statement stmts)Creates a block statement from statements and optional scope. |
|
public static BooleanExpression |
boolX(Expression expr)Wraps an expression in a BooleanExpression. |
|
public static BytecodeExpression |
bytecodeX(Consumer<org.objectweb.asm.MethodVisitor> writer)Creates a custom BytecodeExpression. |
|
public static BytecodeExpression |
bytecodeX(ClassNode type, Consumer<org.objectweb.asm.MethodVisitor> writer)Creates a custom BytecodeExpression. |
|
public static MethodCallExpression |
callSuperX(String methodName)Creates a method call expression on super. |
|
public static MethodCallExpression |
callSuperX(String methodName, Expression args)Creates a method call expression on super. |
|
public static MethodCallExpression |
callThisX(String methodName)Creates a method call expression on this. |
|
public static MethodCallExpression |
callThisX(String methodName, Expression args)Creates a method call expression on this. |
|
public static MethodCallExpression |
callX(Expression receiver, String methodName)Creates a method call expression. |
|
public static MethodCallExpression |
callX(Expression receiver, String methodName, Expression args)Creates a method call expression. |
|
public static MethodCallExpression |
callX(Expression receiver, Expression method, Expression args)Creates a method call expression. |
|
public static StaticMethodCallExpression |
callX(ClassNode receiver, String methodName)Creates a method call expression. |
|
public static StaticMethodCallExpression |
callX(ClassNode receiver, String methodName, Expression args)Creates a method call expression. |
|
public static CaseStatement |
caseS(Expression expression, Statement code)Creates a switch-case statement. |
|
public static CastExpression |
castX(ClassNode type, Expression expression)Creates a cast expression. |
|
public static CastExpression |
castX(ClassNode type, Expression expression, boolean ignoreAutoboxing)Creates a cast expression. |
|
public static CatchStatement |
catchS(Parameter variable, Statement code)Creates a catch statement. |
|
public static ListExpression |
classList2args(List<String> args)Converts class-name strings into class-literal expressions. |
|
public static ClassExpression |
classX(ClassNode clazz)Creates a class literal expression. |
|
public static ClassExpression |
classX(Class<?> clazz)Creates a class literal expression. |
|
public static Parameter[] |
cloneParams(Parameter[] parameters)Clones parameter metadata as new Parameter instances with original type and name. |
|
public static ClosureExpression |
closureX(Parameter[] params, Statement code)Creates a closure expression. |
|
public static ClosureExpression |
closureX(Statement code)Creates a closure expression. |
|
public static BinaryExpression |
cmpX(Expression lhv, Expression rhv)Builds a binary expression that compares two values. |
|
public static ConstantExpression |
constX(Object val)Creates a constant expression. |
|
public static ConstantExpression |
constX(Object val, boolean keepPrimitive)Creates a constant expression. |
|
public static String |
convertASTToSource(ReaderSource readerSource, ASTNode expression)Converts an expression into the String source. |
|
public static void |
copyAnnotatedNodeAnnotations(AnnotatedNode annotatedNode, List<AnnotationNode> copied, List<AnnotationNode> notCopied)Copies all candidateAnnotations with retention policy RetentionPolicy.RUNTIME and RetentionPolicy.CLASS. |
|
public static void |
copyAnnotatedNodeAnnotations(AnnotatedNode annotatedNode, List<AnnotationNode> copied, List<AnnotationNode> notCopied, boolean includeGenerated)Copies all candidateAnnotations with retention policy RetentionPolicy.RUNTIME and RetentionPolicy.CLASS. |
|
public static boolean |
copyStatementsWithSuperAdjustment(ClosureExpression pre, BlockStatement body)Copies closure statements into a block and rewrites a leading super(...) call when present. |
|
public static Statement |
createConstructorStatementDefault(FieldNode fNode)Builds default constructor-assignment logic for a field and matching argument. |
|
public static Statement |
ctorSuperS(Expression args)Creates a super(...) constructor call statement. |
|
public static Statement |
ctorSuperS()Creates a super(...) constructor call statement. |
|
public static ConstructorCallExpression |
ctorSuperX(Expression args)Creates a super(...) constructor call expression. |
|
public static ConstructorCallExpression |
ctorSuperX()Creates a super(...) constructor call expression. |
|
public static Statement |
ctorThisS(Expression args)Creates a this(...) constructor call statement. |
|
public static Statement |
ctorThisS()Creates a this(...) constructor call statement. |
|
public static ConstructorCallExpression |
ctorThisX(Expression args)Creates a this(...) constructor call expression. |
|
public static ConstructorCallExpression |
ctorThisX()Creates a this(...) constructor call expression. |
|
public static ConstructorCallExpression |
ctorX(ClassNode type, Expression args)Creates a constructor call expression. |
|
public static ConstructorCallExpression |
ctorX(ClassNode type)Creates a constructor call expression. |
|
public static Statement |
declS(Expression target, Expression init)Creates a variable declaration statement. |
|
public static DeclarationExpression |
declX(Expression target, Expression init)Creates a variable declaration expression. |
|
public static ConstantExpression |
defaultValueX(ClassNode type)Returns a constant expression with the default value for the given type (i.e., false for boolean, 0 for numbers or null). |
|
public static ElvisOperatorExpression |
elvisX(Expression base, Expression otherwise)Creates an Elvis operator expression. |
|
public static MapEntryExpression |
entryX(Expression key, Expression value)Creates a map entry expression. |
|
public static BinaryExpression |
eqX(Expression left, Expression right)Creates an equality comparison expression. |
|
public static BooleanExpression |
equalsNullX(Expression expr)Creates a null-equality test expression. |
|
public static FieldExpression |
fieldX(FieldNode fieldNode)Creates a field expression. |
|
public static FieldExpression |
fieldX(ClassNode owner, String fieldName)Creates a field expression. |
|
public static Expression |
findArg(String argName)Creates an expression that resolves an entry from script args. |
|
public static MethodNode |
findDeclaredMethod(ClassNode cNode, String name, int argsCount)Finds the first declared method with the specified name and arity. |
|
public static ForStatement |
forS(Parameter variable, Expression collectionExpression, Statement loopS)Creates a for-loop statement. |
|
public static BinaryExpression |
geX(Expression lhv, Expression rhv)Creates a greater-than-or-equal comparison expression. |
|
public static List<MethodNode> |
getAllMethods(ClassNode type)Collects methods declared on a class and its super classes. |
|
public static List<PropertyNode> |
getAllProperties(ClassNode type)Collects properties according to the supplied inclusion flags. |
|
public static List<PropertyNode> |
getAllProperties(Set<String> names, ClassNode cNode, boolean includeProperties, boolean includeFields, boolean includePseudoGetters, boolean includePseudoSetters, boolean traverseSuperClasses, boolean skipReadonly)Collects properties according to the supplied inclusion flags. |
|
public static List<PropertyNode> |
getAllProperties(Set<String> names, ClassNode origType, ClassNode cNode, boolean includeProperties, boolean includeFields, boolean includePseudoGetters, boolean includePseudoSetters, boolean traverseSuperClasses, boolean skipReadonly)Collects properties according to the supplied inclusion flags. |
|
public static List<PropertyNode> |
getAllProperties(Set<String> names, ClassNode origType, ClassNode cNode, boolean includeProperties, boolean includeFields, boolean includePseudoGetters, boolean includePseudoSetters, boolean traverseSuperClasses, boolean skipReadonly, boolean reverse, boolean allNames, boolean includeStatic)Collects properties according to the supplied inclusion flags. |
|
public static String |
getGetterName(PropertyNode pNode)Generally preferred to use PropertyNode.getGetterNameOrDefault directly. |
|
public static String |
getGetterName(String name, Class<?> type)WARNING: Avoid this method unless just the name and type are available. |
|
public static String |
getGetterName(String name)WARNING: Avoid this method unless just the name is available. |
|
public static List<String> |
getInstanceNonPropertyFieldNames(ClassNode cNode)Collects names of instance fields that are not exposed as properties. |
|
public static List<FieldNode> |
getInstanceNonPropertyFields(ClassNode cNode)Collects instance fields that are not exposed as properties. |
|
public static List<PropertyNode> |
getInstanceProperties(ClassNode cNode)Collects instance (non-static) properties. |
|
public static List<FieldNode> |
getInstancePropertyFields(ClassNode cNode)Collects backing fields for instance properties. |
|
public static List<String> |
getInstancePropertyNames(ClassNode cNode)Collects names of instance properties. |
|
public static Set<ClassNode> |
getInterfacesAndSuperInterfaces(ClassNode cNode)Collects interfaces implemented directly or transitively. |
|
public static String |
getSetterName(String name)Computes the JavaBean setter name for a property. |
|
public static List<FieldNode> |
getSuperNonPropertyFields(ClassNode cNode)Collects inherited instance fields that are not properties. |
|
public static List<FieldNode> |
getSuperPropertyFields(ClassNode cNode)Collects inherited property backing fields. |
|
public static Expression |
getterThisX(ClassNode annotatedNode, PropertyNode pNode)This method is similar to propX(Expression, Expression) but will make sure that if the property being accessed is defined inside the classnode provided as a parameter, then a getter call is generated instead of a field access. |
|
public static Expression |
getterX(ClassNode annotatedNode, Expression receiver, PropertyNode pNode)This method is similar to propX(Expression, Expression) but will make sure that if the property being accessed is defined inside the classnode provided as a parameter, then a getter call is generated instead of a field access. |
|
public static BinaryExpression |
gtX(Expression lhv, Expression rhv)Creates a greater-than comparison expression. |
|
public static BinaryExpression |
hasClassX(Expression instance, ClassNode cNode)Creates an expression testing whether instance.getClass() equals the supplied class. |
|
public static boolean |
hasDeclaredMethod(ClassNode cNode, String name, int argsCount)Checks whether a class declares a method with the specified name and arity. |
|
public static BinaryExpression |
hasEqualFieldX(FieldNode fNode, Expression other)Creates an equality comparison against another object's field value. |
|
public static BinaryExpression |
hasEqualPropertyX(ClassNode cNode, PropertyNode pNode, VariableExpression other)Creates an equality comparison against another object's property value. |
|
public static BinaryExpression |
hasEqualPropertyX(PropertyNode pNode, Expression other)Creates an equality comparison against another object's property value. |
|
public static BooleanExpression |
hasSameFieldX(FieldNode fNode, Expression other)Creates an identity comparison against another object's field value. |
|
public static BooleanExpression |
hasSamePropertyX(PropertyNode pNode, Expression other)Creates an identity comparison against another object's property value. |
|
public static IfStatement |
ifElseS(Expression cond, Statement thenStmt, Statement elseStmt)Creates an if/else statement. |
|
public static IfStatement |
ifS(Expression cond, Expression trueExpr)Creates an if statement with an empty else branch. |
|
public static IfStatement |
ifS(Expression cond, Statement trueStmt)Creates an if statement with an empty else branch. |
|
public static boolean |
inSamePackage(ClassNode first, ClassNode second)Checks whether two classes belong to the same package. |
|
public static boolean |
inSamePackage(Class<?> first, Class<?> second)Checks whether two classes belong to the same package. |
|
public static Expression |
indexX(Expression target, Expression value)Creates an index access expression. |
|
public static boolean |
isDefaultVisibility(int modifiers)Checks whether modifier bits indicate package-private visibility. |
|
public static BooleanExpression |
isInstanceOfX(Expression expr, ClassNode type)Creates an instanceof test expression. |
|
public static BooleanExpression |
isNullOrInstanceOfX(Expression expr, ClassNode type)
|
|
public static BooleanExpression |
isNullX(Expression expr)Alias for equalsNullX(Expression) |
|
public static BooleanExpression |
isOneX(Expression expr)Creates an equality test against numeric one. |
|
public static boolean |
isOrImplements(ClassNode type, ClassNode interfaceType)Checks whether a type equals or implements an interface type. |
|
public static BooleanExpression |
isTrueX(Expression argExpr)Creates an equality test against Boolean.TRUE. |
|
public static BooleanExpression |
isZeroX(Expression expr)Creates an equality test against numeric zero. |
|
public static LambdaExpression |
lambdaX(Parameter[] params, Statement code)Builds a lambda expression |
|
public static LambdaExpression |
lambdaX(Statement code)Builds a lambda expression with no parameters |
|
public static BinaryExpression |
leX(Expression lhv, Expression rhv)Creates a less-than-or-equal comparison expression. |
|
public static ListExpression |
list2args(List<?> args)Converts values into a constant-based list expression. |
|
public static ListExpression |
listX(List<Expression> args)Creates a list expression. |
|
public static VariableExpression |
localVarX(String name)Creates a local variable expression and marks it as the accessed variable. |
|
public static VariableExpression |
localVarX(String name, ClassNode type)Creates a local variable expression and marks it as the accessed variable. |
|
public static BinaryExpression |
ltX(Expression lhv, Expression rhv)Creates a less-than comparison expression. |
|
public static String |
makeDescriptorWithoutReturnType(MethodNode mn)
|
|
public static MapEntryExpression |
mapEntryX(Expression keyExpr, Expression valueExpr)Creates a map entry expression. |
|
public static MapEntryExpression |
mapEntryX(String key, Expression valueExpr)Creates a map entry expression. |
|
public static MapExpression |
mapX()Creates a map expression. |
|
public static MapExpression |
mapX(List<MapEntryExpression> expressions)Creates a map expression. |
|
public static boolean |
maybeFallsThrough(Statement statement)Determines whether execution may continue past the supplied statement. |
|
public static BinaryExpression |
minusX(Expression lhv, Expression rhv)Creates a subtraction expression. |
|
public static BinaryExpression |
neX(Expression lhv, Expression rhv)Creates an inequality comparison expression. |
|
public static BinaryExpression |
notIdenticalX(Expression lhv, Expression rhv)Creates a non-identity comparison expression. |
|
public static BooleanExpression |
notNullX(Expression expr)Creates a non-null test expression. |
|
public static NotExpression |
notX(Expression expr)Creates a logical NOT expression. |
|
public static ConstantExpression |
nullX()Creates a null constant expression. |
|
public static BinaryExpression |
orX(Expression lhv, Expression rhv)Creates a logical OR expression. |
|
public static Parameter |
param(ClassNode type, String name)Creates a parameter node. |
|
public static Parameter |
param(ClassNode type, String name, Expression initialExpression)Creates a parameter node. |
|
public static Parameter[] |
params(Parameter params)Returns the input parameters or Parameter.EMPTY_ARRAY when input is null. |
|
public static BinaryExpression |
plusX(Expression lhv, Expression rhv)Creates an addition expression. |
|
public static PropertyExpression |
propX(Expression owner, String property)Creates a property access expression. |
|
public static PropertyExpression |
propX(Expression owner, Expression property)Creates a property access expression. |
|
public static PropertyExpression |
propX(Expression owner, Expression property, boolean safe)Creates a property access expression. |
|
public static Statement |
returnS(Expression expr)Creates a return statement. |
|
public static Statement |
safeExpression(Expression fieldExpr, Expression expression)Creates a null-guarded statement sequence. |
|
public static BooleanExpression |
sameX(Expression self, Expression other)Creates an identity test expression using Groovy's is method. |
|
public static SpreadExpression |
spreadX(Expression expr)Creates a spread expression. |
|
public static Statement |
stmt(Expression expr)Wraps an expression in an ExpressionStatement. |
|
public static SwitchStatement |
switchS(Expression expr)Creates a switch statement. |
|
public static SwitchStatement |
switchS(Expression expr, Statement defaultStatement)Creates a switch statement. |
|
public static SwitchStatement |
switchS(Expression expr, List<CaseStatement> caseStatements, Statement defaultStatement)Creates a switch statement. |
|
public static TernaryExpression |
ternaryX(Expression cond, Expression trueExpr, Expression elseExpr)Creates a ternary expression. |
|
public static PropertyExpression |
thisPropX(boolean implicit, String property)Creates a property expression on this with configurable implicit-this behavior. |
|
public static ThrowStatement |
throwS(Expression expr)Creates a throw statement. |
|
public static TryCatchStatement |
tryCatchS(Statement tryStatement)Creates a try/catch/finally statement. |
|
public static TryCatchStatement |
tryCatchS(Statement tryStatement, Statement finallyStatement)Creates a try/catch/finally statement. |
|
public static TryCatchStatement |
tryCatchS(Statement tryStatement, Statement finallyStatement, CatchStatement catchStatements)Creates a try/catch/finally statement. |
|
public static VariableExpression |
varX(String name)Creates a variable expression. |
|
public static VariableExpression |
varX(Variable variable)Creates a variable expression. |
|
public static VariableExpression |
varX(String name, ClassNode type)Creates a variable expression. |
AST logical AND operator token ("&&").
AST assignment operator token ("=").
AST compare-to operator token ("<=>").
AST equality operator token ("==").
AST greater-than-or-equal operator token (">=").
AST greater-than operator token (">").
AST instanceof keyword token.
AST less-than-or-equal operator token ("<=").
AST less-than operator token ("<").
AST subtraction operator token ("-").
AST inequality operator token ("!=").
AST non-identity operator token ("!==").
AST logical OR operator token ("||").
AST addition operator token ("+").
Creates a binary expression with the AND operator joining two expressions.
lhv - the left-hand-side operandrhv - the right-hand-side operandCreates an ArgumentListExpression from individual expression arguments.
expressions - the argument expressions (may be empty)Creates an ArgumentListExpression from a list of expressions.
expressions - the list of argument expressions (may be empty)Creates an ArgumentListExpression from parameter nodes, extracting their names as variable references.
parameters - the parameter nodesCreates an ArgumentListExpression from variable names, converting each to a VariableExpression.
names - the variable names (non-null strings)Creates an ArrayExpression for the given element type and initial value expressions.
elementType - the ClassNode representing the array element typeinitExpressions - the expressions providing initial array valuesCreates an ArrayExpression for the given element type, dimensions, and initial values.
elementType - the ClassNode representing the array element typeinitExpressions - the expressions providing initial array valuessizeExpressions - the expressions providing array dimensionsCreates a CastExpression converting the given expression to the specified type.
type - the ClassNode to cast toexpression - the expression to castCreates a statement that assigns a null/empty value to the target expression. Used to clear or reset variable values.
target - the expression to assign toCreates an assignment statement for the supplied target and value.
target - the assignment target expressionvalue - the value expressionCreates an assignment expression using ASSIGN.
target - the assignment target expressionvalue - the value expression
Creates an attribute access expression.
owner - the owner expressionattribute - the attribute expressionCreates a binary expression from operands and an operator token.
left - the left-hand operandtoken - the operator tokenright - the right-hand operandCreates a block statement from statements and optional scope.
scope - the variable scope for the blockstmts - the statements to include in the blockCreates a block statement from statements and optional scope.
scope - the variable scope for the blockstmts - the statements to include in the blockCreates a block statement from statements and optional scope.
stmts - the statements to include in the blockWraps an expression in a BooleanExpression.
expr - the expressionCreates a custom BytecodeExpression.
writer - the bytecode writer callbackCreates a custom BytecodeExpression.
type - the target typewriter - the bytecode writer callback Creates a method call expression on super.
methodName - the method name Creates a method call expression on super.
methodName - the method nameargs - the argument expression(s) Creates a method call expression on this.
methodName - the method name Creates a method call expression on this.
methodName - the method nameargs - the argument expression(s)Creates a method call expression.
receiver - the call receivermethodName - the method nameCreates a method call expression.
receiver - the call receivermethodName - the method nameargs - the argument expression(s)Creates a method call expression.
receiver - the call receivermethod - the method expressionargs - the argument expression(s)Creates a method call expression.
receiver - the call receivermethodName - the method nameCreates a method call expression.
receiver - the call receivermethodName - the method nameargs - the argument expression(s)Creates a switch-case statement.
expression - the expressioncode - the statement bodyCreates a cast expression.
type - the target typeexpression - the expressionCreates a cast expression.
type - the target typeexpression - the expressionignoreAutoboxing - whether autoboxing should be ignoredCreates a catch statement.
variable - the loop or catch parametercode - the statement bodyConverts class-name strings into class-literal expressions.
args - the argument expression(s)Creates a class literal expression.
clazz - the class referenceCreates a class literal expression.
clazz - the class referenceClones parameter metadata as new Parameter instances with original type and name.
parameters - the parameters to cloneCreates a closure expression.
params - the parameter arraycode - the statement bodyCreates a closure expression.
code - the statement bodyBuilds a binary expression that compares two values.
lhv - expression for the value to compare fromrhv - expression for the value to compare toCreates a constant expression.
val - the valCreates a constant expression.
val - the valkeepPrimitive - whether primitive-wrapper constants should be preservedConverts an expression into the String source. Only some specific expressions like closure expression support this.
readerSource - a sourceexpression - an expression. Can't be nullCopies all candidateAnnotations with retention policy RetentionPolicy.RUNTIME and RetentionPolicy.CLASS.
Annotations with GeneratedClosure members are not supported at present.
Copies all candidateAnnotations with retention policy RetentionPolicy.RUNTIME
and RetentionPolicy.CLASS.
Generated annotations will be copied if includeGenerated is true.
Annotations with GeneratedClosure members are not supported at present.
Copies closure statements into a block and rewrites a leading super(...) call when present.
pre - the closure containing statements to copybody - the destination blockBuilds default constructor-assignment logic for a field and matching argument.
fNode - the field node Creates a super(...) constructor call statement.
args - the argument expression(s) Creates a super(...) constructor call statement.
Creates a super(...) constructor call expression.
args - the argument expression(s) Creates a super(...) constructor call expression.
Creates a this(...) constructor call statement.
args - the argument expression(s) Creates a this(...) constructor call statement.
Creates a this(...) constructor call expression.
args - the argument expression(s) Creates a this(...) constructor call expression.
Creates a constructor call expression.
type - the target typeargs - the argument expression(s)Creates a constructor call expression.
type - the target typeCreates a variable declaration statement.
target - the assignment target expressioninit - the initializer expressionCreates a variable declaration expression.
target - the assignment target expressioninit - the initializer expression Returns a constant expression with the default value for the given type
(i.e., false for boolean, 0 for numbers or null).
Creates an Elvis operator expression.
base - the base expressionotherwise - the fallback expressionCreates a map entry expression.
key - the key expressionvalue - the value expressionCreates an equality comparison expression.
left - the left-hand operandright - the right-hand operandCreates a null-equality test expression.
expr - the expressionCreates a field expression.
fieldNode - the fieldNodeCreates a field expression.
owner - the owner expressionfieldName - the field nameCreates an expression that resolves an entry from script args.
argName - the argument nameFinds the first declared method with the specified name and arity.
cNode - the class nodename - the property nameargsCount - the expected argument countnull if not foundCreates a for-loop statement.
variable - the loop or catch parametercollectionExpression - the collection expressionloopS - the loop body statementCreates a greater-than-or-equal comparison expression.
lhv - the left-hand operandrhv - the right-hand operandCollects methods declared on a class and its super classes.
type - the target typeCollects properties according to the supplied inclusion flags.
type - the target typeCollects properties according to the supplied inclusion flags.
names - the set tracking already-added property namescNode - the class nodeincludeProperties - whether declared properties are includedincludeFields - whether fields are exposed as propertiesincludePseudoGetters - whether pseudo-getter properties are includedincludePseudoSetters - whether pseudo-setter properties are includedtraverseSuperClasses - whether super classes are traversedskipReadonly - whether read-only initialized fields are excludedCollects properties according to the supplied inclusion flags.
names - the set tracking already-added property namesorigType - the original class node used for pseudo-property resolutioncNode - the class nodeincludeProperties - whether declared properties are includedincludeFields - whether fields are exposed as propertiesincludePseudoGetters - whether pseudo-getter properties are includedincludePseudoSetters - whether pseudo-setter properties are includedtraverseSuperClasses - whether super classes are traversedskipReadonly - whether read-only initialized fields are excludedCollects properties according to the supplied inclusion flags.
names - the set tracking already-added property namesorigType - the original class node used for pseudo-property resolutioncNode - the class nodeincludeProperties - whether declared properties are includedincludeFields - whether fields are exposed as propertiesincludePseudoGetters - whether pseudo-getter properties are includedincludePseudoSetters - whether pseudo-setter properties are includedtraverseSuperClasses - whether super classes are traversedskipReadonly - whether read-only initialized fields are excludedreverse - whether superclass traversal order is reversedallNames - whether special/internal field names are includedincludeStatic - whether static members are includedGenerally preferred to use PropertyNode.getGetterNameOrDefault directly.
WARNING: Avoid this method unless just the name and type are available. Use getGetterName(PropertyNode) if the propertyNode is available.
WARNING: Avoid this method unless just the name is available. Use getGetterName(PropertyNode) if the propertyNode is available. Use getGetterName(String, Class) if the type is available.
Collects names of instance fields that are not exposed as properties.
cNode - the class nodeCollects instance fields that are not exposed as properties.
cNode - the class nodeCollects instance (non-static) properties.
cNode - the class nodeCollects backing fields for instance properties.
cNode - the class nodeCollects names of instance properties.
cNode - the class nodeCollects interfaces implemented directly or transitively.
cNode - the class nodeComputes the JavaBean setter name for a property.
name - the property nameCollects inherited instance fields that are not properties.
cNode - the class nodeCollects inherited property backing fields.
cNode - the class nodeThis method is similar to propX(Expression, Expression) but will make sure that if the property being accessed is defined inside the classnode provided as a parameter, then a getter call is generated instead of a field access.
annotatedNode - the class node where the property node is accessed frompNode - the property being accessedThis method is similar to propX(Expression, Expression) but will make sure that if the property being accessed is defined inside the classnode provided as a parameter, then a getter call is generated instead of a field access.
annotatedNode - the class node where the property node is accessed fromreceiver - the object having the propertypNode - the property being accessedCreates a greater-than comparison expression.
lhv - the left-hand operandrhv - the right-hand operand Creates an expression testing whether instance.getClass() equals the supplied class.
instance - the instance expressioncNode - the class nodeChecks whether a class declares a method with the specified name and arity.
cNode - the class nodename - the property nameargsCount - the expected argument countCreates an equality comparison against another object's field value.
fNode - the field nodeother - the other object/value expressionCreates an equality comparison against another object's property value.
cNode - the class nodepNode - the property nodeother - the other object/value expressionCreates an equality comparison against another object's property value.
pNode - the property nodeother - the other object/value expressionCreates an identity comparison against another object's field value.
fNode - the field nodeother - the other object/value expressionCreates an identity comparison against another object's property value.
pNode - the property nodeother - the other object/value expressionCreates an if/else statement.
cond - the condition expressionthenStmt - the true-branch statementelseStmt - the false-branch statementCreates an if statement with an empty else branch.
cond - the condition expressiontrueExpr - the true-branch expressionCreates an if statement with an empty else branch.
cond - the condition expressiontrueStmt - the true-branch statementChecks whether two classes belong to the same package.
first - the first class/typesecond - the second class/typeChecks whether two classes belong to the same package.
first - the first class/typesecond - the second class/typeCreates an index access expression.
target - the assignment target expressionvalue - the value expressionChecks whether modifier bits indicate package-private visibility.
modifiers - the modifier bit mask Creates an instanceof test expression.
expr - the expressiontype - the target type
Alias for equalsNullX(Expression)
Creates an equality test against numeric one.
expr - the expressionChecks whether a type equals or implements an interface type.
type - the target typeinterfaceType - the interface to test againstCreates an equality test against Boolean.TRUE.
argExpr - the argument expressionCreates an equality test against numeric zero.
expr - the expressionBuilds a lambda expression
params - lambda parameterscode - lambda codeBuilds a lambda expression with no parameters
code - lambda codeCreates a less-than-or-equal comparison expression.
lhv - the left-hand operandrhv - the right-hand operandConverts values into a constant-based list expression.
args - the argument expression(s)Creates a list expression.
args - the argument expression(s)Creates a local variable expression and marks it as the accessed variable.
name - the property nameCreates a local variable expression and marks it as the accessed variable.
name - the property nametype - the target typeCreates a less-than comparison expression.
lhv - the left-hand operandrhv - the right-hand operandCreates a map entry expression.
keyExpr - the map-entry key expressionvalueExpr - the map-entry value expressionCreates a map entry expression.
key - the key expressionvalueExpr - the map-entry value expressionCreates a map expression.
Creates a map expression.
expressions - the map-entry expressionsDetermines whether execution may continue past the supplied statement.
statement - the statement to analyzeCreates a subtraction expression.
lhv - the left-hand operandrhv - the right-hand operandCreates an inequality comparison expression.
lhv - the left-hand operandrhv - the right-hand operandCreates a non-identity comparison expression.
lhv - the left-hand operandrhv - the right-hand operandCreates a non-null test expression.
expr - the expressionCreates a logical NOT expression.
expr - the expression Creates a null constant expression.
Creates a logical OR expression.
lhv - the left-hand operandrhv - the right-hand operandCreates a parameter node.
type - the target typename - the property nameCreates a parameter node.
type - the target typename - the property nameinitialExpression - the initial expression for the parameter Returns the input parameters or Parameter.EMPTY_ARRAY when input is null.
params - the parameter arrayCreates an addition expression.
lhv - the left-hand operandrhv - the right-hand operandCreates a property access expression.
owner - the owner expressionproperty - the property name/expressionCreates a property access expression.
owner - the owner expressionproperty - the property name/expressionCreates a property access expression.
owner - the owner expressionproperty - the property name/expressionsafe - whether safe-navigation is enabledCreates a return statement.
expr - the expressionCreates a null-guarded statement sequence.
fieldExpr - the field expression used in the guardexpression - the expression Creates an identity test expression using Groovy's is method.
self - the left-hand expressionother - the other object/value expressionCreates a spread expression.
expr - the expressionWraps an expression in an ExpressionStatement.
expr - the expressionCreates a switch statement.
expr - the expressionCreates a switch statement.
expr - the expressiondefaultStatement - the default branch statementCreates a switch statement.
expr - the expressioncaseStatements - the case statementsdefaultStatement - the default branch statementCreates a ternary expression.
cond - the condition expressiontrueExpr - the true-branch expressionelseExpr - the false-branch expression Creates a property expression on this with configurable implicit-this behavior.
implicit - whether the receiver is implicit thisproperty - the property name/expressionCreates a throw statement.
expr - the expressionCreates a try/catch/finally statement.
tryStatement - the try-block statementCreates a try/catch/finally statement.
tryStatement - the try-block statementfinallyStatement - the finally-block statementCreates a try/catch/finally statement.
tryStatement - the try-block statementfinallyStatement - the finally-block statementcatchStatements - the catch statementsCreates a variable expression.
name - the property nameCreates a variable expression.
variable - the loop or catch parameterCreates a variable expression.
name - the property nametype - the target type