Class PluginUtils
java.lang.Object
io.micronaut.sourcegen.generator.visitors.PluginUtils
Common utility methods for plugin generation.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final record
Configuration for a plugin parameter. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic 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.static @NonNull PluginUtils.ParameterConfig
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.
-
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 withPluginTask
.- 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 typeproperty
- The property representing the parametertype
- 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 elementname
- The name to use for the local variablearguments
- The arguments provided for type creation corresponding to propertiesstatements
- 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 withPluginTask
methodName
- The name of the method annotated withPluginTaskExecutable
arguments
- The prepared arguments for the task by name- Returns:
- The statements to execute the task method
-