Class QualifierDefaults.DefaultApplierElement

java.lang.Object
org.checkerframework.framework.util.defaults.QualifierDefaults.DefaultApplierElement
Enclosing class:
QualifierDefaults

protected class QualifierDefaults.DefaultApplierElement extends Object
A default applier element.
  • Field Details

    • atypeFactory

      protected final AnnotatedTypeFactory atypeFactory
      The annotated type factory.
    • qualHierarchy

      protected final QualifierHierarchy qualHierarchy
      The qualifier hierarchy.
    • scope

      protected final Element scope
      The scope of the default.
    • type

      protected final AnnotatedTypeMirror type
      The type to which to apply the default.
    • fromTree

      protected final boolean fromTree
      Whether the element came from a tree.
    • location

      protected TypeUseLocation location
      Location to which to apply the default. (Should only be set by the applyDefault method.)
  • Constructor Details

    • DefaultApplierElement

      public DefaultApplierElement(AnnotatedTypeFactory atypeFactory, Element scope, AnnotatedTypeMirror type, boolean fromTree)
      Create an instance.
      Parameters:
      atypeFactory - the type factory
      scope - the scope for the defaults
      type - the type to default
      fromTree - whether the element came from a tree
  • Method Details

    • applyDefaults

      public void applyDefaults(List<Default> defaults)
      Apply all of defaults (in precedence order) to the type in a single traversal, rather than scanning the whole type once per default. addMissingAnnotation only adds an annotation when the hierarchy is unannotated, so a single ordered pass reproduces the precedence of the old per-default scans.
      Parameters:
      defaults - the defaults to apply, in precedence order
    • shouldBeAnnotated

      protected boolean shouldBeAnnotated(AnnotatedTypeMirror type)
      Returns true if the given qualifier should be applied to the given type. Currently we do not apply defaults to void types, none types, wildcards, type variables, packages, and modules.
      Parameters:
      type - type to which qual would be applied
      Returns:
      true if this application should proceed
    • addAnnotation

      protected void addAnnotation(AnnotatedTypeMirror type, AnnotationMirror qual)
      Add the qualifier to the type if it does not already have an annotation in the same hierarchy as qual.
      Parameters:
      type - type to add qual
      qual - annotation to add