public class MethodApplier
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected javax.lang.model.element.Element |
element
An Element that type represents.
|
protected AnnotatedTypeMirror |
type
The type to which we wish to apply annotations.
|
Modifier and Type | Method and Description |
---|---|
static boolean |
accepts(AnnotatedTypeMirror typeMirror,
javax.lang.model.element.Element element) |
protected com.sun.tools.javac.code.TargetType[] |
annotatedTargets() |
static void |
apply(AnnotatedTypeMirror type,
javax.lang.model.element.Element element,
AnnotatedTypeFactory typeFactory) |
void |
extractAndApply()
Sets the method's element, annotates its return type, parameters, type parameters, and throws
annotations.
|
protected java.lang.Iterable<com.sun.tools.javac.code.Attribute.TypeCompound> |
getRawTypeAttributes()
Annotations on elements are represented as Attribute.TypeCompounds ( a subtype of
AnnotationMirror) that are usually accessed through a getRawTypeAttributes method on the
element.
|
protected void |
handleInvalid(java.util.List<com.sun.tools.javac.code.Attribute.TypeCompound> invalid) |
protected void |
handleTargeted(java.util.List<com.sun.tools.javac.code.Attribute.TypeCompound> targeted)
This method should apply all annotations that are handled by this object.
|
protected void |
handleValid(java.util.List<com.sun.tools.javac.code.Attribute.TypeCompound> valid)
The default implementation of this method does nothing.
|
protected boolean |
isAccepted()
Tests element/type fields to ensure that this TargetedElementAnnotationApplier is valid for
this element/type pair.
|
protected java.util.Map<org.checkerframework.framework.util.element.TargetedElementAnnotationApplier.TargetClass,java.util.List<com.sun.tools.javac.code.Attribute.TypeCompound>> |
sift(java.lang.Iterable<com.sun.tools.javac.code.Attribute.TypeCompound> typeCompounds)
Separate the input annotations into a Map of TargetClass (TARGETED, VALID, INVALID) to the
annotations that fall into each of those categories.
|
protected com.sun.tools.javac.code.TargetType[] |
validTargets() |
protected final AnnotatedTypeMirror type
protected final javax.lang.model.element.Element element
public static void apply(AnnotatedTypeMirror type, javax.lang.model.element.Element element, AnnotatedTypeFactory typeFactory)
public static boolean accepts(AnnotatedTypeMirror typeMirror, javax.lang.model.element.Element element)
protected com.sun.tools.javac.code.TargetType[] annotatedTargets()
protected com.sun.tools.javac.code.TargetType[] validTargets()
protected java.lang.Iterable<com.sun.tools.javac.code.Attribute.TypeCompound> getRawTypeAttributes()
In Java 8 and later these annotations are generally contained by elements to which they apply. However, in earlier versions of Java many of these annotations are handled by either the enclosing method, e.g. parameters and method type parameters, or enclosing class, e.g. class type parameters. Therefore, many annotations are addressed by first getting all annotations on a method or class and the picking out only the ones we wish to target (see extractAndApply).
protected boolean isAccepted()
public void extractAndApply()
protected void handleTargeted(java.util.List<com.sun.tools.javac.code.Attribute.TypeCompound> targeted)
targeted
- the list of annotations that were returned by getRawTypeAttributes and had a
TargetType contained by annotatedTargetsprotected void handleValid(java.util.List<com.sun.tools.javac.code.Attribute.TypeCompound> valid)
valid
- the list of annotations that were returned by getRawTypeAttributes and had a
TargetType contained by valid and NOT annotatedTargetsprotected void handleInvalid(java.util.List<com.sun.tools.javac.code.Attribute.TypeCompound> invalid)
invalid
- the list of annotations that were returned by getRawTypeAttributes and were
not handled by handleTargeted or handleValidprotected java.util.Map<org.checkerframework.framework.util.element.TargetedElementAnnotationApplier.TargetClass,java.util.List<com.sun.tools.javac.code.Attribute.TypeCompound>> sift(java.lang.Iterable<com.sun.tools.javac.code.Attribute.TypeCompound> typeCompounds)
typeCompounds
- annotations to sift through, should be those returned by
getRawTypeAttributes