langtools/src/share/classes/javax/lang/model/util/ElementKindVisitor6.java
author darcy
Tue, 05 Jul 2011 16:37:24 -0700
changeset 10192 378321489bea
parent 8235 0f7e1f7a6a4b
child 15386 92bc08d96f0c
permissions -rw-r--r--
7025809: Provided new utility visitors supporting SourceVersion.RELEASE_8 Reviewed-by: jjg, mcimadamore
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
8235
0f7e1f7a6a4b 6961571: Update visitors to support ARM's ElementKind.RESOURCE_VARIABLE
darcy
parents: 7681
diff changeset
     2
 * Copyright (c) 2005, 2011, 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
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
 * @param <R> the return type of this visitor's methods.  Use {@link
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
 *            Void} for visitors that do not need to return results.
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
 * @param <P> the type of the additional parameter to this visitor's
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
 *            methods.  Use {@code Void} for visitors that do not need an
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
 *            additional parameter.
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
 * @author Joseph D. Darcy
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
 * @author Scott Seligman
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
 * @author Peter von der Ah&eacute;
5841
7a8448425bb7 6933147: Provided new utility visitors supporting SourceVersion.RELEASE_7
darcy
parents: 5520
diff changeset
    79
 *
7a8448425bb7 6933147: Provided new utility visitors supporting SourceVersion.RELEASE_7
darcy
parents: 5520
diff changeset
    80
 * @see ElementKindVisitor7
10192
378321489bea 7025809: Provided new utility visitors supporting SourceVersion.RELEASE_8
darcy
parents: 8235
diff changeset
    81
 * @see ElementKindVisitor8
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
 * @since 1.6
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
@SupportedSourceVersion(RELEASE_6)
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
public class ElementKindVisitor6<R, P>
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
                  extends SimpleElementVisitor6<R, P> {
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
     * Constructor for concrete subclasses; uses {@code null} for the
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
     * default value.
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
    protected ElementKindVisitor6() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
        super(null);
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
     * Constructor for concrete subclasses; uses the argument for the
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
     * default value.
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
     * @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
    protected ElementKindVisitor6(R defaultValue) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
        super(defaultValue);
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
     * The element argument has kind {@code PACKAGE}.
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
     * @param e {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
     * @param p {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
     * @return  {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
    @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
    public R visitPackage(PackageElement e, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
        assert e.getKind() == PACKAGE: "Bad kind on PackageElement";
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
        return defaultAction(e, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
     * Visits a type element, dispatching to the visit method for the
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
     * specific {@linkplain ElementKind kind} of type, {@code
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
     * ANNOTATION_TYPE}, {@code CLASS}, {@code ENUM}, or {@code
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
     * INTERFACE}.
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
     * @param e {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
     * @param p {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
     * @return  the result of the kind-specific visit method
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
    @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
    public R visitType(TypeElement e, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
        ElementKind k = e.getKind();
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
        switch(k) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
        case ANNOTATION_TYPE:
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
            return visitTypeAsAnnotationType(e, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
        case CLASS:
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
            return visitTypeAsClass(e, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
        case ENUM:
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
            return visitTypeAsEnum(e, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
        case INTERFACE:
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
            return visitTypeAsInterface(e, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
        default:
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
            throw new AssertionError("Bad kind " + k + " for TypeElement" + e);
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
     * Visits an {@code ANNOTATION_TYPE} type element by calling
06bc494ca11e Initial load
duke
parents:
diff changeset
   153
     * {@code defaultAction}.
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   155
     * @param e the element to visit
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
     * @param p a visitor-specified parameter
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
     * @return  the result of {@code defaultAction}
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   159
    public R visitTypeAsAnnotationType(TypeElement e, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
        return defaultAction(e, p);
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
     * Visits a {@code CLASS} type element by calling {@code
06bc494ca11e Initial load
duke
parents:
diff changeset
   165
     * defaultAction}.
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   167
     * @param e the element to visit
06bc494ca11e Initial load
duke
parents:
diff changeset
   168
     * @param p a visitor-specified parameter
06bc494ca11e Initial load
duke
parents:
diff changeset
   169
     * @return  the result of {@code defaultAction}
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   171
    public R visitTypeAsClass(TypeElement e, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   172
        return defaultAction(e, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   173
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   174
06bc494ca11e Initial load
duke
parents:
diff changeset
   175
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   176
     * Visits an {@code ENUM} type element by calling {@code
06bc494ca11e Initial load
duke
parents:
diff changeset
   177
     * defaultAction}.
06bc494ca11e Initial load
duke
parents:
diff changeset
   178
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   179
     * @param e the element to visit
06bc494ca11e Initial load
duke
parents:
diff changeset
   180
     * @param p a visitor-specified parameter
06bc494ca11e Initial load
duke
parents:
diff changeset
   181
     * @return  the result of {@code defaultAction}
06bc494ca11e Initial load
duke
parents:
diff changeset
   182
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   183
    public R visitTypeAsEnum(TypeElement e, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   184
        return defaultAction(e, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   185
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   186
06bc494ca11e Initial load
duke
parents:
diff changeset
   187
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   188
     * Visits an {@code INTERFACE} type element by calling {@code
06bc494ca11e Initial load
duke
parents:
diff changeset
   189
     * defaultAction}.
06bc494ca11e Initial load
duke
parents:
diff changeset
   190
     *.
06bc494ca11e Initial load
duke
parents:
diff changeset
   191
     * @param e the element to visit
06bc494ca11e Initial load
duke
parents:
diff changeset
   192
     * @param p a visitor-specified parameter
06bc494ca11e Initial load
duke
parents:
diff changeset
   193
     * @return  the result of {@code defaultAction}
06bc494ca11e Initial load
duke
parents:
diff changeset
   194
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   195
    public R visitTypeAsInterface(TypeElement e, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   196
        return defaultAction(e, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   197
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   198
06bc494ca11e Initial load
duke
parents:
diff changeset
   199
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   200
     * Visits a variable element, dispatching to the visit method for
06bc494ca11e Initial load
duke
parents:
diff changeset
   201
     * the specific {@linkplain ElementKind kind} of variable, {@code
06bc494ca11e Initial load
duke
parents:
diff changeset
   202
     * ENUM_CONSTANT}, {@code EXCEPTION_PARAMETER}, {@code FIELD},
8235
0f7e1f7a6a4b 6961571: Update visitors to support ARM's ElementKind.RESOURCE_VARIABLE
darcy
parents: 7681
diff changeset
   203
     * {@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
   204
     *
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   205
     * @param e {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   206
     * @param p {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   207
     * @return  the result of the kind-specific visit method
06bc494ca11e Initial load
duke
parents:
diff changeset
   208
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   209
    @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
   210
    public R visitVariable(VariableElement e, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   211
        ElementKind k = e.getKind();
06bc494ca11e Initial load
duke
parents:
diff changeset
   212
        switch(k) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   213
        case ENUM_CONSTANT:
06bc494ca11e Initial load
duke
parents:
diff changeset
   214
            return visitVariableAsEnumConstant(e, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   215
06bc494ca11e Initial load
duke
parents:
diff changeset
   216
        case EXCEPTION_PARAMETER:
06bc494ca11e Initial load
duke
parents:
diff changeset
   217
            return visitVariableAsExceptionParameter(e, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   218
06bc494ca11e Initial load
duke
parents:
diff changeset
   219
        case FIELD:
06bc494ca11e Initial load
duke
parents:
diff changeset
   220
            return visitVariableAsField(e, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   221
06bc494ca11e Initial load
duke
parents:
diff changeset
   222
        case LOCAL_VARIABLE:
06bc494ca11e Initial load
duke
parents:
diff changeset
   223
            return visitVariableAsLocalVariable(e, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   224
06bc494ca11e Initial load
duke
parents:
diff changeset
   225
        case PARAMETER:
06bc494ca11e Initial load
duke
parents:
diff changeset
   226
            return visitVariableAsParameter(e, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   227
8235
0f7e1f7a6a4b 6961571: Update visitors to support ARM's ElementKind.RESOURCE_VARIABLE
darcy
parents: 7681
diff changeset
   228
        case RESOURCE_VARIABLE:
0f7e1f7a6a4b 6961571: Update visitors to support ARM's ElementKind.RESOURCE_VARIABLE
darcy
parents: 7681
diff changeset
   229
            return visitVariableAsResourceVariable(e, p);
0f7e1f7a6a4b 6961571: Update visitors to support ARM's ElementKind.RESOURCE_VARIABLE
darcy
parents: 7681
diff changeset
   230
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   231
        default:
06bc494ca11e Initial load
duke
parents:
diff changeset
   232
            throw new AssertionError("Bad kind " + k + " for VariableElement" + e);
06bc494ca11e Initial load
duke
parents:
diff changeset
   233
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   234
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   235
06bc494ca11e Initial load
duke
parents:
diff changeset
   236
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   237
     * Visits an {@code ENUM_CONSTANT} variable element by calling
06bc494ca11e Initial load
duke
parents:
diff changeset
   238
     * {@code defaultAction}.
06bc494ca11e Initial load
duke
parents:
diff changeset
   239
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   240
     * @param e the element to visit
06bc494ca11e Initial load
duke
parents:
diff changeset
   241
     * @param p a visitor-specified parameter
06bc494ca11e Initial load
duke
parents:
diff changeset
   242
     * @return  the result of {@code defaultAction}
06bc494ca11e Initial load
duke
parents:
diff changeset
   243
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   244
    public R visitVariableAsEnumConstant(VariableElement e, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   245
        return defaultAction(e, p);
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
     * Visits an {@code EXCEPTION_PARAMETER} variable element by calling
06bc494ca11e Initial load
duke
parents:
diff changeset
   250
     * {@code defaultAction}.
06bc494ca11e Initial load
duke
parents:
diff changeset
   251
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   252
     * @param e the element to visit
06bc494ca11e Initial load
duke
parents:
diff changeset
   253
     * @param p a visitor-specified parameter
06bc494ca11e Initial load
duke
parents:
diff changeset
   254
     * @return  the result of {@code defaultAction}
06bc494ca11e Initial load
duke
parents:
diff changeset
   255
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   256
    public R visitVariableAsExceptionParameter(VariableElement e, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   257
        return defaultAction(e, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   258
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   259
06bc494ca11e Initial load
duke
parents:
diff changeset
   260
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   261
     * Visits a {@code FIELD} variable element by calling
06bc494ca11e Initial load
duke
parents:
diff changeset
   262
     * {@code defaultAction}.
06bc494ca11e Initial load
duke
parents:
diff changeset
   263
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   264
     * @param e the element to visit
06bc494ca11e Initial load
duke
parents:
diff changeset
   265
     * @param p a visitor-specified parameter
06bc494ca11e Initial load
duke
parents:
diff changeset
   266
     * @return  the result of {@code defaultAction}
06bc494ca11e Initial load
duke
parents:
diff changeset
   267
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   268
    public R visitVariableAsField(VariableElement e, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   269
        return defaultAction(e, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   270
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   271
06bc494ca11e Initial load
duke
parents:
diff changeset
   272
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   273
     * Visits a {@code LOCAL_VARIABLE} variable element by calling
06bc494ca11e Initial load
duke
parents:
diff changeset
   274
     * {@code defaultAction}.
06bc494ca11e Initial load
duke
parents:
diff changeset
   275
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   276
     * @param e the element to visit
06bc494ca11e Initial load
duke
parents:
diff changeset
   277
     * @param p a visitor-specified parameter
06bc494ca11e Initial load
duke
parents:
diff changeset
   278
     * @return  the result of {@code defaultAction}
06bc494ca11e Initial load
duke
parents:
diff changeset
   279
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   280
    public R visitVariableAsLocalVariable(VariableElement e, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   281
        return defaultAction(e, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   282
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   283
06bc494ca11e Initial load
duke
parents:
diff changeset
   284
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   285
     * Visits a {@code PARAMETER} variable element by calling
06bc494ca11e Initial load
duke
parents:
diff changeset
   286
     * {@code defaultAction}.
06bc494ca11e Initial load
duke
parents:
diff changeset
   287
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   288
     * @param e the element to visit
06bc494ca11e Initial load
duke
parents:
diff changeset
   289
     * @param p a visitor-specified parameter
06bc494ca11e Initial load
duke
parents:
diff changeset
   290
     * @return  the result of {@code defaultAction}
06bc494ca11e Initial load
duke
parents:
diff changeset
   291
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   292
    public R visitVariableAsParameter(VariableElement e, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   293
        return defaultAction(e, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   294
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   295
06bc494ca11e Initial load
duke
parents:
diff changeset
   296
    /**
8235
0f7e1f7a6a4b 6961571: Update visitors to support ARM's ElementKind.RESOURCE_VARIABLE
darcy
parents: 7681
diff changeset
   297
     * 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
   298
     * {@code visitUnknown}.
0f7e1f7a6a4b 6961571: Update visitors to support ARM's ElementKind.RESOURCE_VARIABLE
darcy
parents: 7681
diff changeset
   299
     *
0f7e1f7a6a4b 6961571: Update visitors to support ARM's ElementKind.RESOURCE_VARIABLE
darcy
parents: 7681
diff changeset
   300
     * @param e the element to visit
0f7e1f7a6a4b 6961571: Update visitors to support ARM's ElementKind.RESOURCE_VARIABLE
darcy
parents: 7681
diff changeset
   301
     * @param p a visitor-specified parameter
0f7e1f7a6a4b 6961571: Update visitors to support ARM's ElementKind.RESOURCE_VARIABLE
darcy
parents: 7681
diff changeset
   302
     * @return  the result of {@code visitUnknown}
0f7e1f7a6a4b 6961571: Update visitors to support ARM's ElementKind.RESOURCE_VARIABLE
darcy
parents: 7681
diff changeset
   303
     *
0f7e1f7a6a4b 6961571: Update visitors to support ARM's ElementKind.RESOURCE_VARIABLE
darcy
parents: 7681
diff changeset
   304
     * @since 1.7
0f7e1f7a6a4b 6961571: Update visitors to support ARM's ElementKind.RESOURCE_VARIABLE
darcy
parents: 7681
diff changeset
   305
     */
0f7e1f7a6a4b 6961571: Update visitors to support ARM's ElementKind.RESOURCE_VARIABLE
darcy
parents: 7681
diff changeset
   306
    public R visitVariableAsResourceVariable(VariableElement e, P p) {
0f7e1f7a6a4b 6961571: Update visitors to support ARM's ElementKind.RESOURCE_VARIABLE
darcy
parents: 7681
diff changeset
   307
        return visitUnknown(e, p);
0f7e1f7a6a4b 6961571: Update visitors to support ARM's ElementKind.RESOURCE_VARIABLE
darcy
parents: 7681
diff changeset
   308
    }
0f7e1f7a6a4b 6961571: Update visitors to support ARM's ElementKind.RESOURCE_VARIABLE
darcy
parents: 7681
diff changeset
   309
0f7e1f7a6a4b 6961571: Update visitors to support ARM's ElementKind.RESOURCE_VARIABLE
darcy
parents: 7681
diff changeset
   310
    /**
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   311
     * Visits an executable element, dispatching to the visit method
06bc494ca11e Initial load
duke
parents:
diff changeset
   312
     * for the specific {@linkplain ElementKind kind} of executable,
06bc494ca11e Initial load
duke
parents:
diff changeset
   313
     * {@code CONSTRUCTOR}, {@code INSTANCE_INIT}, {@code METHOD}, or
06bc494ca11e Initial load
duke
parents:
diff changeset
   314
     * {@code STATIC_INIT}.
06bc494ca11e Initial load
duke
parents:
diff changeset
   315
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   316
     * @param e {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   317
     * @param p {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   318
     * @return  the result of the kind-specific visit method
06bc494ca11e Initial load
duke
parents:
diff changeset
   319
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   320
    @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
   321
    public R visitExecutable(ExecutableElement e, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   322
        ElementKind k = e.getKind();
06bc494ca11e Initial load
duke
parents:
diff changeset
   323
        switch(k) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   324
        case CONSTRUCTOR:
06bc494ca11e Initial load
duke
parents:
diff changeset
   325
            return visitExecutableAsConstructor(e, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   326
06bc494ca11e Initial load
duke
parents:
diff changeset
   327
        case INSTANCE_INIT:
06bc494ca11e Initial load
duke
parents:
diff changeset
   328
            return visitExecutableAsInstanceInit(e, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   329
06bc494ca11e Initial load
duke
parents:
diff changeset
   330
        case METHOD:
06bc494ca11e Initial load
duke
parents:
diff changeset
   331
            return visitExecutableAsMethod(e, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   332
06bc494ca11e Initial load
duke
parents:
diff changeset
   333
        case STATIC_INIT:
06bc494ca11e Initial load
duke
parents:
diff changeset
   334
            return visitExecutableAsStaticInit(e, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   335
06bc494ca11e Initial load
duke
parents:
diff changeset
   336
        default:
06bc494ca11e Initial load
duke
parents:
diff changeset
   337
            throw new AssertionError("Bad kind " + k + " for ExecutableElement" + e);
06bc494ca11e Initial load
duke
parents:
diff changeset
   338
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   339
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   340
06bc494ca11e Initial load
duke
parents:
diff changeset
   341
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   342
     * Visits a {@code CONSTRUCTOR} executable element by calling
06bc494ca11e Initial load
duke
parents:
diff changeset
   343
     * {@code defaultAction}.
06bc494ca11e Initial load
duke
parents:
diff changeset
   344
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   345
     * @param e the element to visit
06bc494ca11e Initial load
duke
parents:
diff changeset
   346
     * @param p a visitor-specified parameter
06bc494ca11e Initial load
duke
parents:
diff changeset
   347
     * @return  the result of {@code defaultAction}
06bc494ca11e Initial load
duke
parents:
diff changeset
   348
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   349
    public R visitExecutableAsConstructor(ExecutableElement e, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   350
        return defaultAction(e, p);
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
     * Visits an {@code INSTANCE_INIT} executable element by calling
06bc494ca11e Initial load
duke
parents:
diff changeset
   355
     * {@code defaultAction}.
06bc494ca11e Initial load
duke
parents:
diff changeset
   356
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   357
     * @param e the element to visit
06bc494ca11e Initial load
duke
parents:
diff changeset
   358
     * @param p a visitor-specified parameter
06bc494ca11e Initial load
duke
parents:
diff changeset
   359
     * @return  the result of {@code defaultAction}
06bc494ca11e Initial load
duke
parents:
diff changeset
   360
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   361
    public R visitExecutableAsInstanceInit(ExecutableElement e, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   362
        return defaultAction(e, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   363
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   364
06bc494ca11e Initial load
duke
parents:
diff changeset
   365
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   366
     * Visits a {@code METHOD} executable element by calling
06bc494ca11e Initial load
duke
parents:
diff changeset
   367
     * {@code defaultAction}.
06bc494ca11e Initial load
duke
parents:
diff changeset
   368
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   369
     * @param e the element to visit
06bc494ca11e Initial load
duke
parents:
diff changeset
   370
     * @param p a visitor-specified parameter
06bc494ca11e Initial load
duke
parents:
diff changeset
   371
     * @return  the result of {@code defaultAction}
06bc494ca11e Initial load
duke
parents:
diff changeset
   372
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   373
    public R visitExecutableAsMethod(ExecutableElement e, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   374
        return defaultAction(e, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   375
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   376
06bc494ca11e Initial load
duke
parents:
diff changeset
   377
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   378
     * Visits a {@code STATIC_INIT} executable element by calling
06bc494ca11e Initial load
duke
parents:
diff changeset
   379
     * {@code defaultAction}.
06bc494ca11e Initial load
duke
parents:
diff changeset
   380
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   381
     * @param e the element to visit
06bc494ca11e Initial load
duke
parents:
diff changeset
   382
     * @param p a visitor-specified parameter
06bc494ca11e Initial load
duke
parents:
diff changeset
   383
     * @return  the result of {@code defaultAction}
06bc494ca11e Initial load
duke
parents:
diff changeset
   384
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   385
    public R visitExecutableAsStaticInit(ExecutableElement e, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   386
        return defaultAction(e, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   387
    }
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
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   392
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   393
     * The element argument has kind {@code TYPE_PARAMETER}.
06bc494ca11e Initial load
duke
parents:
diff changeset
   394
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   395
     * @param e {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   396
     * @param p {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   397
     * @return  {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   398
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   399
    @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
   400
    public R visitTypeParameter(TypeParameterElement e, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   401
        assert e.getKind() == TYPE_PARAMETER: "Bad kind on TypeParameterElement";
06bc494ca11e Initial load
duke
parents:
diff changeset
   402
        return defaultAction(e, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   403
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   404
}