Package org.checkerframework.javacutil
Class TypeAnnotationUtils
java.lang.Object
org.checkerframework.javacutil.TypeAnnotationUtils
A collection of helper methods related to type annotation handling.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic com.sun.tools.javac.code.AttributeReturns a newly created Attribute corresponding to an argument AnnotationValue.static com.sun.tools.javac.code.TypeAnnotationPositionclassExtendsTAPosition(int implidx, int pos) Create a class extends TypeAnnotationPosition.static com.sun.tools.javac.code.TypeAnnotationPositioncopyTAPosition(com.sun.tools.javac.code.TypeAnnotationPosition tapos) Copy a TypeAnnotationPosition.static com.sun.tools.javac.code.Attribute.CompoundReturns a newly created Attribute.Compound corresponding to an argument AnnotationMirror.static com.sun.tools.javac.code.Attribute.TypeCompoundcreateTypeCompoundFromAnnotationMirror(AnnotationMirror am, com.sun.tools.javac.code.TypeAnnotationPosition tapos, ProcessingEnvironment env) Returns a newly created Attribute.TypeCompound corresponding to an argument AnnotationMirror.static com.sun.tools.javac.code.TypeAnnotationPositionfieldTAPosition(int pos) Create a field TypeAnnotationPosition.static booleanisSameTAPosition(com.sun.tools.javac.code.TypeAnnotationPosition p1, com.sun.tools.javac.code.TypeAnnotationPosition p2) Compare two TypeAnnotationPositions for equality.static booleanisSameTAPositionExceptTreePos(com.sun.tools.javac.code.TypeAnnotationPosition p1, com.sun.tools.javac.code.TypeAnnotationPosition p2) Compare two TypeAnnotationPositions for equality, ignoring the source tree position.static booleanisTypeCompoundContained(com.sun.tools.javac.util.List<com.sun.tools.javac.code.Attribute.TypeCompound> list, com.sun.tools.javac.code.Attribute.TypeCompound tc, Types types) Check whether a TypeCompound is contained in a list of TypeCompounds.static com.sun.tools.javac.code.TypeAnnotationPositionmethodParameterTAPosition(int pidx, int pos) Create a method parameter TypeAnnotationPosition.static com.sun.tools.javac.code.TypeAnnotationPositionmethodReceiverTAPosition(int pos) Create a method receiver TypeAnnotationPosition.static com.sun.tools.javac.code.TypeAnnotationPositionmethodReturnTAPosition(int pos) Create a method return TypeAnnotationPosition.static com.sun.tools.javac.code.TypeAnnotationPositionmethodThrowsTAPosition(int tidx, int pos) Create a method throws TypeAnnotationPosition.static com.sun.tools.javac.code.TypeAnnotationPositionmethodTypeParameterBoundTAPosition(int tpidx, int bndidx, int pos) Create a method type parameter bound TypeAnnotationPosition.static com.sun.tools.javac.code.TypeAnnotationPositionmethodTypeParameterTAPosition(int tpidx, int pos) Create a method type parameter TypeAnnotationPosition.static com.sun.tools.javac.code.TypeAnnotationPositiontypeParameterBoundTAPosition(int tpidx, int bndidx, int pos) Create a type parameter bound TypeAnnotationPosition.static com.sun.tools.javac.code.TypeAnnotationPositiontypeParameterTAPosition(int tpidx, int pos) Create a type parameter TypeAnnotationPosition.static com.sun.tools.javac.code.TypeRemove type annotations from the given type.static com.sun.tools.javac.code.TypeAnnotationPositionCreate an unknown TypeAnnotationPosition.
-
Method Details
-
isTypeCompoundContained
public static boolean isTypeCompoundContained(com.sun.tools.javac.util.List<com.sun.tools.javac.code.Attribute.TypeCompound> list, com.sun.tools.javac.code.Attribute.TypeCompound tc, Types types) Check whether a TypeCompound is contained in a list of TypeCompounds.- Parameters:
list- the input list of TypeCompoundstc- the TypeCompound to findtypes- type utilities- Returns:
- true, iff a TypeCompound equal to tc is contained in list
-
isSameTAPosition
public static boolean isSameTAPosition(com.sun.tools.javac.code.TypeAnnotationPosition p1, com.sun.tools.javac.code.TypeAnnotationPosition p2) Compare two TypeAnnotationPositions for equality.- Parameters:
p1- the first positionp2- the second position- Returns:
- true, iff the two positions are equal
-
isSameTAPositionExceptTreePos
public static boolean isSameTAPositionExceptTreePos(com.sun.tools.javac.code.TypeAnnotationPosition p1, com.sun.tools.javac.code.TypeAnnotationPosition p2) Compare two TypeAnnotationPositions for equality, ignoring the source tree position.- Parameters:
p1- the first positionp2- the second position- Returns:
- true, iff the two positions are equal except for the source tree position
-
createCompoundFromAnnotationMirror
public static com.sun.tools.javac.code.Attribute.Compound createCompoundFromAnnotationMirror(AnnotationMirror am, ProcessingEnvironment env) Returns a newly created Attribute.Compound corresponding to an argument AnnotationMirror.- Parameters:
am- an AnnotationMirror, which may be part of an AST or an internally created subclass- Returns:
- a new Attribute.Compound corresponding to the AnnotationMirror
-
createTypeCompoundFromAnnotationMirror
public static com.sun.tools.javac.code.Attribute.TypeCompound createTypeCompoundFromAnnotationMirror(AnnotationMirror am, com.sun.tools.javac.code.TypeAnnotationPosition tapos, ProcessingEnvironment env) Returns a newly created Attribute.TypeCompound corresponding to an argument AnnotationMirror.- Parameters:
am- an AnnotationMirror, which may be part of an AST or an internally created subclasstapos- the type annotation position to use- Returns:
- a new Attribute.TypeCompound corresponding to the AnnotationMirror
-
attributeFromAnnotationValue
public static com.sun.tools.javac.code.Attribute attributeFromAnnotationValue(ExecutableElement meth, AnnotationValue av, ProcessingEnvironment env) Returns a newly created Attribute corresponding to an argument AnnotationValue.- Parameters:
meth- the ExecutableElement that is assigned the value, needed for empty arraysav- an AnnotationValue, which may be part of an AST or an internally created subclass- Returns:
- a new Attribute corresponding to the AnnotationValue
-
unknownTAPosition
public static com.sun.tools.javac.code.TypeAnnotationPosition unknownTAPosition()Create an unknown TypeAnnotationPosition.- Returns:
- an unkown TypeAnnotationPosition
-
methodReturnTAPosition
public static com.sun.tools.javac.code.TypeAnnotationPosition methodReturnTAPosition(int pos) Create a method return TypeAnnotationPosition.- Parameters:
pos- the source tree position- Returns:
- a method return TypeAnnotationPosition
-
methodReceiverTAPosition
public static com.sun.tools.javac.code.TypeAnnotationPosition methodReceiverTAPosition(int pos) Create a method receiver TypeAnnotationPosition.- Parameters:
pos- the source tree position- Returns:
- a method receiver TypeAnnotationPosition
-
methodParameterTAPosition
public static com.sun.tools.javac.code.TypeAnnotationPosition methodParameterTAPosition(int pidx, int pos) Create a method parameter TypeAnnotationPosition.- Parameters:
pidx- the parameter indexpos- the source tree position- Returns:
- a method parameter TypeAnnotationPosition
-
methodThrowsTAPosition
public static com.sun.tools.javac.code.TypeAnnotationPosition methodThrowsTAPosition(int tidx, int pos) Create a method throws TypeAnnotationPosition.- Parameters:
tidx- the throws indexpos- the source tree position- Returns:
- a method throws TypeAnnotationPosition
-
fieldTAPosition
public static com.sun.tools.javac.code.TypeAnnotationPosition fieldTAPosition(int pos) Create a field TypeAnnotationPosition.- Parameters:
pos- the source tree position- Returns:
- a field TypeAnnotationPosition
-
classExtendsTAPosition
public static com.sun.tools.javac.code.TypeAnnotationPosition classExtendsTAPosition(int implidx, int pos) Create a class extends TypeAnnotationPosition.- Parameters:
implidx- the class extends indexpos- the source tree position- Returns:
- a class extends TypeAnnotationPosition
-
typeParameterTAPosition
public static com.sun.tools.javac.code.TypeAnnotationPosition typeParameterTAPosition(int tpidx, int pos) Create a type parameter TypeAnnotationPosition.- Parameters:
tpidx- the type parameter indexpos- the source tree position- Returns:
- a type parameter TypeAnnotationPosition
-
methodTypeParameterTAPosition
public static com.sun.tools.javac.code.TypeAnnotationPosition methodTypeParameterTAPosition(int tpidx, int pos) Create a method type parameter TypeAnnotationPosition.- Parameters:
tpidx- the method type parameter indexpos- the source tree position- Returns:
- a method type parameter TypeAnnotationPosition
-
typeParameterBoundTAPosition
public static com.sun.tools.javac.code.TypeAnnotationPosition typeParameterBoundTAPosition(int tpidx, int bndidx, int pos) Create a type parameter bound TypeAnnotationPosition.- Parameters:
tpidx- the type parameter indexbndidx- the bound indexpos- the source tree position- Returns:
- a method parameter TypeAnnotationPosition
-
methodTypeParameterBoundTAPosition
public static com.sun.tools.javac.code.TypeAnnotationPosition methodTypeParameterBoundTAPosition(int tpidx, int bndidx, int pos) Create a method type parameter bound TypeAnnotationPosition.- Parameters:
tpidx- the type parameter indexbndidx- the bound indexpos- the source tree position- Returns:
- a method parameter TypeAnnotationPosition
-
copyTAPosition
public static com.sun.tools.javac.code.TypeAnnotationPosition copyTAPosition(com.sun.tools.javac.code.TypeAnnotationPosition tapos) Copy a TypeAnnotationPosition.- Parameters:
tapos- the input TypeAnnotationPosition- Returns:
- a copied TypeAnnotationPosition
-
unannotatedType
Remove type annotations from the given type.- Parameters:
in- the input type- Returns:
- the same underlying type, but without type annotations
-