src/jdk.compiler/share/classes/com/sun/source/tree/CompilationUnitTree.java
changeset 47216 71c04702a3d5
parent 34916 16043fc1d90b
child 54817 ef73702a906e
equal deleted inserted replaced
47215:4ebc2e2fb97c 47216:71c04702a3d5
       
     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 sections 7.3, and 7.4
       
    36  *
       
    37  * @author Peter von der Ahé
       
    38  * @since 1.6
       
    39  */
       
    40 public interface CompilationUnitTree extends Tree {
       
    41     /**
       
    42      * Returns the annotations listed on any package declaration
       
    43      * at the head of this compilation unit, or {@code null} if there
       
    44      * is no package declaration.
       
    45      * @return the package annotations
       
    46      */
       
    47     List<? extends AnnotationTree> getPackageAnnotations();
       
    48 
       
    49     /**
       
    50      * Returns the name contained in any package declaration
       
    51      * at the head of this compilation unit, or {@code null} if there
       
    52      * is no package declaration.
       
    53      * @return the package name
       
    54      */
       
    55     ExpressionTree getPackageName();
       
    56 
       
    57     /**
       
    58      * Returns the package tree associated with this compilation unit,
       
    59      * or {@code null} if there is no package declaration.
       
    60      * @return the package tree
       
    61      * @since 9
       
    62      */
       
    63     PackageTree getPackage();
       
    64 
       
    65     /**
       
    66      * Returns the import declarations appearing in this compilation unit.
       
    67      * @return the import declarations
       
    68      */
       
    69     List<? extends ImportTree> getImports();
       
    70 
       
    71     /**
       
    72      * Returns the type declarations appearing in this compilation unit.
       
    73      * The list may also include empty statements resulting from
       
    74      * extraneous semicolons.
       
    75      * @return the type declarations
       
    76      */
       
    77     List<? extends Tree> getTypeDecls();
       
    78 
       
    79     /**
       
    80      * Returns the file object containing the source for this compilation unit.
       
    81      * @return the file object
       
    82      */
       
    83     JavaFileObject getSourceFile();
       
    84 
       
    85     /**
       
    86      * Returns the line map for this compilation unit, if available.
       
    87      * Returns {@code null} if the line map is not available.
       
    88      * @return the line map for this compilation unit
       
    89      */
       
    90     LineMap getLineMap();
       
    91 }