Interface CompilationUnitTree
- All Superinterfaces:
Tree
public interface CompilationUnitTree extends Tree
Represents the abstract syntax tree for compilation units (source files) and package declarations (package-info.java).
- Since:
- 1.6
Nested Classes
Nested classes/interfaces declared in interface com.sun.source.tree.Tree
Tree.Kind
Methods
Modifier and Type | Method | Description |
---|---|---|
List<? extends ImportTree> | getImports() | Returns the import declarations appearing in this compilation unit. |
LineMap | getLineMap() | Returns the line map for this compilation unit, if available. |
PackageTree | getPackage() | Returns the package tree associated with this compilation unit, or |
List<? extends AnnotationTree> | getPackageAnnotations() | Returns the annotations listed on any package declaration at the head of this compilation unit, or |
ExpressionTree | getPackageName() | Returns the name contained in any package declaration at the head of this compilation unit, or |
JavaFileObject | getSourceFile() | Returns the file object containing the source for this compilation unit. |
List<? extends Tree> | getTypeDecls() | Returns the type declarations appearing in this compilation unit. |
Methods declared in interface com.sun.source.tree.Tree
accept, getKind
Methods
getPackageAnnotations
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:
- the package annotations
getPackageName
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:
- the package name
getPackage
PackageTree getPackage()
Returns the package tree associated with this compilation unit, or null
if there is no package declaration.
- Returns:
- the package tree
- Since:
- 9
getImports
List<? extends ImportTree> getImports()
Returns the import declarations appearing in this compilation unit.
- Returns:
- the import declarations
getTypeDecls
List<? extends Tree> getTypeDecls()
Returns the type declarations appearing in this compilation unit. The list may also include empty statements resulting from extraneous semicolons.
- Returns:
- the type declarations
getSourceFile
JavaFileObject getSourceFile()
Returns the file object containing the source for this compilation unit.
- Returns:
- the file object
getLineMap
LineMap getLineMap()
Returns the line map for this compilation unit, if available. Returns null
if the line map is not available.
- Returns:
- the line map for this compilation unit
© 1993, 2020, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/11/docs/api/jdk.compiler/com/sun/source/tree/CompilationUnitTree.html