Package org.codehaus.groovy.ast.expr

# Class ConstructorCallExpression

java.lang.Object
org.codehaus.groovy.ast.ASTNode
org.codehaus.groovy.ast.AnnotatedNode
org.codehaus.groovy.ast.expr.Expression
org.codehaus.groovy.ast.expr.ConstructorCallExpression

All Implemented Interfaces:
  `GroovydocHolder<AnnotatedNode>`, `MethodCall`, `NodeMetaDataHandler`

public class ConstructorCallExpression extends Expression implements MethodCall
Represents a constructor call expression. This includes regular object construction (e.g., `new MyClass(args)`), as well as special constructor calls like `this()` and `super()` calls within constructors. The constructor is identified by the type being constructed, and the arguments are wrapped in a `TupleExpression`. May optionally use an anonymous inner class. Explicit constructor type arguments (`new <T>Box(t)`, `<T>this(t)`, `<T>super(t)`) are stored separately from the constructed type's own type arguments.

- ## Field Summary

  ### Fields inherited from class org.codehaus.groovy.ast.expr.Expression

  `EMPTY_ARRAY`

  ### Fields inherited from interface groovy.lang.groovydoc.GroovydocHolder

  `DOC_COMMENT`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ConstructorCallExpression(ClassNode type, Expression arguments)`
  Creates a constructor call expression.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Expression`
  `getArguments()`
  Returns the constructor arguments.
  `GenericsType[]`
  `getGenericsTypes()`
  Returns the explicit constructor type arguments, if specified.
  `String`
  `getMethodAsString()`
  `ASTNode`
  `getReceiver()`
  `String`
  `getText()`
  Returns a human-readable text representation of this AST node.
  `boolean`
  `isSpecialCall()`
  Indicates whether this is a special constructor call (`this()` or `super()`).
  `boolean`
  `isSuperCall()`
  Indicates whether this is a `super()` constructor call.
  `boolean`
  `isThisCall()`
  Indicates whether this is a `this()` constructor call.
  `boolean`
  `isUsingAnonymousInnerClass()`
  Indicates whether this constructor call uses an anonymous inner class.
  `boolean`
  `isUsingGenerics()`
  Indicates whether explicit constructor type arguments are specified.
  `void`
  `setGenericsTypes(GenericsType[] genericsTypes)`
  Sets the explicit constructor type arguments.
  `void`
  `setUsingAnonymousInnerClass(boolean usage)`
  Sets whether this constructor call uses an anonymous inner class.
  `String`
  `toString()`
  `Expression`
  `transformExpression(ExpressionTransformer transformer)`
  Transforms this expression and any nested expressions according to the provided transformer.
  `void`
  `visit(GroovyCodeVisitor visitor)`
  Accepts a code visitor for AST traversal and transformation.

  ### Methods inherited from class org.codehaus.groovy.ast.expr.Expression

  `getType, setType, transformExpressions, transformExpressions`

  ### Methods inherited from class org.codehaus.groovy.ast.AnnotatedNode

  `addAnnotation, addAnnotation, addAnnotations, getAnnotations, getAnnotations, getDeclaringClass, getGroovydoc, getInstance, hasNoRealSourcePosition, isSynthetic, setDeclaringClass, setHasNoRealSourcePosition, setSynthetic`

  ### Methods inherited from class org.codehaus.groovy.ast.ASTNode

  `copyNodeMetaData, getColumnNumber, getLastColumnNumber, getLastLineNumber, getLineNumber, getMetaDataMap, setColumnNumber, setLastColumnNumber, setLastLineNumber, setLineNumber, setMetaDataMap, setSourcePosition`

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

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

  ### Methods inherited from interface org.codehaus.groovy.ast.NodeMetaDataHandler

  `copyNodeMetaData, getNodeMetaData, getNodeMetaData, getNodeMetaData, newMetaDataMap, putNodeMetaData, removeNodeMetaData, setNodeMetaData`

- ## Constructor Details

  - ### ConstructorCallExpression

    public ConstructorCallExpression(ClassNode type, Expression arguments)
    Creates a constructor call expression. Arguments are automatically wrapped in a `TupleExpression` if not already.
    Parameters:
      `type` - the type being constructed (non-null), or `ClassNode.THIS`/`ClassNode.SUPER` for special calls
      `arguments` - the constructor arguments (may be a single expression or already a `TupleExpression`)

- ## Method Details

  - ### visit

    public void visit(GroovyCodeVisitor visitor)
    Description copied from class: `ASTNode`
    Accepts a code visitor for AST traversal and transformation. Subclasses must implement this method to support visitor pattern-based processing. The visitor pattern enables decoupling of AST structure from processing logic.
    Overrides:
      `visit` in class `ASTNode`
    Parameters:
      `visitor` - the `GroovyCodeVisitor` to process this node

  - ### transformExpression

    public Expression transformExpression(ExpressionTransformer transformer)
    Description copied from class: `Expression`
    Transforms this expression and any nested expressions according to the provided transformer. This method is called during AST transformation phases and must recursively transform any nested expressions to support full AST tree transformation.
    Specified by:
      `transformExpression` in class `Expression`
    Parameters:
      `transformer` - the `ExpressionTransformer` to apply
    Returns:
      a transformed copy of this expression (or this expression itself if no changes are needed)

  - ### getReceiver

    public ASTNode getReceiver()
    Specified by:
      `getReceiver` in interface `MethodCall`

  - ### getMethodAsString

    public String getMethodAsString()
    Specified by:
      `getMethodAsString` in interface `MethodCall`

  - ### getArguments

    public Expression getArguments()
    Returns the constructor arguments.
    Specified by:
      `getArguments` in interface `MethodCall`
    Returns:
      a `TupleExpression` containing the arguments

  - ### getText

    public String getText()
    Description copied from class: `ASTNode`
    Returns a human-readable text representation of this AST node. Used for debugging and error messages. Default implementation returns a message indicating the representation is not yet implemented for this node type.
    Specified by:
      `getText` in interface `MethodCall`
    Overrides:
      `getText` in class `ASTNode`
    Returns:
      text representation of this node, or placeholder for unimplemented types

  - ### getGenericsTypes

    public GenericsType[] getGenericsTypes()
    Returns the explicit constructor type arguments, if specified. Used for generic constructor invocations such as `new <String>Box("x")`, `<T>this(t)` and `<T>super(t)`.
    Returns:
      an array of `GenericsType` parameters, or `null` if none are specified
    Since:
      6.0.0

  - ### setGenericsTypes

    public void setGenericsTypes(GenericsType[] genericsTypes)
    Sets the explicit constructor type arguments.
    Parameters:
      `genericsTypes` - an array of `GenericsType` parameters; may be `null`
    Since:
      6.0.0

  - ### isUsingGenerics

    public boolean isUsingGenerics()
    Indicates whether explicit constructor type arguments are specified.
    Returns:
      `true` if type arguments are present; `false` otherwise
    Since:
      6.0.0

  - ### isSpecialCall

    public boolean isSpecialCall()
    Indicates whether this is a special constructor call (`this()` or `super()`).
    Returns:
      true if this is a `this()` or `super()` call, false for regular constructor calls

  - ### isSuperCall

    public boolean isSuperCall()
    Indicates whether this is a `super()` constructor call.
    Returns:
      true if this calls the superclass constructor, false otherwise

  - ### isThisCall

    public boolean isThisCall()
    Indicates whether this is a `this()` constructor call.
    Returns:
      true if this calls another constructor in the same class, false otherwise

  - ### isUsingAnonymousInnerClass

    public boolean isUsingAnonymousInnerClass()
    Indicates whether this constructor call uses an anonymous inner class.
    Returns:
      true if an anonymous inner class is being created, false for regular construction

  - ### setUsingAnonymousInnerClass

    public void setUsingAnonymousInnerClass(boolean usage)
    Sets whether this constructor call uses an anonymous inner class.
    Parameters:
      `usage` - true if an anonymous inner class is being used, false otherwise

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`