mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-20 19:14:38 +02:00
6933147: Provided new utility visitors supporting SourceVersion.RELEASE_7
Reviewed-by: jjg
This commit is contained in:
parent
2592bab72c
commit
fa91c4b435
32 changed files with 829 additions and 22 deletions
|
@ -745,7 +745,7 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
|
||||||
* Leave class public for external testing purposes.
|
* Leave class public for external testing purposes.
|
||||||
*/
|
*/
|
||||||
public static class ComputeAnnotationSet extends
|
public static class ComputeAnnotationSet extends
|
||||||
ElementScanner6<Set<TypeElement>, Set<TypeElement>> {
|
ElementScanner7<Set<TypeElement>, Set<TypeElement>> {
|
||||||
final Elements elements;
|
final Elements elements;
|
||||||
|
|
||||||
public ComputeAnnotationSet(Elements elements) {
|
public ComputeAnnotationSet(Elements elements) {
|
||||||
|
|
|
@ -125,7 +125,7 @@ public class JavacRoundEnvironment implements RoundEnvironment {
|
||||||
else
|
else
|
||||||
throw new AssertionError("Bad implementation type for " + tm);
|
throw new AssertionError("Bad implementation type for " + tm);
|
||||||
|
|
||||||
ElementScanner6<Set<Element>, DeclaredType> scanner =
|
ElementScanner7<Set<Element>, DeclaredType> scanner =
|
||||||
new AnnotationSetScanner(result, typeUtil);
|
new AnnotationSetScanner(result, typeUtil);
|
||||||
|
|
||||||
for (Element element : rootElements)
|
for (Element element : rootElements)
|
||||||
|
@ -136,7 +136,7 @@ public class JavacRoundEnvironment implements RoundEnvironment {
|
||||||
|
|
||||||
// Could be written as a local class inside getElementsAnnotatedWith
|
// Could be written as a local class inside getElementsAnnotatedWith
|
||||||
private class AnnotationSetScanner extends
|
private class AnnotationSetScanner extends
|
||||||
ElementScanner6<Set<Element>, DeclaredType> {
|
ElementScanner7<Set<Element>, DeclaredType> {
|
||||||
// Insertion-order preserving set
|
// Insertion-order preserving set
|
||||||
Set<Element> annotatedElements = new LinkedHashSet<Element>();
|
Set<Element> annotatedElements = new LinkedHashSet<Element>();
|
||||||
Types typeUtil;
|
Types typeUtil;
|
||||||
|
|
|
@ -83,7 +83,7 @@ public class PrintingProcessor extends AbstractProcessor {
|
||||||
* Used for the -Xprint option and called by Elements.printElements
|
* Used for the -Xprint option and called by Elements.printElements
|
||||||
*/
|
*/
|
||||||
public static class PrintingElementVisitor
|
public static class PrintingElementVisitor
|
||||||
extends SimpleElementVisitor6<PrintingElementVisitor, Boolean> {
|
extends SimpleElementVisitor7<PrintingElementVisitor, Boolean> {
|
||||||
int indentation; // Indentation level;
|
int indentation; // Indentation level;
|
||||||
final PrintWriter writer;
|
final PrintWriter writer;
|
||||||
final Elements elementUtils;
|
final Elements elementUtils;
|
||||||
|
@ -117,7 +117,7 @@ public class PrintingProcessor extends AbstractProcessor {
|
||||||
enclosing != null &&
|
enclosing != null &&
|
||||||
NestingKind.ANONYMOUS ==
|
NestingKind.ANONYMOUS ==
|
||||||
// Use an anonymous class to determine anonymity!
|
// Use an anonymous class to determine anonymity!
|
||||||
(new SimpleElementVisitor6<NestingKind, Void>() {
|
(new SimpleElementVisitor7<NestingKind, Void>() {
|
||||||
@Override
|
@Override
|
||||||
public NestingKind visitType(TypeElement e, Void p) {
|
public NestingKind visitType(TypeElement e, Void p) {
|
||||||
return e.getNestingKind();
|
return e.getNestingKind();
|
||||||
|
|
|
@ -59,7 +59,7 @@ import javax.lang.model.type.DeclaredType;
|
||||||
import javax.lang.model.type.TypeMirror;
|
import javax.lang.model.type.TypeMirror;
|
||||||
import javax.lang.model.type.TypeVisitor;
|
import javax.lang.model.type.TypeVisitor;
|
||||||
import javax.lang.model.util.ElementFilter;
|
import javax.lang.model.util.ElementFilter;
|
||||||
import javax.lang.model.util.SimpleTypeVisitor6;
|
import javax.lang.model.util.SimpleTypeVisitor7;
|
||||||
import javax.lang.model.util.Types;
|
import javax.lang.model.util.Types;
|
||||||
|
|
||||||
import javax.tools.Diagnostic;
|
import javax.tools.Diagnostic;
|
||||||
|
@ -705,7 +705,7 @@ public class JavahTask implements NativeHeaderTool.NativeHeaderTask {
|
||||||
}
|
}
|
||||||
|
|
||||||
private TypeVisitor<Void,Types> checkMethodParametersVisitor =
|
private TypeVisitor<Void,Types> checkMethodParametersVisitor =
|
||||||
new SimpleTypeVisitor6<Void,Types>() {
|
new SimpleTypeVisitor7<Void,Types>() {
|
||||||
@Override
|
@Override
|
||||||
public Void visitArray(ArrayType t, Types types) {
|
public Void visitArray(ArrayType t, Types types) {
|
||||||
visit(t.getComponentType(), types);
|
visit(t.getComponentType(), types);
|
||||||
|
|
|
@ -45,7 +45,7 @@ import javax.lang.model.type.TypeKind;
|
||||||
import javax.lang.model.type.TypeMirror;
|
import javax.lang.model.type.TypeMirror;
|
||||||
import javax.lang.model.type.TypeVisitor;
|
import javax.lang.model.type.TypeVisitor;
|
||||||
import javax.lang.model.util.ElementFilter;
|
import javax.lang.model.util.ElementFilter;
|
||||||
import javax.lang.model.util.SimpleTypeVisitor6;
|
import javax.lang.model.util.SimpleTypeVisitor7;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* <p><b>This is NOT part of any API supported by Sun Microsystems.
|
* <p><b>This is NOT part of any API supported by Sun Microsystems.
|
||||||
|
@ -620,7 +620,7 @@ public class LLNI extends Gen {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final boolean isLongOrDouble(TypeMirror t) {
|
protected final boolean isLongOrDouble(TypeMirror t) {
|
||||||
TypeVisitor<Boolean,Void> v = new SimpleTypeVisitor6<Boolean,Void>() {
|
TypeVisitor<Boolean,Void> v = new SimpleTypeVisitor7<Boolean,Void>() {
|
||||||
public Boolean defaultAction(TypeMirror t, Void p){
|
public Boolean defaultAction(TypeMirror t, Void p){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ import javax.lang.model.type.TypeMirror;
|
||||||
import javax.lang.model.type.TypeVariable;
|
import javax.lang.model.type.TypeVariable;
|
||||||
import javax.lang.model.type.TypeVisitor;
|
import javax.lang.model.type.TypeVisitor;
|
||||||
import javax.lang.model.util.Elements;
|
import javax.lang.model.util.Elements;
|
||||||
import javax.lang.model.util.SimpleTypeVisitor6;
|
import javax.lang.model.util.SimpleTypeVisitor7;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns internal type signature.
|
* Returns internal type signature.
|
||||||
|
@ -239,7 +239,7 @@ public class TypeSignature{
|
||||||
|
|
||||||
|
|
||||||
String qualifiedTypeName(TypeMirror type) {
|
String qualifiedTypeName(TypeMirror type) {
|
||||||
TypeVisitor<Name, Void> v = new SimpleTypeVisitor6<Name, Void>() {
|
TypeVisitor<Name, Void> v = new SimpleTypeVisitor7<Name, Void>() {
|
||||||
@Override
|
@Override
|
||||||
public Name visitArray(ArrayType t, Void p) {
|
public Name visitArray(ArrayType t, Void p) {
|
||||||
return t.getComponentType().accept(this, p);
|
return t.getComponentType().accept(this, p);
|
||||||
|
|
|
@ -62,6 +62,7 @@ import javax.lang.model.util.*;
|
||||||
* @author Scott Seligman
|
* @author Scott Seligman
|
||||||
* @author Peter von der Ahé
|
* @author Peter von der Ahé
|
||||||
* @see AbstractElementVisitor6
|
* @see AbstractElementVisitor6
|
||||||
|
* @see AbstractElementVisitor7
|
||||||
* @since 1.6
|
* @since 1.6
|
||||||
*/
|
*/
|
||||||
public interface ElementVisitor<R, P> {
|
public interface ElementVisitor<R, P> {
|
||||||
|
|
|
@ -62,6 +62,8 @@ import javax.annotation.processing.SupportedSourceVersion;
|
||||||
* @author Joseph D. Darcy
|
* @author Joseph D. Darcy
|
||||||
* @author Scott Seligman
|
* @author Scott Seligman
|
||||||
* @author Peter von der Ahé
|
* @author Peter von der Ahé
|
||||||
|
*
|
||||||
|
* @see AbstractAnnotationValueVisitor7
|
||||||
* @since 1.6
|
* @since 1.6
|
||||||
*/
|
*/
|
||||||
@SupportedSourceVersion(RELEASE_6)
|
@SupportedSourceVersion(RELEASE_6)
|
||||||
|
|
|
@ -0,0 +1,73 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation. Oracle designates this
|
||||||
|
* particular file as subject to the "Classpath" exception as provided
|
||||||
|
* by Oracle in the LICENSE file that accompanied this code.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package javax.lang.model.util;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import javax.lang.model.element.*;
|
||||||
|
|
||||||
|
import javax.lang.model.type.TypeMirror;
|
||||||
|
import static javax.lang.model.SourceVersion.*;
|
||||||
|
import javax.lang.model.SourceVersion;
|
||||||
|
import javax.annotation.processing.SupportedSourceVersion;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A skeletal visitor for annotation values with default behavior
|
||||||
|
* appropriate for the {@link SourceVersion#RELEASE_7 RELEASE_7}
|
||||||
|
* source version.
|
||||||
|
*
|
||||||
|
* <p> <b>WARNING:</b> The {@code AnnotationValueVisitor} interface
|
||||||
|
* implemented by this class may have methods added to it in the
|
||||||
|
* future to accommodate new, currently unknown, language structures
|
||||||
|
* added to future versions of the Java™ programming language.
|
||||||
|
* Therefore, methods whose names begin with {@code "visit"} may be
|
||||||
|
* added to this class in the future; to avoid incompatibilities,
|
||||||
|
* classes which extend this class should not declare any instance
|
||||||
|
* methods with names beginning with {@code "visit"}.
|
||||||
|
*
|
||||||
|
* <p>When such a new visit method is added, the default
|
||||||
|
* implementation in this class will be to call the {@link
|
||||||
|
* #visitUnknown visitUnknown} method. A new abstract annotation
|
||||||
|
* value visitor class will also be introduced to correspond to the
|
||||||
|
* new language level; this visitor will have different default
|
||||||
|
* behavior for the visit method in question. When the new visitor is
|
||||||
|
* introduced, all or portions of this visitor may be deprecated.
|
||||||
|
*
|
||||||
|
* @param <R> the return type of this visitor's methods
|
||||||
|
* @param <P> the type of the additional parameter to this visitor's methods.
|
||||||
|
*
|
||||||
|
* @see AbstractAnnotationValueVisitor6
|
||||||
|
* @since 1.7
|
||||||
|
*/
|
||||||
|
@SupportedSourceVersion(RELEASE_7)
|
||||||
|
public abstract class AbstractAnnotationValueVisitor7<R, P> extends AbstractAnnotationValueVisitor6<R, P> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for concrete subclasses to call.
|
||||||
|
*/
|
||||||
|
protected AbstractAnnotationValueVisitor7() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
}
|
|
@ -65,6 +65,8 @@ import javax.lang.model.SourceVersion;
|
||||||
* @author Joseph D. Darcy
|
* @author Joseph D. Darcy
|
||||||
* @author Scott Seligman
|
* @author Scott Seligman
|
||||||
* @author Peter von der Ahé
|
* @author Peter von der Ahé
|
||||||
|
*
|
||||||
|
* @see AbstractElementVisitor7
|
||||||
* @since 1.6
|
* @since 1.6
|
||||||
*/
|
*/
|
||||||
@SupportedSourceVersion(RELEASE_6)
|
@SupportedSourceVersion(RELEASE_6)
|
||||||
|
|
|
@ -0,0 +1,75 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation. Oracle designates this
|
||||||
|
* particular file as subject to the "Classpath" exception as provided
|
||||||
|
* by Oracle in the LICENSE file that accompanied this code.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package javax.lang.model.util;
|
||||||
|
|
||||||
|
import javax.lang.model.element.*;
|
||||||
|
import javax.annotation.processing.SupportedSourceVersion;
|
||||||
|
import javax.lang.model.element.*;
|
||||||
|
import static javax.lang.model.element.ElementKind.*;
|
||||||
|
import static javax.lang.model.SourceVersion.*;
|
||||||
|
import javax.lang.model.SourceVersion;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A skeletal visitor of program elements with default behavior
|
||||||
|
* appropriate for the {@link SourceVersion#RELEASE_7 RELEASE_7}
|
||||||
|
* source version.
|
||||||
|
*
|
||||||
|
* <p> <b>WARNING:</b> The {@code ElementVisitor} interface
|
||||||
|
* implemented by this class may have methods added to it in the
|
||||||
|
* future to accommodate new, currently unknown, language structures
|
||||||
|
* added to future versions of the Java™ programming language.
|
||||||
|
* Therefore, methods whose names begin with {@code "visit"} may be
|
||||||
|
* added to this class in the future; to avoid incompatibilities,
|
||||||
|
* classes which extend this class should not declare any instance
|
||||||
|
* methods with names beginning with {@code "visit"}.
|
||||||
|
*
|
||||||
|
* <p>When such a new visit method is added, the default
|
||||||
|
* implementation in this class will be to call the {@link
|
||||||
|
* #visitUnknown visitUnknown} method. A new abstract element visitor
|
||||||
|
* class will also be introduced to correspond to the new language
|
||||||
|
* level; this visitor will have different default behavior for the
|
||||||
|
* visit method in question. When the new visitor is introduced, all
|
||||||
|
* or portions of this visitor may be deprecated.
|
||||||
|
*
|
||||||
|
* @param <R> the return type of this visitor's methods. Use {@link
|
||||||
|
* Void} for visitors that do not need to return results.
|
||||||
|
* @param <P> the type of the additional parameter to this visitor's
|
||||||
|
* methods. Use {@code Void} for visitors that do not need an
|
||||||
|
* additional parameter.
|
||||||
|
*
|
||||||
|
* @see AbstractElementVisitor6
|
||||||
|
* @since 1.7
|
||||||
|
*/
|
||||||
|
@SupportedSourceVersion(RELEASE_7)
|
||||||
|
public abstract class AbstractElementVisitor7<R, P> extends AbstractElementVisitor6<R, P> {
|
||||||
|
/**
|
||||||
|
* Constructor for concrete subclasses to call.
|
||||||
|
*/
|
||||||
|
protected AbstractElementVisitor7(){
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
}
|
|
@ -57,6 +57,8 @@ import javax.lang.model.type.*;
|
||||||
* @author Joseph D. Darcy
|
* @author Joseph D. Darcy
|
||||||
* @author Scott Seligman
|
* @author Scott Seligman
|
||||||
* @author Peter von der Ahé
|
* @author Peter von der Ahé
|
||||||
|
*
|
||||||
|
* @see AbstractTypeVisitor7
|
||||||
* @since 1.6
|
* @since 1.6
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractTypeVisitor6<R, P> implements TypeVisitor<R, P> {
|
public abstract class AbstractTypeVisitor6<R, P> implements TypeVisitor<R, P> {
|
||||||
|
|
|
@ -0,0 +1,67 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation. Oracle designates this
|
||||||
|
* particular file as subject to the "Classpath" exception as provided
|
||||||
|
* by Oracle in the LICENSE file that accompanied this code.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package javax.lang.model.util;
|
||||||
|
|
||||||
|
import javax.lang.model.type.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A skeletal visitor of types with default behavior appropriate for
|
||||||
|
* the version 7 language level.
|
||||||
|
*
|
||||||
|
* <p> <b>WARNING:</b> The {@code TypeVisitor} interface implemented
|
||||||
|
* by this class may have methods added to it in the future to
|
||||||
|
* accommodate new, currently unknown, language structures added to
|
||||||
|
* future versions of the Java™ programming language.
|
||||||
|
* Therefore, methods whose names begin with {@code "visit"} may be
|
||||||
|
* added to this class in the future; to avoid incompatibilities,
|
||||||
|
* classes which extend this class should not declare any instance
|
||||||
|
* methods with names beginning with {@code "visit"}.
|
||||||
|
*
|
||||||
|
* <p>When such a new visit method is added, the default
|
||||||
|
* implementation in this class will be to call the {@link
|
||||||
|
* #visitUnknown visitUnknown} method. A new abstract type visitor
|
||||||
|
* class will also be introduced to correspond to the new language
|
||||||
|
* level; this visitor will have different default behavior for the
|
||||||
|
* visit method in question. When the new visitor is introduced, all
|
||||||
|
* or portions of this visitor may be deprecated.
|
||||||
|
*
|
||||||
|
* @param <R> the return type of this visitor's methods. Use {@link
|
||||||
|
* Void} for visitors that do not need to return results.
|
||||||
|
* @param <P> the type of the additional parameter to this visitor's
|
||||||
|
* methods. Use {@code Void} for visitors that do not need an
|
||||||
|
* additional parameter.
|
||||||
|
*
|
||||||
|
* @see AbstractTypeVisitor6
|
||||||
|
* @since 1.7
|
||||||
|
*/
|
||||||
|
public abstract class AbstractTypeVisitor7<R, P> extends AbstractTypeVisitor6<R, P> {
|
||||||
|
/**
|
||||||
|
* Constructor for concrete subclasses to call.
|
||||||
|
*/
|
||||||
|
protected AbstractTypeVisitor7() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
}
|
|
@ -76,6 +76,8 @@ import javax.lang.model.SourceVersion;
|
||||||
* @author Joseph D. Darcy
|
* @author Joseph D. Darcy
|
||||||
* @author Scott Seligman
|
* @author Scott Seligman
|
||||||
* @author Peter von der Ahé
|
* @author Peter von der Ahé
|
||||||
|
*
|
||||||
|
* @see ElementKindVisitor7
|
||||||
* @since 1.6
|
* @since 1.6
|
||||||
*/
|
*/
|
||||||
@SupportedSourceVersion(RELEASE_6)
|
@SupportedSourceVersion(RELEASE_6)
|
||||||
|
|
|
@ -0,0 +1,97 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation. Oracle designates this
|
||||||
|
* particular file as subject to the "Classpath" exception as provided
|
||||||
|
* by Oracle in the LICENSE file that accompanied this code.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package javax.lang.model.util;
|
||||||
|
|
||||||
|
import javax.lang.model.element.*;
|
||||||
|
import static javax.lang.model.element.ElementKind.*;
|
||||||
|
import javax.annotation.processing.SupportedSourceVersion;
|
||||||
|
import static javax.lang.model.SourceVersion.*;
|
||||||
|
import javax.lang.model.SourceVersion;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A visitor of program elements based on their {@linkplain
|
||||||
|
* ElementKind kind} with default behavior appropriate for the {@link
|
||||||
|
* SourceVersion#RELEASE_6 RELEASE_6} source version. For {@linkplain
|
||||||
|
* Element elements} <tt><i>XYZ</i></tt> that may have more than one
|
||||||
|
* kind, the <tt>visit<i>XYZ</i></tt> methods in this class delegate
|
||||||
|
* to the <tt>visit<i>XYZKind</i></tt> method corresponding to the
|
||||||
|
* first argument's kind. The <tt>visit<i>XYZKind</i></tt> methods
|
||||||
|
* call {@link #defaultAction defaultAction}, passing their arguments
|
||||||
|
* to {@code defaultAction}'s corresponding parameters.
|
||||||
|
*
|
||||||
|
* <p> Methods in this class may be overridden subject to their
|
||||||
|
* general contract. Note that annotating methods in concrete
|
||||||
|
* subclasses with {@link java.lang.Override @Override} will help
|
||||||
|
* ensure that methods are overridden as intended.
|
||||||
|
*
|
||||||
|
* <p> <b>WARNING:</b> The {@code ElementVisitor} interface
|
||||||
|
* implemented by this class may have methods added to it or the
|
||||||
|
* {@code ElementKind} {@code enum} used in this case may have
|
||||||
|
* constants added to it in the future to accommodate new, currently
|
||||||
|
* unknown, language structures added to future versions of the
|
||||||
|
* Java™ programming language. Therefore, methods whose names
|
||||||
|
* begin with {@code "visit"} may be added to this class in the
|
||||||
|
* future; to avoid incompatibilities, classes which extend this class
|
||||||
|
* should not declare any instance methods with names beginning with
|
||||||
|
* {@code "visit"}.
|
||||||
|
*
|
||||||
|
* <p>When such a new visit method is added, the default
|
||||||
|
* implementation in this class will be to call the {@link
|
||||||
|
* #visitUnknown visitUnknown} method. A new abstract element kind
|
||||||
|
* visitor class will also be introduced to correspond to the new
|
||||||
|
* language level; this visitor will have different default behavior
|
||||||
|
* for the visit method in question. When the new visitor is
|
||||||
|
* introduced, all or portions of this visitor may be deprecated.
|
||||||
|
*
|
||||||
|
* @param <R> the return type of this visitor's methods. Use {@link
|
||||||
|
* Void} for visitors that do not need to return results.
|
||||||
|
* @param <P> the type of the additional parameter to this visitor's
|
||||||
|
* methods. Use {@code Void} for visitors that do not need an
|
||||||
|
* additional parameter.
|
||||||
|
*
|
||||||
|
* @see ElementKindVisitor6
|
||||||
|
* @since 1.7
|
||||||
|
*/
|
||||||
|
@SupportedSourceVersion(RELEASE_7)
|
||||||
|
public class ElementKindVisitor7<R, P> extends ElementKindVisitor6<R, P> {
|
||||||
|
/**
|
||||||
|
* Constructor for concrete subclasses; uses {@code null} for the
|
||||||
|
* default value.
|
||||||
|
*/
|
||||||
|
protected ElementKindVisitor7() {
|
||||||
|
super(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for concrete subclasses; uses the argument for the
|
||||||
|
* default value.
|
||||||
|
*
|
||||||
|
* @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
|
||||||
|
*/
|
||||||
|
protected ElementKindVisitor7(R defaultValue) {
|
||||||
|
super(defaultValue);
|
||||||
|
}
|
||||||
|
}
|
|
@ -88,6 +88,8 @@ import static javax.lang.model.SourceVersion.*;
|
||||||
* @author Joseph D. Darcy
|
* @author Joseph D. Darcy
|
||||||
* @author Scott Seligman
|
* @author Scott Seligman
|
||||||
* @author Peter von der Ahé
|
* @author Peter von der Ahé
|
||||||
|
*
|
||||||
|
* @see ElementScanner7
|
||||||
* @since 1.6
|
* @since 1.6
|
||||||
*/
|
*/
|
||||||
@SupportedSourceVersion(RELEASE_6)
|
@SupportedSourceVersion(RELEASE_6)
|
||||||
|
|
|
@ -0,0 +1,108 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation. Oracle designates this
|
||||||
|
* particular file as subject to the "Classpath" exception as provided
|
||||||
|
* by Oracle in the LICENSE file that accompanied this code.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package javax.lang.model.util;
|
||||||
|
|
||||||
|
import javax.lang.model.element.*;
|
||||||
|
import javax.annotation.processing.SupportedSourceVersion;
|
||||||
|
import static javax.lang.model.element.ElementKind.*;
|
||||||
|
import javax.lang.model.SourceVersion;
|
||||||
|
import static javax.lang.model.SourceVersion.*;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A scanning visitor of program elements with default behavior
|
||||||
|
* appropriate for the {@link SourceVersion#RELEASE_7 RELEASE_7}
|
||||||
|
* source version. The <tt>visit<i>XYZ</i></tt> methods in this
|
||||||
|
* class scan their component elements by calling {@code scan} on
|
||||||
|
* their {@linkplain Element#getEnclosedElements enclosed elements},
|
||||||
|
* {@linkplain ExecutableElement#getParameters parameters}, etc., as
|
||||||
|
* indicated in the individual method specifications. A subclass can
|
||||||
|
* control the order elements are visited by overriding the
|
||||||
|
* <tt>visit<i>XYZ</i></tt> methods. Note that clients of a scanner
|
||||||
|
* may get the desired behavior be invoking {@code v.scan(e, p)} rather
|
||||||
|
* than {@code v.visit(e, p)} on the root objects of interest.
|
||||||
|
*
|
||||||
|
* <p>When a subclass overrides a <tt>visit<i>XYZ</i></tt> method, the
|
||||||
|
* new method can cause the enclosed elements to be scanned in the
|
||||||
|
* default way by calling <tt>super.visit<i>XYZ</i></tt>. In this
|
||||||
|
* fashion, the concrete visitor can control the ordering of traversal
|
||||||
|
* over the component elements with respect to the additional
|
||||||
|
* processing; for example, consistently calling
|
||||||
|
* <tt>super.visit<i>XYZ</i></tt> at the start of the overridden
|
||||||
|
* methods will yield a preorder traversal, etc. If the component
|
||||||
|
* elements should be traversed in some other order, instead of
|
||||||
|
* calling <tt>super.visit<i>XYZ</i></tt>, an overriding visit method
|
||||||
|
* should call {@code scan} with the elements in the desired order.
|
||||||
|
*
|
||||||
|
* <p> Methods in this class may be overridden subject to their
|
||||||
|
* general contract. Note that annotating methods in concrete
|
||||||
|
* subclasses with {@link java.lang.Override @Override} will help
|
||||||
|
* ensure that methods are overridden as intended.
|
||||||
|
*
|
||||||
|
* <p> <b>WARNING:</b> The {@code ElementVisitor} interface
|
||||||
|
* implemented by this class may have methods added to it in the
|
||||||
|
* future to accommodate new, currently unknown, language structures
|
||||||
|
* added to future versions of the Java™ programming language.
|
||||||
|
* Therefore, methods whose names begin with {@code "visit"} may be
|
||||||
|
* added to this class in the future; to avoid incompatibilities,
|
||||||
|
* classes which extend this class should not declare any instance
|
||||||
|
* methods with names beginning with {@code "visit"}.
|
||||||
|
*
|
||||||
|
* <p>When such a new visit method is added, the default
|
||||||
|
* implementation in this class will be to call the {@link
|
||||||
|
* #visitUnknown visitUnknown} method. A new element scanner visitor
|
||||||
|
* class will also be introduced to correspond to the new language
|
||||||
|
* level; this visitor will have different default behavior for the
|
||||||
|
* visit method in question. When the new visitor is introduced, all
|
||||||
|
* or portions of this visitor may be deprecated.
|
||||||
|
*
|
||||||
|
* @param <R> the return type of this visitor's methods. Use {@link
|
||||||
|
* Void} for visitors that do not need to return results.
|
||||||
|
* @param <P> the type of the additional parameter to this visitor's
|
||||||
|
* methods. Use {@code Void} for visitors that do not need an
|
||||||
|
* additional parameter.
|
||||||
|
*
|
||||||
|
* @see ElementScanner6
|
||||||
|
* @since 1.7
|
||||||
|
*/
|
||||||
|
@SupportedSourceVersion(RELEASE_7)
|
||||||
|
public class ElementScanner7<R, P> extends ElementScanner6<R, P> {
|
||||||
|
/**
|
||||||
|
* Constructor for concrete subclasses; uses {@code null} for the
|
||||||
|
* default value.
|
||||||
|
*/
|
||||||
|
protected ElementScanner7(){
|
||||||
|
super(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for concrete subclasses; uses the argument for the
|
||||||
|
* default value.
|
||||||
|
*/
|
||||||
|
protected ElementScanner7(R defaultValue){
|
||||||
|
super(defaultValue);
|
||||||
|
}
|
||||||
|
}
|
|
@ -69,6 +69,8 @@ import javax.annotation.processing.SupportedSourceVersion;
|
||||||
* @author Joseph D. Darcy
|
* @author Joseph D. Darcy
|
||||||
* @author Scott Seligman
|
* @author Scott Seligman
|
||||||
* @author Peter von der Ahé
|
* @author Peter von der Ahé
|
||||||
|
*
|
||||||
|
* @see SimpleAnnotationValueVisitor7
|
||||||
* @since 1.6
|
* @since 1.6
|
||||||
*/
|
*/
|
||||||
@SupportedSourceVersion(RELEASE_6)
|
@SupportedSourceVersion(RELEASE_6)
|
||||||
|
|
|
@ -0,0 +1,90 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation. Oracle designates this
|
||||||
|
* particular file as subject to the "Classpath" exception as provided
|
||||||
|
* by Oracle in the LICENSE file that accompanied this code.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package javax.lang.model.util;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import javax.lang.model.element.*;
|
||||||
|
|
||||||
|
import javax.lang.model.type.TypeMirror;
|
||||||
|
import static javax.lang.model.SourceVersion.*;
|
||||||
|
import javax.lang.model.SourceVersion;
|
||||||
|
import javax.annotation.processing.SupportedSourceVersion;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A simple visitor for annotation values with default behavior
|
||||||
|
* appropriate for the {@link SourceVersion#RELEASE_7 RELEASE_7}
|
||||||
|
* source version. Visit methods call {@link
|
||||||
|
* #defaultAction} passing their arguments to {@code defaultAction}'s
|
||||||
|
* corresponding parameters.
|
||||||
|
*
|
||||||
|
* <p> Methods in this class may be overridden subject to their
|
||||||
|
* general contract. Note that annotating methods in concrete
|
||||||
|
* subclasses with {@link java.lang.Override @Override} will help
|
||||||
|
* ensure that methods are overridden as intended.
|
||||||
|
*
|
||||||
|
* <p> <b>WARNING:</b> The {@code AnnotationValueVisitor} interface
|
||||||
|
* implemented by this class may have methods added to it in the
|
||||||
|
* future to accommodate new, currently unknown, language structures
|
||||||
|
* added to future versions of the Java™ programming language.
|
||||||
|
* Therefore, methods whose names begin with {@code "visit"} may be
|
||||||
|
* added to this class in the future; to avoid incompatibilities,
|
||||||
|
* classes which extend this class should not declare any instance
|
||||||
|
* methods with names beginning with {@code "visit"}.
|
||||||
|
*
|
||||||
|
* <p>When such a new visit method is added, the default
|
||||||
|
* implementation in this class will be to call the {@link
|
||||||
|
* #visitUnknown visitUnknown} method. A new simple annotation
|
||||||
|
* value visitor class will also be introduced to correspond to the
|
||||||
|
* new language level; this visitor will have different default
|
||||||
|
* behavior for the visit method in question. When the new visitor is
|
||||||
|
* introduced, all or portions of this visitor may be deprecated.
|
||||||
|
*
|
||||||
|
* @param <R> the return type of this visitor's methods
|
||||||
|
* @param <P> the type of the additional parameter to this visitor's methods.
|
||||||
|
*
|
||||||
|
* @see SimpleAnnotationValueVisitor6
|
||||||
|
* @since 1.7
|
||||||
|
*/
|
||||||
|
@SupportedSourceVersion(RELEASE_7)
|
||||||
|
public class SimpleAnnotationValueVisitor7<R, P> extends SimpleAnnotationValueVisitor6<R, P> {
|
||||||
|
/**
|
||||||
|
* Constructor for concrete subclasses; uses {@code null} for the
|
||||||
|
* default value.
|
||||||
|
*/
|
||||||
|
protected SimpleAnnotationValueVisitor7() {
|
||||||
|
super(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for concrete subclasses; uses the argument for the
|
||||||
|
* default value.
|
||||||
|
*
|
||||||
|
* @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
|
||||||
|
*/
|
||||||
|
protected SimpleAnnotationValueVisitor7(R defaultValue) {
|
||||||
|
super(defaultValue);
|
||||||
|
}
|
||||||
|
}
|
|
@ -71,6 +71,8 @@ import static javax.lang.model.SourceVersion.*;
|
||||||
* @author Joseph D. Darcy
|
* @author Joseph D. Darcy
|
||||||
* @author Scott Seligman
|
* @author Scott Seligman
|
||||||
* @author Peter von der Ahé
|
* @author Peter von der Ahé
|
||||||
|
*
|
||||||
|
* @see SimpleElementVisitor7
|
||||||
* @since 1.6
|
* @since 1.6
|
||||||
*/
|
*/
|
||||||
@SupportedSourceVersion(RELEASE_6)
|
@SupportedSourceVersion(RELEASE_6)
|
||||||
|
|
|
@ -0,0 +1,92 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation. Oracle designates this
|
||||||
|
* particular file as subject to the "Classpath" exception as provided
|
||||||
|
* by Oracle in the LICENSE file that accompanied this code.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package javax.lang.model.util;
|
||||||
|
|
||||||
|
import javax.lang.model.element.*;
|
||||||
|
import javax.annotation.processing.SupportedSourceVersion;
|
||||||
|
import static javax.lang.model.element.ElementKind.*;
|
||||||
|
import javax.lang.model.SourceVersion;
|
||||||
|
import static javax.lang.model.SourceVersion.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A simple visitor of program elements with default behavior
|
||||||
|
* appropriate for the {@link SourceVersion#RELEASE_7 RELEASE_7}
|
||||||
|
* source version.
|
||||||
|
*
|
||||||
|
* Visit methods corresponding to {@code RELEASE_7} language
|
||||||
|
* constructs call {@link #defaultAction}, passing their arguments to
|
||||||
|
* {@code defaultAction}'s corresponding parameters.
|
||||||
|
*
|
||||||
|
* <p> Methods in this class may be overridden subject to their
|
||||||
|
* general contract. Note that annotating methods in concrete
|
||||||
|
* subclasses with {@link java.lang.Override @Override} will help
|
||||||
|
* ensure that methods are overridden as intended.
|
||||||
|
*
|
||||||
|
* <p> <b>WARNING:</b> The {@code ElementVisitor} interface
|
||||||
|
* implemented by this class may have methods added to it in the
|
||||||
|
* future to accommodate new, currently unknown, language structures
|
||||||
|
* added to future versions of the Java™ programming language.
|
||||||
|
* Therefore, methods whose names begin with {@code "visit"} may be
|
||||||
|
* added to this class in the future; to avoid incompatibilities,
|
||||||
|
* classes which extend this class should not declare any instance
|
||||||
|
* methods with names beginning with {@code "visit"}.
|
||||||
|
*
|
||||||
|
* <p>When such a new visit method is added, the default
|
||||||
|
* implementation in this class will be to call the {@link
|
||||||
|
* #visitUnknown visitUnknown} method. A new simple element visitor
|
||||||
|
* class will also be introduced to correspond to the new language
|
||||||
|
* level; this visitor will have different default behavior for the
|
||||||
|
* visit method in question. When the new visitor is introduced, all
|
||||||
|
* or portions of this visitor may be deprecated.
|
||||||
|
*
|
||||||
|
* @param <R> the return type of this visitor's methods. Use {@code Void}
|
||||||
|
* for visitors that do not need to return results.
|
||||||
|
* @param <P> the type of the additional parameter to this visitor's methods. Use {@code Void}
|
||||||
|
* for visitors that do not need an additional parameter.
|
||||||
|
*
|
||||||
|
* @see SimpleElementVisitor6
|
||||||
|
* @since 1.7
|
||||||
|
*/
|
||||||
|
@SupportedSourceVersion(RELEASE_7)
|
||||||
|
public class SimpleElementVisitor7<R, P> extends SimpleElementVisitor6<R, P> {
|
||||||
|
/**
|
||||||
|
* Constructor for concrete subclasses; uses {@code null} for the
|
||||||
|
* default value.
|
||||||
|
*/
|
||||||
|
protected SimpleElementVisitor7(){
|
||||||
|
super(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for concrete subclasses; uses the argument for the
|
||||||
|
* default value.
|
||||||
|
*
|
||||||
|
* @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
|
||||||
|
*/
|
||||||
|
protected SimpleElementVisitor7(R defaultValue){
|
||||||
|
super(defaultValue);
|
||||||
|
}
|
||||||
|
}
|
|
@ -70,6 +70,8 @@ import static javax.lang.model.SourceVersion.*;
|
||||||
* @author Joseph D. Darcy
|
* @author Joseph D. Darcy
|
||||||
* @author Scott Seligman
|
* @author Scott Seligman
|
||||||
* @author Peter von der Ahé
|
* @author Peter von der Ahé
|
||||||
|
*
|
||||||
|
* @see SimpleTypeVisitor7
|
||||||
* @since 1.6
|
* @since 1.6
|
||||||
*/
|
*/
|
||||||
@SupportedSourceVersion(RELEASE_6)
|
@SupportedSourceVersion(RELEASE_6)
|
||||||
|
|
|
@ -0,0 +1,91 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation. Oracle designates this
|
||||||
|
* particular file as subject to the "Classpath" exception as provided
|
||||||
|
* by Oracle in the LICENSE file that accompanied this code.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package javax.lang.model.util;
|
||||||
|
|
||||||
|
import javax.lang.model.type.*;
|
||||||
|
import javax.annotation.processing.SupportedSourceVersion;
|
||||||
|
import javax.lang.model.SourceVersion;
|
||||||
|
import static javax.lang.model.SourceVersion.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A simple visitor of types with default behavior appropriate for the
|
||||||
|
* {@link SourceVersion#RELEASE_7 RELEASE_7} source version.
|
||||||
|
*
|
||||||
|
* Visit methods corresponding to {@code RELEASE_7} language
|
||||||
|
* constructs call {@link #defaultAction}, passing their arguments to
|
||||||
|
* {@code defaultAction}'s corresponding parameters.
|
||||||
|
*
|
||||||
|
* <p> Methods in this class may be overridden subject to their
|
||||||
|
* general contract. Note that annotating methods in concrete
|
||||||
|
* subclasses with {@link java.lang.Override @Override} will help
|
||||||
|
* ensure that methods are overridden as intended.
|
||||||
|
*
|
||||||
|
* <p> <b>WARNING:</b> The {@code TypeVisitor} interface implemented
|
||||||
|
* by this class may have methods added to it in the future to
|
||||||
|
* accommodate new, currently unknown, language structures added to
|
||||||
|
* future versions of the Java™ programming language.
|
||||||
|
* Therefore, methods whose names begin with {@code "visit"} may be
|
||||||
|
* added to this class in the future; to avoid incompatibilities,
|
||||||
|
* classes which extend this class should not declare any instance
|
||||||
|
* methods with names beginning with {@code "visit"}.
|
||||||
|
*
|
||||||
|
* <p>When such a new visit method is added, the default
|
||||||
|
* implementation in this class will be to call the {@link
|
||||||
|
* #visitUnknown visitUnknown} method. A new simple type visitor
|
||||||
|
* class will also be introduced to correspond to the new language
|
||||||
|
* level; this visitor will have different default behavior for the
|
||||||
|
* visit method in question. When the new visitor is introduced, all
|
||||||
|
* or portions of this visitor may be deprecated.
|
||||||
|
*
|
||||||
|
* @param <R> the return type of this visitor's methods. Use {@link
|
||||||
|
* Void} for visitors that do not need to return results.
|
||||||
|
* @param <P> the type of the additional parameter to this visitor's
|
||||||
|
* methods. Use {@code Void} for visitors that do not need an
|
||||||
|
* additional parameter.
|
||||||
|
*
|
||||||
|
* @see SimpleTypeVisitor6
|
||||||
|
* @since 1.7
|
||||||
|
*/
|
||||||
|
@SupportedSourceVersion(RELEASE_7)
|
||||||
|
public class SimpleTypeVisitor7<R, P> extends SimpleTypeVisitor6<R, P> {
|
||||||
|
/**
|
||||||
|
* Constructor for concrete subclasses; uses {@code null} for the
|
||||||
|
* default value.
|
||||||
|
*/
|
||||||
|
protected SimpleTypeVisitor7(){
|
||||||
|
super(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for concrete subclasses; uses the argument for the
|
||||||
|
* default value.
|
||||||
|
*
|
||||||
|
* @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
|
||||||
|
*/
|
||||||
|
protected SimpleTypeVisitor7(R defaultValue){
|
||||||
|
super(defaultValue);
|
||||||
|
}
|
||||||
|
}
|
|
@ -74,6 +74,8 @@ import javax.lang.model.SourceVersion;
|
||||||
* @author Joseph D. Darcy
|
* @author Joseph D. Darcy
|
||||||
* @author Scott Seligman
|
* @author Scott Seligman
|
||||||
* @author Peter von der Ahé
|
* @author Peter von der Ahé
|
||||||
|
*
|
||||||
|
* @see TypeKindVisitor7
|
||||||
* @since 1.6
|
* @since 1.6
|
||||||
*/
|
*/
|
||||||
@SupportedSourceVersion(RELEASE_6)
|
@SupportedSourceVersion(RELEASE_6)
|
||||||
|
|
|
@ -0,0 +1,95 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation. Oracle designates this
|
||||||
|
* particular file as subject to the "Classpath" exception as provided
|
||||||
|
* by Oracle in the LICENSE file that accompanied this code.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package javax.lang.model.util;
|
||||||
|
|
||||||
|
import javax.lang.model.type.*;
|
||||||
|
import javax.annotation.processing.SupportedSourceVersion;
|
||||||
|
import static javax.lang.model.element.ElementKind.*;
|
||||||
|
import static javax.lang.model.SourceVersion.*;
|
||||||
|
import javax.lang.model.SourceVersion;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A visitor of types based on their {@linkplain TypeKind kind} with
|
||||||
|
* default behavior appropriate for the {@link SourceVersion#RELEASE_7
|
||||||
|
* RELEASE_7} source version. For {@linkplain
|
||||||
|
* TypeMirror types} <tt><i>XYZ</i></tt> that may have more than one
|
||||||
|
* kind, the <tt>visit<i>XYZ</i></tt> methods in this class delegate
|
||||||
|
* to the <tt>visit<i>XYZKind</i></tt> method corresponding to the
|
||||||
|
* first argument's kind. The <tt>visit<i>XYZKind</i></tt> methods
|
||||||
|
* call {@link #defaultAction defaultAction}, passing their arguments
|
||||||
|
* to {@code defaultAction}'s corresponding parameters.
|
||||||
|
*
|
||||||
|
* <p> Methods in this class may be overridden subject to their
|
||||||
|
* general contract. Note that annotating methods in concrete
|
||||||
|
* subclasses with {@link java.lang.Override @Override} will help
|
||||||
|
* ensure that methods are overridden as intended.
|
||||||
|
*
|
||||||
|
* <p> <b>WARNING:</b> The {@code TypeVisitor} interface implemented
|
||||||
|
* by this class may have methods added to it in the future to
|
||||||
|
* accommodate new, currently unknown, language structures added to
|
||||||
|
* future versions of the Java™ programming language.
|
||||||
|
* Therefore, methods whose names begin with {@code "visit"} may be
|
||||||
|
* added to this class in the future; to avoid incompatibilities,
|
||||||
|
* classes which extend this class should not declare any instance
|
||||||
|
* methods with names beginning with {@code "visit"}.
|
||||||
|
*
|
||||||
|
* <p>When such a new visit method is added, the default
|
||||||
|
* implementation in this class will be to call the {@link
|
||||||
|
* #visitUnknown visitUnknown} method. A new type kind visitor class
|
||||||
|
* will also be introduced to correspond to the new language level;
|
||||||
|
* this visitor will have different default behavior for the visit
|
||||||
|
* method in question. When the new visitor is introduced, all or
|
||||||
|
* portions of this visitor may be deprecated.
|
||||||
|
*
|
||||||
|
* @param <R> the return type of this visitor's methods. Use {@link
|
||||||
|
* Void} for visitors that do not need to return results.
|
||||||
|
* @param <P> the type of the additional parameter to this visitor's
|
||||||
|
* methods. Use {@code Void} for visitors that do not need an
|
||||||
|
* additional parameter.
|
||||||
|
*
|
||||||
|
* @see TypeKindVisitor6
|
||||||
|
* @since 1.7
|
||||||
|
*/
|
||||||
|
@SupportedSourceVersion(RELEASE_7)
|
||||||
|
public class TypeKindVisitor7<R, P> extends TypeKindVisitor6<R, P> {
|
||||||
|
/**
|
||||||
|
* Constructor for concrete subclasses to call; uses {@code null}
|
||||||
|
* for the default value.
|
||||||
|
*/
|
||||||
|
protected TypeKindVisitor7() {
|
||||||
|
super(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for concrete subclasses to call; uses the argument
|
||||||
|
* for the default value.
|
||||||
|
*
|
||||||
|
* @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
|
||||||
|
*/
|
||||||
|
protected TypeKindVisitor7(R defaultValue) {
|
||||||
|
super(defaultValue);
|
||||||
|
}
|
||||||
|
}
|
|
@ -138,7 +138,7 @@ public class CheckNamesProcessor extends AbstractProcessor {
|
||||||
public SourceVersion getSupportedSourceVersion() {
|
public SourceVersion getSupportedSourceVersion() {
|
||||||
/*
|
/*
|
||||||
* Return latest source version instead of a fixed version
|
* Return latest source version instead of a fixed version
|
||||||
* like RELEASE_6. To return a fixed version, this class
|
* like RELEASE_7. To return a fixed version, this class
|
||||||
* could be annotated with a SupportedSourceVersion
|
* could be annotated with a SupportedSourceVersion
|
||||||
* annotation.
|
* annotation.
|
||||||
*
|
*
|
||||||
|
@ -190,7 +190,7 @@ public class CheckNamesProcessor extends AbstractProcessor {
|
||||||
/**
|
/**
|
||||||
* Visitor to implement name checks.
|
* Visitor to implement name checks.
|
||||||
*/
|
*/
|
||||||
private class NameCheckScanner extends ElementScanner6<Void, Void> {
|
private class NameCheckScanner extends ElementScanner7<Void, Void> {
|
||||||
// The visitor could be enhanced to return true/false if
|
// The visitor could be enhanced to return true/false if
|
||||||
// there were warnings reported or a count of the number
|
// there were warnings reported or a count of the number
|
||||||
// of warnings. This could be facilitated by using
|
// of warnings. This could be facilitated by using
|
||||||
|
@ -312,7 +312,7 @@ public class CheckNamesProcessor extends AbstractProcessor {
|
||||||
@Override
|
@Override
|
||||||
public Void visitUnknown(Element e, Void p) {
|
public Void visitUnknown(Element e, Void p) {
|
||||||
// This method will be called if a kind of element
|
// This method will be called if a kind of element
|
||||||
// added after JDK 6 is visited. Since as of this
|
// added after JDK 7 is visited. Since as of this
|
||||||
// writing the conventions for such constructs aren't
|
// writing the conventions for such constructs aren't
|
||||||
// known, issue a warning.
|
// known, issue a warning.
|
||||||
messager.printMessage(WARNING,
|
messager.printMessage(WARNING,
|
||||||
|
|
|
@ -95,7 +95,7 @@ public class CheckLocalElements extends Checker {
|
||||||
return encl == null ? "" : encl.accept(qualNameVisitor, null);
|
return encl == null ? "" : encl.accept(qualNameVisitor, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ElementVisitor<String,Void> qualNameVisitor = new SimpleElementVisitor6<String,Void>() {
|
private ElementVisitor<String,Void> qualNameVisitor = new SimpleElementVisitor7<String,Void>() {
|
||||||
protected String defaultAction(Element e, Void ignore) {
|
protected String defaultAction(Element e, Void ignore) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
|
@ -299,7 +299,7 @@ public class TestOperators extends AbstractProcessor {
|
||||||
final Trees trees = Trees.instance(processingEnv);
|
final Trees trees = Trees.instance(processingEnv);
|
||||||
final Messager log = processingEnv.getMessager();
|
final Messager log = processingEnv.getMessager();
|
||||||
final Elements elements = processingEnv.getElementUtils();
|
final Elements elements = processingEnv.getElementUtils();
|
||||||
class Scan extends ElementScanner6<Void,Void> {
|
class Scan extends ElementScanner7<Void,Void> {
|
||||||
@Override
|
@Override
|
||||||
public Void visitExecutable(ExecutableElement e, Void p) {
|
public Void visitExecutable(ExecutableElement e, Void p) {
|
||||||
Object debug = e; // info for exception handler
|
Object debug = e; // info for exception handler
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class T6424358 extends AbstractProcessor {
|
||||||
final Messager log = processingEnv.getMessager();
|
final Messager log = processingEnv.getMessager();
|
||||||
final Elements elements = processingEnv.getElementUtils();
|
final Elements elements = processingEnv.getElementUtils();
|
||||||
final TypeElement testMe = elements.getTypeElement("TestMe");
|
final TypeElement testMe = elements.getTypeElement("TestMe");
|
||||||
class Scan extends ElementScanner6<Void,Void> {
|
class Scan extends ElementScanner7<Void,Void> {
|
||||||
@Override
|
@Override
|
||||||
public Void visitExecutable(ExecutableElement e, Void p) {
|
public Void visitExecutable(ExecutableElement e, Void p) {
|
||||||
System.err.println("Looking at " + e);
|
System.err.println("Looking at " + e);
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class T6194785 extends AbstractProcessor {
|
||||||
{
|
{
|
||||||
final Messager log = processingEnv.getMessager();
|
final Messager log = processingEnv.getMessager();
|
||||||
final Elements elements = processingEnv.getElementUtils();
|
final Elements elements = processingEnv.getElementUtils();
|
||||||
class Scan extends ElementScanner6<Void,Void> {
|
class Scan extends ElementScanner7<Void,Void> {
|
||||||
@Override
|
@Override
|
||||||
public Void visitExecutable(ExecutableElement e, Void ignored) {
|
public Void visitExecutable(ExecutableElement e, Void ignored) {
|
||||||
for (VariableElement p : e.getParameters())
|
for (VariableElement p : e.getParameters())
|
||||||
|
|
|
@ -89,7 +89,7 @@ public class NoTypes extends AbstractProcessor {
|
||||||
verifyKind(NONE, types.getNoType(NONE));
|
verifyKind(NONE, types.getNoType(NONE));
|
||||||
|
|
||||||
// The return type of a constructor or void method is VOID.
|
// The return type of a constructor or void method is VOID.
|
||||||
class Scanner extends ElementScanner6<Void, Void> {
|
class Scanner extends ElementScanner7<Void, Void> {
|
||||||
@Override
|
@Override
|
||||||
public Void visitExecutable(ExecutableElement e, Void p) {
|
public Void visitExecutable(ExecutableElement e, Void p) {
|
||||||
verifyKind(VOID, e.getReturnType());
|
verifyKind(VOID, e.getReturnType());
|
||||||
|
@ -104,10 +104,10 @@ public class NoTypes extends AbstractProcessor {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verify that a NoType instance is of a particular kind,
|
* Verify that a NoType instance is of a particular kind,
|
||||||
* and that TypeKindVisitor6 properly dispatches on it.
|
* and that TypeKindVisitor7 properly dispatches on it.
|
||||||
*/
|
*/
|
||||||
private void verifyKind(TypeKind kind, TypeMirror type) {
|
private void verifyKind(TypeKind kind, TypeMirror type) {
|
||||||
class Vis extends TypeKindVisitor6<TypeKind, Void> {
|
class Vis extends TypeKindVisitor7<TypeKind, Void> {
|
||||||
@Override
|
@Override
|
||||||
public TypeKind visitNoTypeAsVoid(NoType t, Void p) {
|
public TypeKind visitNoTypeAsVoid(NoType t, Void p) {
|
||||||
return VOID;
|
return VOID;
|
||||||
|
|
|
@ -67,7 +67,7 @@ public class TestDeprecation extends AbstractProcessor {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class DeprecationChecker extends ElementScanner6<Boolean,Void> {
|
private class DeprecationChecker extends ElementScanner7<Boolean,Void> {
|
||||||
private Elements elementUtils;
|
private Elements elementUtils;
|
||||||
private boolean failure;
|
private boolean failure;
|
||||||
DeprecationChecker() {
|
DeprecationChecker() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue