Tue, 09 Oct 2012 19:10:00 -0700
8000663: clean up langtools imports
Reviewed-by: darcy
duke@1 | 1 | /* |
jjg@1357 | 2 | * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. |
duke@1 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@1 | 4 | * |
duke@1 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@1 | 6 | * under the terms of the GNU General Public License version 2 only, as |
ohair@554 | 7 | * published by the Free Software Foundation. Oracle designates this |
duke@1 | 8 | * particular file as subject to the "Classpath" exception as provided |
ohair@554 | 9 | * by Oracle in the LICENSE file that accompanied this code. |
duke@1 | 10 | * |
duke@1 | 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@1 | 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@1 | 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@1 | 14 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@1 | 15 | * accompanied this code). |
duke@1 | 16 | * |
duke@1 | 17 | * You should have received a copy of the GNU General Public License version |
duke@1 | 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@1 | 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@1 | 20 | * |
ohair@554 | 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ohair@554 | 22 | * or visit www.oracle.com if you need additional information or have any |
ohair@554 | 23 | * questions. |
duke@1 | 24 | */ |
duke@1 | 25 | |
duke@1 | 26 | package javax.lang.model.util; |
duke@1 | 27 | |
jjg@1357 | 28 | import javax.annotation.processing.SupportedSourceVersion; |
jjg@1357 | 29 | import javax.lang.model.SourceVersion; |
duke@1 | 30 | import javax.lang.model.element.*; |
duke@1 | 31 | import static javax.lang.model.SourceVersion.*; |
duke@1 | 32 | |
duke@1 | 33 | |
duke@1 | 34 | /** |
duke@1 | 35 | * A skeletal visitor of program elements with default behavior |
duke@1 | 36 | * appropriate for the {@link SourceVersion#RELEASE_6 RELEASE_6} |
duke@1 | 37 | * source version. |
duke@1 | 38 | * |
duke@1 | 39 | * <p> <b>WARNING:</b> The {@code ElementVisitor} interface |
duke@1 | 40 | * implemented by this class may have methods added to it in the |
duke@1 | 41 | * future to accommodate new, currently unknown, language structures |
duke@1 | 42 | * added to future versions of the Java™ programming language. |
duke@1 | 43 | * Therefore, methods whose names begin with {@code "visit"} may be |
duke@1 | 44 | * added to this class in the future; to avoid incompatibilities, |
duke@1 | 45 | * classes which extend this class should not declare any instance |
duke@1 | 46 | * methods with names beginning with {@code "visit"}. |
duke@1 | 47 | * |
duke@1 | 48 | * <p>When such a new visit method is added, the default |
duke@1 | 49 | * implementation in this class will be to call the {@link |
duke@1 | 50 | * #visitUnknown visitUnknown} method. A new abstract element visitor |
duke@1 | 51 | * class will also be introduced to correspond to the new language |
duke@1 | 52 | * level; this visitor will have different default behavior for the |
duke@1 | 53 | * visit method in question. When the new visitor is introduced, all |
duke@1 | 54 | * or portions of this visitor may be deprecated. |
duke@1 | 55 | * |
duke@1 | 56 | * @param <R> the return type of this visitor's methods. Use {@link |
duke@1 | 57 | * Void} for visitors that do not need to return results. |
duke@1 | 58 | * @param <P> the type of the additional parameter to this visitor's |
duke@1 | 59 | * methods. Use {@code Void} for visitors that do not need an |
duke@1 | 60 | * additional parameter. |
duke@1 | 61 | * |
duke@1 | 62 | * @author Joseph D. Darcy |
duke@1 | 63 | * @author Scott Seligman |
duke@1 | 64 | * @author Peter von der Ahé |
darcy@575 | 65 | * |
darcy@575 | 66 | * @see AbstractElementVisitor7 |
darcy@1054 | 67 | * @see AbstractElementVisitor8 |
duke@1 | 68 | * @since 1.6 |
duke@1 | 69 | */ |
duke@1 | 70 | @SupportedSourceVersion(RELEASE_6) |
duke@1 | 71 | public abstract class AbstractElementVisitor6<R, P> implements ElementVisitor<R, P> { |
duke@1 | 72 | /** |
duke@1 | 73 | * Constructor for concrete subclasses to call. |
duke@1 | 74 | */ |
duke@1 | 75 | protected AbstractElementVisitor6(){} |
duke@1 | 76 | |
duke@1 | 77 | /** |
duke@1 | 78 | * Visits any program element as if by passing itself to that |
duke@1 | 79 | * element's {@link Element#accept accept} method. The invocation |
duke@1 | 80 | * {@code v.visit(elem)} is equivalent to {@code elem.accept(v, |
duke@1 | 81 | * p)}. |
duke@1 | 82 | * |
duke@1 | 83 | * @param e the element to visit |
duke@1 | 84 | * @param p a visitor-specified parameter |
duke@1 | 85 | * @return a visitor-specified result |
duke@1 | 86 | */ |
duke@1 | 87 | public final R visit(Element e, P p) { |
duke@1 | 88 | return e.accept(this, p); |
duke@1 | 89 | } |
duke@1 | 90 | |
duke@1 | 91 | /** |
duke@1 | 92 | * Visits any program element as if by passing itself to that |
duke@1 | 93 | * element's {@link Element#accept accept} method and passing |
duke@1 | 94 | * {@code null} for the additional parameter. The invocation |
duke@1 | 95 | * {@code v.visit(elem)} is equivalent to {@code elem.accept(v, |
duke@1 | 96 | * null)}. |
duke@1 | 97 | * |
duke@1 | 98 | * @param e the element to visit |
duke@1 | 99 | * @return a visitor-specified result |
duke@1 | 100 | */ |
duke@1 | 101 | public final R visit(Element e) { |
duke@1 | 102 | return e.accept(this, null); |
duke@1 | 103 | } |
duke@1 | 104 | |
duke@1 | 105 | /** |
duke@1 | 106 | * {@inheritDoc} |
duke@1 | 107 | * |
duke@1 | 108 | * <p> The default implementation of this method in |
duke@1 | 109 | * {@code AbstractElementVisitor6} will always throw |
duke@1 | 110 | * {@code UnknownElementException}. |
duke@1 | 111 | * This behavior is not required of a subclass. |
duke@1 | 112 | * |
duke@1 | 113 | * @param e the element to visit |
duke@1 | 114 | * @param p a visitor-specified parameter |
duke@1 | 115 | * @return a visitor-specified result |
duke@1 | 116 | * @throws UnknownElementException |
duke@1 | 117 | * a visitor implementation may optionally throw this exception |
duke@1 | 118 | */ |
duke@1 | 119 | public R visitUnknown(Element e, P p) { |
duke@1 | 120 | throw new UnknownElementException(e, p); |
duke@1 | 121 | } |
duke@1 | 122 | } |