Overview | Package | Class
| FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.codehaus.groovy.control
Class CompilationUnit

Collects all compilation data as it is generated by the compiler system. Allows additional source units to be added and compilation run again (to affect only the deltas).

author:
  Chris Poirier

author:
  Jochen Theodorou

version:
  $Id: CompilationUnit.java 8552 2007-10-10 20:56:37Z blackdrag $

Field Summary
`CompileUnit` | `ast`
`Map` | `classSourcesByPublicClassName`
`ClassgenCallback` | `classgenCallback`
`boolean` | `configured`
`boolean` | `debug`
`List` | `generatedClasses`
`List` | `names`
`def` | `phaseOperations`
`ProgressCallback` | `progressCallback`
`LinkedList` | `queuedSources`
`ResolveVisitor` | `resolveVisitor`
`Map` | `sources`
`StaticImportVisitor` | `staticImportVisitor`
`Map` | `summariesByPublicClassName`
`Map` | `summariesBySourceName`
`Verifier` | `verifier`

Constructor Summary
`CompilationUnit()` Initializes the CompilationUnit with defaults.
`CompilationUnit(GroovyClassLoader loader)` Initializes the CompilationUnit with defaults except for class loader.
`CompilationUnit(CompilerConfiguration configuration)` Initializes the CompilationUnit with no security considerations.
`CompilationUnit(CompilerConfiguration configuration, CodeSource security, GroovyClassLoader loader)` Initializes the CompilationUnit with a CodeSource for controlling security stuff and a class loader for loading classes.

Method Summary
`void` | `addClassNode(ClassNode node)` Adds a ClassNode directly to the unit (ie. without source).
`void` | `addPhaseOperation(SourceUnitOperation op, int phase)`
`void` | `addPhaseOperation(PrimaryClassNodeOperation op, int phase)`
`void` | `addPhaseOperation(GroovyClassOperation op)`
`SourceUnit` | `addSource(File file)` Adds a source file to the unit.
`SourceUnit` | `addSource(URL url)` Adds a source file to the unit.
`SourceUnit` | `addSource(String name, InputStream stream)` Adds a InputStream source to the unit.
`SourceUnit` | `addSource(SourceUnit source)` Adds a SourceUnit to the unit.
`void` | `addSources(def paths)` Adds a set of file paths to the unit.
`void` | `addSources(def files)` Adds a set of source files to the unit.
`void` | `appendCompilerConfigurationClasspathToClassLoader(CompilerConfiguration configuration, GroovyClassLoader classLoader)`
`void` | `configure(CompilerConfiguration configuration)`
`CompileUnit` | `getAST()` Returns the CompileUnit that roots our AST.
`ClassNode` | `getClassNode(String name)` Convenience routine to get the named ClassNode.
`Map` | `getClassSourcesByPublicClassName()`
`List` | `getClasses()` Get the GroovyClasses generated by compile().
`ClassNode` | `getFirstClassNode()` Convenience routine to get the first ClassNode, for when you are sure there is only one.
`Map` | `getSummariesByPublicClassName()`
`Map` | `getSummariesBySourceName()` Get the source summaries
`boolean` | `isPublicClass(String className)`
`Iterator` | `iterator()` Returns an iterator on the unit's SourceUnits.

Constructor Detail

### 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.

Method Detail

### addClassNode

    public void addClassNode(ClassNode node)

  Adds a ClassNode directly to the unit (ie. without source). WARNING: the source is needed for error reporting, using this method without setting a SourceUnit will cause NullPinterExceptions

### addPhaseOperation

    public void addPhaseOperation(SourceUnitOperation op, int phase)

### addPhaseOperation

    public void addPhaseOperation(PrimaryClassNodeOperation op, int phase)

### addPhaseOperation

    public void addPhaseOperation(GroovyClassOperation op)

### addSource

    public SourceUnit addSource(File file)

  Adds a source file to the unit.

### addSource

    public SourceUnit addSource(URL url)

  Adds a source file to the unit.

### addSource

    public SourceUnit addSource(String name, InputStream stream)

  Adds a InputStream source to the unit.

### addSource

    public SourceUnit addSource(SourceUnit source)

  Adds a SourceUnit to the unit.

### addSources

    public void addSources(def paths)

  Adds a set of file paths to the unit.

### addSources

    public void addSources(def files)

  Adds a set of source files to the unit.

### appendCompilerConfigurationClasspathToClassLoader

    void appendCompilerConfigurationClasspathToClassLoader(CompilerConfiguration configuration, GroovyClassLoader classLoader)

### configure

    public void configure(CompilerConfiguration configuration)

### getAST

    public CompileUnit getAST()

  Returns the CompileUnit that roots our AST.

### getClassNode

    public ClassNode getClassNode(String name)

  Convenience routine to get the named ClassNode.

### getClassSourcesByPublicClassName

    public Map getClassSourcesByPublicClassName()

### getClasses

    public List getClasses()

  Get the GroovyClasses generated by compile().

### getFirstClassNode

    public ClassNode getFirstClassNode()

  Convenience routine to get the first ClassNode, for when you are sure there is only one.

### getSummariesByPublicClassName

    public Map getSummariesByPublicClassName()

### getSummariesBySourceName

    public Map getSummariesBySourceName()

  Get the source summaries

### isPublicClass

    public boolean isPublicClass(String className)

### iterator

    public Iterator iterator()

  Returns an iterator on the unit's SourceUnits.