Interface CompilationUnitTree

All Superinterfaces:
Tree

public interface CompilationUnitTree extends Tree
Represents the abstract syntax tree for ordinary compilation units and modular compilation units.
See Java Language Specification:
7.3 Compilation Units
7.4 Package Declarations
7.7 Module Declarations
Since:
1.6
  • Nested Class Summary Link icon

    Nested classes/interfaces declared in interface com.sun.source.tree.Tree Link icon

    Tree.Kind
  • Method Summary Link icon

    Modifier and Type
    Method
    Description
    List<? extends ImportTree>
    Returns the import declarations appearing in this compilation unit, or an empty list if there are no import declarations.
    Returns the line map for this compilation unit, if available, or null if the line map is not available.
    default ModuleTree
    Returns the module tree associated with this compilation unit, or null if there is no module declaration.
    Returns the package tree associated with this compilation unit, or null if there is no package declaration.
    List<? extends AnnotationTree>
    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 name contained in any package declaration at the head of this compilation unit, or null if there is no package declaration.
    Returns the file object containing the source for this compilation unit.
    List<? extends Tree>
    Returns the type declarations appearing in this compilation unit, or an empty list if there are no type declarations.

    Methods declared in interface com.sun.source.tree.Tree Link icon

    accept, getKind
  • Method Details Link icon

    • getModule Link icon

      default ModuleTree getModule()
      Returns the module tree associated with this compilation unit, or null if there is no module declaration.
      Implementation Requirements:
      This implementation throws UnsupportedOperationException
      Returns:
      the module tree
      Since:
      17
    • getPackageAnnotations Link icon

      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 Link icon

      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 Link icon

      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 Link icon

      List<? extends ImportTree> getImports()
      Returns the import declarations appearing in this compilation unit, or an empty list if there are no import declarations.
      Returns:
      the import declarations
    • getTypeDecls Link icon

      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:
      the type declarations
    • getSourceFile Link icon

      JavaFileObject getSourceFile()
      Returns the file object containing the source for this compilation unit.
      Returns:
      the file object
    • getLineMap Link icon

      LineMap getLineMap()
      Returns the line map for this compilation unit, if available, or null if the line map is not available.
      Returns:
      the line map for this compilation unit