Class AnnotationFileElementTypes
java.lang.Object
org.checkerframework.framework.stub.AnnotationFileElementTypes
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 Summary
ConstructorsConstructorDescriptionCreates an empty annotation source. -
Method Summary
Modifier and TypeMethodDescriptionReturns the annotated type forecontaining only annotations explicitly written in an annotation file.Returns the set of declaration annotations forecontaining only annotations explicitly written in an annotation file or the empty set ifedoes not appear in an annotation file.getFakeOverride(Element elt, AnnotatedTypeMirror receiverType) Returns the method type of the most specific fake override for the given element, when used as a member of the given type.voidinjectRecordComponentType(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).booleanReturns true if files are currently being parsed; otherwise, false.voidParses the ajava files passed through the -Aajava command-line option.voidparseAjavaFileWithTree(String ajavaPath, CompilationUnitTree root) Parses the ajava file atajavaPathassumingrootrepresents the compilation unit of that file.voidParses the stub files in the following order: jdk.astub in this directory, if it exists and ignorejdkastub option is not supplied jdk.astub in the same directory as the checker, if it exists and ignorejdkastub option is not supplied If parsing annotated JDK as stub files, all package-info.java files under the jdk/ directory Stub files listed in @StubFiles annotation on the checker; must be in same directory as the checker Stub files returned bySourceChecker.getExtraStubFiles()(treated like those listed in @StubFiles annotation) Stub files provided via-Astubscompiler option
-
Constructor Details
-
AnnotationFileElementTypes
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:- jdk.astub in this directory, if it exists and ignorejdkastub option is not supplied
- jdk.astub in the same directory as the checker, if it exists and ignorejdkastub option is not supplied
- If parsing annotated JDK as stub files, all package-info.java files under the jdk/ directory
- Stub files listed in @StubFiles annotation on the checker; must be in same directory as the checker
- Stub files returned by
SourceChecker.getExtraStubFiles()(treated like those listed in @StubFiles annotation) - Stub files provided via
-Astubscompiler 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
Parses the ajava file atajavaPathassumingrootrepresents the compilation unit of that file. Usesrootto get information from javac on specific elements ofajavaPath, enabling storage of more detailed annotation information than with just the ajava file.- Parameters:
ajavaPath- path to an ajava fileroot- javac tree for the compilation unit stored inajavaFile
-
getAnnotatedTypeMirror
Returns the annotated type forecontaining only annotations explicitly written in an annotation file. Returnsnullifedoes not appear in an annotation file.- Parameters:
e- an Element whose type is returned- Returns:
- an AnnotatedTypeMirror for
econtaining only annotations explicitly written in the annotation file and in the element. Returnsnullifelementdoes not appear in an annotation file.
-
getDeclAnnotations
Returns the set of declaration annotations forecontaining only annotations explicitly written in an annotation file or the empty set ifedoes not appear in an annotation file.- Parameters:
elt- element for which annotations are returned- Returns:
- an AnnotatedTypeMirror for
econtaining only annotations explicitly written in the annotation file and in the element.nullis returned ifelementdoes 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 equivalenceelt- 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
public @Nullable AnnotatedTypeMirror.AnnotatedExecutableType getFakeOverride(Element elt, AnnotatedTypeMirror receiverType) 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 returnedreceiverType- the type of the class that contains member (or a subtype of it)- Returns:
- the most specific AnnotatedTypeMirror for
eltthat is a fake override, or null if there are no fake overrides
-