public class TypeDeclarationApplier extends Object
Modifier and Type | Field and Description |
---|---|
protected Element |
element
An Element that type represents.
|
static int |
SUPERCLASS_INDEX
If a type_index == -1 it means that the index refers to the immediate supertype class of the
declaration.
|
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)
Returns true if type is an annotated declared type and element is a ClassSymbol.
|
protected com.sun.tools.javac.code.TargetType[] |
annotatedTargets()
Returns the TargetTypes that identify annotations we wish to apply with this object.
|
static void |
apply(AnnotatedTypeMirror type,
Element element,
AnnotatedTypeFactory typeFactory) |
void |
extractAndApply()
Adds extends/implements and class annotations to type.
|
protected Iterable<com.sun.tools.javac.code.Attribute.TypeCompound> |
getRawTypeAttributes()
All TypeCompounds (annotations) on the ClassSymbol.
|
protected void |
handleInvalid(List<com.sun.tools.javac.code.Attribute.TypeCompound> invalid)
This implementation reports all invalid annotations as errors.
|
protected void |
handleTargeted(List<com.sun.tools.javac.code.Attribute.TypeCompound> extendsAndImplementsAnnos)
While more than just annotations on extends or implements clause are annotated by this class,
only these annotations are passed to handleTargeted (as they are the only in the
annotatedTargets list).
|
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()
Returns the TargetTypes that identify annotations that are valid but we wish to ignore.
|
public static final int SUPERCLASS_INDEX
protected final AnnotatedTypeMirror type
protected final Element element
public static void apply(AnnotatedTypeMirror type, Element element, AnnotatedTypeFactory typeFactory) throws ElementAnnotationUtil.UnexpectedAnnotationLocationException
public static boolean accepts(AnnotatedTypeMirror type, Element element)
type
- a typeelement
- an elementprotected com.sun.tools.javac.code.TargetType[] validTargets()
protected com.sun.tools.javac.code.TargetType[] annotatedTargets()
protected Iterable<com.sun.tools.javac.code.Attribute.TypeCompound> getRawTypeAttributes()
protected void handleTargeted(List<com.sun.tools.javac.code.Attribute.TypeCompound> extendsAndImplementsAnnos) throws ElementAnnotationUtil.UnexpectedAnnotationLocationException
extendsAndImplementsAnnos
- annotations with a TargetType of CLASS_EXTENDSElementAnnotationUtil.UnexpectedAnnotationLocationException
public void extractAndApply() throws ElementAnnotationUtil.UnexpectedAnnotationLocationException
protected boolean isAccepted()
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 handleValidprotected 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
getRawTypeAttributes