Package io.determann.shadow.api
Interface ShadowApi
- All Superinterfaces:
ApiHolder,DeclaredHolder
- All Known Implementing Classes:
ShadowApiImpl
This is the core class for a lightweight wrapper around the java annotationProcessor api. The
ShadowApi is transient. Meaning you can
transition between using the shadow and the java annotation processor api from line to line if you so wish. Methods in the ShadowApi that leak
the annotation processor api are annotated with JdkApi.
Usage:
- get anything that is annotated
getAnnotatedWith(String) - get already compiled sources
DeclaredHolder.getDeclaredOrThrow(String)for example - get constants
getConstants() - log using
logError(String)or log atlogErrorAt(ElementBacked, String) - convert between sourceCode representations. So called
Shadowsconvert(Shadow)
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic AnnotationConverterconvert(Annotation annotationShadow) static ArrayConverterstatic ClassConverterstatic ConstructorConverterconvert(Constructor constructor) static DeclaredConverterstatic EnumConverterstatic EnumConstantConverterconvert(EnumConstant enumConstant) static ExecutableConverterconvert(Executable executable) static FieldConverterstatic GenericConverterstatic InterfaceConverterstatic IntersectionConverterconvert(Intersection intersection) static MethodConverterstatic ModuleConverterstatic DirectiveConverterstatic ExportsConverterstatic OpensConverterstatic ProvidesConverterstatic RequiresConverterstatic UsesConverterstatic NullConverterstatic PackageConverterstatic ParameterConverterstatic PrimitiveConverterstatic RecordConverterstatic RecordComponentConverterconvert(RecordComponent recordComponent) static ShadowConverterconvert(Shadow<? extends TypeMirror> shadow) static VariableConverterstatic VoidConverterstatic WildcardConverterstatic ShadowApicreate(ShadowApi apiFromPreviousRound, ProcessingEnvironment processingEnv, RoundEnvironment roundEnv, int processingRound) static ShadowApicreate(ProcessingEnvironment processingEnv, RoundEnvironment roundEnv, int processingRound) static DeclaredConvince method that performs erasure on all declared types that support itgetAnnotatedWith(Annotation annotation) Looks up annotated elements in currently compiled code.getAnnotatedWith(String qualifiedAnnotation) Looks up annotated elements in currently compiled code.java.util.function.BiConsumer<ShadowApi,DiagnosticContext> getModuleOrThrow(String name) getPackage(Module module, String qualifiedPackageName) getPackage(String qualifiedModuleName, String qualifiedPackageName) getPackageOrThrow(Module module, String qualifiedPackageName) getPackageOrThrow(String qualifiedModuleName, String qualifiedPackageName) getPackages(String qualifiedName) a package is unique per module.intstarts at 0booleanFirst round of annotation processingbooleanLast round of annotation processingvoidvoidlogErrorAt(ElementBacked<?> elementBacked, String msg) voidvoidlogInfoAt(ElementBacked<?> elementBacked, String msg) voidlogWarning(String msg) voidlogWarningAt(ElementBacked<?> elementBacked, String msg) voidonNameRendered(java.util.function.Consumer<NameRenderedEvent> onNameRendered) readResource(StandardLocation location, String moduleAndPkg, String relativPath) static AnnotationRendererrender(Annotation annotation) static AnnotationUsageRendererrender(AnnotationUsage annotationUsage) static ArrayRendererstatic ClassRendererstatic ConstructorRendererrender(Constructor constructor) static EnumRendererstatic EnumConstantRendererrender(EnumConstant enumConstant) static FieldRendererstatic GenericRendererstatic InterfaceRendererstatic IntersectionRendererrender(Intersection intersection) static MethodRendererstatic ModuleRendererstatic PackageRendererstatic ParameterRendererstatic PrimitiveRendererstatic RecordRendererstatic RecordComponentRendererrender(RecordComponent recordComponent) static WildcardRenderervoidall render methods produce qualified names except for the content ofjava.lang.voidall render methods produce qualified names default isrenderNamesWithoutNeedingImports()voidall render methods produce simple names.voidsetDiagnosticHandler(java.util.function.BiConsumer<ShadowApi, DiagnosticContext> diagnosticHandler) Executed at the end of each round.voidsetExceptionHandler(java.util.function.BiConsumer<ShadowApi, Throwable> exceptionHandler) Consumer to handle exceptions that occur in this annotation processor.voidsetSystemErrorHandler(java.util.function.BiConsumer<ShadowApi, String> systemErrorHandler) SomeTooldon't supportSystem.err.voidsetSystemOutHandler(java.util.function.BiConsumer<ShadowApi, String> systemOutHandler) SomeTooldon't supportSystem.out.voidwriteClassFile(String qualifiedName, String content) the created file will be registered for the next annotation processor round. writes .class filesvoidwriteResource(StandardLocation location, String moduleAndPkg, String relativPath, String content) the created file will NOT be registered for the next annotation processor round. writes anythingvoidwriteSourceFile(String qualifiedName, String content) the created file will be registered for the next annotation processor round. writes .java filesMethods inherited from interface io.determann.shadow.api.DeclaredHolder
getAnnotation, getAnnotationOrThrow, getAnnotations, getClass, getClasses, getClassOrThrow, getDeclared, getDeclared, getDeclaredOrThrow, getEnum, getEnumOrThrow, getEnums, getInterface, getInterfaceOrThrow, getInterfaces, getRecord, getRecordOrThrow, getRecords
-
Method Details
-
create
static ShadowApi create(ProcessingEnvironment processingEnv, RoundEnvironment roundEnv, int processingRound) -
create
static ShadowApi create(ShadowApi apiFromPreviousRound, ProcessingEnvironment processingEnv, RoundEnvironment roundEnv, int processingRound) -
getJdkApiContext
JdkApiContext getJdkApiContext() -
getAnnotatedWith
Looks up annotated elements in currently compiled code.
Annotation processing happens in rounds. If a processor generates sources the next round will contain only these. -
getAnnotatedWith
Looks up annotated elements in currently compiled code.
Annotation processing happens in rounds. If a processor generates sources the next round will contain only these. -
getModules
-
getModule
-
getModuleOrThrow
-
getPackages
a package is unique per module. With multiple modules there can be multiple packages with the same name -
getPackages
-
getPackage
-
getPackageOrThrow
-
getPackage
-
getPackageOrThrow
-
getConstants
ShadowConstants getConstants() -
getShadowFactory
ShadowFactory getShadowFactory() -
logError
-
logInfo
-
logWarning
-
logErrorAt
-
logInfoAt
-
logWarningAt
-
writeSourceFile
the created file will be registered for the next annotation processor round. writes .java files -
writeClassFile
the created file will be registered for the next annotation processor round. writes .class files -
writeResource
void writeResource(StandardLocation location, String moduleAndPkg, String relativPath, String content) the created file will NOT be registered for the next annotation processor round. writes anything -
readResource
FileObject readResource(StandardLocation location, String moduleAndPkg, String relativPath) throws IOException - Throws:
IOException
-
isProcessingOver
boolean isProcessingOver()Last round of annotation processing -
isFirstRound
boolean isFirstRound()First round of annotation processing -
getProcessingRound
int getProcessingRound()starts at 0 -
setExceptionHandler
Consumer to handle exceptions that occur in this annotation processor. If you want the compilation to stop because of it just throw any expedition. -
getExceptionHandler
- See Also:
-
setDiagnosticHandler
void setDiagnosticHandler(java.util.function.BiConsumer<ShadowApi, DiagnosticContext> diagnosticHandler) Executed at the end of each round. When the processing is over each Processor gets called one more time withisProcessingOver()= true. -
getDiagnosticHandler
java.util.function.BiConsumer<ShadowApi,DiagnosticContext> getDiagnosticHandler()- See Also:
-
setSystemOutHandler
SomeTooldon't supportSystem.out. By default, it is proxied and redirected to the logger as warning -
getSystemOutHandler
- See Also:
-
setSystemErrorHandler
SomeTooldon't supportSystem.err. By default, it is proxied and redirected to the logger as error during -
getSystemErrorHandler
- See Also:
-
erasure
Convince method that performs erasure on all declared types that support it -
renderQualifiedNames
void renderQualifiedNames()all render methods produce qualified names default isrenderNamesWithoutNeedingImports() -
renderSimpleNames
void renderSimpleNames()all render methods produce simple names. default isrenderNamesWithoutNeedingImports() -
renderNamesWithoutNeedingImports
void renderNamesWithoutNeedingImports()all render methods produce qualified names except for the content ofjava.lang. this is the default -
onNameRendered
-
render
-
render
-
render
-
render
-
render
-
render
-
render
-
render
-
render
-
render
-
render
-
render
-
render
-
render
-
render
-
render
-
render
-
render
-
render
-
convert
-
convert
-
convert
-
convert
-
convert
-
convert
-
convert
-
convert
-
convert
-
convert
-
convert
-
convert
-
convert
-
convert
-
convert
-
convert
-
convert
-
convert
-
convert
-
convert
-
convert
-
convert
-
convert
-
convert
-
convert
-
convert
-
convert
-
convert
-
convert
-
convert
-