Package org.codehaus.groovy.ast.tools

# Class GeneralUtils

java.lang.Object
org.codehaus.groovy.ast.tools.GeneralUtils

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:

- Statement constructors: `block()`, `expr()`, `assign()`, `ret()`, etc.
- Expression constructors: `var()`, `constX()`, `classX()`, `cast()`, etc.
- Operator expressions: `binX()`, `andX()`, `orX()`, `cmp()`, etc.
- Collection literals: `list()`, `map()`, `tuple()`, `array()`, etc.
- Method calls: `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.

See Also:
  - `for the base expression type`
  - `for the base statement type`
  - `for type information`
  - `for generic type utilities`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final Token`
  `AND`
  `static final Token`
  `ASSIGN`
  `static final Token`
  `CMP`
  `static final Token`
  `EQ`
  `static final Token`
  `GE`
  `static final Token`
  `GT`
  `static final Token`
  `INSTANCEOF`
  `static final Token`
  `LE`
  `static final Token`
  `LT`
  `static final Token`
  `MINUS`
  `static final Token`
  `NE`
  `static final Token`
  `NOT_IDENTICAL`
  `static final Token`
  `OR`
  `static final Token`
  `PLUS`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `GeneralUtils()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static BinaryExpression`
  `andX(Expression lhv, Expression rhv)`
  Creates a binary expression with the AND operator joining two expressions.
  `static ArgumentListExpression`
  `args(String... names)`
  Creates an ArgumentListExpression from variable names, converting each to a VariableExpression.
  `static ArgumentListExpression`
  `args(List<Expression> expressions)`
  Creates an ArgumentListExpression from a list of expressions.
  `static ArgumentListExpression`
  `args(Expression... expressions)`
  Creates an ArgumentListExpression from individual expression arguments.
  `static ArgumentListExpression`
  `args(Parameter... parameters)`
  Creates an ArgumentListExpression from parameter nodes, extracting their names as variable references.
  `static ArrayExpression`
  `arrayX(ClassNode elementType, List<Expression> initExpressions)`
  Creates an ArrayExpression for the given element type and initial value expressions.
  `static ArrayExpression`
  `arrayX(ClassNode elementType, List<Expression> initExpressions, List<Expression> sizeExpressions)`
  Creates an ArrayExpression for the given element type, dimensions, and initial values.
  `static Statement`
  `assignNullS(Expression target)`
  Creates a statement that assigns a null/empty value to the target expression.
  `static Statement`
  `assignS(Expression target, Expression value)`
  `static Expression`
  `assignX(Expression target, Expression value)`
  `static CastExpression`
  `asX(ClassNode type, Expression expression)`
  Creates a CastExpression converting the given expression to the specified type.
  `static AttributeExpression`
  `attrX(Expression owner, String attribute)`
  `static AttributeExpression`
  `attrX(Expression owner, Expression attribute)`
  `static Expression`
  `attrX$$bridge(Expression owner, Expression attribute)`
  Deprecated.
  `static BinaryExpression`
  `binX(Expression left, Token token, Expression right)`
  `static BlockStatement`
  `block(Statement... stmts)`
  `static BlockStatement`
  `block(VariableScope scope, List<Statement> stmts)`
  `static BlockStatement`
  `block(VariableScope scope, Statement... stmts)`
  `static BooleanExpression`
  `boolX(Expression expr)`
  `static BytecodeExpression`
  `bytecodeX(Consumer<org.objectweb.asm.MethodVisitor> writer)`
  `static BytecodeExpression`
  `bytecodeX(ClassNode type, Consumer<org.objectweb.asm.MethodVisitor> writer)`
  `static MethodCallExpression`
  `callSuperX(String methodName)`
  `static MethodCallExpression`
  `callSuperX(String methodName, Expression args)`
  `static MethodCallExpression`
  `callThisX(String methodName)`
  `static MethodCallExpression`
  `callThisX(String methodName, Expression args)`
  `static StaticMethodCallExpression`
  `callX(ClassNode receiver, String methodName)`
  `static StaticMethodCallExpression`
  `callX(ClassNode receiver, String methodName, Expression args)`
  `static MethodCallExpression`
  `callX(Expression receiver, String methodName)`
  `static MethodCallExpression`
  `callX(Expression receiver, String methodName, Expression args)`
  `static MethodCallExpression`
  `callX(Expression receiver, Expression method, Expression args)`
  `static CaseStatement`
  `caseS(Expression expression, Statement code)`
  `static CastExpression`
  `castX(ClassNode type, Expression expression)`
  `static CastExpression`
  `castX(ClassNode type, Expression expression, boolean ignoreAutoboxing)`
  `static CatchStatement`
  `catchS(Parameter variable, Statement code)`
  `static ListExpression`
  `classList2args(List<String> args)`
  `static ClassExpression`
  `classX(Class<?> clazz)`
  `static ClassExpression`
  `classX(ClassNode clazz)`
  `static Parameter[]`
  `cloneParams(Parameter[] parameters)`
  `static ClosureExpression`
  `closureX(Parameter[] params, Statement code)`
  `static ClosureExpression`
  `closureX(Statement code)`
  `static BinaryExpression`
  `cmpX(Expression lhv, Expression rhv)`
  Builds a binary expression that compares two values.
  `static ConstantExpression`
  `constX(Object val)`
  `static ConstantExpression`
  `constX(Object val, boolean keepPrimitive)`
  `static String`
  `convertASTToSource(ReaderSource readerSource, ASTNode expression)`
  Converts an expression into the String source.
  `static void`
  `copyAnnotatedNodeAnnotations(AnnotatedNode annotatedNode, List<AnnotationNode> copied, List<AnnotationNode> notCopied)`
  Copies all `candidateAnnotations` with retention policy `RetentionPolicy.RUNTIME` and `RetentionPolicy.CLASS`.
  `static void`
  `copyAnnotatedNodeAnnotations(AnnotatedNode annotatedNode, List<AnnotationNode> copied, List<AnnotationNode> notCopied, boolean includeGenerated)`
  Copies all `candidateAnnotations` with retention policy `RetentionPolicy.RUNTIME` and `RetentionPolicy.CLASS`.
  `static boolean`
  `copyStatementsWithSuperAdjustment(ClosureExpression pre, BlockStatement body)`
  `static Statement`
  `createConstructorStatementDefault(FieldNode fNode)`
  `static Statement`
  `ctorSuperS()`
  `static Statement`
  `ctorSuperS(Expression args)`
  `static ConstructorCallExpression`
  `ctorSuperX()`
  `static ConstructorCallExpression`
  `ctorSuperX(Expression args)`
  `static Statement`
  `ctorThisS()`
  `static Statement`
  `ctorThisS(Expression args)`
  `static ConstructorCallExpression`
  `ctorThisX()`
  `static ConstructorCallExpression`
  `ctorThisX(Expression args)`
  `static ConstructorCallExpression`
  `ctorX(ClassNode type)`
  `static ConstructorCallExpression`
  `ctorX(ClassNode type, Expression args)`
  `static Statement`
  `declS(Expression target, Expression init)`
  `static DeclarationExpression`
  `declX(Expression target, Expression init)`
  `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`.
  `static ElvisOperatorExpression`
  `elvisX(Expression base, Expression otherwise)`
  `static MapEntryExpression`
  `entryX(Expression key, Expression value)`
  `static BooleanExpression`
  `equalsNullX(Expression expr)`
  `static BinaryExpression`
  `eqX(Expression left, Expression right)`
  `static FieldExpression`
  `fieldX(ClassNode owner, String fieldName)`
  `static FieldExpression`
  `fieldX(FieldNode fieldNode)`
  `static Expression`
  `findArg(String argName)`
  `static MethodNode`
  `findDeclaredMethod(ClassNode cNode, String name, int argsCount)`
  `static ForStatement`
  `forS(Parameter variable, Expression collectionExpression, Statement loopS)`
  `static List<MethodNode>`
  `getAllMethods(ClassNode type)`
  `static List<PropertyNode>`
  `getAllProperties(Set<String> names, ClassNode cNode, boolean includeProperties, boolean includeFields, boolean includePseudoGetters, boolean includePseudoSetters, boolean traverseSuperClasses, boolean skipReadonly)`
  `static List<PropertyNode>`
  `getAllProperties(Set<String> names, ClassNode origType, ClassNode cNode, boolean includeProperties, boolean includeFields, boolean includePseudoGetters, boolean includePseudoSetters, boolean traverseSuperClasses, boolean skipReadonly)`
  `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)`
  `static List<PropertyNode>`
  `getAllProperties(ClassNode type)`
  `static String`
  `getGetterName(String name)`
  WARNING: Avoid this method unless just the name is available.
  `static String`
  `getGetterName(String name, Class<?> type)`
  WARNING: Avoid this method unless just the name and type are available.
  `static String`
  `getGetterName(PropertyNode pNode)`
  Generally preferred to use `PropertyNode.getGetterNameOrDefault()` directly.
  `static List<String>`
  `getInstanceNonPropertyFieldNames(ClassNode cNode)`
  `static List<FieldNode>`
  `getInstanceNonPropertyFields(ClassNode cNode)`
  `static List<PropertyNode>`
  `getInstanceProperties(ClassNode cNode)`
  `static List<FieldNode>`
  `getInstancePropertyFields(ClassNode cNode)`
  `static List<String>`
  `getInstancePropertyNames(ClassNode cNode)`
  `static Set<ClassNode>`
  `getInterfacesAndSuperInterfaces(ClassNode cNode)`
  `static String`
  `getSetterName(String name)`
  `static List<FieldNode>`
  `getSuperNonPropertyFields(ClassNode cNode)`
  `static List<FieldNode>`
  `getSuperPropertyFields(ClassNode cNode)`
  `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.
  `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.
  `static BinaryExpression`
  `geX(Expression lhv, Expression rhv)`
  `static BinaryExpression`
  `gtX(Expression lhv, Expression rhv)`
  `static BinaryExpression`
  `hasClassX(Expression instance, ClassNode cNode)`
  `static boolean`
  `hasDeclaredMethod(ClassNode cNode, String name, int argsCount)`
  `static BinaryExpression`
  `hasEqualFieldX(FieldNode fNode, Expression other)`
  `static BinaryExpression`
  `hasEqualPropertyX(ClassNode cNode, PropertyNode pNode, VariableExpression other)`
  `static BinaryExpression`
  `hasEqualPropertyX(PropertyNode pNode, Expression other)`
  Deprecated.
  `static BooleanExpression`
  `hasSameFieldX(FieldNode fNode, Expression other)`
  `static BooleanExpression`
  `hasSamePropertyX(PropertyNode pNode, Expression other)`
  `static IfStatement`
  `ifElseS(Expression cond, Statement thenStmt, Statement elseStmt)`
  `static Statement`
  `ifElseS$$bridge(Expression cond, Statement thenStmt, Statement elseStmt)`
  Deprecated.
  `static IfStatement`
  `ifS(Expression cond, Expression trueExpr)`
  `static IfStatement`
  `ifS(Expression cond, Statement trueStmt)`
  `static Statement`
  `ifS$$bridge(Expression cond, Expression trueExpr)`
  Deprecated.
  `static Statement`
  `ifS$$bridge(Expression cond, Statement trueStmt)`
  Deprecated.
  `static Expression`
  `indexX(Expression target, Expression value)`
  `static boolean`
  `inSamePackage(Class<?> first, Class<?> second)`
  `static boolean`
  `inSamePackage(ClassNode first, ClassNode second)`
  `static boolean`
  `isDefaultVisibility(int modifiers)`
  `static BooleanExpression`
  `isInstanceOfX(Expression expr, ClassNode type)`
  `static BooleanExpression`
  `isNullOrInstanceOfX(Expression expr, ClassNode type)`
  `static BooleanExpression`
  `isNullX(Expression expr)`
  Alias for `equalsNullX(Expression)`
  `static BooleanExpression`
  `isOneX(Expression expr)`
  `static boolean`
  `isOrImplements(ClassNode type, ClassNode interfaceType)`
  `static BooleanExpression`
  `isTrueX(Expression argExpr)`
  `static BooleanExpression`
  `isZeroX(Expression expr)`
  `static LambdaExpression`
  `lambdaX(Parameter[] params, Statement code)`
  Builds a lambda expression
  `static LambdaExpression`
  `lambdaX(Statement code)`
  Builds a lambda expression with no parameters
  `static BinaryExpression`
  `leX(Expression lhv, Expression rhv)`
  `static ListExpression`
  `list2args(List<?> args)`
  `static ListExpression`
  `listX(List<Expression> args)`
  `static VariableExpression`
  `localVarX(String name)`
  `static VariableExpression`
  `localVarX(String name, ClassNode type)`
  `static BinaryExpression`
  `ltX(Expression lhv, Expression rhv)`
  `static String`
  `makeDescriptorWithoutReturnType(MethodNode mn)`
  Deprecated.
  use MethodNodeUtils#methodDescriptorWithoutReturnType(MethodNode) instead
  `static MapEntryExpression`
  `mapEntryX(String key, Expression valueExpr)`
  `static MapEntryExpression`
  `mapEntryX(Expression keyExpr, Expression valueExpr)`
  `static MapExpression`
  `mapX()`
  `static MapExpression`
  `mapX(List<MapEntryExpression> expressions)`
  `static boolean`
  `maybeFallsThrough(Statement statement)`
  `static BinaryExpression`
  `minusX(Expression lhv, Expression rhv)`
  `static BinaryExpression`
  `neX(Expression lhv, Expression rhv)`
  `static BinaryExpression`
  `notIdenticalX(Expression lhv, Expression rhv)`
  `static BooleanExpression`
  `notNullX(Expression expr)`
  `static NotExpression`
  `notX(Expression expr)`
  `static ConstantExpression`
  `nullX()`
  `static BinaryExpression`
  `orX(Expression lhv, Expression rhv)`
  `static Parameter`
  `param(ClassNode type, String name)`
  `static Parameter`
  `param(ClassNode type, String name, Expression initialExpression)`
  `static Parameter[]`
  `params(Parameter... params)`
  `static BinaryExpression`
  `plusX(Expression lhv, Expression rhv)`
  `static PropertyExpression`
  `propX(Expression owner, String property)`
  `static PropertyExpression`
  `propX(Expression owner, Expression property)`
  `static PropertyExpression`
  `propX(Expression owner, Expression property, boolean safe)`
  `static Expression`
  `propX$$bridge(Expression owner, String property)`
  Deprecated.
  `static Expression`
  `propX$$bridge(Expression owner, Expression property)`
  Deprecated.
  `static Statement`
  `returnS(Expression expr)`
  `static Statement`
  `safeExpression(Expression fieldExpr, Expression expression)`
  `static BooleanExpression`
  `sameX(Expression self, Expression other)`
  `static SpreadExpression`
  `spreadX(Expression expr)`
  `static Statement`
  `stmt(Expression expr)`
  `static SwitchStatement`
  `switchS(Expression expr)`
  `static SwitchStatement`
  `switchS(Expression expr, List<CaseStatement> caseStatements, Statement defaultStatement)`
  `static SwitchStatement`
  `switchS(Expression expr, Statement defaultStatement)`
  `static TernaryExpression`
  `ternaryX(Expression cond, Expression trueExpr, Expression elseExpr)`
  `static PropertyExpression`
  `thisPropX(boolean implicit, String property)`
  `static ThrowStatement`
  `throwS(Expression expr)`
  `static TryCatchStatement`
  `tryCatchS(Statement tryStatement)`
  `static TryCatchStatement`
  `tryCatchS(Statement tryStatement, Statement finallyStatement)`
  `static TryCatchStatement`
  `tryCatchS(Statement tryStatement, Statement finallyStatement, CatchStatement... catchStatements)`
  `static VariableExpression`
  `varX(String name)`
  `static VariableExpression`
  `varX(String name, ClassNode type)`
  `static VariableExpression`
  `varX(Variable variable)`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### ASSIGN

    public static final Token ASSIGN

  - ### CMP

    public static final Token CMP

  - ### EQ

    public static final Token EQ

  - ### NE

    public static final Token NE

  - ### NOT_IDENTICAL

    public static final Token NOT_IDENTICAL

  - ### GE

    public static final Token GE

  - ### GT

    public static final Token GT

  - ### LE

    public static final Token LE

  - ### LT

    public static final Token LT

  - ### AND

    public static final Token AND

  - ### OR

    public static final Token OR

  - ### INSTANCEOF

    public static final Token INSTANCEOF

  - ### MINUS

    public static final Token MINUS

  - ### PLUS

    public static final Token PLUS

- ## Constructor Details

  - ### GeneralUtils

    public GeneralUtils()

- ## Method Details

  - ### andX

    public static BinaryExpression andX(Expression lhv, Expression rhv)
    Creates a binary expression with the AND operator joining two expressions.
    Parameters:
      `lhv` - the left-hand-side operand
      `rhv` - the right-hand-side operand
    Returns:
      a BinaryExpression with AND operator
    See Also:
      - `binX(Expression, Token, Expression)`

  - ### args

    public static ArgumentListExpression args(Expression... expressions)
    Creates an ArgumentListExpression from individual expression arguments.
    Parameters:
      `expressions` - the argument expressions (may be empty)
    Returns:
      an ArgumentListExpression containing the arguments

  - ### args

    public static ArgumentListExpression args(List<Expression> expressions)
    Creates an ArgumentListExpression from a list of expressions.
    Parameters:
      `expressions` - the list of argument expressions (may be empty)
    Returns:
      an ArgumentListExpression containing the arguments

  - ### args

    public static ArgumentListExpression args(Parameter... parameters)
    Creates an ArgumentListExpression from parameter nodes, extracting their names as variable references.
    Parameters:
      `parameters` - the parameter nodes
    Returns:
      an ArgumentListExpression with variable expressions for each parameter

  - ### args

    public static ArgumentListExpression args(String... names)
    Creates an ArgumentListExpression from variable names, converting each to a VariableExpression.
    Parameters:
      `names` - the variable names (non-null strings)
    Returns:
      an ArgumentListExpression with variable expressions for each name

  - ### arrayX

    public static ArrayExpression arrayX(ClassNode elementType, List<Expression> initExpressions)
    Creates an ArrayExpression for the given element type and initial value expressions.
    Parameters:
      `elementType` - the `ClassNode` representing the array element type
      `initExpressions` - the expressions providing initial array values
    Returns:
      an ArrayExpression with the given element type and values

  - ### arrayX

    public static ArrayExpression arrayX(ClassNode elementType, List<Expression> initExpressions, List<Expression> sizeExpressions)
    Creates an ArrayExpression for the given element type, dimensions, and initial values.
    Parameters:
      `elementType` - the `ClassNode` representing the array element type
      `initExpressions` - the expressions providing initial array values
      `sizeExpressions` - the expressions providing array dimensions
    Returns:
      an ArrayExpression with the given element type, dimensions, and values

  - ### asX

    public static CastExpression asX(ClassNode type, Expression expression)
    Creates a CastExpression converting the given expression to the specified type.
    Parameters:
      `type` - the `ClassNode` to cast to
      `expression` - the expression to cast
    Returns:
      a CastExpression with the given type and expression

  - ### assignNullS

    public static Statement assignNullS(Expression target)
    Creates a statement that assigns a null/empty value to the target expression. Used to clear or reset variable values.
    Parameters:
      `target` - the expression to assign to
    Returns:
      an ExpressionStatement assigning null to the target

  - ### assignS

    public static Statement assignS(Expression target, Expression value)

  - ### assignX

    public static Expression assignX(Expression target, Expression value)

  - ### attrX

    public static AttributeExpression attrX(Expression owner, String attribute)
    Since:
      5.0.0

  - ### attrX

    public static AttributeExpression attrX(Expression owner, Expression attribute)

  - ### attrX$$bridge

    @Deprecated public static Expression attrX$$bridge(Expression owner, Expression attribute)
    Deprecated.

  - ### binX

    public static BinaryExpression binX(Expression left, Token token, Expression right)

  - ### block

    public static BlockStatement block(VariableScope scope, Statement... stmts)

  - ### block

    public static BlockStatement block(VariableScope scope, List<Statement> stmts)

  - ### block

    public static BlockStatement block(Statement... stmts)

  - ### boolX

    public static BooleanExpression boolX(Expression expr)

  - ### bytecodeX

    public static BytecodeExpression bytecodeX(Consumer<org.objectweb.asm.MethodVisitor> writer)

  - ### bytecodeX

    public static BytecodeExpression bytecodeX(ClassNode type, Consumer<org.objectweb.asm.MethodVisitor> writer)

  - ### callSuperX

    public static MethodCallExpression callSuperX(String methodName)

  - ### callSuperX

    public static MethodCallExpression callSuperX(String methodName, Expression args)

  - ### callThisX

    public static MethodCallExpression callThisX(String methodName)

  - ### callThisX

    public static MethodCallExpression callThisX(String methodName, Expression args)

  - ### callX

    public static MethodCallExpression callX(Expression receiver, String methodName)

  - ### callX

    public static MethodCallExpression callX(Expression receiver, String methodName, Expression args)

  - ### callX

    public static MethodCallExpression callX(Expression receiver, Expression method, Expression args)

  - ### callX

    public static StaticMethodCallExpression callX(ClassNode receiver, String methodName)

  - ### callX

    public static StaticMethodCallExpression callX(ClassNode receiver, String methodName, Expression args)

  - ### caseS

    public static CaseStatement caseS(Expression expression, Statement code)

  - ### castX

    public static CastExpression castX(ClassNode type, Expression expression)

  - ### castX

    public static CastExpression castX(ClassNode type, Expression expression, boolean ignoreAutoboxing)

  - ### catchS

    public static CatchStatement catchS(Parameter variable, Statement code)

  - ### classX

    public static ClassExpression classX(ClassNode clazz)

  - ### classX

    public static ClassExpression classX(Class<?> clazz)

  - ### closureX

    public static ClosureExpression closureX(Parameter[] params, Statement code)

  - ### closureX

    public static ClosureExpression closureX(Statement code)

  - ### lambdaX

    public static LambdaExpression lambdaX(Parameter[] params, Statement code)
    Builds a lambda expression
    Parameters:
      `params` - lambda parameters
      `code` - lambda code
    Returns:
      the lambda expression

  - ### lambdaX

    public static LambdaExpression lambdaX(Statement code)
    Builds a lambda expression with no parameters
    Parameters:
      `code` - lambda code
    Returns:
      the lambda expression

  - ### cmpX

    public static BinaryExpression cmpX(Expression lhv, Expression rhv)
    Builds a binary expression that compares two values.
    Parameters:
      `lhv` - expression for the value to compare from
      `rhv` - expression for the value to compare to
    Returns:
      the expression comparing two values

  - ### constX

    public static ConstantExpression constX(Object val)

  - ### constX

    public static ConstantExpression constX(Object val, boolean keepPrimitive)

  - ### ctorX

    public static ConstructorCallExpression ctorX(ClassNode type, Expression args)

  - ### ctorX

    public static ConstructorCallExpression ctorX(ClassNode type)

  - ### ctorSuperS

    public static Statement ctorSuperS(Expression args)

  - ### ctorSuperX

    public static ConstructorCallExpression ctorSuperX(Expression args)

  - ### ctorThisS

    public static Statement ctorThisS(Expression args)

  - ### ctorThisX

    public static ConstructorCallExpression ctorThisX(Expression args)

  - ### ctorSuperS

    public static Statement ctorSuperS()

  - ### ctorSuperX

    public static ConstructorCallExpression ctorSuperX()

  - ### ctorThisS

    public static Statement ctorThisS()

  - ### ctorThisX

    public static ConstructorCallExpression ctorThisX()

  - ### declS

    public static Statement declS(Expression target, Expression init)

  - ### declX

    public static DeclarationExpression declX(Expression target, Expression init)

  - ### defaultValueX

    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`.
    Since:
      4.0.0

  - ### elvisX

    public static ElvisOperatorExpression elvisX(Expression base, Expression otherwise)

  - ### entryX

    public static MapEntryExpression entryX(Expression key, Expression value)

  - ### eqX

    public static BinaryExpression eqX(Expression left, Expression right)

  - ### equalsNullX

    public static BooleanExpression equalsNullX(Expression expr)

  - ### fieldX

    public static FieldExpression fieldX(FieldNode fieldNode)

  - ### fieldX

    public static FieldExpression fieldX(ClassNode owner, String fieldName)

  - ### findArg

    public static Expression findArg(String argName)

  - ### forS

    public static ForStatement forS(Parameter variable, Expression collectionExpression, Statement loopS)

  - ### getAllMethods

    public static List<MethodNode> getAllMethods(ClassNode type)

  - ### getAllProperties

    public static List<PropertyNode> getAllProperties(ClassNode type)

  - ### getInstanceNonPropertyFields

    public static List<FieldNode> getInstanceNonPropertyFields(ClassNode cNode)

  - ### getInstanceNonPropertyFieldNames

    public static List<String> getInstanceNonPropertyFieldNames(ClassNode cNode)

  - ### getInstanceProperties

    public static List<PropertyNode> getInstanceProperties(ClassNode cNode)

  - ### getInstancePropertyNames

    public static List<String> getInstancePropertyNames(ClassNode cNode)

  - ### getInstancePropertyFields

    public static List<FieldNode> getInstancePropertyFields(ClassNode cNode)

  - ### getInterfacesAndSuperInterfaces

    public static Set<ClassNode> getInterfacesAndSuperInterfaces(ClassNode cNode)

  - ### getSuperNonPropertyFields

    public static List<FieldNode> getSuperNonPropertyFields(ClassNode cNode)

  - ### getSuperPropertyFields

    public static List<FieldNode> getSuperPropertyFields(ClassNode cNode)

  - ### getAllProperties

    public static List<PropertyNode> getAllProperties(Set<String> names, ClassNode cNode, boolean includeProperties, boolean includeFields, boolean includePseudoGetters, boolean includePseudoSetters, boolean traverseSuperClasses, boolean skipReadonly)

  - ### getAllProperties

    public static List<PropertyNode> getAllProperties(Set<String> names, ClassNode origType, ClassNode cNode, boolean includeProperties, boolean includeFields, boolean includePseudoGetters, boolean includePseudoSetters, boolean traverseSuperClasses, boolean skipReadonly)

  - ### getAllProperties

    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)

  - ### getterThisX

    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.
    Parameters:
      `annotatedNode` - the class node where the property node is accessed from
      `pNode` - the property being accessed
    Returns:
      a method call expression or a property expression

  - ### getterX

    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.
    Parameters:
      `annotatedNode` - the class node where the property node is accessed from
      `receiver` - the object having the property
      `pNode` - the property being accessed
    Returns:
      a method call expression or a property expression

  - ### geX

    public static BinaryExpression geX(Expression lhv, Expression rhv)

  - ### gtX

    public static BinaryExpression gtX(Expression lhv, Expression rhv)

  - ### hasClassX

    public static BinaryExpression hasClassX(Expression instance, ClassNode cNode)

  - ### hasEqualFieldX

    public static BinaryExpression hasEqualFieldX(FieldNode fNode, Expression other)

  - ### hasEqualPropertyX

    public static BinaryExpression hasEqualPropertyX(ClassNode cNode, PropertyNode pNode, VariableExpression other)

  - ### hasEqualPropertyX

    @Deprecated public static BinaryExpression hasEqualPropertyX(PropertyNode pNode, Expression other)
    Deprecated.

  - ### hasSameFieldX

    public static BooleanExpression hasSameFieldX(FieldNode fNode, Expression other)

  - ### hasSamePropertyX

    public static BooleanExpression hasSamePropertyX(PropertyNode pNode, Expression other)

  - ### ifElseS$$bridge

    @Deprecated public static Statement ifElseS$$bridge(Expression cond, Statement thenStmt, Statement elseStmt)
    Deprecated.

  - ### ifElseS

    public static IfStatement ifElseS(Expression cond, Statement thenStmt, Statement elseStmt)

  - ### ifS$$bridge

    @Deprecated public static Statement ifS$$bridge(Expression cond, Expression trueExpr)
    Deprecated.

  - ### ifS

    public static IfStatement ifS(Expression cond, Expression trueExpr)

  - ### ifS$$bridge

    @Deprecated public static Statement ifS$$bridge(Expression cond, Statement trueStmt)
    Deprecated.

  - ### ifS

    public static IfStatement ifS(Expression cond, Statement trueStmt)

  - ### indexX

    public static Expression indexX(Expression target, Expression value)

  - ### isInstanceOfX

    public static BooleanExpression isInstanceOfX(Expression expr, ClassNode type)

  - ### isNullOrInstanceOfX

    public static BooleanExpression isNullOrInstanceOfX(Expression expr, ClassNode type)
    Since:
      4.0.8

  - ### isNullX

    public static BooleanExpression isNullX(Expression expr)
    Alias for `equalsNullX(Expression)`

  - ### isOneX

    public static BooleanExpression isOneX(Expression expr)

  - ### isTrueX

    public static BooleanExpression isTrueX(Expression argExpr)

  - ### isZeroX

    public static BooleanExpression isZeroX(Expression expr)

  - ### listX

    public static ListExpression listX(List<Expression> args)

  - ### list2args

    public static ListExpression list2args(List<?> args)

  - ### classList2args

    public static ListExpression classList2args(List<String> args)

  - ### localVarX

    public static VariableExpression localVarX(String name)

  - ### localVarX

    public static VariableExpression localVarX(String name, ClassNode type)

  - ### leX

    public static BinaryExpression leX(Expression lhv, Expression rhv)

  - ### ltX

    public static BinaryExpression ltX(Expression lhv, Expression rhv)

  - ### mapEntryX

    public static MapEntryExpression mapEntryX(Expression keyExpr, Expression valueExpr)

  - ### mapEntryX

    public static MapEntryExpression mapEntryX(String key, Expression valueExpr)

  - ### mapX

    public static MapExpression mapX()

  - ### mapX

    public static MapExpression mapX(List<MapEntryExpression> expressions)

  - ### minusX

    public static BinaryExpression minusX(Expression lhv, Expression rhv)

  - ### neX

    public static BinaryExpression neX(Expression lhv, Expression rhv)

  - ### notIdenticalX

    public static BinaryExpression notIdenticalX(Expression lhv, Expression rhv)

  - ### notNullX

    public static BooleanExpression notNullX(Expression expr)

  - ### notX

    public static NotExpression notX(Expression expr)

  - ### nullX

    public static ConstantExpression nullX()

  - ### orX

    public static BinaryExpression orX(Expression lhv, Expression rhv)

  - ### param

    public static Parameter param(ClassNode type, String name)

  - ### param

    public static Parameter param(ClassNode type, String name, Expression initialExpression)

  - ### params

    public static Parameter[] params(Parameter... params)

  - ### plusX

    public static BinaryExpression plusX(Expression lhv, Expression rhv)

  - ### propX

    public static PropertyExpression propX(Expression owner, String property)

  - ### propX$$bridge

    @Deprecated public static Expression propX$$bridge(Expression owner, String property)
    Deprecated.

  - ### propX

    public static PropertyExpression propX(Expression owner, Expression property)

  - ### propX$$bridge

    @Deprecated public static Expression propX$$bridge(Expression owner, Expression property)
    Deprecated.

  - ### propX

    public static PropertyExpression propX(Expression owner, Expression property, boolean safe)

  - ### returnS

    public static Statement returnS(Expression expr)

  - ### safeExpression

    public static Statement safeExpression(Expression fieldExpr, Expression expression)

  - ### sameX

    public static BooleanExpression sameX(Expression self, Expression other)

  - ### stmt

    public static Statement stmt(Expression expr)

  - ### spreadX

    public static SpreadExpression spreadX(Expression expr)

  - ### switchS

    public static SwitchStatement switchS(Expression expr)

  - ### switchS

    public static SwitchStatement switchS(Expression expr, Statement defaultStatement)

  - ### switchS

    public static SwitchStatement switchS(Expression expr, List<CaseStatement> caseStatements, Statement defaultStatement)

  - ### ternaryX

    public static TernaryExpression ternaryX(Expression cond, Expression trueExpr, Expression elseExpr)

  - ### thisPropX

    public static PropertyExpression thisPropX(boolean implicit, String property)

  - ### throwS

    public static ThrowStatement throwS(Expression expr)

  - ### tryCatchS

    public static TryCatchStatement tryCatchS(Statement tryStatement)

  - ### tryCatchS

    public static TryCatchStatement tryCatchS(Statement tryStatement, Statement finallyStatement)

  - ### tryCatchS

    public static TryCatchStatement tryCatchS(Statement tryStatement, Statement finallyStatement, CatchStatement... catchStatements)

  - ### varX

    public static VariableExpression varX(String name)

  - ### varX

    public static VariableExpression varX(Variable variable)

  - ### varX

    public static VariableExpression varX(String name, ClassNode type)

  - ### cloneParams

    public static Parameter[] cloneParams(Parameter[] parameters)

  - ### copyAnnotatedNodeAnnotations

    public static void copyAnnotatedNodeAnnotations(AnnotatedNode annotatedNode, List<AnnotationNode> copied, List<AnnotationNode> notCopied)
    Copies all `candidateAnnotations` with retention policy `RetentionPolicy.RUNTIME` and `RetentionPolicy.CLASS`.

    Annotations with `GeneratedClosure` members are not supported at present.

  - ### copyAnnotatedNodeAnnotations

    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`. `Generated` annotations will be copied if `includeGenerated` is true.

    Annotations with `GeneratedClosure` members are not supported at present.

  - ### createConstructorStatementDefault

    public static Statement createConstructorStatementDefault(FieldNode fNode)

  - ### getGetterName

    public static String getGetterName(PropertyNode pNode)
    Generally preferred to use `PropertyNode.getGetterNameOrDefault()` directly.

  - ### getGetterName

    public static String getGetterName(String name, Class<?> type)
    WARNING: Avoid this method unless just the name and type are available. Use `getGetterName(PropertyNode)` if the propertyNode is available.

  - ### getGetterName

    public static String getGetterName(String name)
    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.

  - ### getSetterName

    public static String getSetterName(String name)

  - ### convertASTToSource

    public static String convertASTToSource(ReaderSource readerSource, ASTNode expression) throws Exception
    Converts an expression into the String source. Only some specific expressions like closure expression support this.
    Parameters:
      `readerSource` - a source
      `expression` - an expression. Can't be null
    Returns:
      the source the closure was created from
    Throws:
      `IllegalArgumentException` - when expression is null
      `Exception` - when closure can't be read from source

  - ### copyStatementsWithSuperAdjustment

    public static boolean copyStatementsWithSuperAdjustment(ClosureExpression pre, BlockStatement body)

  - ### hasDeclaredMethod

    public static boolean hasDeclaredMethod(ClassNode cNode, String name, int argsCount)

  - ### findDeclaredMethod

    public static MethodNode findDeclaredMethod(ClassNode cNode, String name, int argsCount)

  - ### inSamePackage

    public static boolean inSamePackage(ClassNode first, ClassNode second)

  - ### inSamePackage

    public static boolean inSamePackage(Class<?> first, Class<?> second)

  - ### isDefaultVisibility

    public static boolean isDefaultVisibility(int modifiers)

  - ### isOrImplements

    public static boolean isOrImplements(ClassNode type, ClassNode interfaceType)

  - ### makeDescriptorWithoutReturnType

    @Deprecated public static String makeDescriptorWithoutReturnType(MethodNode mn)
    Deprecated.
    use MethodNodeUtils#methodDescriptorWithoutReturnType(MethodNode) instead

  - ### maybeFallsThrough

    public static boolean maybeFallsThrough(Statement statement)