com.faendir.kotlin.autodsl.ksp.KspCodeWriter.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of processor Show documentation
Show all versions of processor Show documentation
Auto-generates DSL for your Kotlin projects using annotations.
package com.faendir.kotlin.autodsl.ksp
import com.faendir.kotlin.autodsl.CodeWriter
import com.google.devtools.ksp.processing.CodeGenerator
import com.google.devtools.ksp.processing.Dependencies
import com.google.devtools.ksp.symbol.KSClassDeclaration
import com.squareup.kotlinpoet.FileSpec
class KspCodeWriter(private val codeGenerator: CodeGenerator) : CodeWriter {
override fun emit(source: KSClassDeclaration, fileSpec: FileSpec) =
codeGenerator.createNewFile(Dependencies(false, source.containingFile!!), fileSpec.packageName, fileSpec.name).writer().use { fileSpec.writeTo(it) }
}