langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor6.java
author yan
Mon, 10 Nov 2014 16:23:30 +0300
changeset 27763 1fba965925e8
parent 25874 83c19f00452c
child 43133 08a858022ea6
permissions -rw-r--r--
8063102: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 1 Reviewed-by: pchelko, serb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
25690
b1dac768ab79 8050430: Provided new utility visitors supporting SourceVersion.RELEASE_9
darcy
parents: 15386
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: 10
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: 10
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: 10
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
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 javax.lang.model.util;
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
import javax.lang.model.element.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
import static javax.lang.model.element.ElementKind.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
import javax.annotation.processing.SupportedSourceVersion;
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
import static javax.lang.model.SourceVersion.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
import javax.lang.model.SourceVersion;
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
 * A visitor of program elements based on their {@linkplain
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
 * ElementKind kind} with default behavior appropriate for the {@link
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
 * SourceVersion#RELEASE_6 RELEASE_6} source version.  For {@linkplain
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
 * Element elements} <tt><i>XYZ</i></tt> that may have more than one
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
 * kind, the <tt>visit<i>XYZ</i></tt> methods in this class delegate
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
 * to the <tt>visit<i>XYZKind</i></tt> method corresponding to the
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
 * first argument's kind.  The <tt>visit<i>XYZKind</i></tt> methods
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
 * call {@link #defaultAction defaultAction}, passing their arguments
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
 * to {@code defaultAction}'s corresponding parameters.
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
 * <p> Methods in this class may be overridden subject to their
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
 * general contract.  Note that annotating methods in concrete
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
 * subclasses with {@link java.lang.Override @Override} will help
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
 * ensure that methods are overridden as intended.
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
 * <p> <b>WARNING:</b> The {@code ElementVisitor} interface
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
 * implemented by this class may have methods added to it or the
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
 * {@code ElementKind} {@code enum} used in this case may have
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
 * constants added to it in the future to accommodate new, currently
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
 * unknown, language structures added to future versions of the
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
 * Java&trade; programming language.  Therefore, methods whose names
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
 * begin with {@code "visit"} may be added to this class in the
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
 * future; to avoid incompatibilities, classes which extend this class
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
 * should not declare any instance methods with names beginning with
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
 * {@code "visit"}.
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
 * <p>When such a new visit method is added, the default
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
 * implementation in this class will be to call the {@link
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
 * #visitUnknown visitUnknown} method.  A new abstract element kind
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
 * visitor class will also be introduced to correspond to the new
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
 * language level; this visitor will have different default behavior
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
 * for the visit method in question.  When the new visitor is
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
 * introduced, all or portions of this visitor may be deprecated.
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
 *
15386
92bc08d96f0c 8006264: Add explanation of why default methods cannot be used in JDK 8 javax.lang.model
darcy
parents: 10192
diff changeset
    70
 * <p>Note that adding a default implementation of a new visit method
92bc08d96f0c 8006264: Add explanation of why default methods cannot be used in JDK 8 javax.lang.model
darcy
parents: 10192
diff changeset
    71
 * in a visitor class will occur instead of adding a <em>default
92bc08d96f0c 8006264: Add explanation of why default methods cannot be used in JDK 8 javax.lang.model
darcy
parents: 10192
diff changeset
    72
 * method</em> directly in the visitor interface since a Java SE 8
92bc08d96f0c 8006264: Add explanation of why default methods cannot be used in JDK 8 javax.lang.model
darcy
parents: 10192
diff changeset
    73
 * language feature cannot be used to this version of the API since
92bc08d96f0c 8006264: Add explanation of why default methods cannot be used in JDK 8 javax.lang.model
darcy
parents: 10192
diff changeset
    74
 * this version is required to be runnable on Java SE 7
92bc08d96f0c 8006264: Add explanation of why default methods cannot be used in JDK 8 javax.lang.model
darcy
parents: 10192
diff changeset
    75
 * implementations.  Future versions of the API that are only required
92bc08d96f0c 8006264: Add explanation of why default methods cannot be used in JDK 8 javax.lang.model
darcy
parents: 10192
diff changeset
    76
 * to run on Java SE 8 and later may take advantage of default methods
92bc08d96f0c 8006264: Add explanation of why default methods cannot be used in JDK 8 javax.lang.model
darcy
parents: 10192
diff changeset
    77
 * in this situation.
92bc08d96f0c 8006264: Add explanation of why default methods cannot be used in JDK 8 javax.lang.model
darcy
parents: 10192
diff changeset
    78
 *
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
 * @param <R> the return type of this visitor's methods.  Use {@link
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
 *            Void} for visitors that do not need to return results.
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
 * @param <P> the type of the additional parameter to this visitor's
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
 *            methods.  Use {@code Void} for visitors that do not need an
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
 *            additional parameter.
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
 * @author Joseph D. Darcy
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
 * @author Scott Seligman
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
 * @author Peter von der Ah&eacute;
5841
7a8448425bb7 6933147: Provided new utility visitors supporting SourceVersion.RELEASE_7
darcy
parents: 5520
diff changeset
    88
 *
7a8448425bb7 6933147: Provided new utility visitors supporting SourceVersion.RELEASE_7
darcy
parents: 5520
diff changeset
    89
 * @see ElementKindVisitor7
10192
378321489bea 7025809: Provided new utility visitors supporting SourceVersion.RELEASE_8
darcy
parents: 8235
diff changeset
    90
 * @see ElementKindVisitor8
25690
b1dac768ab79 8050430: Provided new utility visitors supporting SourceVersion.RELEASE_9
darcy
parents: 15386
diff changeset
    91
 * @see ElementKindVisitor9
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
 * @since 1.6
25690
b1dac768ab79 8050430: Provided new utility visitors supporting SourceVersion.RELEASE_9
darcy
parents: 15386
diff changeset
    93
 * @deprecated Release 6 is obsolete; update to a visitor for a newer
b1dac768ab79 8050430: Provided new utility visitors supporting SourceVersion.RELEASE_9
darcy
parents: 15386
diff changeset
    94
 * release level.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
 */
25690
b1dac768ab79 8050430: Provided new utility visitors supporting SourceVersion.RELEASE_9
darcy
parents: 15386
diff changeset
    96
@Deprecated
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
@SupportedSourceVersion(RELEASE_6)
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
public class ElementKindVisitor6<R, P>
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
                  extends SimpleElementVisitor6<R, P> {
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
     * Constructor for concrete subclasses; uses {@code null} for the
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
     * default value.
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
    protected ElementKindVisitor6() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
        super(null);
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
     * Constructor for concrete subclasses; uses the argument for the
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
     * default value.
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
     * @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
    protected ElementKindVisitor6(R defaultValue) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
        super(defaultValue);
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
     * The element argument has kind {@code PACKAGE}.
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
     * @param e {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
     * @param p {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
     * @return  {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
    @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
    public R visitPackage(PackageElement e, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
        assert e.getKind() == PACKAGE: "Bad kind on PackageElement";
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
        return defaultAction(e, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
     * Visits a type element, dispatching to the visit method for the
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
     * specific {@linkplain ElementKind kind} of type, {@code
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
     * ANNOTATION_TYPE}, {@code CLASS}, {@code ENUM}, or {@code
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
     * INTERFACE}.
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
     * @param e {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
     * @param p {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
     * @return  the result of the kind-specific visit method
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
    @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
    public R visitType(TypeElement e, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
        ElementKind k = e.getKind();
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
        switch(k) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
        case ANNOTATION_TYPE:
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
            return visitTypeAsAnnotationType(e, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
        case CLASS:
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
            return visitTypeAsClass(e, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
06bc494ca11e Initial load
duke
parents:
diff changeset
   153
        case ENUM:
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
            return visitTypeAsEnum(e, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   155
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
        case INTERFACE:
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
            return visitTypeAsInterface(e, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
06bc494ca11e Initial load
duke
parents:
diff changeset
   159
        default:
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
            throw new AssertionError("Bad kind " + k + " for TypeElement" + e);
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   163
06bc494ca11e Initial load
duke
parents:
diff changeset
   164
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   165
     * Visits an {@code ANNOTATION_TYPE} type element by calling
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
     * {@code defaultAction}.
06bc494ca11e Initial load
duke
parents:
diff changeset
   167
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   168
     * @param e the element to visit
06bc494ca11e Initial load
duke
parents:
diff changeset
   169
     * @param p a visitor-specified parameter
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
     * @return  the result of {@code defaultAction}
06bc494ca11e Initial load
duke
parents:
diff changeset
   171
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   172
    public R visitTypeAsAnnotationType(TypeElement e, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   173
        return defaultAction(e, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   174
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   175
06bc494ca11e Initial load
duke
parents:
diff changeset
   176
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   177
     * Visits a {@code CLASS} type element by calling {@code
06bc494ca11e Initial load
duke
parents:
diff changeset
   178
     * defaultAction}.
06bc494ca11e Initial load
duke
parents:
diff changeset
   179
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   180
     * @param e the element to visit
06bc494ca11e Initial load
duke
parents:
diff changeset
   181
     * @param p a visitor-specified parameter
06bc494ca11e Initial load
duke
parents:
diff changeset
   182
     * @return  the result of {@code defaultAction}
06bc494ca11e Initial load
duke
parents:
diff changeset
   183
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   184
    public R visitTypeAsClass(TypeElement e, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   185
        return defaultAction(e, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   186
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   187
06bc494ca11e Initial load
duke
parents:
diff changeset
   188
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   189
     * Visits an {@code ENUM} type element by calling {@code
06bc494ca11e Initial load
duke
parents:
diff changeset
   190
     * defaultAction}.
06bc494ca11e Initial load
duke
parents:
diff changeset
   191
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   192
     * @param e the element to visit
06bc494ca11e Initial load
duke
parents:
diff changeset
   193
     * @param p a visitor-specified parameter
06bc494ca11e Initial load
duke
parents:
diff changeset
   194
     * @return  the result of {@code defaultAction}
06bc494ca11e Initial load
duke
parents:
diff changeset
   195
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   196
    public R visitTypeAsEnum(TypeElement e, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   197
        return defaultAction(e, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   198
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   199
06bc494ca11e Initial load
duke
parents:
diff changeset
   200
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   201
     * Visits an {@code INTERFACE} type element by calling {@code
06bc494ca11e Initial load
duke
parents:
diff changeset
   202
     * defaultAction}.
06bc494ca11e Initial load
duke
parents:
diff changeset
   203
     *.
06bc494ca11e Initial load
duke
parents:
diff changeset
   204
     * @param e the element to visit
06bc494ca11e Initial load
duke
parents:
diff changeset
   205
     * @param p a visitor-specified parameter
06bc494ca11e Initial load
duke
parents:
diff changeset
   206
     * @return  the result of {@code defaultAction}
06bc494ca11e Initial load
duke
parents:
diff changeset
   207
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   208
    public R visitTypeAsInterface(TypeElement e, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   209
        return defaultAction(e, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   210
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   211
06bc494ca11e Initial load
duke
parents:
diff changeset
   212
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   213
     * Visits a variable element, dispatching to the visit method for
06bc494ca11e Initial load
duke
parents:
diff changeset
   214
     * the specific {@linkplain ElementKind kind} of variable, {@code
06bc494ca11e Initial load
duke
parents:
diff changeset
   215
     * ENUM_CONSTANT}, {@code EXCEPTION_PARAMETER}, {@code FIELD},
8235
0f7e1f7a6a4b 6961571: Update visitors to support ARM's ElementKind.RESOURCE_VARIABLE
darcy
parents: 7681
diff changeset
   216
     * {@code LOCAL_VARIABLE}, {@code PARAMETER}, or {@code RESOURCE_VARIABLE}.
0f7e1f7a6a4b 6961571: Update visitors to support ARM's ElementKind.RESOURCE_VARIABLE
darcy
parents: 7681
diff changeset
   217
     *
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   218
     * @param e {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   219
     * @param p {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   220
     * @return  the result of the kind-specific visit method
06bc494ca11e Initial load
duke
parents:
diff changeset
   221
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   222
    @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
   223
    public R visitVariable(VariableElement e, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   224
        ElementKind k = e.getKind();
06bc494ca11e Initial load
duke
parents:
diff changeset
   225
        switch(k) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   226
        case ENUM_CONSTANT:
06bc494ca11e Initial load
duke
parents:
diff changeset
   227
            return visitVariableAsEnumConstant(e, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   228
06bc494ca11e Initial load
duke
parents:
diff changeset
   229
        case EXCEPTION_PARAMETER:
06bc494ca11e Initial load
duke
parents:
diff changeset
   230
            return visitVariableAsExceptionParameter(e, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   231
06bc494ca11e Initial load
duke
parents:
diff changeset
   232
        case FIELD:
06bc494ca11e Initial load
duke
parents:
diff changeset
   233
            return visitVariableAsField(e, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   234
06bc494ca11e Initial load
duke
parents:
diff changeset
   235
        case LOCAL_VARIABLE:
06bc494ca11e Initial load
duke
parents:
diff changeset
   236
            return visitVariableAsLocalVariable(e, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   237
06bc494ca11e Initial load
duke
parents:
diff changeset
   238
        case PARAMETER:
06bc494ca11e Initial load
duke
parents:
diff changeset
   239
            return visitVariableAsParameter(e, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   240
8235
0f7e1f7a6a4b 6961571: Update visitors to support ARM's ElementKind.RESOURCE_VARIABLE
darcy
parents: 7681
diff changeset
   241
        case RESOURCE_VARIABLE:
0f7e1f7a6a4b 6961571: Update visitors to support ARM's ElementKind.RESOURCE_VARIABLE
darcy
parents: 7681
diff changeset
   242
            return visitVariableAsResourceVariable(e, p);
0f7e1f7a6a4b 6961571: Update visitors to support ARM's ElementKind.RESOURCE_VARIABLE
darcy
parents: 7681
diff changeset
   243
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   244
        default:
06bc494ca11e Initial load
duke
parents:
diff changeset
   245
            throw new AssertionError("Bad kind " + k + " for VariableElement" + e);
06bc494ca11e Initial load
duke
parents:
diff changeset
   246
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   247
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   248
06bc494ca11e Initial load
duke
parents:
diff changeset
   249
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   250
     * Visits an {@code ENUM_CONSTANT} variable element by calling
06bc494ca11e Initial load
duke
parents:
diff changeset
   251
     * {@code defaultAction}.
06bc494ca11e Initial load
duke
parents:
diff changeset
   252
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   253
     * @param e the element to visit
06bc494ca11e Initial load
duke
parents:
diff changeset
   254
     * @param p a visitor-specified parameter
06bc494ca11e Initial load
duke
parents:
diff changeset
   255
     * @return  the result of {@code defaultAction}
06bc494ca11e Initial load
duke
parents:
diff changeset
   256
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   257
    public R visitVariableAsEnumConstant(VariableElement e, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   258
        return defaultAction(e, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   259
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   260
06bc494ca11e Initial load
duke
parents:
diff changeset
   261
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   262
     * Visits an {@code EXCEPTION_PARAMETER} variable element by calling
06bc494ca11e Initial load
duke
parents:
diff changeset
   263
     * {@code defaultAction}.
06bc494ca11e Initial load
duke
parents:
diff changeset
   264
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   265
     * @param e the element to visit
06bc494ca11e Initial load
duke
parents:
diff changeset
   266
     * @param p a visitor-specified parameter
06bc494ca11e Initial load
duke
parents:
diff changeset
   267
     * @return  the result of {@code defaultAction}
06bc494ca11e Initial load
duke
parents:
diff changeset
   268
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   269
    public R visitVariableAsExceptionParameter(VariableElement e, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   270
        return defaultAction(e, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   271
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   272
06bc494ca11e Initial load
duke
parents:
diff changeset
   273
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   274
     * Visits a {@code FIELD} variable element by calling
06bc494ca11e Initial load
duke
parents:
diff changeset
   275
     * {@code defaultAction}.
06bc494ca11e Initial load
duke
parents:
diff changeset
   276
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   277
     * @param e the element to visit
06bc494ca11e Initial load
duke
parents:
diff changeset
   278
     * @param p a visitor-specified parameter
06bc494ca11e Initial load
duke
parents:
diff changeset
   279
     * @return  the result of {@code defaultAction}
06bc494ca11e Initial load
duke
parents:
diff changeset
   280
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   281
    public R visitVariableAsField(VariableElement e, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   282
        return defaultAction(e, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   283
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   284
06bc494ca11e Initial load
duke
parents:
diff changeset
   285
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   286
     * Visits a {@code LOCAL_VARIABLE} variable element by calling
06bc494ca11e Initial load
duke
parents:
diff changeset
   287
     * {@code defaultAction}.
06bc494ca11e Initial load
duke
parents:
diff changeset
   288
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   289
     * @param e the element to visit
06bc494ca11e Initial load
duke
parents:
diff changeset
   290
     * @param p a visitor-specified parameter
06bc494ca11e Initial load
duke
parents:
diff changeset
   291
     * @return  the result of {@code defaultAction}
06bc494ca11e Initial load
duke
parents:
diff changeset
   292
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   293
    public R visitVariableAsLocalVariable(VariableElement e, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   294
        return defaultAction(e, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   295
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   296
06bc494ca11e Initial load
duke
parents:
diff changeset
   297
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   298
     * Visits a {@code PARAMETER} variable element by calling
06bc494ca11e Initial load
duke
parents:
diff changeset
   299
     * {@code defaultAction}.
06bc494ca11e Initial load
duke
parents:
diff changeset
   300
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   301
     * @param e the element to visit
06bc494ca11e Initial load
duke
parents:
diff changeset
   302
     * @param p a visitor-specified parameter
06bc494ca11e Initial load
duke
parents:
diff changeset
   303
     * @return  the result of {@code defaultAction}
06bc494ca11e Initial load
duke
parents:
diff changeset
   304
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   305
    public R visitVariableAsParameter(VariableElement e, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   306
        return defaultAction(e, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   307
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   308
06bc494ca11e Initial load
duke
parents:
diff changeset
   309
    /**
8235
0f7e1f7a6a4b 6961571: Update visitors to support ARM's ElementKind.RESOURCE_VARIABLE
darcy
parents: 7681
diff changeset
   310
     * Visits a {@code RESOURCE_VARIABLE} variable element by calling
0f7e1f7a6a4b 6961571: Update visitors to support ARM's ElementKind.RESOURCE_VARIABLE
darcy
parents: 7681
diff changeset
   311
     * {@code visitUnknown}.
0f7e1f7a6a4b 6961571: Update visitors to support ARM's ElementKind.RESOURCE_VARIABLE
darcy
parents: 7681
diff changeset
   312
     *
0f7e1f7a6a4b 6961571: Update visitors to support ARM's ElementKind.RESOURCE_VARIABLE
darcy
parents: 7681
diff changeset
   313
     * @param e the element to visit
0f7e1f7a6a4b 6961571: Update visitors to support ARM's ElementKind.RESOURCE_VARIABLE
darcy
parents: 7681
diff changeset
   314
     * @param p a visitor-specified parameter
0f7e1f7a6a4b 6961571: Update visitors to support ARM's ElementKind.RESOURCE_VARIABLE
darcy
parents: 7681
diff changeset
   315
     * @return  the result of {@code visitUnknown}
0f7e1f7a6a4b 6961571: Update visitors to support ARM's ElementKind.RESOURCE_VARIABLE
darcy
parents: 7681
diff changeset
   316
     *
0f7e1f7a6a4b 6961571: Update visitors to support ARM's ElementKind.RESOURCE_VARIABLE
darcy
parents: 7681
diff changeset
   317
     * @since 1.7
0f7e1f7a6a4b 6961571: Update visitors to support ARM's ElementKind.RESOURCE_VARIABLE
darcy
parents: 7681
diff changeset
   318
     */
0f7e1f7a6a4b 6961571: Update visitors to support ARM's ElementKind.RESOURCE_VARIABLE
darcy
parents: 7681
diff changeset
   319
    public R visitVariableAsResourceVariable(VariableElement e, P p) {
0f7e1f7a6a4b 6961571: Update visitors to support ARM's ElementKind.RESOURCE_VARIABLE
darcy
parents: 7681
diff changeset
   320
        return visitUnknown(e, p);
0f7e1f7a6a4b 6961571: Update visitors to support ARM's ElementKind.RESOURCE_VARIABLE
darcy
parents: 7681
diff changeset
   321
    }
0f7e1f7a6a4b 6961571: Update visitors to support ARM's ElementKind.RESOURCE_VARIABLE
darcy
parents: 7681
diff changeset
   322
0f7e1f7a6a4b 6961571: Update visitors to support ARM's ElementKind.RESOURCE_VARIABLE
darcy
parents: 7681
diff changeset
   323
    /**
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   324
     * Visits an executable element, dispatching to the visit method
06bc494ca11e Initial load
duke
parents:
diff changeset
   325
     * for the specific {@linkplain ElementKind kind} of executable,
06bc494ca11e Initial load
duke
parents:
diff changeset
   326
     * {@code CONSTRUCTOR}, {@code INSTANCE_INIT}, {@code METHOD}, or
06bc494ca11e Initial load
duke
parents:
diff changeset
   327
     * {@code STATIC_INIT}.
06bc494ca11e Initial load
duke
parents:
diff changeset
   328
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   329
     * @param e {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   330
     * @param p {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   331
     * @return  the result of the kind-specific visit method
06bc494ca11e Initial load
duke
parents:
diff changeset
   332
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   333
    @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
   334
    public R visitExecutable(ExecutableElement e, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   335
        ElementKind k = e.getKind();
06bc494ca11e Initial load
duke
parents:
diff changeset
   336
        switch(k) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   337
        case CONSTRUCTOR:
06bc494ca11e Initial load
duke
parents:
diff changeset
   338
            return visitExecutableAsConstructor(e, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   339
06bc494ca11e Initial load
duke
parents:
diff changeset
   340
        case INSTANCE_INIT:
06bc494ca11e Initial load
duke
parents:
diff changeset
   341
            return visitExecutableAsInstanceInit(e, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   342
06bc494ca11e Initial load
duke
parents:
diff changeset
   343
        case METHOD:
06bc494ca11e Initial load
duke
parents:
diff changeset
   344
            return visitExecutableAsMethod(e, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   345
06bc494ca11e Initial load
duke
parents:
diff changeset
   346
        case STATIC_INIT:
06bc494ca11e Initial load
duke
parents:
diff changeset
   347
            return visitExecutableAsStaticInit(e, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   348
06bc494ca11e Initial load
duke
parents:
diff changeset
   349
        default:
06bc494ca11e Initial load
duke
parents:
diff changeset
   350
            throw new AssertionError("Bad kind " + k + " for ExecutableElement" + e);
06bc494ca11e Initial load
duke
parents:
diff changeset
   351
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   352
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   353
06bc494ca11e Initial load
duke
parents:
diff changeset
   354
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   355
     * Visits a {@code CONSTRUCTOR} executable element by calling
06bc494ca11e Initial load
duke
parents:
diff changeset
   356
     * {@code defaultAction}.
06bc494ca11e Initial load
duke
parents:
diff changeset
   357
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   358
     * @param e the element to visit
06bc494ca11e Initial load
duke
parents:
diff changeset
   359
     * @param p a visitor-specified parameter
06bc494ca11e Initial load
duke
parents:
diff changeset
   360
     * @return  the result of {@code defaultAction}
06bc494ca11e Initial load
duke
parents:
diff changeset
   361
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   362
    public R visitExecutableAsConstructor(ExecutableElement e, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   363
        return defaultAction(e, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   364
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   365
06bc494ca11e Initial load
duke
parents:
diff changeset
   366
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   367
     * Visits an {@code INSTANCE_INIT} executable element by calling
06bc494ca11e Initial load
duke
parents:
diff changeset
   368
     * {@code defaultAction}.
06bc494ca11e Initial load
duke
parents:
diff changeset
   369
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   370
     * @param e the element to visit
06bc494ca11e Initial load
duke
parents:
diff changeset
   371
     * @param p a visitor-specified parameter
06bc494ca11e Initial load
duke
parents:
diff changeset
   372
     * @return  the result of {@code defaultAction}
06bc494ca11e Initial load
duke
parents:
diff changeset
   373
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   374
    public R visitExecutableAsInstanceInit(ExecutableElement e, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   375
        return defaultAction(e, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   376
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   377
06bc494ca11e Initial load
duke
parents:
diff changeset
   378
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   379
     * Visits a {@code METHOD} executable element by calling
06bc494ca11e Initial load
duke
parents:
diff changeset
   380
     * {@code defaultAction}.
06bc494ca11e Initial load
duke
parents:
diff changeset
   381
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   382
     * @param e the element to visit
06bc494ca11e Initial load
duke
parents:
diff changeset
   383
     * @param p a visitor-specified parameter
06bc494ca11e Initial load
duke
parents:
diff changeset
   384
     * @return  the result of {@code defaultAction}
06bc494ca11e Initial load
duke
parents:
diff changeset
   385
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   386
    public R visitExecutableAsMethod(ExecutableElement e, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   387
        return defaultAction(e, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   388
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   389
06bc494ca11e Initial load
duke
parents:
diff changeset
   390
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   391
     * Visits a {@code STATIC_INIT} executable element by calling
06bc494ca11e Initial load
duke
parents:
diff changeset
   392
     * {@code defaultAction}.
06bc494ca11e Initial load
duke
parents:
diff changeset
   393
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   394
     * @param e the element to visit
06bc494ca11e Initial load
duke
parents:
diff changeset
   395
     * @param p a visitor-specified parameter
06bc494ca11e Initial load
duke
parents:
diff changeset
   396
     * @return  the result of {@code defaultAction}
06bc494ca11e Initial load
duke
parents:
diff changeset
   397
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   398
    public R visitExecutableAsStaticInit(ExecutableElement e, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   399
        return defaultAction(e, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   400
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   401
06bc494ca11e Initial load
duke
parents:
diff changeset
   402
06bc494ca11e Initial load
duke
parents:
diff changeset
   403
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   404
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   405
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   406
     * The element argument has kind {@code TYPE_PARAMETER}.
06bc494ca11e Initial load
duke
parents:
diff changeset
   407
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   408
     * @param e {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   409
     * @param p {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   410
     * @return  {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   411
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   412
    @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
   413
    public R visitTypeParameter(TypeParameterElement e, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   414
        assert e.getKind() == TYPE_PARAMETER: "Bad kind on TypeParameterElement";
06bc494ca11e Initial load
duke
parents:
diff changeset
   415
        return defaultAction(e, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   416
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   417
}