public class CompileUnit
extends java.lang.Object
ModuleNode
instances. There's one instance of this that's shared by all modules and
classes compiled during a single invocation of the compiler.
It's attached to MethodNodes and ClassNodes and is used to find fully qualified names of classes, resolve imports, and that sort of thing.
Constructor and Description |
---|
CompileUnit(GroovyClassLoader classLoader,
java.security.CodeSource codeSource,
CompilerConfiguration config) |
CompileUnit(GroovyClassLoader classLoader,
CompilerConfiguration config) |
Modifier and Type | Method and Description |
---|---|
void |
addClass(ClassNode node)
Adds a class to the unit.
|
void |
addClassNodeToCompile(ClassNode node,
SourceUnit location)
this method actually does not compile a class.
|
void |
addGeneratedInnerClass(InnerClassNode icn) |
void |
addModule(ModuleNode node) |
ClassNode |
getClass(java.lang.String name) |
java.util.List |
getClasses() |
GroovyClassLoader |
getClassLoader() |
java.security.CodeSource |
getCodeSource() |
CompilerConfiguration |
getConfig() |
InnerClassNode |
getGeneratedInnerClass(java.lang.String name) |
java.util.Map<java.lang.String,InnerClassNode> |
getGeneratedInnerClasses() |
ListHashMap |
getMetaDataMap() |
java.util.List<ModuleNode> |
getModules() |
java.util.Map<?,?> |
getNodeMetaData()
Returns an unmodifiable view of the current node metadata.
|
<T> T |
getNodeMetaData(java.lang.Object key)
Gets the node meta data for the provided key.
|
SourceUnit |
getScriptSourceLocation(java.lang.String className) |
boolean |
hasClassNodeToCompile() |
java.util.Iterator<java.lang.String> |
iterateClassNodeToCompile() |
java.lang.Object |
putNodeMetaData(java.lang.Object key,
java.lang.Object value)
Sets the node meta data but allows overwriting values.
|
void |
removeNodeMetaData(java.lang.Object key)
Removes a node meta data entry.
|
void |
setNodeMetaData(java.lang.Object key,
java.lang.Object value)
Sets the node meta data for the provided key.
|
public CompileUnit(GroovyClassLoader classLoader, CompilerConfiguration config)
public CompileUnit(GroovyClassLoader classLoader, java.security.CodeSource codeSource, CompilerConfiguration config)
public java.util.List<ModuleNode> getModules()
public void addModule(ModuleNode node)
public ClassNode getClass(java.lang.String name)
public java.util.List getClasses()
public CompilerConfiguration getConfig()
public GroovyClassLoader getClassLoader()
public java.security.CodeSource getCodeSource()
public void addClass(ClassNode node)
public void addClassNodeToCompile(ClassNode node, SourceUnit location)
public SourceUnit getScriptSourceLocation(java.lang.String className)
public boolean hasClassNodeToCompile()
public java.util.Iterator<java.lang.String> iterateClassNodeToCompile()
public InnerClassNode getGeneratedInnerClass(java.lang.String name)
public void addGeneratedInnerClass(InnerClassNode icn)
public java.util.Map<java.lang.String,InnerClassNode> getGeneratedInnerClasses()
public <T> T getNodeMetaData(java.lang.Object key)
key
- - the meta data keypublic void setNodeMetaData(java.lang.Object key, java.lang.Object value)
key
- - the meta data keyvalue
- - the meta data valueGroovyBugError
- if key is null or there is already meta
data under that keypublic java.lang.Object putNodeMetaData(java.lang.Object key, java.lang.Object value)
key
- - the meta data keyvalue
- - the meta data valueGroovyBugError
- if key is nullpublic void removeNodeMetaData(java.lang.Object key)
key
- - the meta data keyGroovyBugError
- if the key is nullpublic java.util.Map<?,?> getNodeMetaData()
public ListHashMap getMetaDataMap()