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
ConstructorDescriptionCreates an empty annotation source. -
Method Summary
Modifier and TypeMethodDescriptionReturns the annotated type fore
containing only annotations explicitly written in an annotation file.Returns the set of declaration annotations fore
containing only annotations explicitly written in an annotation file or the empty set ife
does 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.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).boolean
Returns true if files are currently being parsed; otherwise, false.void
Parses the ajava files passed through the -Aajava command-line option.void
parseAjavaFileWithTree
(String ajavaPath, CompilationUnitTree root) Parses the ajava file atajavaPath
assumingroot
represents the compilation unit of that file.void
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 byBaseTypeChecker.getExtraStubFiles()
(treated like those listed in @StubFiles annotation) Stub files provided via-Astubs
compiler 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
BaseTypeChecker.getExtraStubFiles()
(treated like those listed in @StubFiles annotation) - 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
Parses the ajava file atajavaPath
assumingroot
represents the compilation unit of that file. Usesroot
to 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 fore
containing only annotations explicitly written in an annotation file. Returnsnull
ife
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. Returnsnull
ifelement
does not appear in an annotation file.
-
getDeclAnnotations
Returns the set of declaration annotations fore
containing only annotations explicitly written in an annotation file or the empty set ife
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 ifelement
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 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
elt
that is a fake override, or null if there are no fake overrides
-