Package org.checkerframework.javacutil
Class TypeAnnotationUtils
- java.lang.Object
-
- org.checkerframework.javacutil.TypeAnnotationUtils
-
public class TypeAnnotationUtils extends java.lang.Object
A collection of helper methods related to type annotation handling.- See Also:
AnnotationUtils
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static com.sun.tools.javac.code.Attribute
attributeFromAnnotationValue(javax.lang.model.element.ExecutableElement meth, javax.lang.model.element.AnnotationValue av, javax.annotation.processing.ProcessingEnvironment env)
Returns a newly created Attribute corresponding to an argument AnnotationValue.static com.sun.tools.javac.code.TypeAnnotationPosition
classExtendsTAPosition(int implidx, int pos)
Create a class extends TypeAnnotationPosition.static com.sun.tools.javac.code.TypeAnnotationPosition
copyTAPosition(com.sun.tools.javac.code.TypeAnnotationPosition tapos)
Copy a TypeAnnotationPosition.static com.sun.tools.javac.code.Attribute.Compound
createCompoundFromAnnotationMirror(javax.lang.model.element.AnnotationMirror am, javax.annotation.processing.ProcessingEnvironment env)
Returns a newly created Attribute.Compound corresponding to an argument AnnotationMirror.static com.sun.tools.javac.code.Attribute.TypeCompound
createTypeCompoundFromAnnotationMirror(javax.lang.model.element.AnnotationMirror am, com.sun.tools.javac.code.TypeAnnotationPosition tapos, javax.annotation.processing.ProcessingEnvironment env)
Returns a newly created Attribute.TypeCompound corresponding to an argument AnnotationMirror.static com.sun.tools.javac.code.TypeAnnotationPosition
fieldTAPosition(int pos)
Create a field TypeAnnotationPosition.static boolean
isSameTAPosition(com.sun.tools.javac.code.TypeAnnotationPosition p1, com.sun.tools.javac.code.TypeAnnotationPosition p2)
Compare two TypeAnnotationPositions for equality.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.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, javax.lang.model.util.Types types)
Check whether a TypeCompound is contained in a list of TypeCompounds.static com.sun.tools.javac.code.TypeAnnotationPosition
methodParameterTAPosition(int pidx, int pos)
Create a method parameter TypeAnnotationPosition.static com.sun.tools.javac.code.TypeAnnotationPosition
methodReceiverTAPosition(int pos)
Create a method receiver TypeAnnotationPosition.static com.sun.tools.javac.code.TypeAnnotationPosition
methodReturnTAPosition(int pos)
Create a method return TypeAnnotationPosition.static com.sun.tools.javac.code.TypeAnnotationPosition
methodThrowsTAPosition(int tidx, int pos)
Create a method throws TypeAnnotationPosition.static com.sun.tools.javac.code.TypeAnnotationPosition
methodTypeParameterBoundTAPosition(int tpidx, int bndidx, int pos)
Create a method type parameter bound TypeAnnotationPosition.static com.sun.tools.javac.code.TypeAnnotationPosition
methodTypeParameterTAPosition(int tpidx, int pos)
Create a method type parameter TypeAnnotationPosition.static com.sun.tools.javac.code.TypeAnnotationPosition
typeParameterBoundTAPosition(int tpidx, int bndidx, int pos)
Create a type parameter bound TypeAnnotationPosition.static com.sun.tools.javac.code.TypeAnnotationPosition
typeParameterTAPosition(int tpidx, int pos)
Create a type parameter TypeAnnotationPosition.static com.sun.tools.javac.code.Type
unannotatedType(javax.lang.model.type.TypeMirror in)
Remove type annotations from the given type.static com.sun.tools.javac.code.TypeAnnotationPosition
unknownTAPosition()
Create an unknown TypeAnnotationPosition.
-
-
-
Method Detail
-
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, javax.lang.model.util.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(javax.lang.model.element.AnnotationMirror am, javax.annotation.processing.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(javax.lang.model.element.AnnotationMirror am, com.sun.tools.javac.code.TypeAnnotationPosition tapos, javax.annotation.processing.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(javax.lang.model.element.ExecutableElement meth, javax.lang.model.element.AnnotationValue av, javax.annotation.processing.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
public static com.sun.tools.javac.code.Type unannotatedType(javax.lang.model.type.TypeMirror in)
Remove type annotations from the given type.- Parameters:
in
- the input type- Returns:
- the same underlying type, but without type annotations
-
-