Class AnnotationFileElementTypes

java.lang.Object
org.checkerframework.framework.stub.AnnotationFileElementTypes

public class AnnotationFileElementTypes extends Object
Holds information about types parsed from annotation files (stub files or ajava files). When using an ajava file, only holds information on public elements as with stub files.
  • Constructor Details

    • AnnotationFileElementTypes

      public AnnotationFileElementTypes(AnnotatedTypeFactory factory)
      Creates an empty annotation source.
      Parameters:
      factory - a type factory
  • Method Details

    • isParsing

      public boolean isParsing()
      Returns true if files are currently being parsed; otherwise, false.
      Returns:
      true if files are currently being parsed; otherwise, false
    • parseStubFiles

      public void parseStubFiles()
      Parses the stub files in the following order:
      1. jdk.astub in this directory, if it exists and ignorejdkastub option is not supplied
      2. jdk.astub in the same directory as the checker, if it exists and ignorejdkastub option is not supplied
      3. If parsing annotated JDK as stub files, all package-info.java files under the jdk/ directory
      4. Stub files listed in @StubFiles annotation on the checker; must be in same directory as the checker
      5. Stub files returned by SourceChecker.getExtraStubFiles() (treated like those listed in @StubFiles annotation)
      6. Stub files provided via -Astubs compiler option

      If a type is annotated with a qualifier from the same hierarchy in more than one stub file, the qualifier in the last stub file is applied.

      If using JDK 11, then the JDK stub files are only parsed if a type or declaration annotation is requested from a class in that file.

    • parseAjavaFiles

      public void parseAjavaFiles()
      Parses the ajava files passed through the -Aajava command-line option.
    • parseAjavaFileWithTree

      public void parseAjavaFileWithTree(String ajavaPath, CompilationUnitTree root)
      Parses the ajava file at ajavaPath assuming root represents the compilation unit of that file. Uses root to get information from javac on specific elements of ajavaPath, enabling storage of more detailed annotation information than with just the ajava file.
      Parameters:
      ajavaPath - path to an ajava file
      root - javac tree for the compilation unit stored in ajavaFile
    • getAnnotatedTypeMirror

      public @Nullable AnnotatedTypeMirror getAnnotatedTypeMirror(Element e)
      Returns the annotated type for e containing only annotations explicitly written in an annotation file. Returns null if e does not appear in an annotation file.
      Parameters:
      e - an Element whose type is returned
      Returns:
      an AnnotatedTypeMirror for e containing only annotations explicitly written in the annotation file and in the element. Returns null if element does not appear in an annotation file.
    • getDeclAnnotations

      public @Nullable AnnotationMirrorSet getDeclAnnotations(Element elt)
      Returns the set of declaration annotations for e containing only annotations explicitly written in an annotation file or the empty set if e does not appear in an annotation file.
      Parameters:
      elt - element for which annotations are returned
      Returns:
      an AnnotatedTypeMirror for e containing only annotations explicitly written in the annotation file and in the element. null is returned if element does not appear in an annotation file.
    • injectRecordComponentType

      public void injectRecordComponentType(Types types, Element elt, AnnotatedTypeMirror.AnnotatedExecutableType memberType)
      Adds annotations from stub files for the corresponding record components (if the given constructor/method is the canonical constructor or a record accessor). Such transfer is automatically done by javac usually, but not from stubs.
      Parameters:
      types - a Types instance used for checking type equivalence
      elt - a member. This method does nothing if it's not a method or constructor.
      memberType - the type corresponding to the element elt; side-effected by this method
    • getFakeOverride

      Returns the method type of the most specific fake override for the given element, when used as a member of the given type.
      Parameters:
      elt - element for which annotations are returned
      receiverType - the type of the class that contains member (or a subtype of it)
      Returns:
      the most specific AnnotatedTypeMirror for elt that is a fake override, or null if there are no fake overrides