Generate Js source map embed mode type
^KT-27301 In Progress
This commit is contained in:
@@ -37,6 +37,7 @@ fun generateKotlinGradleOptions(withPrinterToFile: (targetFile: File, Printer.()
|
|||||||
generateJvmTarget(apiSrcDir, withPrinterToFile)
|
generateJvmTarget(apiSrcDir, withPrinterToFile)
|
||||||
generateJsMainFunctionExecutionMode(apiSrcDir, withPrinterToFile)
|
generateJsMainFunctionExecutionMode(apiSrcDir, withPrinterToFile)
|
||||||
generateJsModuleKind(apiSrcDir, withPrinterToFile)
|
generateJsModuleKind(apiSrcDir, withPrinterToFile)
|
||||||
|
generateJsSourceMapEmbedMode(apiSrcDir, withPrinterToFile)
|
||||||
|
|
||||||
// common interface
|
// common interface
|
||||||
val commonInterfaceFqName = FqName("org.jetbrains.kotlin.gradle.dsl.KotlinCommonToolOptions")
|
val commonInterfaceFqName = FqName("org.jetbrains.kotlin.gradle.dsl.KotlinCommonToolOptions")
|
||||||
|
|||||||
@@ -72,3 +72,34 @@ internal fun generateJsModuleKind(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal fun generateJsSourceMapEmbedMode(
|
||||||
|
apiDir: File,
|
||||||
|
filePrinter: (targetFile: File, Printer.() -> Unit) -> Unit
|
||||||
|
) {
|
||||||
|
val jsSourceMapEmbedKindFqName = FqName("org.jetbrains.kotlin.gradle.dsl.JsSourceMapEmbedMode")
|
||||||
|
filePrinter(file(apiDir, jsSourceMapEmbedKindFqName)) {
|
||||||
|
generateDeclaration("enum class", jsSourceMapEmbedKindFqName, afterType = "(val mode: String)") {
|
||||||
|
val modes = hashMapOf(
|
||||||
|
K2JsArgumentConstants::SOURCE_MAP_SOURCE_CONTENT_ALWAYS.name to K2JsArgumentConstants.SOURCE_MAP_SOURCE_CONTENT_ALWAYS,
|
||||||
|
K2JsArgumentConstants::SOURCE_MAP_SOURCE_CONTENT_NEVER.name to K2JsArgumentConstants.SOURCE_MAP_SOURCE_CONTENT_NEVER,
|
||||||
|
K2JsArgumentConstants::SOURCE_MAP_SOURCE_CONTENT_INLINING.name to K2JsArgumentConstants.SOURCE_MAP_SOURCE_CONTENT_INLINING,
|
||||||
|
)
|
||||||
|
|
||||||
|
val lastIndex = modes.size - 1
|
||||||
|
modes.entries.forEachIndexed { index, mode ->
|
||||||
|
val lastChar = if (index == lastIndex) ";" else ","
|
||||||
|
println("${mode.key}(\"${mode.value}\")$lastChar")
|
||||||
|
}
|
||||||
|
|
||||||
|
println()
|
||||||
|
println("companion object {")
|
||||||
|
withIndent {
|
||||||
|
println("fun fromMode(mode: String): JsSourceMapEmbedMode =")
|
||||||
|
println(" JsSourceMapEmbedMode.values().firstOrNull { it.mode == mode }")
|
||||||
|
println(" ?: throw IllegalArgumentException(\"Unknown JS source map embed mode: ${'$'}mode\")")
|
||||||
|
}
|
||||||
|
println("}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
+16
@@ -0,0 +1,16 @@
|
|||||||
|
// DO NOT EDIT MANUALLY!
|
||||||
|
// Generated by org/jetbrains/kotlin/generators/arguments/GenerateGradleOptions.kt
|
||||||
|
package org.jetbrains.kotlin.gradle.dsl
|
||||||
|
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
|
enum class JsSourceMapEmbedMode (val mode: String) {
|
||||||
|
SOURCE_MAP_SOURCE_CONTENT_INLINING("inlining"),
|
||||||
|
SOURCE_MAP_SOURCE_CONTENT_NEVER("never"),
|
||||||
|
SOURCE_MAP_SOURCE_CONTENT_ALWAYS("always");
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun fromMode(mode: String): JsSourceMapEmbedMode =
|
||||||
|
JsSourceMapEmbedMode.values().firstOrNull { it.mode == mode }
|
||||||
|
?: throw IllegalArgumentException("Unknown JS source map embed mode: $mode")
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user