Class BaseProcessor
java.lang.Object
javax.annotation.processing.AbstractProcessor
com.oracle.truffle.libgraal.processor.BaseProcessor
- All Implemented Interfaces:
Processor
- Direct Known Subclasses:
TruffleFromLibGraalProcessor
AbstractProcessor subclass that provides extra functionality.-
Field Summary
Fields inherited from class javax.annotation.processing.AbstractProcessor
processingEnv -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionasTypeElement(TypeMirror type) Converts a givenTypeMirrorto aTypeElement.voidcreateProviderFile(String providerClassName, String serviceClassName, Element... originatingElements) Creates aMETA-INF/providers/<providerClassName>file whose contents are a single line containingserviceClassName.static PrintWritercreateSourceFile(String pkg, String relativeName, Filer filer, Element... originatingElements) protected abstract booleandoProcess(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) env()Gets the processing environment available to this processor.getAnnotation(Element element, TypeMirror annotationType) Gets the annotation of typeannotationTypedirectly present onelement.getAnnotations(Element element, TypeMirror typeMirror) Gets all annotations directly present onelement.static <T> TgetAnnotationValue(AnnotationMirror annotation, String name, Class<T> type) Gets the value of thenameelement ofannotationand converts it to a value of typetype.static <T> List<T> getAnnotationValueList(AnnotationMirror annotation, String name, Class<T> componentType) Gets the value of thenamearray-typed element ofannotationand converts it to list of values of typetype.static PackageElementgetPackage(Element element) static StringgetPackageName(String className) Gets the package component of a qualified class name.static StringgetSimpleName(String className) Gets the non-package component of a qualified class name.final SourceVersionGets theTypeMirrorfor a given class name.getTypeElement(String className) Gets theTypeElementfor a given class name.getTypeElementOrNull(String className) Gets theTypeElementfor a given class name.getTypeOrNull(String className) Gets theTypeMirrorfor a given class name.booleanprocess(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) Methods inherited from class javax.annotation.processing.AbstractProcessor
getCompletions, getSupportedAnnotationTypes, getSupportedOptions, init, isInitialized
-
Constructor Details
-
BaseProcessor
public BaseProcessor()
-
-
Method Details
-
env
Gets the processing environment available to this processor. -
getSupportedSourceVersion
- Specified by:
getSupportedSourceVersionin interfaceProcessor- Overrides:
getSupportedSourceVersionin classAbstractProcessor
-
process
- Specified by:
processin interfaceProcessor- Specified by:
processin classAbstractProcessor
-
doProcess
protected abstract boolean doProcess(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) -
getType
Gets theTypeMirrorfor a given class name.- Throws:
NoClassDefFoundError- if the class cannot be resolved
-
getType
-
getTypeOrNull
Gets theTypeMirrorfor a given class name.- Returns:
nullif the class cannot be resolved
-
getTypeElement
Gets theTypeElementfor a given class name.- Throws:
NoClassDefFoundError- if the class cannot be resolved
-
getTypeElementOrNull
Gets theTypeElementfor a given class name.- Returns:
nullif the class cannot be resolved
-
asTypeElement
Converts a givenTypeMirrorto aTypeElement.- Throws:
ClassCastException- if type cannot be converted to aTypeElement
-
getSimpleName
Gets the non-package component of a qualified class name.- Throws:
IllegalArgumentException- ifclassNamedoes not matchQUALIFIED_CLASS_NAME_RE
-
getPackageName
Gets the package component of a qualified class name.- Throws:
IllegalArgumentException- ifclassNamedoes not matchQUALIFIED_CLASS_NAME_RE
-
getAnnotation
Gets the annotation of typeannotationTypedirectly present onelement.- Returns:
nullif an annotation of typeannotationTypeis not onelement
-
getAnnotations
Gets all annotations directly present onelement. -
getAnnotationValue
Gets the value of thenameelement ofannotationand converts it to a value of typetype.- Parameters:
type- the expected type of the element value. This must be a subclass of one of the types described byAnnotationValue.- Throws:
NoSuchElementException- ifannotationhas no element namednameClassCastException- if the value of the specified element cannot be converted totype
-
getAnnotationValueList
public static <T> List<T> getAnnotationValueList(AnnotationMirror annotation, String name, Class<T> componentType) Gets the value of thenamearray-typed element ofannotationand converts it to list of values of typetype.- Parameters:
componentType- the expected component type of the element value. This must be a subclass of one of the types described byAnnotationValue.- Throws:
NoSuchElementException- ifannotationhas no element namednameClassCastException- if the value of the specified element is not an array whose components cannot be converted tocomponentType
-
getPackage
-
createSourceFile
public static PrintWriter createSourceFile(String pkg, String relativeName, Filer filer, Element... originatingElements) -
createProviderFile
public void createProviderFile(String providerClassName, String serviceClassName, Element... originatingElements) Creates aMETA-INF/providers/<providerClassName>file whose contents are a single line containingserviceClassName.
-