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.

Author:
Chris Poirier, Jochen Theodorou, Roshan Dawrani
  • Field Details

  • 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, CodeSource security, GroovyClassLoader loader)
      Initializes the CompilationUnit with a CodeSource for controlling security stuff and a class loader for loading classes.
    • CompilationUnit

      public CompilationUnit(CompilerConfiguration configuration, CodeSource security, 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 CompilationUnit.class.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
      security - - security setting for the compilation
      configuration - - compilation configuration
  • Method Details