CompilationUnitTree (Compiler Tree API )
Keywords: com.sun.source.tree.CompilationUnitTree interface
Date: 2016-12-09

com.sun.source.tree

## Interface CompilationUnitTree

- All Superinterfaces:
    Tree

      @Exported
      public interface CompilationUnitTree
      extends Tree

  Represents the abstract syntax tree for compilation units (source files) and package declarations (package-info.java).
  Since:
    1.6
  See The Java™ Language Specification:
    sections 7.3, and 7.4

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface com.sun.source.tree.Tree

      `Tree.Kind`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `List<? extends ImportTree>` | `getImports()`
    `LineMap` | `getLineMap()` Gets the line map for this compilation unit, if available.
    `List<? extends AnnotationTree>` | `getPackageAnnotations()`
    `ExpressionTree` | `getPackageName()`
    `JavaFileObject` | `getSourceFile()`
    `List<? extends Tree>` | `getTypeDecls()`

    - ### Methods inherited from interface com.sun.source.tree.Tree

      `accept, getKind`

- - ### Method Detail

    - #### getPackageAnnotations

          List<? extends AnnotationTree> getPackageAnnotations()

    - #### getPackageName

          ExpressionTree getPackageName()

    - #### getImports

          List<? extends ImportTree> getImports()

    - #### getTypeDecls

          List<? extends Tree> getTypeDecls()

    - #### getSourceFile

          JavaFileObject getSourceFile()

    - #### getLineMap

          LineMap getLineMap()

      Gets 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

Copyright © 2005, 2016, Oracle and/or its affiliates. All rights reserved.