This class represents the entire compilation unit. Each java file denotes a compilation unit.
A compilation unit start with an optional package declaration, followed by zero or more import declarations, followed by zero or more type declarations.PackageDeclaration, ImportDeclaration, TypeDeclaration, Storage
| Modifier and Type | Class and Description |
|---|---|
| public static class | CompilationUnit.
Information about where this compilation unit was loaded from. |
| Modifier and Type | Field and Description |
|---|---|
| private NodeList | |
| private ModuleDeclaration | |
| private PackageDeclaration | |
| private CompilationUnit. | |
| private NodeList |
| Access | Constructor and Description |
|---|---|
| public | |
| public | |
| public | CompilationUnit(PackageDeclaration packageDeclaration, NodeList<ImportDeclaration> imports, NodeList<TypeDeclaration<?>> types, ModuleDeclaration module)
|
| public | CompilationUnit(TokenRange tokenRange, PackageDeclaration packageDeclaration, NodeList<ImportDeclaration> imports, NodeList<TypeDeclaration<?>> types, ModuleDeclaration module)
This constructor is used by the parser and is considered private. |
| Modifier and Type | Method and Description |
|---|---|
| public <R, A> R | accept(final GenericVisitor<R, A>
the visitor implementation v, final A the argument passed to the visitor (of type A) arg)Implements com. |
| public <A> void | accept(final VoidVisitor<A>
the visitor implementation v, final A any value relevant for the visitor (of type A) arg)Implements com. |
| public AnnotationDeclaration | Returns: the newly created classthe annotation name name)Add a public annotation declaration to the types of this compilation unit |
| public AnnotationDeclaration | Returns: the newly created classthe annotation name name, Modifier.the modifiers (like Modifier.PUBLIC) modifiersAdd an annotation declaration to the types of this compilation unit |
| public ClassOrInterfaceDeclaration | |
| public ClassOrInterfaceDeclaration | |
| public EnumDeclaration | |
| public EnumDeclaration | |
| public CompilationUnit | |
| public CompilationUnit | Returns: this, theCompilationUnitthe import name name)Add an import to the list of |
| public CompilationUnit | Returns: this, theCompilationUnitthe class to import clazz)Add an import to the list of |
| public CompilationUnit | Returns: this, theCompilationUnitthe import name name, boolean is it an "import static" isStatic, boolean does the import end with ".*" isAsterisk)Add an import to the list of |
| public ClassOrInterfaceDeclaration | Returns: the newly created classthe interface name name)Add a public interface class to the types of this compilation unit |
| public ClassOrInterfaceDeclaration | Returns: the newly created classthe interface name name, Modifier.the modifiers (like Modifier.PUBLIC) modifiersAdd an interface to the types of this compilation unit |
| public CompilationUnit | |
| public CompilationUnit | |
| public Optional | getAnnotationDeclarationByName(String
the annotation name (case-sensitive) annotationName)Try to get a top level annotation type declaration by its name |
| public Optional | getClassByName(String
the class name (case-sensitive) className)Try to get a top level class declaration by its name |
| public List | Returns: list with all comments of this compilation unit.Return a list containing all comments declared in this compilation unit. |
| public Optional | getEnumByName(String
the enum name (case-sensitive) enumName)Try to get a top level enum declaration by its name |
| public ImportDeclaration | |
| public NodeList | Returns: the list of imports ornone if there is no importRetrieves the list of imports declared in this compilation unit or
|
| public Optional | getInterfaceByName(String
the interface name (case-sensitive) interfaceName)Try to get a top level interface declaration by its name |
| public CompilationUnitMetaModel | |
| public Optional | |
| public Optional | Returns: the package declaration ornoneRetrieves the package declaration of this compilation unit. |
| public Optional | Returns: the type whose name corresponds to the file name. Empty if no file information is present (when this compilation unit wasn't parsed from a file.) If for some strange reason there are multiple types of this name, the first one is returned.
|
| public Optional | Returns: the name that the primary type in this file should have, according to the filename inStorage#getFileName().
Empty if no file information is present (when this compilation unit wasn't parsed from a file.)
|
| public Optional | Returns: information about where this compilation unit was loaded from, or empty if it wasn't loaded from a file.
|
| public TypeDeclaration | getType(int
the index of the type declaration to retrieve i)Convenience method that wraps |
| public NodeList | Returns: the list of types ornone null if there is no typeReturn the list of top level types declared in this compilation unit. |
| public void | |
| public boolean | |
| public CompilationUnit | |
| public CompilationUnit | |
| public boolean | |
| public CompilationUnit | |
| public CompilationUnit | setImports(final NodeList<ImportDeclaration>
the list of imports imports)Sets the list of imports of this compilation unit. |
| public CompilationUnit | |
| public ModuleDeclaration | |
| public CompilationUnit | setPackageDeclaration(final PackageDeclaration
the packageDeclaration declaration to set or packageDeclaration)null to default packageSets or clear the package declarations of this compilation unit. |
| public CompilationUnit | Returns: this, theCompilationUnitthe name of the package name)sets the package declaration of this compilation unit |
| public CompilationUnit | |
| public CompilationUnit | |
| public CompilationUnit | |
| public CompilationUnit | setTypes(final NodeList<TypeDeclaration<?>> types)
Sets the list of types declared in this compilation unit. |