Class LessThanAnnotatedTypeFactory

All Implemented Interfaces:
AnnotationProvider

public class LessThanAnnotatedTypeFactory extends BaseAnnotatedTypeFactoryForIndexChecker
The type factory for the Less Than Checker.
  • Field Details

    • LESS_THAN_UNKNOWN

      public final AnnotationMirror LESS_THAN_UNKNOWN
      The @LessThanUnknown annotation.
  • Constructor Details

    • LessThanAnnotatedTypeFactory

      public LessThanAnnotatedTypeFactory(BaseTypeChecker checker)
      Creates a new LessThanAnnotatedTypeFactory.
      Parameters:
      checker - the type-checker associated with this type factory
  • Method Details

    • getValueAnnotatedTypeFactory

      public ValueAnnotatedTypeFactory getValueAnnotatedTypeFactory()
      Returns the Value Checker's annotated type factory.
      Returns:
      the Value Checker's annotated type factory
    • createSupportedTypeQualifiers

      protected Set<Class<? extends Annotation>> createSupportedTypeQualifiers()
      Description copied from class: AnnotatedTypeFactory
      Returns a mutable set of annotation classes that are supported by a checker.

      Subclasses may override this method to return a mutable set of their supported type qualifiers through one of the 5 approaches shown below.

      Subclasses should not call this method; they should call AnnotatedTypeFactory.getSupportedTypeQualifiers() instead.

      By default, a checker supports all annotations located in a subdirectory called qual that's located in the same directory as the checker. Note that only annotations defined with the @Target({ElementType.TYPE_USE}) meta-annotation (and optionally with the additional value of ElementType.TYPE_PARAMETER, but no other ElementType values) are automatically considered as supported annotations.

      To support a different set of annotations than those in the qual subdirectory, or that have other ElementType values, see examples below.

      In total, there are 5 ways to indicate annotations that are supported by a checker:

      1. Only support annotations located in a checker's qual directory:

        This is the default behavior. Simply place those annotations within the qual directory.

      2. Support annotations located in a checker's qual directory and a list of other annotations:

        Place those annotations within the qual directory, and override AnnotatedTypeFactory.createSupportedTypeQualifiers() by calling AnnotatedTypeFactory.getBundledTypeQualifiers(Class...) with a varargs parameter list of the other annotations. Code example:

         @Override protected Set<Class<? extends Annotation>> createSupportedTypeQualifiers() {
              return getBundledTypeQualifiers(Regex.class, PartialRegex.class, RegexBottom.class, UnknownRegex.class);
          } 
         
      3. Supporting only annotations that are explicitly listed: Override AnnotatedTypeFactory.createSupportedTypeQualifiers() and return a mutable set of the supported annotations. Code example:
         @Override protected Set<Class<? extends Annotation>> createSupportedTypeQualifiers() {
              return new HashSet<Class<? extends Annotation>>(
                      Arrays.asList(A.class, B.class));
          } 
         
        The set of qualifiers returned by AnnotatedTypeFactory.createSupportedTypeQualifiers() must be a fresh, mutable set. The methods AnnotatedTypeFactory.getBundledTypeQualifiers(Class...) must return a fresh, mutable set
      Overrides:
      createSupportedTypeQualifiers in class AnnotatedTypeFactory
      Returns:
      the type qualifiers supported this processor, or an empty set if none
    • createDependentTypesHelper

      protected DependentTypesHelper createDependentTypesHelper()
      Description copied from class: GenericAnnotatedTypeFactory
      Creates a DependentTypesHelper and returns it. Use GenericAnnotatedTypeFactory.getDependentTypesHelper() to access the value.
      Overrides:
      createDependentTypesHelper in class GenericAnnotatedTypeFactory<CFValue,CFStore,CFTransfer,CFAnalysis>
      Returns:
      a new DependentTypesHelper
    • createQualifierHierarchy

      protected QualifierHierarchy createQualifierHierarchy()
      Description copied from class: AnnotatedTypeFactory
      Returns the QualifierHierarchy to be used by this checker.

      The implementation builds the type qualifier hierarchy for the AnnotatedTypeFactory.getSupportedTypeQualifiers() using the meta-annotations found in them. The current implementation returns an instance of NoElementQualifierHierarchy.

      Subclasses must override this method if their qualifiers have elements; the method must return an implementation of QualifierHierarchy, such as ElementQualifierHierarchy.

      Overrides:
      createQualifierHierarchy in class AnnotatedTypeFactory
      Returns:
      a QualifierHierarchy for this type system
    • isLessThan

      public boolean isLessThan(Tree left, String right)
      Returns true if left is less than right.
      Parameters:
      left - the first tree to compare
      right - the second tree to compare
      Returns:
      is left less than right?
    • isLessThan

      public boolean isLessThan(AnnotationMirror left, String right)
      Returns true if left is less than right.
      Parameters:
      left - the first value to compare (an annotation)
      right - the second value to compare (an expression)
      Returns:
      is left less than right?
    • isLessThanByValue

      public boolean isLessThanByValue(Tree smaller, String bigger, TreePath path)
      Returns true if smaller < bigger.
      Parameters:
      smaller - the first value to compare
      bigger - the second value to compare
      path - used to parse expressions strings
      Returns:
      smaller < bigger, using information from the Value Checker
    • isLessThanOrEqual

      public boolean isLessThanOrEqual(Tree left, String right)
      Returns true if left is less than or equal to right.
      Parameters:
      left - the first value to compare
      right - the second value to compare
      Returns:
      is left less than or equal to right?
    • isLessThanOrEqual

      public boolean isLessThanOrEqual(AnnotationMirror left, String right)
      Returns true if left is less than or equal to right.
      Parameters:
      left - the first value to compare
      right - the second value to compare
      Returns:
      is left less than or equal to right?
    • getLessThanExpressions

      public @Nullable List<String> getLessThanExpressions(ExpressionTree expression)
      Returns a sorted, modifiable list of expressions that expression is less than. If the expression is annotated with LessThanBottom, null is returned.
      Parameters:
      expression - an expression
      Returns:
      expressions that expression is less than
    • createLessThanQualifier

      public AnnotationMirror createLessThanQualifier(@Nullable List<String> expressions)
      Creates a less than qualifier given the expressions.

      If expressions is null, LessThanBottom is returned. If expressions is empty, LessThanUnknown is returned. Otherwise, @LessThan(expressions) is returned.

      Parameters:
      expressions - a list of expressions
      Returns:
      a @LessThan qualifier with the given arguments
    • createLessThanQualifier

      public AnnotationMirror createLessThanQualifier(String expression)
      Returns @LessThan(expression).
    • getLessThanExpressions

      public @Nullable List<String> getLessThanExpressions(AnnotationMirror annotation)
      If the annotation is LessThan, returns a list of expressions in the annotation. If the annotation is LessThanBottom, returns null. If the annotation is LessThanUnknown, returns the empty list.
      Parameters:
      annotation - an annotation from the same hierarchy as LessThan
      Returns:
      the list of expressions in the annotation