public interface VisitorContext extends MutableConvertibleValues<Object>, ClassWriterOutputVisitor
TypeElementVisitor classes to log messages during compilation and fail compilation.| Modifier and Type | Field and Description |
|---|---|
static String |
MICRONAUT_BASE_OPTION_NAME |
static String |
MICRONAUT_PROCESSING_GROUP |
static String |
MICRONAUT_PROCESSING_MODULE |
static String |
MICRONAUT_PROCESSING_PROJECT_DIR |
EMPTY| Modifier and Type | Method and Description |
|---|---|
default void |
addGeneratedResource(String resource)
Some TypeElementVisitors generate classpath resources that other visitors might be interested in.
|
void |
fail(String message,
Element element)
Allows failing compilation for a given element with the given message.
|
default Optional<ClassElement> |
getClassElement(Class<?> type)
This method will lookup another class element by name.
|
default Optional<ClassElement> |
getClassElement(String name)
This method will lookup another class element by name.
|
default ClassElement[] |
getClassElements(String aPackage,
String... stereotypes)
Find all the classes within the given package and having the given annotation.
|
default Optional<Path> |
getClassesOutputPath()
Provide the Path to the annotation processing classes output directory, i.e.
|
default Iterable<URL> |
getClasspathResources(String path)
Obtain a set of resources from the user classpath.
|
default VisitorConfiguration |
getConfiguration() |
ElementFactory<?,?,?,?> |
getElementFactory()
Gets the element factory for this visitor context.
|
default Collection<String> |
getGeneratedResources()
Provide a collection of generated classpath resources that other TypeElement visitors might want to consume.
|
default Map<String,String> |
getOptions()
The annotation processor environment custom options.
|
default Optional<Path> |
getProjectDir()
Obtain the project directory.
|
void |
info(String message)
Allows printing informational messages.
|
void |
info(String message,
Element element)
Allows printing informational messages.
|
Optional<GeneratedFile> |
visitGeneratedFile(String path)
Visit a file that will be located within the generated source directory.
|
default Optional<GeneratedFile> |
visitMetaInfFile(String path)
Deprecated.
Visiting a file should supply the originating elements. Use
visitMetaInfFile(String, Element...) instead |
Optional<GeneratedFile> |
visitMetaInfFile(String path,
Element... originatingElements)
Visit a file within the META-INF directory.
|
void |
warn(String message,
Element element)
Allows printing a warning for the given message and element.
|
clear, of, put, putAll, putAll, removeasMap, asMap, asProperties, contains, empty, forEach, getValue, getValueType, isEmpty, iterator, names, subMap, subMap, subMap, valuesget, get, get, getforEach, spliteratorfinish, getServiceEntries, visitClass, visitClass, visitClass, visitServiceDescriptor, visitServiceDescriptorstatic final String MICRONAUT_BASE_OPTION_NAME
static final String MICRONAUT_PROCESSING_PROJECT_DIR
static final String MICRONAUT_PROCESSING_GROUP
static final String MICRONAUT_PROCESSING_MODULE
@NonNull ElementFactory<?,?,?,?> getElementFactory()
void info(String message, @Nullable Element element)
message - The messageelement - The elementvoid info(String message)
message - The messagevoid fail(String message, @Nullable Element element)
message - The messageelement - The elementvoid warn(String message, @Nullable Element element)
message - The messageelement - The element@NonNull default VisitorConfiguration getConfiguration()
@Deprecated default Optional<GeneratedFile> visitMetaInfFile(String path)
visitMetaInfFile(String, Element...) insteadvisitMetaInfFile in interface ClassWriterOutputVisitorpath - The path to the fileOptional<GeneratedFile> visitMetaInfFile(String path, Element... originatingElements)
visitMetaInfFile in interface ClassWriterOutputVisitorpath - The path to the fileoriginatingElements - The originating elementsOptional<GeneratedFile> visitGeneratedFile(String path)
visitGeneratedFile in interface ClassWriterOutputVisitorpath - The path to the file@NonNull default Iterable<URL> getClasspathResources(@NonNull String path)
path - The pathdefault Optional<Path> getProjectDir()
default Optional<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
visitorContext.getClassesOutputPath().ifPresent(path ->
visitorContext.addGeneratedResource(path.relativize(resource).toString()));
default Optional<ClassElement> getClassElement(String name)
name - The namedefault Optional<ClassElement> getClassElement(Class<?> type)
type - The name@NonNull default ClassElement[] getClassElements(@NonNull String aPackage, @NonNull String... stereotypes)
aPackage - The packagestereotypes - The stereotypesdefault Map<String,String> getOptions()
All options names MUST start with MICRONAUT_BASE_OPTION_NAME
ProcessingEnvironment.getOptions()default Collection<String> getGeneratedResources()
default void addGeneratedResource(String resource)
resource - the relative path to add