Class PythonVisitorContext
java.lang.Object
io.micronaut.python.processing.visitor.PythonVisitorContext
- All Implemented Interfaces:
ConversionServiceProvider, ConvertibleValues<Object>, MutableConvertibleValues<Object>, ValueResolver<CharSequence>, VisitorContext, ClassWriterOutputVisitor, Iterable<Map.Entry<String,Object>>
Visitor context implementation backed by the Python processing environment.
-
Nested Class Summary
Nested classes/interfaces inherited from interface VisitorContext
VisitorContext.Language -
Field Summary
Fields inherited from interface ConvertibleValues
EMPTY -
Constructor Summary
ConstructorsConstructorDescriptionPythonVisitorContext(Map<String, DecoratorDef> decorators, PythonProcessingEnvironment processingEnvironment) PythonVisitorContext(Map<String, DecoratorDef> decorators, PythonProcessingEnvironment processingEnvironment, JavaVisitorContext javaVisitorContext) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddGeneratedResource(String resource) Some TypeElementVisitors generate classpath resources that other visitors might be interested in.clear()Clear all values.voidAllows failing compilation for a given element with the given message.voidfinish()Finish writing and flush any service entries to disk.<T> Optional<T> get(CharSequence name, ArgumentConversionContext<T> conversionContext) Resolve the given property for the given name.Gets the annotation metadata builder.getClassElement(String name) This method will look up another class element by name.getClassElement(String name, ElementAnnotationMetadataFactory annotationMetadataFactory) This method will look up another class element by name.getClassElements(String aPackage, String... stereotypes) Find all the classes within the given package and having the given annotation.Gets the element annotation metadata factory.ElementFactory<?, ?, ?, ?> Gets the element factory for this visitor context.Provide a collection of generated classpath resources that other TypeElement visitors might want to consume.voidAllows printing informational messages.voidAllows printing informational messages.names()put(CharSequence key, Object value) Insert a value for the given key and value.remove(CharSequence key) Remove a value for the given key.values()visitClass(String classname, Element... originatingElements) Visits a new class and returns the output stream with which should be written the bytes of the class to be generated.visitGeneratedFile(String path) Visit a file that will be located within the generated source directory.visitGeneratedFile(String path, Element... originatingElements) Visit a file that will be generated within the generated 'sources' directory.visitGeneratedSourceFile(String packageName, String fileNameWithoutExtension, Element... originatingElements) Visit a source file that will be generated within the generated 'sources' directory.visitMetaInfFile(String path, Element... originatingElements) Visit a file within the META-INF directory.voidvisitServiceDescriptor(String type, String classname) Allows adding a class that will be written to theMETA-INF/servicesfile under the given type and class name.voidvisitServiceDescriptor(String type, String classname, Element originatingElement) Allows adding a class that will be written to theMETA-INF/servicesfile under the given type and class name.voidAllows printing a warning for the given message and element.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ClassWriterOutputVisitor
getServiceEntries, visitClass, visitClass, visitMetaInfFile, visitServiceDescriptor, visitServiceDescriptorMethods inherited from interface ConvertibleValues
asMap, asMap, asProperties, contains, forEach, getConversionService, getValue, getValueType, isEmpty, iterator, subMap, subMap, subMapMethods inherited from interface Iterable
forEach, spliteratorMethods inherited from interface MutableConvertibleValues
putAll, putAllMethods inherited from interface ValueResolver
get, get, getMethods inherited from interface VisitorContext
getAnnotationDefaultValues, getAnnotationRetentionPolicy, getClassElement, getClassElements, getClassesOutputPath, getClasspathResources, getConfiguration, getOptions, getProjectDir, getRequiredClassElement
-
Constructor Details
-
PythonVisitorContext
public PythonVisitorContext(Map<String, DecoratorDef> decorators, PythonProcessingEnvironment processingEnvironment) -
PythonVisitorContext
public PythonVisitorContext(Map<String, DecoratorDef> decorators, PythonProcessingEnvironment processingEnvironment, JavaVisitorContext javaVisitorContext)
-
-
Method Details
-
getJavaVisitorContext
-
getProcessingEnvironment
-
getLanguage
- Specified by:
getLanguagein interfaceVisitorContext- Returns:
- The visitor context's language.
-
getElementFactory
Description copied from interface:VisitorContextGets the element factory for this visitor context.- Specified by:
getElementFactoryin interfaceVisitorContext- Returns:
- The element factory
-
getElementAnnotationMetadataFactory
Description copied from interface:VisitorContextGets the element annotation metadata factory.- Specified by:
getElementAnnotationMetadataFactoryin interfaceVisitorContext- Returns:
- The element annotation metadata factory
-
getExpressionCompilationContextFactory
- Specified by:
getExpressionCompilationContextFactoryin interfaceVisitorContext- Returns:
- The expression compilation context factory.
-
getAnnotationMetadataBuilder
Description copied from interface:VisitorContextGets the annotation metadata builder.- Specified by:
getAnnotationMetadataBuilderin interfaceVisitorContext- Returns:
- The annotation metadata builder
-
info
Description copied from interface:VisitorContextAllows printing informational messages.- Specified by:
infoin interfaceVisitorContext- Parameters:
message- The messageelement- The element
-
info
Description copied from interface:VisitorContextAllows printing informational messages.- Specified by:
infoin interfaceVisitorContext- Parameters:
message- The message
-
fail
Description copied from interface:VisitorContextAllows failing compilation for a given element with the given message.- Specified by:
failin interfaceVisitorContext- Parameters:
message- The messageelement- The element
-
warn
Description copied from interface:VisitorContextAllows printing a warning for the given message and element.- Specified by:
warnin interfaceVisitorContext- Parameters:
message- The messageelement- The element
-
visitMetaInfFile
Description copied from interface:VisitorContextVisit a file within the META-INF directory.- Specified by:
visitMetaInfFilein interfaceClassWriterOutputVisitor- Specified by:
visitMetaInfFilein interfaceVisitorContext- Parameters:
path- The path to the fileoriginatingElements- The originating elements- Returns:
- An optional file it was possible to create it
-
visitGeneratedFile
Description copied from interface:VisitorContextVisit a file that will be located within the generated source directory.- Specified by:
visitGeneratedFilein interfaceClassWriterOutputVisitor- Specified by:
visitGeneratedFilein interfaceVisitorContext- Parameters:
path- The path to the file- Returns:
- An optional file it was possible to create it
-
put
Description copied from interface:MutableConvertibleValuesInsert a value for the given key and value.- Specified by:
putin interfaceMutableConvertibleValues<Object>- Parameters:
key- The keyvalue- The value- Returns:
- This values instance
-
remove
Description copied from interface:MutableConvertibleValuesRemove a value for the given key.- Specified by:
removein interfaceMutableConvertibleValues<Object>- Parameters:
key- The key- Returns:
- This values instance
-
clear
Description copied from interface:MutableConvertibleValuesClear all values.- Specified by:
clearin interfaceMutableConvertibleValues<Object>- Returns:
- This values instance
-
names
- Specified by:
namesin interfaceConvertibleValues<Object>- Returns:
- The names of the values
-
values
- Specified by:
valuesin interfaceConvertibleValues<Object>- Returns:
- The values
-
get
Description copied from interface:ValueResolverResolve the given property for the given name.- Specified by:
getin interfaceValueResolver<CharSequence>- Type Parameters:
T- The concrete type- Parameters:
name- The nameconversionContext- The conversion context- Returns:
- An optional containing the property value if it exists and is able to be converted
-
visitClass
Description copied from interface:ClassWriterOutputVisitorVisits a new class and returns the output stream with which should be written the bytes of the class to be generated.Note that this method should only be called from a
TypeElementVisitor.VisitorKind.AGGREGATINGvisitor from within theTypeElementVisitor.finish(io.micronaut.inject.visitor.VisitorContext)method. If the file- Specified by:
visitClassin interfaceClassWriterOutputVisitor- Parameters:
classname- the fully qualified classnameoriginatingElements- The originating elements- Returns:
- the output stream to write to
- Throws:
IOException- if an error occurs creating the output stream
-
visitServiceDescriptor
Description copied from interface:ClassWriterOutputVisitorAllows adding a class that will be written to theMETA-INF/servicesfile under the given type and class name.- Specified by:
visitServiceDescriptorin interfaceClassWriterOutputVisitor- Parameters:
type- the fully qualified service nameclassname- the fully qualified classname
-
visitServiceDescriptor
Description copied from interface:ClassWriterOutputVisitorAllows adding a class that will be written to theMETA-INF/servicesfile under the given type and class name.- Specified by:
visitServiceDescriptorin interfaceClassWriterOutputVisitor- Parameters:
type- the fully qualified service nameclassname- the fully qualified classnameoriginatingElement- The originating element
-
visitGeneratedFile
Description copied from interface:ClassWriterOutputVisitorVisit a file that will be generated within the generated 'sources' directory.- Specified by:
visitGeneratedFilein interfaceClassWriterOutputVisitor- Parameters:
path- The pathoriginatingElements- the originating elements- Returns:
- The file if it was possible to create it
-
visitGeneratedSourceFile
public Optional<GeneratedFile> visitGeneratedSourceFile(String packageName, String fileNameWithoutExtension, Element... originatingElements) Description copied from interface:ClassWriterOutputVisitorVisit a source file that will be generated within the generated 'sources' directory.- Specified by:
visitGeneratedSourceFilein interfaceClassWriterOutputVisitor- Parameters:
packageName- The package for the source filefileNameWithoutExtension- the name of the source file, without extension (determined automatically)originatingElements- the originating elements- Returns:
- The file if it was possible to create it
-
getClassElement
public Optional<ClassElement> getClassElement(String name, ElementAnnotationMetadataFactory annotationMetadataFactory) Description copied from interface:VisitorContextThis method will look up another class element by name. If it cannot be found an empty optional will be returned.- Specified by:
getClassElementin interfaceVisitorContext- Parameters:
name- The nameannotationMetadataFactory- The element annotation metadata factory- Returns:
- The class element
-
getClassElement
Description copied from interface:VisitorContextThis method will look up another class element by name. If it cannot be found an empty optional will be returned.- Specified by:
getClassElementin interfaceVisitorContext- Parameters:
name- The name- Returns:
- The class element
-
getClassElements
Description copied from interface:VisitorContextFind all the classes within the given package and having the given annotation.- Specified by:
getClassElementsin interfaceVisitorContext- Parameters:
aPackage- The packagestereotypes- The stereotypes- Returns:
- The class elements
-
finish
public void finish()Description copied from interface:ClassWriterOutputVisitorFinish writing and flush any service entries to disk.- Specified by:
finishin interfaceClassWriterOutputVisitor
-
addGeneratedResource
Description copied from interface:VisitorContextSome 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- Specified by:
addGeneratedResourcein interfaceVisitorContext- Parameters:
resource- the relative path to add
-
getGeneratedResources
Description copied from interface:VisitorContextProvide 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.- Specified by:
getGeneratedResourcesin interfaceVisitorContext- Returns:
- a possibly empty collection of resource paths
-