public interface VisitorContext extends MutableConvertibleValues<java.lang.Object>, ClassWriterOutputVisitor
TypeElementVisitor
classes to log messages during compilation and fail compilation.Modifier and Type | Field and Description |
---|---|
static java.lang.String |
MICRONAUT_BASE_OPTION_NAME |
static java.lang.String |
MICRONAUT_PROCESSING_GROUP |
static java.lang.String |
MICRONAUT_PROCESSING_MODULE |
static java.lang.String |
MICRONAUT_PROCESSING_PROJECT_DIR |
EMPTY
Modifier and Type | Method and Description |
---|---|
default void |
addGeneratedResource(java.lang.String resource)
Some TypeElementVisitors generate classpath resources that other visitors might be interested in.
|
void |
fail(java.lang.String message,
Element element)
Allows failing compilation for a given element with the given message.
|
default java.util.Optional<ClassElement> |
getClassElement(java.lang.Class<?> type)
This method will lookup another class element by name.
|
default java.util.Optional<ClassElement> |
getClassElement(java.lang.String name)
This method will lookup another class element by name.
|
default ClassElement[] |
getClassElements(java.lang.String aPackage,
java.lang.String... stereotypes)
Find all the classes within the given package and having the given annotation.
|
default java.util.Optional<java.nio.file.Path> |
getClassesOutputPath()
Provide the URI to the annotation processing classes output directory, i.e.
|
default java.lang.Iterable<java.net.URL> |
getClasspathResources(java.lang.String path)
Obtain a set of resources from the user classpath.
|
default java.util.Collection<java.lang.String> |
getGeneratedResources()
Provide a collection of generated classpath resources that other TypeElement visitors might want to consume.
|
default java.util.Map<java.lang.String,java.lang.String> |
getOptions()
The annotation processor environment custom options.
|
default java.util.Optional<java.nio.file.Path> |
getProjectDir()
Obtain the project directory.
|
void |
info(java.lang.String message)
Allows printing informational messages.
|
void |
info(java.lang.String message,
Element element)
Allows printing informational messages.
|
java.util.Optional<GeneratedFile> |
visitGeneratedFile(java.lang.String path)
Visit a file that will be located within the generated source directory.
|
java.util.Optional<GeneratedFile> |
visitMetaInfFile(java.lang.String path)
Visit a file within the META-INF directory.
|
void |
warn(java.lang.String message,
Element element)
Allows printing a warning for the given message and element.
|
clear, of, put, putAll, putAll, remove
asMap, asMap, asProperties, contains, empty, forEach, getValue, getValueType, isEmpty, iterator, names, subMap, subMap, subMap, values
get, get, get, get
finish, getServiceEntries, visitClass, visitClass, visitClass, visitServiceDescriptor, visitServiceDescriptor
static final java.lang.String MICRONAUT_BASE_OPTION_NAME
static final java.lang.String MICRONAUT_PROCESSING_PROJECT_DIR
static final java.lang.String MICRONAUT_PROCESSING_GROUP
static final java.lang.String MICRONAUT_PROCESSING_MODULE
void info(java.lang.String message, @Nullable Element element)
message
- The messageelement
- The elementvoid info(java.lang.String message)
message
- The messagevoid fail(java.lang.String message, @Nullable Element element)
message
- The messageelement
- The elementvoid warn(java.lang.String message, @Nullable Element element)
message
- The messageelement
- The elementjava.util.Optional<GeneratedFile> visitMetaInfFile(java.lang.String path)
visitMetaInfFile
in interface ClassWriterOutputVisitor
path
- The path to the filejava.util.Optional<GeneratedFile> visitGeneratedFile(java.lang.String path)
visitGeneratedFile
in interface ClassWriterOutputVisitor
path
- The path to the file@NonNull default java.lang.Iterable<java.net.URL> getClasspathResources(@NonNull java.lang.String path)
path
- The pathdefault java.util.Optional<java.nio.file.Path> getProjectDir()
default java.util.Optional<java.nio.file.Path> getClassesOutputPath()
This might, for example, be used as a convenience for TypeElementVisitor
classes to provide
relative path strings to addGeneratedResource(String)
Path resource = ... // absolute path to the resource OptionalclassesOutputURI = visitorContext.getClassesOutputUri(); if (classesOutputURI.isPresent()) { // path to resource, relative to classes output Path relativePath = classesOutputURI.get().relativize(resource) visitorContext.addGeneratedResource(relativePath.toString()); }
default java.util.Optional<ClassElement> getClassElement(java.lang.String name)
name
- The namedefault java.util.Optional<ClassElement> getClassElement(java.lang.Class<?> type)
type
- The name@NonNull default ClassElement[] getClassElements(@NonNull java.lang.String aPackage, @NonNull java.lang.String... stereotypes)
aPackage
- The packagestereotypes
- The stereotypesdefault java.util.Map<java.lang.String,java.lang.String> getOptions()
All options names MUST start with MICRONAUT_BASE_OPTION_NAME
ProcessingEnvironment.getOptions()
default java.util.Collection<java.lang.String> getGeneratedResources()
default void addGeneratedResource(java.lang.String resource)
resource
- the relative path to add