Interface VisitorContext
- All Superinterfaces:
ClassWriterOutputVisitor, ConversionServiceProvider, ConvertibleValues<Object>, Iterable<Map.Entry<String,Object>>, MutableConvertibleValues<Object>, ValueResolver<CharSequence>
- All Known Subinterfaces:
BeanElementVisitorContext
- All Known Implementing Classes:
GroovyVisitorContext, JavaVisitorContext
Provides a way for
TypeElementVisitor classes to log messages during compilation and fail compilation.- Since:
- 1.0
- Author:
- James Kleeh, Graeme Rocher
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumThe languages that are supported in source code generation. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final StringFields inherited from interface ConvertibleValues
EMPTY -
Method Summary
Modifier and TypeMethodDescriptiondefault voidaddGeneratedResource(String resource) Deprecated, for removal: This API element is subject to removal in a future version.No longer usedvoidAllows failing compilation for a given element with the given message.Gets the annotation metadata builder.default Optional<ClassElement> getClassElement(Class<?> type) This method will look up another class element by name.default Optional<ClassElement> getClassElement(String name) This method will look up another class element by name.default Optional<ClassElement> getClassElement(String name, ElementAnnotationMetadataFactory annotationMetadataFactory) This method will look up another class element by name.default List<ClassElement> getClassElements(PackageElement packageElement) Find all the classes within the given package.default ClassElement[]getClassElements(String aPackage, String... stereotypes) Find all the classes within the given package and having the given annotation.Provide the Path to the annotation processing classes output directory, i.e.getClasspathResources(String path) Obtain a set of resources from the user classpath.default VisitorConfigurationGets the element annotation metadata factory.ElementFactory<?, ?, ?, ?> Gets the element factory for this visitor context.default Collection<String> Deprecated, for removal: This API element is subject to removal in a future version.No longer usedThe annotation processor environment custom options.Obtain the project directory.default ClassElementgetRequiredClassElement(String name, ElementAnnotationMetadataFactory annotationMetadataFactory) This method will look up another class element by name.voidAllows printing informational messages.voidAllows printing informational messages.visitGeneratedFile(String path) Visit a file that will be located within the generated source directory.visitMetaInfFile(String path, Element... originatingElements) Visit a file within the META-INF directory.voidAllows printing a warning for the given message and element.Methods inherited from interface ClassWriterOutputVisitor
finish, getServiceEntries, visitClass, visitClass, visitClass, visitGeneratedFile, visitGeneratedSourceFile, visitMetaInfFile, visitServiceDescriptor, visitServiceDescriptor, visitServiceDescriptor, visitServiceDescriptorMethods inherited from interface ConvertibleValues
asMap, asMap, asProperties, contains, forEach, getConversionService, getValue, getValueType, isEmpty, iterator, names, subMap, subMap, subMap, valuesMethods inherited from interface Iterable
forEach, spliteratorMethods inherited from interface ValueResolver
get, get, get, get
-
Field Details
-
MICRONAUT_BASE_OPTION_NAME
- See Also:
-
MICRONAUT_PROCESSING_PROJECT_DIR
- See Also:
-
MICRONAUT_PROCESSING_GROUP
- See Also:
-
MICRONAUT_PROCESSING_MODULE
- See Also:
-
-
Method Details
-
getLanguage
VisitorContext.Language getLanguage()- Returns:
- The visitor context's language.
- Since:
- 4.2.0
-
getElementFactory
ElementFactory<?,?, getElementFactory()?, ?> Gets the element factory for this visitor context.- Returns:
- The element factory
- Since:
- 2.3.0
-
getElementAnnotationMetadataFactory
ElementAnnotationMetadataFactory getElementAnnotationMetadataFactory()Gets the element annotation metadata factory.- Returns:
- The element annotation metadata factory
- Since:
- 4.0.0
-
getExpressionCompilationContextFactory
ExpressionCompilationContextFactory getExpressionCompilationContextFactory()- Returns:
- The expression compilation context factory.
- Since:
- 4.0.0
-
getAnnotationMetadataBuilder
Gets the annotation metadata builder.- Returns:
- The annotation metadata builder
- Since:
- 4.0.0
-
info
-
info
-
fail
-
warn
-
getConfiguration
- Returns:
- The visitor configuration
-
visitMetaInfFile
Visit a file within the META-INF directory.- Specified by:
visitMetaInfFilein interfaceClassWriterOutputVisitor- Parameters:
path- The path to the fileoriginatingElements- The originating elements- Returns:
- An optional file it was possible to create it
-
visitGeneratedFile
Visit a file that will be located within the generated source directory.- Specified by:
visitGeneratedFilein interfaceClassWriterOutputVisitor- Parameters:
path- The path to the file- Returns:
- An optional file it was possible to create it
-
getClasspathResources
-
getProjectDir
-
getClassesOutputPath
Provide the Path to the annotation processing classes output directory, i.e. the parent of META-INF.This might, for example, be used as a convenience for
TypeElementVisitorclasses to provide relative path strings toaddGeneratedResource(String)Path resource = ... // absolute path to the resource visitorContext.getClassesOutputPath().ifPresent(path -> visitorContext.addGeneratedResource(path.relativize(resource).toString()));- Returns:
- Path pointing to the classes output directory
-
getClassElement
This method will look up another class element by name. If it cannot be found an empty optional will be returned.- Parameters:
name- The name- Returns:
- The class element
-
getClassElement
default Optional<ClassElement> getClassElement(String name, ElementAnnotationMetadataFactory annotationMetadataFactory) This method will look up another class element by name. If it cannot be found an empty optional will be returned.- Parameters:
name- The nameannotationMetadataFactory- The element annotation metadata factory- Returns:
- The class element
- Since:
- 4.0.0
-
getRequiredClassElement
default ClassElement getRequiredClassElement(String name, ElementAnnotationMetadataFactory annotationMetadataFactory) This method will look up another class element by name. If it cannot be found an exception thrown.- Parameters:
name- The nameannotationMetadataFactory- The element annotation metadata factory- Returns:
- The class element
- Since:
- 4.0.0
-
getClassElement
This method will look up another class element by name. If it cannot be found an empty optional will be returned.- Parameters:
type- The name- Returns:
- The class element
-
getClassElements
Find all the classes within the given package and having the given annotation.- Parameters:
aPackage- The packagestereotypes- The stereotypes- Returns:
- The class elements
-
getClassElements
Find all the classes within the given package.- Parameters:
packageElement- The package- Returns:
- The class elements
-
getOptions
The annotation processor environment custom options.All options names MUST start with
MICRONAUT_BASE_OPTION_NAME- Returns:
- A Map with annotation processor runtime options
- See Also:
-
getGeneratedResources
Deprecated, for removal: This API element is subject to removal in a future version.No longer usedProvide a collection of generated classpath resources that other TypeElement visitors might want to consume. The generated resources are intended to be strings paths relative to the classpath root.- Returns:
- a possibly empty collection of resource paths
-
addGeneratedResource
Deprecated, for removal: This API element is subject to removal in a future version.No longer usedSome TypeElementVisitors generate classpath resources that other visitors might be interested in. The generated resources are intended to be strings paths relative to the classpath root- Parameters:
resource- the relative path to add
-