Skip to content

Commit

Permalink
Add annotation elements and start of type hierarchy.
Browse files Browse the repository at this point in the history
2012-11-26  Andrew John Hughes  <gnu_andrew@member.fsf.org>

	* javax/lang/model/element/AnnotationMirror.java:
	Added.
	(getAnnotationType()): Added.
	(getElementValues()): Likewise.
	* javax/lang/model/element/AnnotationValue.java:
	Added.
	(accept(AnnotationValueVisitor,P)): Added.
	(getValue()): Likewise.
	(toString()): Likewise.
	* javax/lang/model/element/AnnotationValueVisitor.java:
	Added.
	(visit(AnnotationValue)): Added.
	(visit(AnnotationValue, P)): Likewise.
	(visitAnnotation(AnnotationMirror, P)): Likewise.
	(visitArray(List, P)): Likewise.
	(visitBoolean(boolean, P)): Likewise.
	(visitByte(byte, P)): Likewise.
	(visitChar(char, P)): Likewise.
	(visitDouble(double, P)): Likewise.
	(visitEnumConstant(VariableElement, P)): Likewise.
	(visitFloat(float, P)): Likewise.
	(visitInt(float, P)): Likewise.
	(visitLong(long, P)): Likewise.
	(visitShort(short, P)): Likewise.
	(visitString(String, P)): Likewise.
	(visitType(TypeMirror, P)): Likewise.
	(visitUnknown(AnnotationValue, P)): Likewise.
	* javax/lang/model/element/Element.java:
	(asType()): Added.
	(getAnnotationMirrors()): Likewise.
	* javax/lang/model/element/ElementVisitor.java:
	(visitExecutable(ExecutableElement, P)): Added.
	(visitTypeParameter(TypeParameterElement, P)): Likewise.
	(visitVariable(VariableElement, P)): Likewise.
	* javax/lang/model/element/ExecutableElement.java:
	Added.
	(getDefaultValue()): Added.
	(getParameters()): Likewise.
	(getReturnType()): Likewise.
	(getThrownTypes()): Likewise.
	(getTypeParameters()): Likewise.
	(isVarArgs()): Likewise.
	* javax/lang/model/element/TypeElement.java:
	(getInterfaces()): Added.
	(getSuperclass()): Likewise.
	(getTypeParameters()): Likewise.
	* javax/lang/model/element/TypeParameterElement.java:
	Added.
	(getBounds()): Added.
	(getGenericElement()): Likewise.
	* javax/lang/model/element/VariableElement.java:
	Added.
	(getConstantValue()): Added.
	* javax/lang/model/type/DeclaredType.java:
	Added.
	(asElement()): Added.
	(getEnclosingType()): Likewise.
	(getTypeArguments()): Likewise.
	* javax/lang/model/type/ReferenceType.java:
	Added.
	* javax/lang/model/type/TypeKind.java:
	Added.
	(ARRAY): Added.
	(BOOLEAN): Likewise.
	(BYTE): Likewise.
	(CHAR): Likewise.
	(DECLARED): Likewise.
	(DOUBLE): Likewise.
	(ERROR): Likewise.
	(EXECUTABLE): Likewise.
	(FLOAT): Likewise.
	(INT): Likewise.
	(LONG): Likewise.
	(NONE): Likewise.
	(NULL): Likewise.
	(OTHER): Likewise.
	(PACKAGE): Likewise.
	(SHORT): Likewise.
	(TYPEVAR): Likewise.
	(VOID): Likewise.
	(WILDCARD): Likewise.
	(isPrimitive()): Implemented.
	* javax/lang/model/type/TypeMirror.java:
	Added.
	(accept(TypeVisitor, P)): Added.
	(equals(Object)): Likewise.
	(getKind()): Likewise.
	(hashCode()): Likewise.
	(toString()): Likewise.
	* javax/lang/model/type/TypeVisitor.java:
	Added.
	(visit(TypeMirror)): Added.
	(visit(TypeMirror, P)): Likewise.
	(visitUnknown(TypeMirror, P)): Likewise.
	(visitDeclared(DeclaredType, P)): Likewise.
	* javax/lang/model/util/Elements.java:
	(getAllAnnotationMirrors(Element)): Added.
	(getElementValuesWithDefaults(AnnotationMirror)): Likewise.
	(overrides(ExecutableElement, ExecutableElement)): Likewise.
	* javax/lang/model/util/Types.java:
	(asElement(TypeMirror)): Added.
	(asMemberOf(DeclaredType, Element)): Likewise.
	(capture(TypeMirror)): Likewise.
	(contains(TypeMirror, TypeMirror)): Likewise.
	(directSupertypes(TypeMirror)): Likewise.
	(erasure(TypeMirror)): Likewise.
	(getDeclaredType(DeclaredType, TypeElement,
	TypeMirror...)): Likewise.
	(getDeclaredType(TypeElement, TypeMirror...)):
	Likewise.
	(isAssignable(TypeMirror, TypeMirror)): Likewise.
	(isSameType(TypeMirror, TypeMirror)): Likewise.
	(isSubtype(TypeMirror, TypeMirror)): Likewise.

Signed-off-by: Andrew John Hughes <gnu_andrew@member.fsf.org>
  • Loading branch information
gnu-andrew committed Nov 27, 2012
1 parent 75fab28 commit 449a0b9
Show file tree
Hide file tree
Showing 17 changed files with 1,560 additions and 1 deletion.
116 changes: 116 additions & 0 deletions ChangeLog
@@ -1,3 +1,119 @@
2012-11-26 Andrew John Hughes <gnu_andrew@member.fsf.org>

* javax/lang/model/element/AnnotationMirror.java:
Added.
(getAnnotationType()): Added.
(getElementValues()): Likewise.
* javax/lang/model/element/AnnotationValue.java:
Added.
(accept(AnnotationValueVisitor,P)): Added.
(getValue()): Likewise.
(toString()): Likewise.
* javax/lang/model/element/AnnotationValueVisitor.java:
Added.
(visit(AnnotationValue)): Added.
(visit(AnnotationValue, P)): Likewise.
(visitAnnotation(AnnotationMirror, P)): Likewise.
(visitArray(List, P)): Likewise.
(visitBoolean(boolean, P)): Likewise.
(visitByte(byte, P)): Likewise.
(visitChar(char, P)): Likewise.
(visitDouble(double, P)): Likewise.
(visitEnumConstant(VariableElement, P)): Likewise.
(visitFloat(float, P)): Likewise.
(visitInt(float, P)): Likewise.
(visitLong(long, P)): Likewise.
(visitShort(short, P)): Likewise.
(visitString(String, P)): Likewise.
(visitType(TypeMirror, P)): Likewise.
(visitUnknown(AnnotationValue, P)): Likewise.
* javax/lang/model/element/Element.java:
(asType()): Added.
(getAnnotationMirrors()): Likewise.
* javax/lang/model/element/ElementVisitor.java:
(visitExecutable(ExecutableElement, P)): Added.
(visitTypeParameter(TypeParameterElement, P)): Likewise.
(visitVariable(VariableElement, P)): Likewise.
* javax/lang/model/element/ExecutableElement.java:
Added.
(getDefaultValue()): Added.
(getParameters()): Likewise.
(getReturnType()): Likewise.
(getThrownTypes()): Likewise.
(getTypeParameters()): Likewise.
(isVarArgs()): Likewise.
* javax/lang/model/element/TypeElement.java:
(getInterfaces()): Added.
(getSuperclass()): Likewise.
(getTypeParameters()): Likewise.
* javax/lang/model/element/TypeParameterElement.java:
Added.
(getBounds()): Added.
(getGenericElement()): Likewise.
* javax/lang/model/element/VariableElement.java:
Added.
(getConstantValue()): Added.
* javax/lang/model/type/DeclaredType.java:
Added.
(asElement()): Added.
(getEnclosingType()): Likewise.
(getTypeArguments()): Likewise.
* javax/lang/model/type/ReferenceType.java:
Added.
* javax/lang/model/type/TypeKind.java:
Added.
(ARRAY): Added.
(BOOLEAN): Likewise.
(BYTE): Likewise.
(CHAR): Likewise.
(DECLARED): Likewise.
(DOUBLE): Likewise.
(ERROR): Likewise.
(EXECUTABLE): Likewise.
(FLOAT): Likewise.
(INT): Likewise.
(LONG): Likewise.
(NONE): Likewise.
(NULL): Likewise.
(OTHER): Likewise.
(PACKAGE): Likewise.
(SHORT): Likewise.
(TYPEVAR): Likewise.
(VOID): Likewise.
(WILDCARD): Likewise.
(isPrimitive()): Implemented.
* javax/lang/model/type/TypeMirror.java:
Added.
(accept(TypeVisitor, P)): Added.
(equals(Object)): Likewise.
(getKind()): Likewise.
(hashCode()): Likewise.
(toString()): Likewise.
* javax/lang/model/type/TypeVisitor.java:
Added.
(visit(TypeMirror)): Added.
(visit(TypeMirror, P)): Likewise.
(visitUnknown(TypeMirror, P)): Likewise.
(visitDeclared(DeclaredType, P)): Likewise.
* javax/lang/model/util/Elements.java:
(getAllAnnotationMirrors(Element)): Added.
(getElementValuesWithDefaults(AnnotationMirror)): Likewise.
(overrides(ExecutableElement, ExecutableElement)): Likewise.
* javax/lang/model/util/Types.java:
(asElement(TypeMirror)): Added.
(asMemberOf(DeclaredType, Element)): Likewise.
(capture(TypeMirror)): Likewise.
(contains(TypeMirror, TypeMirror)): Likewise.
(directSupertypes(TypeMirror)): Likewise.
(erasure(TypeMirror)): Likewise.
(getDeclaredType(DeclaredType, TypeElement,
TypeMirror...)): Likewise.
(getDeclaredType(TypeElement, TypeMirror...)):
Likewise.
(isAssignable(TypeMirror, TypeMirror)): Likewise.
(isSameType(TypeMirror, TypeMirror)): Likewise.
(isSubtype(TypeMirror, TypeMirror)): Likewise.

2012-11-25 Andrew John Hughes <gnu_andrew@member.fsf.org>

* javax/annotation/processing/Processor.java:
Expand Down
78 changes: 78 additions & 0 deletions javax/lang/model/element/AnnotationMirror.java
@@ -0,0 +1,78 @@
/* AnnotationMirror.java -- Represents an annotation.
Copyright (C) 2012 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath 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 for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */

package javax.lang.model.element;

import java.util.Map;

import javax.lang.model.type.DeclaredType;

/**
* Represents an annotation. An annotation associates values
* with the elements of an annotation type. Annotations should
* be compared using {@link #equals(Object)}. There is no guarantee
* that the same annotation is always represented by the same
* instance.
*
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
* @since 1.6
*/
public interface AnnotationMirror
{

/**
* Returns the type of this annotation.
*
* @return the type of this annotation.
*/
DeclaredType getAnnotationType();

/**
* Returns a map of elements to their values. Only those
* elements explicitly set in the annotation are present;
* default values are not included. To obtain the default
* values as well, use
* {@link javax.lang.model.util.Elements#getElementValuesWithDefaults(AnnotationMirror)}
* A marker annotation, by definition, returns an empty map.
* The order of the elements in the map follows that of the
* source code.
*
* @return the map of elements to values.
*/
Map<? extends ExecutableElement, ? extends AnnotationValue> getElementValues();

}
86 changes: 86 additions & 0 deletions javax/lang/model/element/AnnotationValue.java
@@ -0,0 +1,86 @@
/* AnnotationValue.java -- Represents an annotation value.
Copyright (C) 2012 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath 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 for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */

package javax.lang.model.element;

/**
* <p>Represents the value of an element in an annotation. This
* may be one of the following types:</p>
* <ul>
* <li>a wrapper class for a primitive type (e.g. {@code Integer}
* for {@code int}.</li>
* <li>{@code String}</li>
* <li>{@code TypeMirror}</li>
* <li>{@code VariableElement} (an enum constant)</li>
* <li>{@code AnnotationMirror}</li>
* <li>{@code List<? extends AnnotationValue>} (an array,
* with elements in the order they were declared)</li>
* </ol>
*
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
* @since 1.6
*/
public interface AnnotationValue
{

/**
* Applies a visitor to this type.
*
* @param <R> the return type of the visitor's methods.
* @param <P> the type of the additional parameter used in the visitor's
* methods.
* @param visitor the visitor to apply to the element.
* @param param the additional parameter to be sent to the visitor.
* @return the return value from the visitor.
*/
<R,P> R accept(AnnotationValueVisitor<R,P> visitor, P param);

/**
* Returns the value.
*
* @return the value.
*/
Object getValue();

/**
* Returns a textual representation of the value.
*
* @return a textual representation.
*/
String toString();

}

0 comments on commit 449a0b9

Please sign in to comment.