public class AnnotationFileElementTypes extends Object
Constructor and Description |
---|
AnnotationFileElementTypes(AnnotatedTypeFactory factory)
Creates an empty annotation source.
|
Modifier and Type | Method and Description |
---|---|
AnnotatedTypeMirror |
getAnnotatedTypeMirror(Element e)
Returns the annotated type for
e containing only annotations explicitly written in an
annotation file or null if e does not appear in an annotation file. |
Set<AnnotationMirror> |
getDeclAnnotation(Element elt)
Deprecated.
|
Set<AnnotationMirror> |
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. |
@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.
|
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 |
isParsing()
Returns true if files are currently being parsed; otherwise, false.
|
void |
parseAjavaFiles()
Parses the ajava files passed through the -Aajava command-line option.
|
void |
parseAjavaFileWithTree(String ajavaPath,
CompilationUnitTree root)
Parses the ajava file at
ajavaPath assuming root represents the compilation
unit of that file. |
void |
parseStubFiles()
Parses the stub files in the following order:
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
|
public AnnotationFileElementTypes(AnnotatedTypeFactory factory)
factory
- AnnotatedTypeFactorypublic boolean isParsing()
public void parseStubFiles()
BaseTypeChecker.getExtraStubFiles()
(treated like those
listed in @StubFiles annotation)
-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.
public void parseAjavaFiles()
public void parseAjavaFileWithTree(String ajavaPath, CompilationUnitTree root)
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.ajavaPath
- path to an ajava fileroot
- javac tree for the compilation unit stored in ajavaFile
public AnnotatedTypeMirror getAnnotatedTypeMirror(Element e)
e
containing only annotations explicitly written in an
annotation file or null
if e
does not appear in an annotation file.e
- an Element whose type is returnede
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.@Deprecated public Set<AnnotationMirror> getDeclAnnotation(Element elt)
getDeclAnnotations(javax.lang.model.element.Element)
e
containing only annotations explicitly
written in an annotation file or the empty set if e
does not appear in an annotation
file.elt
- element for which annotations are returnede
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.public Set<AnnotationMirror> getDeclAnnotations(Element elt)
e
containing only annotations explicitly
written in an annotation file or the empty set if e
does not appear in an annotation
file.elt
- element for which annotations are returnede
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.public void injectRecordComponentType(Types types, Element elt, AnnotatedTypeMirror.AnnotatedExecutableType memberType)
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 methodpublic @Nullable AnnotatedTypeMirror.AnnotatedExecutableType getFakeOverride(Element elt, AnnotatedTypeMirror receiverType)
elt
- element for which annotations are returnedreceiverType
- the type of the class that contains member (or a subtype of it)elt
that is a fake override, or null
if there are no fake overrides