langtools/src/share/classes/com/sun/source/util/Trees.java
author jjg
Wed, 25 Jun 2014 19:15:53 -0700
changeset 25288 5234a53b53a8
parent 25287 d2440361b323
permissions -rw-r--r--
8048162: Restrict catch type from Throwable to ReflectiveOperationException Reviewed-by: darcy
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
25287
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
     2
 * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
06bc494ca11e Initial load
duke
parents:
diff changeset
     4
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
06bc494ca11e Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 3149
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 3149
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    10
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
06bc494ca11e Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
06bc494ca11e Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
06bc494ca11e Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
06bc494ca11e Initial load
duke
parents:
diff changeset
    20
 *
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 3149
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 3149
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 3149
diff changeset
    23
 * questions.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
06bc494ca11e Initial load
duke
parents:
diff changeset
    26
package com.sun.source.util;
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
import java.lang.reflect.Method;
14541
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents: 9599
diff changeset
    29
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
import javax.annotation.processing.ProcessingEnvironment;
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
import javax.lang.model.element.AnnotationMirror;
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
import javax.lang.model.element.AnnotationValue;
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
import javax.lang.model.element.Element;
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
import javax.lang.model.element.ExecutableElement;
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
import javax.lang.model.element.TypeElement;
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
import javax.lang.model.type.DeclaredType;
1257
873b053bf757 6557752: Original type of an AST should be made available even if it is replaced with an ErrorType
jjg
parents: 10
diff changeset
    37
import javax.lang.model.type.ErrorType;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
import javax.lang.model.type.TypeMirror;
3149
0cd06d598d6f 6843077: JSR 308: Annotations on types
jjg
parents: 1789
diff changeset
    39
import javax.tools.Diagnostic;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
import javax.tools.JavaCompiler.CompilationTask;
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
9599
0996df19ea87 7029150: Project Coin: present union types from the tree API through to javax.lang.model
jjg
parents: 7681
diff changeset
    42
import com.sun.source.tree.CatchTree;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
import com.sun.source.tree.ClassTree;
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
import com.sun.source.tree.CompilationUnitTree;
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
import com.sun.source.tree.MethodTree;
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
import com.sun.source.tree.Scope;
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
import com.sun.source.tree.Tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
 * Bridges JSR 199, JSR 269, and the Tree API.
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
 * @author Peter von der Ahé
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
 */
20612
4761f3ff7afb 8025913: Rename jdk.Supported to jdk.Exported
darcy
parents: 16303
diff changeset
    54
@jdk.Exported
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
public abstract class Trees {
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
    /**
25287
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
    57
     * Returns a Trees object for a given CompilationTask.
7633
52b637b3b246 6986242: cut-n-paste error in javadoc for Trees.instance(ProcessingEnvironment)
jjg
parents: 7631
diff changeset
    58
     * @param task the compilation task for which to get the Trees object
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
     * @throws IllegalArgumentException if the task does not support the Trees API.
25287
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
    60
     * @return the Trees object
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
    public static Trees instance(CompilationTask task) {
14548
aa687b312c97 8001098: Provide a simple light-weight "plug-in" mechanism for javac
jjg
parents: 14541
diff changeset
    63
        String taskClassName = task.getClass().getName();
aa687b312c97 8001098: Provide a simple light-weight "plug-in" mechanism for javac
jjg
parents: 14541
diff changeset
    64
        if (!taskClassName.equals("com.sun.tools.javac.api.JavacTaskImpl")
aa687b312c97 8001098: Provide a simple light-weight "plug-in" mechanism for javac
jjg
parents: 14541
diff changeset
    65
                && !taskClassName.equals("com.sun.tools.javac.api.BasicJavacTask"))
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
            throw new IllegalArgumentException();
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
        return getJavacTrees(CompilationTask.class, task);
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
    /**
25287
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
    71
     * Returns a Trees object for a given ProcessingEnvironment.
7633
52b637b3b246 6986242: cut-n-paste error in javadoc for Trees.instance(ProcessingEnvironment)
jjg
parents: 7631
diff changeset
    72
     * @param env the processing environment for which to get the Trees object
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
     * @throws IllegalArgumentException if the env does not support the Trees API.
25287
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
    74
     * @return the Trees object
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
    public static Trees instance(ProcessingEnvironment env) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
        if (!env.getClass().getName().equals("com.sun.tools.javac.processing.JavacProcessingEnvironment"))
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
            throw new IllegalArgumentException();
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
        return getJavacTrees(ProcessingEnvironment.class, env);
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
14541
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents: 9599
diff changeset
    82
    static Trees getJavacTrees(Class<?> argType, Object arg) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
        try {
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
            ClassLoader cl = arg.getClass().getClassLoader();
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
            Class<?> c = Class.forName("com.sun.tools.javac.api.JavacTrees", false, cl);
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
            argType = Class.forName(argType.getName(), false, cl);
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 20612
diff changeset
    87
            Method m = c.getMethod("instance", argType);
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 20612
diff changeset
    88
            return (Trees) m.invoke(null, arg);
25288
5234a53b53a8 8048162: Restrict catch type from Throwable to ReflectiveOperationException
jjg
parents: 25287
diff changeset
    89
        } catch (ReflectiveOperationException e) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
            throw new AssertionError(e);
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
    /**
25287
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
    95
     * Returns a utility object for obtaining source positions.
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
    96
     * @return the utility object for obtaining source positions
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
    public abstract SourcePositions getSourcePositions();
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
    /**
25287
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
   101
     * Returns the Tree node for a given Element.
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
   102
     * Returns {@code null} if the node can not be found.
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
   103
     * @param element the element
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
   104
     * @return the tree node
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
    public abstract Tree getTree(Element element);
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
    /**
25287
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
   109
     * Returns the ClassTree node for a given TypeElement.
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
   110
     * Returns {@code null} if the node can not be found.
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
   111
     * @param element the element
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
   112
     * @return the class tree node
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
    public abstract ClassTree getTree(TypeElement element);
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
    /**
25287
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
   117
     * Returns the MethodTree node for a given ExecutableElement.
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
   118
     * Returns {@code null} if the node can not be found.
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
   119
     * @param method the executable element
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
   120
     * @return the method tree node
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
    public abstract MethodTree getTree(ExecutableElement method);
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
    /**
25287
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
   125
     * Returns the Tree node for an AnnotationMirror on a given Element.
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
   126
     * Returns {@code null} if the node can not be found.
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
   127
     * @param e the element
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
   128
     * @param a the annotation mirror
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
   129
     * @return the tree node
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
    public abstract Tree getTree(Element e, AnnotationMirror a);
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
    /**
25287
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
   134
     * Returns the Tree node for an AnnotationValue for an AnnotationMirror on a given Element.
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
   135
     * Returns {@code null} if the node can not be found.
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
   136
     * @param e the element
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
   137
     * @param a the annotation mirror
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
   138
     * @param v the annotation value
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
   139
     * @return the tree node
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
    public abstract Tree getTree(Element e, AnnotationMirror a, AnnotationValue v);
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
    /**
25287
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
   144
     * Returns the path to tree node within the specified compilation unit.
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
   145
     * @param unit the compilation unit
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
   146
     * @param node the tree node
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
   147
     * @return the tree path
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
    public abstract TreePath getPath(CompilationUnitTree unit, Tree node);
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
    /**
25287
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
   152
     * Returns the TreePath node for a given Element.
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
   153
     * Returns {@code null} if the node can not be found.
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
   154
     * @param e the element
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
   155
     * @return the tree path
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
    public abstract TreePath getPath(Element e);
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
06bc494ca11e Initial load
duke
parents:
diff changeset
   159
    /**
25287
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
   160
     * Returns the TreePath node for an AnnotationMirror on a given Element.
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
   161
     * Returns {@code null} if the node can not be found.
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
   162
     * @param e the element
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
   163
     * @param a the annotation mirror
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
   164
     * @return the tree path
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   165
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
    public abstract TreePath getPath(Element e, AnnotationMirror a);
06bc494ca11e Initial load
duke
parents:
diff changeset
   167
06bc494ca11e Initial load
duke
parents:
diff changeset
   168
    /**
25287
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
   169
     * Returns the TreePath node for an AnnotationValue for an AnnotationMirror on a given Element.
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
   170
     * Returns {@code null} if the node can not be found.
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
   171
     * @param e the element
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
   172
     * @param a the annotation mirror
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
   173
     * @param v the annotation value
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
   174
     * @return the tree path
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   175
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   176
    public abstract TreePath getPath(Element e, AnnotationMirror a, AnnotationValue v);
06bc494ca11e Initial load
duke
parents:
diff changeset
   177
06bc494ca11e Initial load
duke
parents:
diff changeset
   178
    /**
25287
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
   179
     * Returns the Element for the Tree node identified by a given TreePath.
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
   180
     * Returns {@code null} if the element is not available.
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
   181
     * @param path the tree path
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
   182
     * @return the element
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   183
     * @throws IllegalArgumentException is the TreePath does not identify
06bc494ca11e Initial load
duke
parents:
diff changeset
   184
     * a Tree node that might have an associated Element.
06bc494ca11e Initial load
duke
parents:
diff changeset
   185
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   186
    public abstract Element getElement(TreePath path);
06bc494ca11e Initial load
duke
parents:
diff changeset
   187
06bc494ca11e Initial load
duke
parents:
diff changeset
   188
    /**
25287
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
   189
     * Returns the TypeMirror for the Tree node identified by a given TreePath.
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
   190
     * Returns {@code null} if the TypeMirror is not available.
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
   191
     * @param path the tree path
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
   192
     * @return the type mirror
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   193
     * @throws IllegalArgumentException is the TreePath does not identify
06bc494ca11e Initial load
duke
parents:
diff changeset
   194
     * a Tree node that might have an associated TypeMirror.
06bc494ca11e Initial load
duke
parents:
diff changeset
   195
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   196
    public abstract TypeMirror getTypeMirror(TreePath path);
06bc494ca11e Initial load
duke
parents:
diff changeset
   197
06bc494ca11e Initial load
duke
parents:
diff changeset
   198
    /**
25287
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
   199
     * Returns the Scope for the Tree node identified by a given TreePath.
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
   200
     * Returns {@code null} if the Scope is not available.
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
   201
     * @param path the tree path
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
   202
     * @return the scope
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   203
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   204
    public abstract Scope getScope(TreePath path);
06bc494ca11e Initial load
duke
parents:
diff changeset
   205
06bc494ca11e Initial load
duke
parents:
diff changeset
   206
    /**
25287
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
   207
     * Returns the doc comment, if any, for the Tree node identified by a given TreePath.
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
   208
     * Returns {@code null} if no doc comment was found.
14541
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents: 9599
diff changeset
   209
     * @see DocTrees#getDocCommentTree(TreePath)
25287
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
   210
     * @param path the tree path
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
   211
     * @return the doc comment
7631
57bce845dcee 6985202: no access to doc comments from Tree API
jjg
parents: 5520
diff changeset
   212
     */
57bce845dcee 6985202: no access to doc comments from Tree API
jjg
parents: 5520
diff changeset
   213
    public abstract String getDocComment(TreePath path);
57bce845dcee 6985202: no access to doc comments from Tree API
jjg
parents: 5520
diff changeset
   214
57bce845dcee 6985202: no access to doc comments from Tree API
jjg
parents: 5520
diff changeset
   215
    /**
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   216
     * Checks whether a given type is accessible in a given scope.
06bc494ca11e Initial load
duke
parents:
diff changeset
   217
     * @param scope the scope to be checked
06bc494ca11e Initial load
duke
parents:
diff changeset
   218
     * @param type the type to be checked
06bc494ca11e Initial load
duke
parents:
diff changeset
   219
     * @return true if {@code type} is accessible
06bc494ca11e Initial load
duke
parents:
diff changeset
   220
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   221
    public abstract boolean isAccessible(Scope scope, TypeElement type);
06bc494ca11e Initial load
duke
parents:
diff changeset
   222
06bc494ca11e Initial load
duke
parents:
diff changeset
   223
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   224
     * Checks whether the given element is accessible as a member of the given
06bc494ca11e Initial load
duke
parents:
diff changeset
   225
     * type in a given scope.
06bc494ca11e Initial load
duke
parents:
diff changeset
   226
     * @param scope the scope to be checked
06bc494ca11e Initial load
duke
parents:
diff changeset
   227
     * @param member the member to be checked
06bc494ca11e Initial load
duke
parents:
diff changeset
   228
     * @param type the type for which to check if the member is accessible
06bc494ca11e Initial load
duke
parents:
diff changeset
   229
     * @return true if {@code member} is accessible in {@code type}
06bc494ca11e Initial load
duke
parents:
diff changeset
   230
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   231
    public abstract boolean isAccessible(Scope scope, Element member, DeclaredType type);
1257
873b053bf757 6557752: Original type of an AST should be made available even if it is replaced with an ErrorType
jjg
parents: 10
diff changeset
   232
873b053bf757 6557752: Original type of an AST should be made available even if it is replaced with an ErrorType
jjg
parents: 10
diff changeset
   233
    /**
25287
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
   234
      * Returns the original type from the ErrorType object.
1257
873b053bf757 6557752: Original type of an AST should be made available even if it is replaced with an ErrorType
jjg
parents: 10
diff changeset
   235
      * @param errorType The errorType for which we want to get the original type.
3149
0cd06d598d6f 6843077: JSR 308: Annotations on types
jjg
parents: 1789
diff changeset
   236
      * @return javax.lang.model.type.TypeMirror corresponding to the original type, replaced by the ErrorType.
1257
873b053bf757 6557752: Original type of an AST should be made available even if it is replaced with an ErrorType
jjg
parents: 10
diff changeset
   237
      */
873b053bf757 6557752: Original type of an AST should be made available even if it is replaced with an ErrorType
jjg
parents: 10
diff changeset
   238
    public abstract TypeMirror getOriginalType(ErrorType errorType);
3149
0cd06d598d6f 6843077: JSR 308: Annotations on types
jjg
parents: 1789
diff changeset
   239
0cd06d598d6f 6843077: JSR 308: Annotations on types
jjg
parents: 1789
diff changeset
   240
    /**
0cd06d598d6f 6843077: JSR 308: Annotations on types
jjg
parents: 1789
diff changeset
   241
     * Prints a message of the specified kind at the location of the
0cd06d598d6f 6843077: JSR 308: Annotations on types
jjg
parents: 1789
diff changeset
   242
     * tree within the provided compilation unit
0cd06d598d6f 6843077: JSR 308: Annotations on types
jjg
parents: 1789
diff changeset
   243
     *
0cd06d598d6f 6843077: JSR 308: Annotations on types
jjg
parents: 1789
diff changeset
   244
     * @param kind the kind of message
0cd06d598d6f 6843077: JSR 308: Annotations on types
jjg
parents: 1789
diff changeset
   245
     * @param msg  the message, or an empty string if none
0cd06d598d6f 6843077: JSR 308: Annotations on types
jjg
parents: 1789
diff changeset
   246
     * @param t    the tree to use as a position hint
0cd06d598d6f 6843077: JSR 308: Annotations on types
jjg
parents: 1789
diff changeset
   247
     * @param root the compilation unit that contains tree
0cd06d598d6f 6843077: JSR 308: Annotations on types
jjg
parents: 1789
diff changeset
   248
     */
0cd06d598d6f 6843077: JSR 308: Annotations on types
jjg
parents: 1789
diff changeset
   249
    public abstract void printMessage(Diagnostic.Kind kind, CharSequence msg,
0cd06d598d6f 6843077: JSR 308: Annotations on types
jjg
parents: 1789
diff changeset
   250
            com.sun.source.tree.Tree t,
0cd06d598d6f 6843077: JSR 308: Annotations on types
jjg
parents: 1789
diff changeset
   251
            com.sun.source.tree.CompilationUnitTree root);
9599
0996df19ea87 7029150: Project Coin: present union types from the tree API through to javax.lang.model
jjg
parents: 7681
diff changeset
   252
0996df19ea87 7029150: Project Coin: present union types from the tree API through to javax.lang.model
jjg
parents: 7681
diff changeset
   253
    /**
25287
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 22163
diff changeset
   254
     * Returns the lub of an exception parameter declared in a catch clause.
9599
0996df19ea87 7029150: Project Coin: present union types from the tree API through to javax.lang.model
jjg
parents: 7681
diff changeset
   255
     * @param tree the tree for the catch clause
0996df19ea87 7029150: Project Coin: present union types from the tree API through to javax.lang.model
jjg
parents: 7681
diff changeset
   256
     * @return The lub of the exception parameter
0996df19ea87 7029150: Project Coin: present union types from the tree API through to javax.lang.model
jjg
parents: 7681
diff changeset
   257
     */
0996df19ea87 7029150: Project Coin: present union types from the tree API through to javax.lang.model
jjg
parents: 7681
diff changeset
   258
    public abstract TypeMirror getLub(CatchTree tree);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   259
}