|
Groovy Documentation | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.codehaus.groovy.control.ProcessingUnit org.codehaus.groovy.control.CompilationUnit
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.
Nested Class Summary | |
---|---|
static class |
CompilationUnit.ClassgenCallback
Sets a ClassgenCallback. |
static class |
CompilationUnit.GroovyClassOperation
|
static class |
CompilationUnit.PrimaryClassNodeOperation
|
static class |
CompilationUnit.ProgressCallback
|
static class |
CompilationUnit.SourceUnitOperation
|
Field Summary | |
---|---|
protected CompileUnit |
ast
|
protected ASTTransformationsContext |
astTransformationsContext
|
protected java.util.Map |
classSourcesByPublicClassName
|
protected CompilationUnit.ClassgenCallback |
classgenCallback
|
protected boolean |
configured
|
protected boolean |
debug
|
protected java.util.List |
generatedClasses
|
protected java.util.List |
names
|
protected OptimizerVisitor |
optimizer
|
protected CompilationUnit.ProgressCallback |
progressCallback
|
protected java.util.LinkedList |
queuedSources
|
protected ResolveVisitor |
resolveVisitor
|
protected java.util.Map |
sources
|
protected StaticImportVisitor |
staticImportVisitor
|
protected java.util.Map |
summariesByPublicClassName
|
protected java.util.Map |
summariesBySourceName
|
protected Verifier |
verifier
|
Fields inherited from class ProcessingUnit | |
---|---|
classLoader, configuration, errorCollector, phase, phaseComplete |
Constructor Summary | |
CompilationUnit()
|
|
CompilationUnit(GroovyClassLoader loader)
|
|
CompilationUnit(CompilerConfiguration configuration)
|
|
CompilationUnit(CompilerConfiguration configuration, java.security.CodeSource security, GroovyClassLoader loader)
|
|
CompilationUnit(CompilerConfiguration configuration, java.security.CodeSource security, GroovyClassLoader loader, GroovyClassLoader transformLoader)
|
Method Summary | |
---|---|
void
|
addClassNode(ClassNode node)
Adds a ClassNode directly to the unit (ie. without source). |
void
|
addNewPhaseOperation(CompilationUnit.SourceUnitOperation op, int phase)
|
void
|
addPhaseOperation(CompilationUnit.SourceUnitOperation op, int phase)
|
void
|
addPhaseOperation(CompilationUnit.PrimaryClassNodeOperation op, int phase)
|
void
|
addPhaseOperation(CompilationUnit.GroovyClassOperation op)
|
SourceUnit
|
addSource(java.io.File file)
Adds a InputStream source to the unit. |
SourceUnit
|
addSource(java.net.URL url)
|
SourceUnit
|
addSource(java.lang.String name, java.io.InputStream stream)
|
SourceUnit
|
addSource(java.lang.String name, java.lang.String scriptText)
|
SourceUnit
|
addSource(SourceUnit source)
Returns an iterator on the unit's SourceUnits. |
void
|
addSources(java.lang.String[] paths)
Adds a set of source files to the unit. |
void
|
addSources(java.io.File[] files)
Adds a source file to the unit. |
void
|
applyToGeneratedGroovyClasses(CompilationUnit.GroovyClassOperation body)
|
void
|
applyToPrimaryClassNodes(CompilationUnit.PrimaryClassNodeOperation body)
|
void
|
applyToSourceUnits(CompilationUnit.SourceUnitOperation body)
|
void
|
compile()
|
void
|
compile(int throughPhase)
|
void
|
configure(CompilerConfiguration configuration)
|
protected org.objectweb.asm.ClassVisitor
|
createClassVisitor()
Updates the phase marker on all sources. |
protected boolean
|
dequeued()
Resolves all types |
CompileUnit
|
getAST()
|
ASTTransformationsContext
|
getASTTransformationsContext()
@return the AST transformations current context |
ClassNode
|
getClassNode(java.lang.String name)
|
java.util.Map
|
getClassSourcesByPublicClassName()
|
java.util.List
|
getClasses()
Convenience routine to get the named ClassNode. |
CompilationUnit.ClassgenCallback
|
getClassgenCallback()
|
ClassNode
|
getFirstClassNode()
|
CompilationUnit.ProgressCallback
|
getProgressCallback()
|
java.util.Map
|
getSummariesByPublicClassName()
Get the GroovyClasses generated by compile(). |
java.util.Map
|
getSummariesBySourceName()
|
GroovyClassLoader
|
getTransformLoader()
Returns the class loader for loading AST transformations. |
boolean
|
isPublicClass(java.lang.String className)
|
java.util.Iterator
|
iterator()
|
protected void
|
mark()
An callback interface for use in the applyToSourceUnits loop driver. |
void
|
setClassgenCallback(CompilationUnit.ClassgenCallback visitor)
Sets a ProgressCallback. |
void
|
setProgressCallback(CompilationUnit.ProgressCallback callback)
Synonym for compile(Phases.ALL). |
Methods inherited from class ProcessingUnit | |
---|---|
completePhase, configure, getClassLoader, getConfiguration, getErrorCollector, getPhase, getPhaseDescription, gotoPhase, nextPhase, setClassLoader, setConfiguration |
Methods inherited from class java.lang.Object | |
---|---|
java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Field Detail |
---|
protected CompileUnit ast
protected ASTTransformationsContext astTransformationsContext
protected java.util.Map classSourcesByPublicClassName
protected CompilationUnit.ClassgenCallback classgenCallback
protected boolean configured
protected boolean debug
protected java.util.List generatedClasses
protected java.util.List names
protected OptimizerVisitor optimizer
protected CompilationUnit.ProgressCallback progressCallback
protected java.util.LinkedList queuedSources
protected ResolveVisitor resolveVisitor
protected java.util.Map sources
protected StaticImportVisitor staticImportVisitor
protected java.util.Map summariesByPublicClassName
protected java.util.Map summariesBySourceName
protected Verifier verifier
Constructor Detail |
---|
public CompilationUnit()
public CompilationUnit(GroovyClassLoader loader)
public CompilationUnit(CompilerConfiguration configuration)
public CompilationUnit(CompilerConfiguration configuration, java.security.CodeSource security, GroovyClassLoader loader)
public CompilationUnit(CompilerConfiguration configuration, java.security.CodeSource security, GroovyClassLoader loader, GroovyClassLoader transformLoader)
Method Detail |
---|
public void addClassNode(ClassNode node)
public void addNewPhaseOperation(CompilationUnit.SourceUnitOperation op, int phase)
public void addPhaseOperation(CompilationUnit.SourceUnitOperation op, int phase)
public void addPhaseOperation(CompilationUnit.PrimaryClassNodeOperation op, int phase)
public void addPhaseOperation(CompilationUnit.GroovyClassOperation op)
public SourceUnit addSource(java.io.File file)
public SourceUnit addSource(java.net.URL url)
public SourceUnit addSource(java.lang.String name, java.io.InputStream stream)
public SourceUnit addSource(java.lang.String name, java.lang.String scriptText)
public SourceUnit addSource(SourceUnit source)
public void addSources(java.lang.String[] paths)
public void addSources(java.io.File[] files)
public void applyToGeneratedGroovyClasses(CompilationUnit.GroovyClassOperation body)
public void applyToPrimaryClassNodes(CompilationUnit.PrimaryClassNodeOperation body)
public void applyToSourceUnits(CompilationUnit.SourceUnitOperation body)
public void compile()
public void compile(int throughPhase)
public void configure(CompilerConfiguration configuration)
protected org.objectweb.asm.ClassVisitor createClassVisitor()
protected boolean dequeued()
public CompileUnit getAST()
public ASTTransformationsContext getASTTransformationsContext()
public ClassNode getClassNode(java.lang.String name)
public java.util.Map getClassSourcesByPublicClassName()
public java.util.List getClasses()
public CompilationUnit.ClassgenCallback getClassgenCallback()
public ClassNode getFirstClassNode()
public CompilationUnit.ProgressCallback getProgressCallback()
public java.util.Map getSummariesByPublicClassName()
public java.util.Map getSummariesBySourceName()
public GroovyClassLoader getTransformLoader()
public boolean isPublicClass(java.lang.String className)
public java.util.Iterator iterator()
protected void mark()
public void setClassgenCallback(CompilationUnit.ClassgenCallback visitor)
public void setProgressCallback(CompilationUnit.ProgressCallback callback)
Groovy Documentation