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

jvmMain.community.flock.wirespec.plugin.FileUtil.kt Maven / Gradle / Ivy

There is a newer version: 0.10.17
Show newest version
package community.flock.wirespec.plugin

import community.flock.wirespec.compiler.core.emit.common.Emitted
import community.flock.wirespec.compiler.core.emit.shared.Shared
import community.flock.wirespec.plugin.Language.Wirespec
import java.io.File

fun Emitted.writeToFiles(
    output: File,
    packageName: PackageName?,
    shared: Shared?,
    fileName: String? = null,
    ext: FileExtension
) {
    if (shared != null) {
        val sharedPackageName = PackageName(shared.packageString)
        writeFile(output, sharedPackageName, Wirespec.name, ext).writeText(shared.source)
    }
    writeFile(output, packageName, fileName ?: typeName, ext).writeText(result)

}

private fun writeFile(output: File, packageName: PackageName?, fileName: String, ext: FileExtension) =
    output
        .resolve(packageName.toDirectory())
        .apply { mkdirs()}
        .resolve("$fileName.${ext.value}")




© 2015 - 2024 Weber Informatics LLC | Privacy Policy