Class TypeAnnotationUtils

java.lang.Object
org.checkerframework.javacutil.TypeAnnotationUtils

public class TypeAnnotationUtils extends Object
A collection of helper methods related to type annotation handling.
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    static com.sun.tools.javac.code.Attribute
    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
    Returns a newly created Attribute.Compound corresponding to an argument AnnotationMirror.
    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.
    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, 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
    Create a method receiver TypeAnnotationPosition.
    static com.sun.tools.javac.code.TypeAnnotationPosition
    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
    Remove type annotations from the given type.
    static com.sun.tools.javac.code.TypeAnnotationPosition
    Create an unknown TypeAnnotationPosition.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 TypeCompounds
      tc - the TypeCompound to find
      types - 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 position
      p2 - 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 position
      p2 - 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 subclass
      tapos - 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 arrays
      av - 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 index
      pos - 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 index
      pos - 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 index
      pos - 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 index
      pos - 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 index
      pos - 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 index
      bndidx - the bound index
      pos - 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 index
      bndidx - the bound index
      pos - 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(TypeMirror in)
      Remove type annotations from the given type.
      Parameters:
      in - the input type
      Returns:
      the same underlying type, but without type annotations