Class CompilationUnit

java.lang.Object
org.codehaus.groovy.control.ProcessingUnit
org.codehaus.groovy.control.CompilationUnit
Direct Known Subclasses:
JavaAwareCompilationUnit, JavaStubCompilationUnit

public class CompilationUnit
extends ProcessingUnit
The CompilationUnit collects all compilation data as it is generated by the compiler system. You can use this object to add additional source units to the compilation, or force the compilation to be run again (to affect only the deltas).

You can also add PhaseOperations to this compilation using the addPhaseOperation method. This is commonly used when you want to wire a new AST Transformation into the compilation.

  • Field Details

    • ast

      protected CompileUnit ast
      The overall AST for this CompilationUnit.
    • sources

      protected java.util.Map<java.lang.String,​SourceUnit> sources
      The source units from which this unit is built.
    • queuedSources

      protected java.util.Queue<SourceUnit> queuedSources
    • debug

      protected boolean debug
      If set, outputs a little more information during compilation when errors occur.
    • configured

      protected boolean configured
      True after the first configure(CompilerConfiguration) operation.
    • classgenCallback

      protected CompilationUnit.ClassgenCallback classgenCallback
      A callback called during the classgen phase of compilation
    • progressCallback

      protected CompilationUnit.ProgressCallback progressCallback
      A callback for use during compile()
    • classNodeResolver

      protected ClassNodeResolver classNodeResolver
    • resolveVisitor

      protected ResolveVisitor resolveVisitor
    • astTransformationsContext

      protected ASTTransformationsContext astTransformationsContext
      The AST transformations state data.
  • Constructor Details

    • CompilationUnit

      public CompilationUnit()
      Initializes the CompilationUnit with defaults.
    • CompilationUnit

      public CompilationUnit​(GroovyClassLoader loader)
      Initializes the CompilationUnit with defaults except for class loader.
    • CompilationUnit

      public CompilationUnit​(CompilerConfiguration configuration)
      Initializes the CompilationUnit with no security considerations.
    • CompilationUnit

      public CompilationUnit​(CompilerConfiguration configuration, java.security.CodeSource codeSource, GroovyClassLoader loader)
      Initializes the CompilationUnit with a CodeSource for controlling security stuff and a class loader for loading classes.
    • CompilationUnit

      public CompilationUnit​(CompilerConfiguration configuration, java.security.CodeSource codeSource, GroovyClassLoader loader, GroovyClassLoader transformLoader)
      Initializes the CompilationUnit with a CodeSource for controlling security stuff, a class loader for loading classes, and a class loader for loading AST transformations.

      Note: The transform loader must be able to load compiler classes. That means ProcessingUnit.classLoader must be at last a parent to transformLoader. The other loader has no such constraint.

      Parameters:
      transformLoader - - the loader for transforms
      loader - - loader used to resolve classes against during compilation
      codeSource - - security setting for the compilation
      configuration - - compilation configuration
  • Method Details