Package org.codehaus.janino
Class Java.CompilationUnit
java.lang.Object
org.codehaus.janino.Java.AbstractCompilationUnit
org.codehaus.janino.Java.CompilationUnit
- All Implemented Interfaces:
Java.Scope
- Enclosing class:
Java
Representation of an "ordinary compilation unit" as explained in JLS9 7.3 (before Java 9 known as "compilation
unit" and described in JLS8 7.3).
-
Nested Class Summary
Nested classes/interfaces inherited from class org.codehaus.janino.Java.AbstractCompilationUnit
Java.AbstractCompilationUnit.ImportDeclaration, Java.AbstractCompilationUnit.SingleStaticImportDeclaration, Java.AbstractCompilationUnit.SingleTypeImportDeclaration, Java.AbstractCompilationUnit.StaticImportOnDemandDeclaration, Java.AbstractCompilationUnit.TypeImportOnDemandDeclaration
-
Field Summary
FieldsModifier and TypeFieldDescriptionThe package declaration at the very top of this compilation unit (if any).The top-level declarations in this compilation unit.Fields inherited from class org.codehaus.janino.Java.AbstractCompilationUnit
fileName, importDeclarations
-
Constructor Summary
ConstructorsConstructorDescriptionCompilationUnit
(String fileName) CompilationUnit
(String fileName, Java.AbstractCompilationUnit.ImportDeclaration[] importDeclarations) -
Method Summary
Modifier and TypeMethodDescription<R,
EX extends Throwable>
Raccept
(Visitor.AbstractCompilationUnitVisitor<R, EX> visitor) Invokes the "visit...()
" method ofVisitor.AbstractCompilationUnitVisitor
for the concreteJava.AbstractCompilationUnit
type.void
Adds one top-level type declaration to this compilation unit.Returns the package member class or interface declared with the given name.Gets all classes and interfaces declared in this compilation unit.void
setPackageDeclaration
(Java.PackageDeclaration packageDeclaration) Sets the package declaration of this compilation unit.Methods inherited from class org.codehaus.janino.Java.AbstractCompilationUnit
getEnclosingScope
-
Field Details
-
packageDeclaration
The package declaration at the very top of this compilation unit (if any). -
packageMemberTypeDeclarations
The top-level declarations in this compilation unit.
-
-
Constructor Details
-
CompilationUnit
-
CompilationUnit
public CompilationUnit(@Nullable String fileName, Java.AbstractCompilationUnit.ImportDeclaration[] importDeclarations)
-
-
Method Details
-
setPackageDeclaration
Sets the package declaration of this compilation unit. -
addPackageMemberTypeDeclaration
Adds one top-level type declaration to this compilation unit. -
getPackageMemberTypeDeclarations
Gets all classes and interfaces declared in this compilation unit. -
getPackageMemberTypeDeclaration
Returns the package member class or interface declared with the given name.- Parameters:
name
- Declared (i.e. not the fully qualified) name- Returns:
null
if a package member type with that name is not declared in this compilation unit
-
accept
@Nullable public <R,EX extends Throwable> R accept(Visitor.AbstractCompilationUnitVisitor<R, EX> visitor) throws EXDescription copied from class:Java.AbstractCompilationUnit
Invokes the "visit...()
" method ofVisitor.AbstractCompilationUnitVisitor
for the concreteJava.AbstractCompilationUnit
type.- Specified by:
accept
in classJava.AbstractCompilationUnit
- Throws:
EX
-