public class CompileUnit extends Object implements NodeMetaDataHandler
Represents the entire contents of a compilation step which consists of one or more 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.
Modifiers | Name | Description |
---|---|---|
static class | CompileUnit.ConstructedOuterNestedClassNode | Represents a resolved type as a placeholder. |
Constructor and description |
---|
CompileUnit
(GroovyClassLoader classLoader, CompilerConfiguration config) |
CompileUnit
(GroovyClassLoader classLoader, CodeSource codeSource, CompilerConfiguration config) |
Type Params | Return Type | Name and description |
---|---|---|
public void |
addClass(ClassNode node) Adds a class to the unit. | |
public void |
addClassNodeToCompile(ClassNode node, SourceUnit location) this method actually does not compile a class. | |
public void |
addClassNodeToResolve(CompileUnit.ConstructedOuterNestedClassNode cn) Add a constructed class node as a placeholder to resolve outer nested class further. | |
public void |
addGeneratedInnerClass(InnerClassNode icn) | |
public void |
addModule(ModuleNode node) | |
public ClassNode |
getClass(String name)
| |
public GroovyClassLoader |
getClassLoader() | |
public List<ClassNode> |
getClasses()
| |
public Map<String, ClassNode> |
getClassesToCompile() | |
public Map<String, ConstructedOuterNestedClassNode> |
getClassesToResolve() | |
public CodeSource |
getCodeSource() | |
public CompilerConfiguration |
getConfig() | |
public InnerClassNode |
getGeneratedInnerClass(String name) | |
public Map<String, InnerClassNode> |
getGeneratedInnerClasses() | |
public Map<?, ?> |
getMetaDataMap() | |
public List<ModuleNode> |
getModules() | |
public SourceUnit |
getScriptSourceLocation(String className) | |
public boolean |
hasClassNodeToCompile() | |
public Iterator<String> |
iterateClassNodeToCompile() | |
public void |
setMetaDataMap(Map<?, ?> metaDataMap) |
Methods inherited from class | Name |
---|---|
class Object | wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll |
Adds a class to the unit.
this method actually does not compile a class. It's only a marker that this type has to be compiled by the CompilationUnit at the end of a parse step no node should be be left.
Add a constructed class node as a placeholder to resolve outer nested class further.
cn
- the constructed class node
© 2003-2020 The Apache Software Foundation
Licensed under the Apache license.
https://docs.groovy-lang.org/3.0.7/html/gapi/org/codehaus/groovy/ast/CompileUnit.html