|
Groovy 1.7.9 | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.codehaus.groovy.control.ProcessingUnit
org.codehaus.groovy.control.CompilationUnit
public class CompilationUnit extends ProcessingUnit
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).
Nested Class Summary | |
---|---|
static class |
CompilationUnit.ClassgenCallback
A callback interface you can use to "accompany" the classgen() code as it traverses the ClassNode tree. |
static class |
CompilationUnit.GroovyClassOperation
|
static class |
CompilationUnit.PrimaryClassNodeOperation
An callback interface for use in the applyToSourceUnits loop driver. |
static class |
CompilationUnit.ProgressCallback
A callback interface you can use to get a callback after every unit of the compile process. |
static class |
CompilationUnit.SourceUnitOperation
An callback interface for use in the applyToSourceUnits loop driver. |
Field Summary | |
---|---|
protected CompileUnit |
ast
|
protected Map |
classSourcesByPublicClassName
|
protected CompilationUnit.ClassgenCallback |
classgenCallback
|
protected boolean |
configured
|
protected boolean |
debug
|
protected List |
generatedClasses
|
protected List |
names
|
protected OptimizerVisitor |
optimizer
|
protected CompilationUnit.ProgressCallback |
progressCallback
|
protected LinkedList |
queuedSources
|
protected ResolveVisitor |
resolveVisitor
|
protected Map |
sources
|
protected StaticImportVisitor |
staticImportVisitor
|
protected Map |
summariesByPublicClassName
|
protected Map |
summariesBySourceName
|
protected Verifier |
verifier
|
Fields inherited from class ProcessingUnit | |
---|---|
classLoader, configuration, errorCollector, phase, phaseComplete |
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. |
|
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. |
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(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(String name, String scriptText)
|
SourceUnit
|
addSource(SourceUnit source)
Adds a SourceUnit to the unit. |
void
|
addSources(String[] paths)
Adds a set of file paths to the unit. |
void
|
addSources(File[] files)
Adds a set of source files to the unit. |
void
|
applyToGeneratedGroovyClasses(CompilationUnit.GroovyClassOperation body)
|
void
|
applyToPrimaryClassNodes(CompilationUnit.PrimaryClassNodeOperation body)
A loop driver for applying operations to all primary ClassNodes in our AST. |
void
|
applyToSourceUnits(CompilationUnit.SourceUnitOperation body)
A loop driver for applying operations to all SourceUnits. |
void
|
compile()
Synonym for compile(Phases.ALL). |
void
|
compile(int throughPhase)
Compiles the compilation unit from sources. |
void
|
configure(CompilerConfiguration configuration)
Configures its debugging mode and classloader classpath from a given compiler configuration. |
protected org.objectweb.asm.ClassVisitor
|
createClassVisitor()
|
protected boolean
|
dequeued()
Dequeues any source units add through addSource and resets the compiler phase to initialization. |
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 |
GroovyClassLoader
|
getTransformLoader()
Returns the class loader for loading AST transformations. |
boolean
|
isPublicClass(String className)
|
Iterator
|
iterator()
Returns an iterator on the unit's SourceUnits. |
protected void
|
mark()
Updates the phase marker on all sources. |
void
|
setClassgenCallback(CompilationUnit.ClassgenCallback visitor)
Sets a ClassgenCallback. |
void
|
setProgressCallback(CompilationUnit.ProgressCallback callback)
Sets a ProgressCallback. |
Methods inherited from class ProcessingUnit | |
---|---|
completePhase, configure, getClassLoader, getConfiguration, getErrorCollector, getPhase, getPhaseDescription, gotoPhase, nextPhase, setClassLoader, setConfiguration |
Methods inherited from class Object | |
---|---|
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll |
Field Detail |
---|
protected CompileUnit ast
protected Map classSourcesByPublicClassName
protected CompilationUnit.ClassgenCallback classgenCallback
protected boolean configured
protected boolean debug
protected List generatedClasses
protected List names
protected OptimizerVisitor optimizer
protected CompilationUnit.ProgressCallback progressCallback
protected LinkedList queuedSources
protected ResolveVisitor resolveVisitor
protected Map sources
protected StaticImportVisitor staticImportVisitor
protected Map summariesByPublicClassName
protected Map summariesBySourceName
protected Verifier verifier
Constructor Detail |
---|
public CompilationUnit()
public CompilationUnit(GroovyClassLoader loader)
public CompilationUnit(CompilerConfiguration configuration)
public CompilationUnit(CompilerConfiguration configuration, CodeSource security, GroovyClassLoader loader)
public CompilationUnit(CompilerConfiguration configuration, CodeSource security, GroovyClassLoader loader, GroovyClassLoader transformLoader)
transformLoader
- - the loader for transformsloader
- - loader used to resolve classes against during compilationsecurity
- - security setting for the compilationconfiguration
- - compilation configuration
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(File file)
public SourceUnit addSource(URL url)
public SourceUnit addSource(String name, InputStream stream)
public SourceUnit addSource(String name, String scriptText)
public SourceUnit addSource(SourceUnit source)
public void addSources(String[] paths)
public void addSources(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 ClassNode getClassNode(String name)
public Map getClassSourcesByPublicClassName()
public List getClasses()
public ClassNode getFirstClassNode()
public Map getSummariesByPublicClassName()
public Map getSummariesBySourceName()
public GroovyClassLoader getTransformLoader()
public boolean isPublicClass(String className)
public Iterator iterator()
protected void mark()
public void setClassgenCallback(CompilationUnit.ClassgenCallback visitor)
public void setProgressCallback(CompilationUnit.ProgressCallback callback)
Copyright © 2003-2010 The Codehaus. All rights reserved.