|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.codehaus.groovy.control.ProcessingUnit
org.codehaus.groovy.control.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).
Nested Class Summary | |
static class |
CompilationUnit.ClassgenCallback
A callback interface you can use to "accompany" the classgen() code as it traverses the ClassNode tree. |
class |
CompilationUnit.LoopBodyForPrimaryClassNodeOperations
An callback interface for use in the applyToSourceUnits loop driver. |
class |
CompilationUnit.LoopBodyForSourceUnitOperations
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. |
Field Summary | |
protected CompileUnit |
ast
|
protected CompilationUnit.ClassgenCallback |
classgenCallback
|
protected Map |
classSourcesByPublicClassName
|
protected ClassCompletionVerifier |
completionVerifier
|
protected boolean |
configured
|
protected boolean |
debug
|
protected ArrayList |
generatedClasses
|
protected ArrayList |
names
|
protected CompilationUnit.ProgressCallback |
progressCallback
|
protected LinkedList |
queuedSources
|
protected HashMap |
sources
|
protected Map |
summariesByPublicClassName
|
protected Map |
summariesBySourceName
|
protected Verifier |
verifier
|
Fields inherited from class org.codehaus.groovy.control.ProcessingUnit |
classLoader, configuration, errorCollector, phase, phaseComplete |
Constructor Summary | |
CompilationUnit()
Initializes the CompilationUnit with defaults. |
|
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(GroovyClassLoader loader)
Initializes the CompilationUnit with defaults except for class loader. |
Method Summary | |
void |
addClassNode(ClassNode node)
Adds a ClassNode directly to the unit (ie. |
SourceUnit |
addSource(File file)
Adds a source file to the unit. |
SourceUnit |
addSource(SourceUnit source)
Adds a SourceUnit to the unit. |
SourceUnit |
addSource(String name,
InputStream stream)
Adds a InputStream source to the unit. |
SourceUnit |
addSource(URL url)
Adds a source file to the unit. |
void |
addSources(File[] files)
Adds a set of source files to the unit. |
void |
addSources(String[] paths)
Adds a set of file paths to the unit. |
void |
applyToPrimaryClassNodes(CompilationUnit.LoopBodyForPrimaryClassNodeOperations body,
boolean sort)
A loop driver for applying operations to all primary ClassNodes in our AST. |
void |
applyToSourceUnits(CompilationUnit.LoopBodyForSourceUnitOperations body)
A loop driver for applying operations to all SourceUnits. |
void |
classgen()
Expands and canonicalizes the ASTs generated during parsing and conversion, then generates classes. |
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. |
void |
convert()
Builds ASTs for all parsed sources. |
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. |
List |
getClasses()
Get the GroovyClasses generated by compile(). |
ClassNode |
getClassNode(String name)
Convenience routine to get the named ClassNode. |
Map |
getClassSourcesByPublicClassName()
|
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. |
protected void |
mark()
Updates the phase marker on all sources. |
void |
output()
Outputs the generated class files to permanent storage. |
void |
parse()
Parses all sources. |
void |
semanticAnalysis()
|
void |
setClassgenCallback(CompilationUnit.ClassgenCallback visitor)
Sets a ClassgenCallback. |
void |
setProgressCallback(CompilationUnit.ProgressCallback callback)
Sets a ProgressCallback. |
Methods inherited from class org.codehaus.groovy.control.ProcessingUnit |
completePhase, getClassLoader, getConfiguration, getErrorCollector, getPhase, getPhaseDescription, gotoPhase, nextPhase, setClassLoader, setConfiguration |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected HashMap sources
protected Map summariesBySourceName
protected Map summariesByPublicClassName
protected Map classSourcesByPublicClassName
protected ArrayList names
protected LinkedList queuedSources
protected CompileUnit ast
protected ArrayList generatedClasses
protected Verifier verifier
protected ClassCompletionVerifier completionVerifier
protected boolean debug
protected boolean configured
protected CompilationUnit.ClassgenCallback classgenCallback
protected CompilationUnit.ProgressCallback progressCallback
Constructor Detail |
public CompilationUnit()
public CompilationUnit(GroovyClassLoader loader)
public CompilationUnit(CompilerConfiguration configuration)
public CompilationUnit(CompilerConfiguration configuration, CodeSource security, GroovyClassLoader loader)
Method Detail |
public void configure(CompilerConfiguration configuration)
URLClassLoader
.
configure
in class ProcessingUnit
public CompileUnit getAST()
public Map getSummariesBySourceName()
public Map getSummariesByPublicClassName()
public Map getClassSourcesByPublicClassName()
public boolean isPublicClass(String className)
public List getClasses()
public ClassNode getFirstClassNode()
public ClassNode getClassNode(String name)
public void addSources(String[] paths)
public void addSources(File[] files)
public SourceUnit addSource(File file)
public SourceUnit addSource(URL url)
public SourceUnit addSource(String name, InputStream stream)
public SourceUnit addSource(SourceUnit source)
public Iterator iterator()
public void addClassNode(ClassNode node)
public void setClassgenCallback(CompilationUnit.ClassgenCallback visitor)
public void setProgressCallback(CompilationUnit.ProgressCallback callback)
public void compile() throws CompilationFailedException
CompilationFailedException
public void compile(int throughPhase) throws CompilationFailedException
CompilationFailedException
protected boolean dequeued() throws CompilationFailedException
CompilationFailedException
public void parse() throws CompilationFailedException
CompilationFailedException
public void convert() throws CompilationFailedException
CompilationFailedException
public void semanticAnalysis() throws CompilationFailedException
CompilationFailedException
public void classgen() throws CompilationFailedException
CompilationFailedException
protected org.objectweb.asm.ClassVisitor createClassVisitor()
public void output() throws CompilationFailedException
CompilationFailedException
protected void mark() throws CompilationFailedException
CompilationFailedException
public void applyToSourceUnits(CompilationUnit.LoopBodyForSourceUnitOperations body) throws CompilationFailedException
CompilationFailedException
public void applyToPrimaryClassNodes(CompilationUnit.LoopBodyForPrimaryClassNodeOperations body, boolean sort) throws CompilationFailedException
CompilationFailedException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |