All Downloads are FREE. Search and download functionalities are using the official Maven repository.

tools.samt.api.plugin.Generator.kt Maven / Gradle / Ivy

The newest version!
package tools.samt.api.plugin

import tools.samt.api.types.SamtPackage

/**
 * A code generator.
 * This interface is intended to be implemented by a code generator, for example Kotlin-Ktor.
 */
interface Generator {
    /**
     * The name of the generator, used to identify it in the configuration
     */
    val name: String

    /**
     * Generate code for the given packages
     * @param generatorParams The parameters for the generator
     * @return A list of generated files, which will be written to disk
     */
    fun generate(generatorParams: GeneratorParams): List
}

/**
 * This class represents a file generated by a [Generator].
 */
data class CodegenFile(val filepath: String, val source: String)

/**
 * The parameters for a [Generator].
 */
interface GeneratorParams {
    /**
     * The packages to generate code for, includes all SAMT subpackages
     */
    val packages: List

    /**
     * The configuration for the generator as specified in the SAMT configuration
     */
    val options: Map

    /**
     * Report an error
     * @param message The error message
     */
    fun reportError(message: String)

    /**
     * Report a warning
     * @param message The warning message
     */
    fun reportWarning(message: String)

    /**
     * Report an info message
     * @param message The info message
     */
    fun reportInfo(message: String)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy