public class ParamApplier extends Object
Modifier and Type | Field and Description |
---|---|
protected Element |
element
An Element that type represents.
|
static int |
RECEIVER_PARAM_INDEX |
protected AnnotatedTypeMirror |
type
The type to which we wish to apply annotations.
|
Modifier and Type | Method and Description |
---|---|
static boolean |
accepts(AnnotatedTypeMirror type,
Element element) |
protected com.sun.tools.javac.code.TargetType[] |
annotatedTargets() |
static void |
apply(AnnotatedTypeMirror type,
Element element,
AnnotatedTypeFactory typeFactory) |
void |
extractAndApply()
Reads the list of annotations that apply to this element (see getRawTypeAttributes).
|
int |
getElementIndex()
The index of element in the list of elements that contains it
|
static com.sun.tools.javac.code.Symbol.MethodSymbol |
getParentMethod(Element methodChildElem)
Return the enclosing MethodSymbol of the given element, throwing an exception of the symbol's enclosing
element is not a MethodSymbol
|
protected 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.
|
int |
getTypeCompoundIndex(com.sun.tools.javac.code.Attribute.TypeCompound anno)
A TypeAnnotationPosition has a number of different indexes (type_index, bound_index, param_index)
Return the index we are interested in.
|
protected void |
handleInvalid(List<com.sun.tools.javac.code.Attribute.TypeCompound> invalid) |
protected void |
handleTargeted(List<com.sun.tools.javac.code.Attribute.TypeCompound> targeted)
This method should apply all annotations that are handled by this object.
|
protected void |
handleValid(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 Map<org.checkerframework.framework.util.element.TargetedElementAnnotationApplier.TargetClass,List<com.sun.tools.javac.code.Attribute.TypeCompound>> |
sift(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() |
public static int RECEIVER_PARAM_INDEX
protected final AnnotatedTypeMirror type
protected final Element element
public static void apply(AnnotatedTypeMirror type, Element element, AnnotatedTypeFactory typeFactory)
public static boolean accepts(AnnotatedTypeMirror type, Element element)
public int getElementIndex()
public int getTypeCompoundIndex(com.sun.tools.javac.code.Attribute.TypeCompound anno)
anno
- An annotation we might wish to applyprotected com.sun.tools.javac.code.TargetType[] annotatedTargets()
protected com.sun.tools.javac.code.TargetType[] validTargets()
protected Iterable<com.sun.tools.javac.code.Attribute.TypeCompound> getRawTypeAttributes()
protected Map<org.checkerframework.framework.util.element.TargetedElementAnnotationApplier.TargetClass,List<com.sun.tools.javac.code.Attribute.TypeCompound>> sift(Iterable<com.sun.tools.javac.code.Attribute.TypeCompound> typeCompounds)
typeCompounds
- Annotations to sift through, should be those returned by getRawTypeAttributesprotected void handleTargeted(List<com.sun.tools.javac.code.Attribute.TypeCompound> targeted)
targeted
- Type compounds with formal method parameter target types with parameter_index == getIndexprotected boolean isAccepted()
public static com.sun.tools.javac.code.Symbol.MethodSymbol getParentMethod(Element methodChildElem)
methodChildElem
- Some element that is a child of a method typeDeclaration (e.g. a parameter or return type)protected void handleValid(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(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 handleValidpublic void extractAndApply()