public class AnnotationFileParser extends Object
AnnotationFileParser.AnnotationFileAnnotations
passed as an argument.
The first main entry point is parseStubFile(String, InputStream, AnnotatedTypeFactory,
ProcessingEnvironment, AnnotationFileAnnotations, AnnotationFileUtil.AnnotationFileType,
AnnotationFileElementTypes)
, which side-effects its last argument. It operates in two steps.
First, it calls the Annotation File Parser to parse an annotation file. Then, it walks the AST to
create/collect types and declaration annotations.
The second main entry point is parseAjavaFile(String, InputStream,
CompilationUnitTree, AnnotatedTypeFactory, ProcessingEnvironment, AnnotationFileAnnotations,
AnnotationFileElementTypes)
. This behaves the same as parseStubFile(String, InputStream, AnnotatedTypeFactory,
ProcessingEnvironment, AnnotationFileAnnotations, AnnotationFileUtil.AnnotationFileType,
AnnotationFileElementTypes)
, but takes an ajava file instead.
Modifier and Type | Class and Description |
---|---|
static class |
AnnotationFileParser.AnnotationFileAnnotations
The result of calling AnnotationFileParser.parse: the annotated types and declaration
annotations from the file.
|
static class |
AnnotationFileParser.AnnotationFileParserException
An exception indicating a problem while parsing an annotation file.
|
static class |
AnnotationFileParser.RecordComponentStub
Information about a record component: its type, and whether there was an accessor in the
stubs for that component.
|
static class |
AnnotationFileParser.RecordStub
Information about a record from a stub file.
|
Modifier and Type | Method and Description |
---|---|
static Map<String,TypeElement> |
annosInPackage(PackageElement packageElement)
All annotations defined in the package (but not those nested within classes in the package).
|
static Map<String,TypeElement> |
annosInType(TypeElement typeElement)
All annotations declared (directly) within a class.
|
static Map<String,TypeElement> |
createNameToAnnotationMap(List<TypeElement> typeElements)
All annotations declared within any of the given elements.
|
static void |
parseAjavaFile(String filename,
InputStream inputStream,
CompilationUnitTree root,
AnnotatedTypeFactory atypeFactory,
ProcessingEnvironment processingEnv,
AnnotationFileParser.AnnotationFileAnnotations ajavaAnnos,
AnnotationFileElementTypes fileElementTypes)
The main entry point when parsing an ajava file.
|
static void |
parseJdkFileAsStub(String filename,
InputStream inputStream,
AnnotatedTypeFactory atypeFactory,
ProcessingEnvironment processingEnv,
AnnotationFileParser.AnnotationFileAnnotations stubAnnos,
AnnotationFileElementTypes fileElementTypes)
Parse a stub file that is a part of the annotated JDK and side-effects the
stubAnnos
argument. |
static void |
parseStubFile(String filename,
InputStream inputStream,
AnnotatedTypeFactory atypeFactory,
ProcessingEnvironment processingEnv,
AnnotationFileParser.AnnotationFileAnnotations annotationFileAnnos,
AnnotationFileUtil.AnnotationFileType fileType,
AnnotationFileElementTypes fileElementTypes)
The main entry point.
|
static <K,V> void |
putAllNew(Map<K,V> m,
Map<K,V> m2)
Just like Map.putAll, but modifies existing values using
putIfAbsent(Map, Object,
Object) . |
static <K,V> void |
putIfAbsent(Map<K,V> m,
K key,
V value)
Just like Map.put, but does not override any existing value in the map.
|
public static Map<String,TypeElement> annosInPackage(PackageElement packageElement)
packageElement
- a packagepublic static Map<String,TypeElement> annosInType(TypeElement typeElement)
typeElement
- a typepublic static Map<String,TypeElement> createNameToAnnotationMap(List<TypeElement> typeElements)
typeElements
- the elements whose annotations to retrievepublic static void parseStubFile(String filename, InputStream inputStream, AnnotatedTypeFactory atypeFactory, ProcessingEnvironment processingEnv, AnnotationFileParser.AnnotationFileAnnotations annotationFileAnnos, AnnotationFileUtil.AnnotationFileType fileType, AnnotationFileElementTypes fileElementTypes)
annotationFileAnnos
argument.filename
- name of stub file, used only for diagnostic messagesinputStream
- of stub file to parseatypeFactory
- AnnotatedTypeFactory to useprocessingEnv
- ProcessingEnvironment to useannotationFileAnnos
- annotations from the annotation file; side-effected by this methodfileType
- the annotation file type and sourcefileElementTypes
- the manager that controls the stub file parsing processpublic static void parseAjavaFile(String filename, InputStream inputStream, CompilationUnitTree root, AnnotatedTypeFactory atypeFactory, ProcessingEnvironment processingEnv, AnnotationFileParser.AnnotationFileAnnotations ajavaAnnos, AnnotationFileElementTypes fileElementTypes)
filename
- name of ajava file, used only for diagnostic messagesinputStream
- of ajava file to parseroot
- javac tree for the file to be parsedatypeFactory
- AnnotatedTypeFactory to useprocessingEnv
- ProcessingEnvironment to useajavaAnnos
- annotations from the ajava file; side-effected by this methodfileElementTypes
- the manager that controls the stub file parsing processpublic static void parseJdkFileAsStub(String filename, InputStream inputStream, AnnotatedTypeFactory atypeFactory, ProcessingEnvironment processingEnv, AnnotationFileParser.AnnotationFileAnnotations stubAnnos, AnnotationFileElementTypes fileElementTypes)
stubAnnos
argument.filename
- name of stub file, used only for diagnostic messagesinputStream
- of stub file to parseatypeFactory
- AnnotatedTypeFactory to useprocessingEnv
- ProcessingEnvironment to usestubAnnos
- annotations from the stub file; side-effected by this methodfileElementTypes
- the manager that controls the stub file parsing processpublic static <K,V> void putIfAbsent(Map<K,V> m, K key, V value)
K
- the key typeV
- the value typem
- a mapkey
- a keyvalue
- the value to associate with the key, if the key isn't already in the mappublic static <K,V> void putAllNew(Map<K,V> m, Map<K,V> m2)
putIfAbsent(Map, Object,
Object)
.K
- the key type for the mapsV
- the value type for the mapsm
- the destination mapm2
- the source map