Package: org.codehaus.groovy.ast.builder

## [Groovy] Class AstSpecificationCompiler

- org.codehaus.groovy.ast.builder.AstSpecificationCompiler

- All Implemented Interfaces and Traits:
    GroovyInterceptable

      class AstSpecificationCompiler
      extends Object

  Handles parsing the properties from the closure into values that can be referenced. This object is very stateful and not threadsafe. It accumulates expressions in the 'expression' field as they are found and executed within the DSL. Note: this class consists of many one-line method calls. A better implementation might be to take a declarative approach and replace the one-liners with map entries.

  Authors:
    Hamlet D'Arcy

- - ### Constructor Summary

    Constructors
    Constructor and description
    `AstSpecificationCompiler (Closure spec)` Creates the DSL compiler.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `void` | `annotation(Class target, Closure argBlock = null)` Creates an AnnotationNode.
    `` | `void` | `annotationConstant(Closure argBlock)` Creates an AnnotationConstantExpression.
    `` | `void` | `annotations(Closure argBlock)` Designates a list of AnnotationNodes.
    `` | `void` | `argumentList(Closure argBlock)` Creates an ArgumentListExpression.
    `` | `void` | `array(Class type, Closure argBlock)` Creates an ArrayExpression.
    `` | `void` | `assertStatement(Closure argBlock)` Creates an AssertStatement.
    `` | `void` | `attribute(Closure argBlock)` Creates an AttributeExpression.
    `` | `void` | `binary(Closure argBlock)` Creates a BinaryExpression.
    `` | `void` | `bitwiseNegation(Closure argBlock)` Creates a BitwiseNegationExpression.
    `` | `void` | `block(Closure argBlock)` Creates a BlockStatement.
    `` | `void` | `booleanExpression(Closure argBlock)` Creates a BooleanExpression.
    `` | `void` | `breakStatement(String label = null)` Creates a BreakStatement.
    `` | `void` | `caseStatement(Closure argBlock)` Create a CaseStatement.
    `` | `void` | `cast(Class type, Closure argBlock)` Creates a CastExpression.
    `` | `void` | `catchStatement(Closure argBlock)` Creates a CatchStatement.
    `` | `void` | `classExpression(Class type)` Creates a ClassExpression.
    `` | `void` | `classNode(Class target)` Creates a ClassNode.
    `` | `void` | `classNode(String name, int modifiers, Closure argBlock)` Creates a ClassNode
    `` | `void` | `closure(Closure argBlock)` Creates a ClosureExpression.
    `` | `void` | `closureList(Closure argBlock)` Creates a ClosureListExpression.
    `` | `void` | `constant(Object value)` Creates a ConstantExpression.
    `` | `void` | `constructor(int modifiers, Closure argBlock)` Creates a ConstructorNode.
    `` | `void` | `constructorCall(Class type, Closure argBlock)` Creates an ConstructorCallExpression.
    `` | `void` | `constructors(Closure argBlock)` Designates a list of ConstructorNodes.
    `` | `void` | `continueStatement(Closure argBlock = null)` Creates a ContinueStatement.
    `` | `void` | `declaration(Closure argBlock)` Creates a DeclarationExpression.
    `` | `void` | `defaultCase(Closure argBlock)` Creates a BlockStatement.
    `` | `void` | `dynamicVariable(String variable, boolean isStatic = false)` Creates a DynamicVariable.
    `` | `void` | `elvisOperator(Closure argBlock)` Creates an ElvisOperatorExpression.
    `` | `void` | `empty()` Creates EmptyStatement.
    `` | `void` | `exceptions(Closure argBlock)` Creates a ClassNode[].
    `` | `void` | `expression(Closure argBlock)` Creates an ExpressionStatement.
    `` | `void` | `field(Closure argBlock)` Creates a FieldExpression.
    `` | `void` | `fieldNode(String name, int modifiers, Class type, Class owner, Closure argBlock)` Creates a FieldNode.
    `` | `void` | `fields(Closure argBlock)` Designates a list of `FieldNode`s.
    `` | `void` | `forStatement(Closure argBlock)` Create a ForStatement.
    `` | `void` | `gString(String verbatimText, Closure argBlock)` Creates a gString.
    `` | `void` | `genericsType(Class type, Closure argBlock = null)` Creates a GenericsType.
    `` | `void` | `genericsTypes(Closure argBlock)` Creates a GenericsTypes[].
    `` | `List<ASTNode>` | `getExpression()` Gets the current generated expression.
    `` | `void` | `ifStatement(Closure argBlock)` Creates an IfStatement.
    `` | `void` | `importNode(Class target, String alias = null)` Creates an ImportNode.
    `` | `void` | `inclusive(boolean value)` Creates a boolean value.
    `` | `void` | `innerClass(String name, int modifiers, Closure argBlock)` Creates an inner class.
    `` | `void` | `interfaces(Closure argBlock)` Creates a ClassNode[].
    `` | `void` | `label(String label)` Creates a label.
    `` | `void` | `list(Closure argBlock)` Creates a ListExpression.
    `` | `void` | `lowerBound(Class target)` Create lowerBound ClassNode.
    `` | `void` | `map(Closure argBlock)` Creates a MapExpression.
    `` | `void` | `mapEntry(Closure argBlock)` Creates a MapEntryExpression.
    `` | `void` | `mapEntry(Map map)` Creates a mapEntry.
    `` | `void` | `member(String name, Closure argBlock)` Creates a 2 element list of name and Annotation.
    `` | `void` | `method(String name, int modifiers, Class returnType, Closure argBlock)` Creates a MethodNode.
    `` | `void` | `methodCall(Closure argBlock)` Creates a MethodCallExpression.
    `` | `void` | `methodPointer(Closure argBlock)` Creates a methodPointer.
    `` | `void` | `methods(Closure argBlock)` Designates a list of MethodNodes.
    `` | `void` | `mixin(String name, int modifiers, Closure argBlock)` Creates a MixinNode.
    `` | `void` | `mixins(Closure argBlock)` Creates a MixinNode[].
    `` | `void` | `namedArgumentList(Closure argBlock)` Creates a NamedArgumentListExpression.
    `` | `void` | `not(Closure argBlock)` Creates a NotExpression.
    `` | `void` | `parameter(Map<String, Class> args, Closure argBlock = null)` Creates a Parameter.
    `` | `void` | `parameters(Closure argBlock)` Creates a Parameter[].
    `` | `void` | `postfix(Closure argBlock)` Creates a PostfixExpression.
    `` | `void` | `prefix(Closure argBlock)` Creates a PrefixExpression.
    `` | `void` | `properties(Closure argBlock)` Designates a list of `PropertyNode`s.
    `` | `void` | `property(Closure argBlock)` Creates a property.
    `` | `void` | `propertyNode(String name, int modifiers, Class type, Class owner, Closure argBlock)` Creates a PropertyNode.
    `` | `void` | `range(Closure argBlock)` Creates a RangeExpression.
    `` | `void` | `range(Range range)` Creates a RangeExpression.
    `` | `void` | `returnStatement(Closure argBlock)` Creates a ReturnStatement.
    `` | `void` | `spread(Closure argBlock)` Creates a SpreadExpression.
    `` | `void` | `spreadMap(Closure argBlock)` Creates a SpreadMapExpression.
    `` | `void` | `staticMethodCall(Class target, String name, Closure argBlock)` Creates a StaticMethodCallExpression.
    `` | `void` | `staticMethodCall(MethodClosure target, Closure argBlock)` Creates a StaticMethodCallExpression.
    `` | `void` | `strings(Closure argBlock)` Designates a list of ConstantExpressions.
    `` | `void` | `switchStatement(Closure argBlock)` Creates a SwitchStatement.
    `` | `void` | `synchronizedStatement(Closure argBlock)` Creates a SynchronizedStatement.
    `` | `void` | `throwStatement(Closure argBlock)` Creates a ThrowStatement.
    `` | `void` | `token(String value)` Creates a token.
    `` | `void` | `tryCatch(Closure argBlock)` Creates a TryCatchStatement.
    `` | `void` | `tuple(Closure argBlock)` Creates a TupleExpression.
    `` | `void` | `unaryMinus(Closure argBlock)` Creates a UnaryMinusExpression
    `` | `void` | `unaryPlus(Closure argBlock)` Creates a UnaryPlusExpression.
    `` | `void` | `upperBound(Closure argBlock)` Creates a list of upperBound ClassNodes.
    `` | `void` | `values(Closure argBlock)` Designates a list of Expressions.
    `` | `void` | `variable(String variable)` Creates a VariableExpression.
    `` | `void` | `whileStatement(Closure argBlock)` Creates a WhileStatement.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `equals, toString, hashCode, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### AstSpecificationCompiler(@DelegatesTo(AstSpecificationCompiler) Closure spec)

      Creates the DSL compiler.

  - ### Method Detail

    - #### void annotation(Class target, @DelegatesTo(AstSpecificationCompiler) Closure argBlock = null)

      Creates an AnnotationNode.

    - #### void annotationConstant(@DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Creates an AnnotationConstantExpression.

    - #### void annotations(@DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Designates a list of AnnotationNodes.

    - #### void argumentList(@DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Creates an ArgumentListExpression.

    - #### void array(Class type, @DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Creates an ArrayExpression.

    - #### void assertStatement(@DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Creates an AssertStatement.

    - #### void attribute(@DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Creates an AttributeExpression.

    - #### void binary(@DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Creates a BinaryExpression.

    - #### void bitwiseNegation(@DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Creates a BitwiseNegationExpression.

    - #### void block(@DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Creates a BlockStatement.

    - #### void booleanExpression(@DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Creates a BooleanExpression.

    - #### void breakStatement(String label = null)

      Creates a BreakStatement.

    - #### void caseStatement(@DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Create a CaseStatement.

    - #### void cast(Class type, @DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Creates a CastExpression.

    - #### void catchStatement(@DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Creates a CatchStatement.

    - #### void classExpression(Class type)

      Creates a ClassExpression.

    - #### void classNode(Class target)

      Creates a ClassNode.

    - #### void classNode(String name, int modifiers, @DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Creates a ClassNode

    - #### void closure(@DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Creates a ClosureExpression.

    - #### void closureList(@DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Creates a ClosureListExpression.

    - #### void constant(Object value)

      Creates a ConstantExpression.

    - #### void constructor(int modifiers, @DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Creates a ConstructorNode.

    - #### void constructorCall(Class type, @DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Creates an ConstructorCallExpression.

    - #### void constructors(@DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Designates a list of ConstructorNodes.

    - #### void continueStatement(@DelegatesTo(AstSpecificationCompiler) Closure argBlock = null)

      Creates a ContinueStatement.

    - #### void declaration(@DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Creates a DeclarationExpression.

    - #### void defaultCase(@DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Creates a BlockStatement.

    - #### void dynamicVariable(String variable, boolean isStatic = false)

      Creates a DynamicVariable.

    - #### void elvisOperator(@DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Creates an ElvisOperatorExpression.

    - #### void empty()

      Creates EmptyStatement.

    - #### void exceptions(@DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Creates a ClassNode[].

    - #### void expression(@DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Creates an ExpressionStatement.

    - #### void field(@DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Creates a FieldExpression.

    - #### void fieldNode(String name, int modifiers, Class type, Class owner, @DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Creates a FieldNode.

    - #### void fields(@DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Designates a list of `FieldNode`s.

    - #### void forStatement(@DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Create a ForStatement.

    - #### void gString(String verbatimText, @DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Creates a gString.

    - #### void genericsType(Class type, @DelegatesTo(AstSpecificationCompiler) Closure argBlock = null)

      Creates a GenericsType.

    - #### void genericsTypes(@DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Creates a GenericsTypes[].

    - #### List<ASTNode> getExpression()

      Gets the current generated expression.

    - #### void ifStatement(@DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Creates an IfStatement.

    - #### void importNode(Class target, String alias = null)

      Creates an ImportNode.

    - #### void inclusive(boolean value)

      Creates a boolean value.

    - #### void innerClass(String name, int modifiers, @DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Creates an inner class.

    - #### void interfaces(@DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Creates a ClassNode[].

    - #### void label(String label)

      Creates a label.

    - #### void list(@DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Creates a ListExpression.

    - #### void lowerBound(Class target)

      Create lowerBound ClassNode.

    - #### void map(@DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Creates a MapExpression.

    - #### void mapEntry(@DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Creates a MapEntryExpression.

    - #### void mapEntry(Map map)

      Creates a mapEntry.

    - #### void member(String name, @DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Creates a 2 element list of name and Annotation. Used with Annotation Members.

    - #### void method(String name, int modifiers, Class returnType, @DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Creates a MethodNode.

    - #### void methodCall(@DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Creates a MethodCallExpression.

    - #### void methodPointer(@DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Creates a methodPointer.

    - #### void methods(@DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Designates a list of MethodNodes.

    - #### void mixin(String name, int modifiers, @DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Creates a MixinNode.

    - #### void mixins(@DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Creates a MixinNode[].

    - #### void namedArgumentList(@DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Creates a NamedArgumentListExpression.

    - #### void not(@DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Creates a NotExpression.

    - #### void parameter(Map<String, Class> args, @DelegatesTo(AstSpecificationCompiler) Closure argBlock = null)

      Creates a Parameter.

    - #### void parameters(@DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Creates a Parameter[].

    - #### void postfix(@DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Creates a PostfixExpression.

    - #### void prefix(@DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Creates a PrefixExpression.

    - #### void properties(@DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Designates a list of `PropertyNode`s.

    - #### void property(@DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Creates a property.

    - #### void propertyNode(String name, int modifiers, Class type, Class owner, @DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Creates a PropertyNode.

    - #### void range(@DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Creates a RangeExpression.

    - #### void range(Range range)

      Creates a RangeExpression.

    - #### void returnStatement(@DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Creates a ReturnStatement.

    - #### void spread(@DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Creates a SpreadExpression.

    - #### void spreadMap(@DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Creates a SpreadMapExpression.

    - #### void staticMethodCall(Class target, String name, @DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Creates a StaticMethodCallExpression.

    - #### void staticMethodCall(MethodClosure target, @DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Creates a StaticMethodCallExpression.

    - #### void strings(@DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Designates a list of ConstantExpressions.

    - #### void switchStatement(@DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Creates a SwitchStatement.

    - #### void synchronizedStatement(@DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Creates a SynchronizedStatement.

    - #### void throwStatement(@DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Creates a ThrowStatement.

    - #### void token(String value)

      Creates a token.

    - #### void tryCatch(@DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Creates a TryCatchStatement.

    - #### void tuple(@DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Creates a TupleExpression.

    - #### void unaryMinus(@DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Creates a UnaryMinusExpression

    - #### void unaryPlus(@DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Creates a UnaryPlusExpression.

    - #### void upperBound(@DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Creates a list of upperBound ClassNodes.

    - #### void values(@DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Designates a list of Expressions.

    - #### void variable(String variable)

      Creates a VariableExpression.

    - #### void whileStatement(@DelegatesTo(AstSpecificationCompiler) Closure argBlock)

      Creates a WhileStatement.