Class PythonAnnotationProcessor

All Implemented Interfaces:
AutoCloseable, Processor

@SupportedAnnotationTypes("io.micronaut.context.python.annotation.PythonApplication") public class PythonAnnotationProcessor extends AbstractInjectAnnotationProcessor implements AutoCloseable
Annotation processor for io.micronaut.context.python.annotation.PythonApplication that enables Python AST processing during Java compilation.
Since:
5.2.0
Author:
Micronaut
  • Field Details

  • Constructor Details

    • PythonAnnotationProcessor

      public PythonAnnotationProcessor()
  • Method Details

    • setClassElementCallback

      public void setClassElementCallback(Consumer<ClassElement> callback)
      Set the callback to be invoked for each class element created during processing. This is primarily used for testing purposes.
      Parameters:
      callback - The callback function
    • setPythonSourceVisitors

      public void setPythonSourceVisitors(List<PythonSourceVisitor> pythonSourceVisitors)
      Sets visitors for Python source metadata in this compilation.
      Parameters:
      pythonSourceVisitors - the visitors
    • setCompilePythonBytecode

      public void setCompilePythonBytecode(boolean compilePythonBytecode)
      Set whether generated Python VFS resources should include optional GraalPy bytecode caches. Application sources that require runtime compatibility transformations may include a cache regardless of this setting so that the original source remains available for debugging.
      Parameters:
      compilePythonBytecode - Whether optional bytecode caches should be emitted
      Since:
      5.2.0
    • setIncrementalSources

      @Internal public void setIncrementalSources(Set<String> incrementalSources)
      Restricts isolating visitors and bean generation to affected Python sources.
      Parameters:
      incrementalSources - The affected absolute source paths, or null for all sources
    • setProcessAggregatingVisitors

      @Internal public void setProcessAggregatingVisitors(boolean processAggregatingVisitors)
      Sets whether aggregating Python type visitors should run.
      Parameters:
      processAggregatingVisitors - Whether aggregating visitors should run
    • setOutputDirectory

      @Internal public void setOutputDirectory(Path outputDirectory)
      Sets the class output directory used to reuse unchanged generated Python resources.
      Parameters:
      outputDirectory - The class output directory, or null for in-memory compilation
    • setProcessingSession

      @Internal public void setProcessingSession(PythonProcessingSession processingSession)
      Sets a session that owns the GraalPy context across compiler invocations.
      Parameters:
      processingSession - The reusable processing session
    • init

      public void init(ProcessingEnvironment processingEnv)
      Specified by:
      init in interface Processor
      Overrides:
      init in class AbstractInjectAnnotationProcessor
    • close

      public void close() throws Exception
      Specified by:
      close in interface AutoCloseable
      Throws:
      Exception
    • process

      public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv)
      Specified by:
      process in interface Processor
      Specified by:
      process in class AbstractProcessor
    • setClassLoader

      public void setClassLoader(ClassLoader classLoader)
      Sets the class loader used for in-memory compiler execution.
      Parameters:
      classLoader - The class loader