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

com.faendir.kotlin.autodsl.kapt.KaptCodeWriter.kt Maven / Gradle / Ivy

There is a newer version: 2.4.0
Show newest version
package com.faendir.kotlin.autodsl.kapt

import com.faendir.kotlin.autodsl.CodeWriter
import com.squareup.kotlinpoet.FileSpec
import java.io.File
import javax.annotation.processing.ProcessingEnvironment
import javax.lang.model.element.Element
import javax.lang.model.element.TypeElement
import javax.tools.Diagnostic

class KaptCodeWriter(processingEnv: ProcessingEnvironment) : CodeWriter {
    private val dir : File = processingEnv.options["kapt.kotlin.generated"]?.let { File(it) }
        ?: run {
            processingEnv.messager.printMessage(Diagnostic.Kind.ERROR, "Can't find the target directory for generated Kotlin files. Are you using kapt?")
            throw IllegalStateException()
        }

    override fun emit(source: Type, fileSpec: FileSpec) = fileSpec.writeTo(dir)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy