APIdia Launch Partner
Top Description Methods
com.sun.source.tree

public Interface CompilationUnitTree

extends Tree
Known Direct Implementers
com.sun.tools.javac.tree.JCTree.JCCompilationUnit
Imports
java.util.List, javax.tools.JavaFileObject

Represents the abstract syntax tree for ordinary compilation units and modular compilation units.
Author
Peter von der Ahé
Since
1.6
Java Language Specification
7.3 Compilation Units, 7.4 Package Declarations, 7.7 Module Declarations

Method Summary

Modifier and TypeMethod and Description
public List<? extends ImportTree>

Returns:

the import declarations
getImports
()

Returns the import declarations appearing in this compilation unit, or an empty list if there are no import declarations.

public LineMap

Returns:

the line map for this compilation unit
getLineMap
()

Returns the line map for this compilation unit, if available, or null if the line map is not available.

public default ModuleTree

Returns:

the module tree
getModule
()

Returns the module tree associated with this compilation unit, or null if there is no module declaration.

public PackageTree

Returns:

the package tree
getPackage
()

Returns the package tree associated with this compilation unit, or null if there is no package declaration.

public List<? extends AnnotationTree>

Returns:

the package annotations
getPackageAnnotations
()

Returns the annotations listed on any package declaration at the head of this compilation unit, or null if there is no package declaration.

public ExpressionTree

Returns:

the package name
getPackageName
()

Returns the name contained in any package declaration at the head of this compilation unit, or null if there is no package declaration.

public JavaFileObject

Returns:

the file object
getSourceFile
()

Returns the file object containing the source for this compilation unit.

public List<? extends Tree>

Returns:

the type declarations
getTypeDecls
()

Returns the type declarations appearing in this compilation unit, or an empty list if there are no type declarations.

Inherited from com.sun.source.tree.Tree:
acceptgetKind

Method Detail

getImportsback to summary
public List<? extends ImportTree> getImports()

Returns the import declarations appearing in this compilation unit, or an empty list if there are no import declarations.

Returns:List<? extends ImportTree>

the import declarations

getLineMapback to summary
public LineMap getLineMap()

Returns the line map for this compilation unit, if available, or null if the line map is not available.

Returns:LineMap

the line map for this compilation unit

getModuleback to summary
public default ModuleTree getModule()

Returns the module tree associated with this compilation unit, or null if there is no module declaration.

Implementation Specification

This implementation throws UnsupportedOperationException

Returns:ModuleTree

the module tree

Since
17
getPackageback to summary
public PackageTree getPackage()

Returns the package tree associated with this compilation unit, or null if there is no package declaration.

Returns:PackageTree

the package tree

Since
9
getPackageAnnotationsback to summary
public List<? extends AnnotationTree> getPackageAnnotations()

Returns the annotations listed on any package declaration at the head of this compilation unit, or null if there is no package declaration.

Returns:List<? extends AnnotationTree>

the package annotations

getPackageNameback to summary
public ExpressionTree getPackageName()

Returns the name contained in any package declaration at the head of this compilation unit, or null if there is no package declaration.

Returns:ExpressionTree

the package name

getSourceFileback to summary
public JavaFileObject getSourceFile()

Returns the file object containing the source for this compilation unit.

Returns:JavaFileObject

the file object

getTypeDeclsback to summary
public List<? extends Tree> getTypeDecls()

Returns the type declarations appearing in this compilation unit, or an empty list if there are no type declarations. The list may also include empty statements resulting from extraneous semicolons. A modular compilation unit does not contain any type declarations.

Returns:List<? extends Tree>

the type declarations