1 /*
2  * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * This code is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License version 2 only, as
7  * published by the Free Software Foundation.  Oracle designates this
8  * particular file as subject to the "Classpath" exception as provided
9  * by Oracle in the LICENSE file that accompanied this code.
10  *
11  * This code is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14  * version 2 for more details (a copy is included in the LICENSE file that
15  * accompanied this code).
16  *
17  * You should have received a copy of the GNU General Public License version
18  * 2 along with this work; if not, write to the Free Software Foundation,
19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20  *
21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22  * or visit www.oracle.com if you need additional information or have any
23  * questions.
24  */
25 
26 package com.sun.source.tree;
27 
28 import java.util.List;
29 import javax.tools.JavaFileObject;
30 
31 /**
32  * Represents the abstract syntax tree for compilation units (source
33  * files) and package declarations (package-info.java).
34  *
35  * @jls 7.3 Compilation Units
36  * @jls 7.4 Package Declarations
37  *
38  * @author Peter von der Ahé
39  * @since 1.6
40  */
41 public interface CompilationUnitTree extends Tree {
42     /**
43      * Returns the annotations listed on any package declaration
44      * at the head of this compilation unit, or {@code null} if there
45      * is no package declaration.
46      * @return the package annotations
47      */
getPackageAnnotations()48     List<? extends AnnotationTree> getPackageAnnotations();
49 
50     /**
51      * Returns the name contained in any package declaration
52      * at the head of this compilation unit, or {@code null} if there
53      * is no package declaration.
54      * @return the package name
55      */
getPackageName()56     ExpressionTree getPackageName();
57 
58     /**
59      * Returns the package tree associated with this compilation unit,
60      * or {@code null} if there is no package declaration.
61      * @return the package tree
62      * @since 9
63      */
getPackage()64     PackageTree getPackage();
65 
66     /**
67      * Returns the import declarations appearing in this compilation unit.
68      * @return the import declarations
69      */
getImports()70     List<? extends ImportTree> getImports();
71 
72     /**
73      * Returns the type declarations appearing in this compilation unit.
74      * The list may also include empty statements resulting from
75      * extraneous semicolons.
76      * @return the type declarations
77      */
getTypeDecls()78     List<? extends Tree> getTypeDecls();
79 
80     /**
81      * Returns the file object containing the source for this compilation unit.
82      * @return the file object
83      */
getSourceFile()84     JavaFileObject getSourceFile();
85 
86     /**
87      * Returns the line map for this compilation unit, if available.
88      * Returns {@code null} if the line map is not available.
89      * @return the line map for this compilation unit
90      */
getLineMap()91     LineMap getLineMap();
92 }
93