Class PluginUtils

java.lang.Object
io.micronaut.sourcegen.generator.visitors.PluginUtils

@Internal public class PluginUtils extends Object
Common utility methods for plugin generation.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final record 
    Configuration for a plugin parameter.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static io.micronaut.sourcegen.model.StatementDef
    executeTaskMethod(io.micronaut.inject.ast.ClassElement source, String methodName, Map<String,io.micronaut.sourcegen.model.ExpressionDef> arguments)
    A common method for executing the main task executable.
    getParameterConfig(JavadocUtils.TypeJavadoc sourceJavadoc, @NonNull io.micronaut.inject.ast.PropertyElement property, @Nullable io.micronaut.sourcegen.model.TypeDef type)
    Get configuration for a plugin parameter.
    static io.micronaut.inject.ast.MethodElement
    getTaskExecutable(io.micronaut.inject.ast.ClassElement source)
    Validate and get the method name of the task executable.
    static io.micronaut.sourcegen.model.VariableDef.Local
    instantiateType(io.micronaut.inject.ast.ClassElement element, String name, Map<String,io.micronaut.sourcegen.model.ExpressionDef> arguments, List<io.micronaut.sourcegen.model.StatementDef> statements)
    Instantiate a type.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • PluginUtils

      public PluginUtils()
  • Method Details

    • getTaskExecutable

      public static io.micronaut.inject.ast.MethodElement getTaskExecutable(io.micronaut.inject.ast.ClassElement source)
      Validate and get the method name of the task executable.
      Parameters:
      source - The source element annotated with PluginTask.
      Returns:
      The method name
    • getParameterConfig

      @NonNull public static @NonNull PluginUtils.ParameterConfig getParameterConfig(@NonNull JavadocUtils.TypeJavadoc sourceJavadoc, @NonNull @NonNull io.micronaut.inject.ast.PropertyElement property, @Nullable @Nullable io.micronaut.sourcegen.model.TypeDef type)
      Get configuration for a plugin parameter.
      Parameters:
      sourceJavadoc - The javadoc for the task type
      property - The property representing the parameter
      type - The type to use for parameter
      Returns:
      THe configuration
    • instantiateType

      public static io.micronaut.sourcegen.model.VariableDef.Local instantiateType(io.micronaut.inject.ast.ClassElement element, String name, Map<String,io.micronaut.sourcegen.model.ExpressionDef> arguments, List<io.micronaut.sourcegen.model.StatementDef> statements)
      Instantiate a type.
      Parameters:
      element - The class element
      name - The name to use for the local variable
      arguments - The arguments provided for type creation corresponding to properties
      statements - A mutable statements list
      Returns:
      The local variable representing the instantiated type
    • executeTaskMethod

      public static io.micronaut.sourcegen.model.StatementDef executeTaskMethod(io.micronaut.inject.ast.ClassElement source, String methodName, Map<String,io.micronaut.sourcegen.model.ExpressionDef> arguments)
      A common method for executing the main task executable.
      Parameters:
      source - The source annotated with PluginTask
      methodName - The name of the method annotated with PluginTaskExecutable
      arguments - The prepared arguments for the task by name
      Returns:
      The statements to execute the task method