From 0254c2fc982a82ac5b7e8e0faba81287e9adecce Mon Sep 17 00:00:00 2001 From: nikpachoo Date: Mon, 4 Aug 2025 17:58:46 +0200 Subject: [PATCH 01/20] Updated to the latest Kotlin dev version --- gradle/libs.versions.toml | 2 +- .../20eb53855eee7f85c7c27851f05b46e4.2.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index a98b38184..7115154ce 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,5 +1,5 @@ [versions] -kotlin = "2.2.20" +kotlin = "2.3.0-dev-2445" kotlinIdeVersion = "1.9.20-506" kotlinIdeVersionWithSuffix = "231-1.9.20-506-IJ8109.175" spring-boot = "3.5.6" diff --git a/src/test/resources/test-compile-output/jvm/kotlin-web-site/kotlin-tour-intermediate-null-safety/20eb53855eee7f85c7c27851f05b46e4.2.json b/src/test/resources/test-compile-output/jvm/kotlin-web-site/kotlin-tour-intermediate-null-safety/20eb53855eee7f85c7c27851f05b46e4.2.json index 4ec4182dd..25cefcb12 100644 --- a/src/test/resources/test-compile-output/jvm/kotlin-web-site/kotlin-tour-intermediate-null-safety/20eb53855eee7f85c7c27851f05b46e4.2.json +++ b/src/test/resources/test-compile-output/jvm/kotlin-web-site/kotlin-tour-intermediate-null-safety/20eb53855eee7f85c7c27851f05b46e4.2.json @@ -1 +1 @@ -{"errors":{"File.kt":[]},"exception":null,"jvmByteCode":null,"text":"null"} \ No newline at end of file +{"errors":{"File.kt":[{"interval":{"start":{"line":3,"ch":14},"end":{"line":3,"ch":24}},"message":"No cast needed.","severity":"WARNING","className":"WARNING"}]},"exception":null,"jvmByteCode":null,"text":"null"} \ No newline at end of file From 845cc9eb9cbdebeab35fe03ca9019de91e084f54 Mon Sep 17 00:00:00 2001 From: Dmitrii Krasnov Date: Thu, 21 Aug 2025 10:57:56 +0200 Subject: [PATCH 02/20] KT-80320 Removed -Wextra and -Xuse-fir-experimental-checkers CLI options from the compiler server build --- buildSrc/src/main/kotlin/base-kotlin-jvm-conventions.gradle.kts | 2 -- 1 file changed, 2 deletions(-) diff --git a/buildSrc/src/main/kotlin/base-kotlin-jvm-conventions.gradle.kts b/buildSrc/src/main/kotlin/base-kotlin-jvm-conventions.gradle.kts index 12345bbe1..f0052a48f 100644 --- a/buildSrc/src/main/kotlin/base-kotlin-jvm-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/base-kotlin-jvm-conventions.gradle.kts @@ -33,11 +33,9 @@ tasks.withType().configureEach freeCompilerArgs.addAll( "-Xreport-all-warnings", "-Xrender-internal-diagnostic-names", - "-Xuse-fir-experimental-checkers" ) allWarningsAsErrors.set(false) - extraWarnings.set(true) // Adding additional cli options for testing purpose project.providers.gradleProperty("kotlin_additional_cli_options").orNull?.let { options -> From 4d44bfed50a1461ae287b73c808f0b38c006754c Mon Sep 17 00:00:00 2001 From: Dmitrii Krasnov Date: Thu, 21 Aug 2025 10:59:34 +0200 Subject: [PATCH 03/20] Updated kotlin version to the latest dev --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 7115154ce..46e6b7212 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,5 +1,5 @@ [versions] -kotlin = "2.3.0-dev-2445" +kotlin = "2.3.0-dev-4315" kotlinIdeVersion = "1.9.20-506" kotlinIdeVersionWithSuffix = "231-1.9.20-506-IJ8109.175" spring-boot = "3.5.6" From 5d3d2bc43a5b994156d2b4a7e2fde6bb7f1771d1 Mon Sep 17 00:00:00 2001 From: berezinant Date: Tue, 2 Sep 2025 18:10:45 +0200 Subject: [PATCH 04/20] Updated kotlin version to the latest dev --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 46e6b7212..5c3a67d24 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,5 +1,5 @@ [versions] -kotlin = "2.3.0-dev-4315" +kotlin = "2.3.0-dev-5897" kotlinIdeVersion = "1.9.20-506" kotlinIdeVersionWithSuffix = "231-1.9.20-506-IJ8109.175" spring-boot = "3.5.6" From 41e3fb99c6525002358b017c111d812153233c40 Mon Sep 17 00:00:00 2001 From: nikpachoo Date: Tue, 9 Sep 2025 14:44:08 +0200 Subject: [PATCH 05/20] chore: update Kotlin to 2.3.0-dev-6977 --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 5c3a67d24..fa2ddb414 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,5 +1,5 @@ [versions] -kotlin = "2.3.0-dev-5897" +kotlin = "2.3.0-dev-6977" kotlinIdeVersion = "1.9.20-506" kotlinIdeVersionWithSuffix = "231-1.9.20-506-IJ8109.175" spring-boot = "3.5.6" From 30df5f95fe7383d55994a6c8bd983db0699424db Mon Sep 17 00:00:00 2001 From: nikpachoo Date: Tue, 9 Sep 2025 15:31:20 +0200 Subject: [PATCH 06/20] fix: update test output --- .../whatsnew14/daa86b4d09879958dd2223f7a0b62b91.4.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/resources/test-compile-output/jvm/kotlin-web-site/whatsnew14/daa86b4d09879958dd2223f7a0b62b91.4.json b/src/test/resources/test-compile-output/jvm/kotlin-web-site/whatsnew14/daa86b4d09879958dd2223f7a0b62b91.4.json index bcfcf4608..60251433e 100644 --- a/src/test/resources/test-compile-output/jvm/kotlin-web-site/whatsnew14/daa86b4d09879958dd2223f7a0b62b91.4.json +++ b/src/test/resources/test-compile-output/jvm/kotlin-web-site/whatsnew14/daa86b4d09879958dd2223f7a0b62b91.4.json @@ -1 +1 @@ -{"errors":{"File.kt":[{"interval":{"start":{"line":21,"ch":14},"end":{"line":21,"ch":18}},"message":"Call uses reflection API which is not found in compilation classpath. Make sure you have kotlin-reflect.jar in the classpath.","severity":"WARNING","className":"WARNING"}]},"exception":{"message":"Kotlin reflection implementation is not found at runtime. Make sure you have kotlin-reflect.jar in the classpath","fullName":"kotlin.jvm.KotlinReflectionNotSupportedError","stackTrace":[{"className":"kotlin.jvm.internal.CallableReference","methodName":"getReflected","fileName":"CallableReference.java","lineNumber":98},{"className":"kotlin.jvm.internal.FunctionReference","methodName":"getReflected","fileName":"FunctionReference.java","lineNumber":63},{"className":"kotlin.jvm.internal.FunctionReference","methodName":"getReflected","fileName":"FunctionReference.java","lineNumber":12}],"cause":null,"localizedMessage":null},"jvmByteCode":null,"text":""} \ No newline at end of file +{"errors":{"File.kt":[{"interval":{"start":{"line":21,"ch":14},"end":{"line":21,"ch":18}},"message":"Call uses reflection API which is not found in compilation classpath. Make sure you have kotlin-reflect.jar in the classpath.","severity":"WARNING","className":"WARNING"}]},"exception":{"message":"Kotlin reflection implementation is not found at runtime. Make sure you have kotlin-reflect.jar in the classpath","fullName":"kotlin.jvm.KotlinReflectionNotSupportedError","stackTrace":[{"className":"kotlin.jvm.internal.CallableReference","methodName":"getReflected","fileName":"CallableReference.java","lineNumber":98},{"className":"kotlin.jvm.internal.FunctionReference","methodName":"getReflected","fileName":"FunctionReference.java","lineNumber":39},{"className":"kotlin.jvm.internal.FunctionReference","methodName":"getReflected","fileName":"FunctionReference.java","lineNumber":12}],"cause":null,"localizedMessage":null},"jvmByteCode":null,"text":""} \ No newline at end of file From 919824b44b3af628cef354e0ec6dcc9b3de42b90 Mon Sep 17 00:00:00 2001 From: Dmitrii Krasnov Date: Tue, 30 Sep 2025 14:17:46 +0200 Subject: [PATCH 07/20] KTL-3738: Updated kotlin dev version --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index fa2ddb414..a335a523e 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,5 +1,5 @@ [versions] -kotlin = "2.3.0-dev-6977" +kotlin = "2.3.0-dev-9317" kotlinIdeVersion = "1.9.20-506" kotlinIdeVersionWithSuffix = "231-1.9.20-506-IJ8109.175" spring-boot = "3.5.6" From 376770e315064cc8f0d94e68ac14bebcccea8d52 Mon Sep 17 00:00:00 2001 From: Dmitrii Krasnov Date: Tue, 30 Sep 2025 14:17:55 +0200 Subject: [PATCH 08/20] KTL-3738: Fixed compilation after js compiler updates in kotlin repo --- common/src/main/kotlin/component/KotlinEnvironment.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/main/kotlin/component/KotlinEnvironment.kt b/common/src/main/kotlin/component/KotlinEnvironment.kt index 96b0ff06a..f51a24f46 100644 --- a/common/src/main/kotlin/component/KotlinEnvironment.kt +++ b/common/src/main/kotlin/component/KotlinEnvironment.kt @@ -16,10 +16,10 @@ import org.jetbrains.kotlin.config.CompilerConfiguration import org.jetbrains.kotlin.config.JVMConfigurationKeys import org.jetbrains.kotlin.config.languageVersionSettings import org.jetbrains.kotlin.js.config.JSConfigurationKeys +import org.jetbrains.kotlin.js.config.ModuleKind import org.jetbrains.kotlin.library.impl.isKotlinLibrary import org.jetbrains.kotlin.serialization.js.JsModuleDescriptor import org.jetbrains.kotlin.serialization.js.KotlinJavascriptSerializationUtil -import org.jetbrains.kotlin.serialization.js.ModuleKind import org.jetbrains.kotlin.utils.KotlinJavascriptMetadataUtils import org.jetbrains.kotlin.wasm.config.WasmConfigurationKeys import java.io.File From 0744de2c86b95433e3091413801f44466d302262 Mon Sep 17 00:00:00 2001 From: Dmitrii Krasnov Date: Thu, 7 Aug 2025 09:57:29 +0200 Subject: [PATCH 09/20] KTL-1220: Removed indexation module and kotlin idea dependencies --- Dockerfile | 4 - ...server-version-catalog.settings.gradle.kts | 4 - build.gradle.kts | 25 +- .../base-kotlin-jvm-conventions.gradle.kts | 2 + common/build.gradle.kts | 2 - .../kotlin/component/KotlinEnvironment.kt | 98 +---- dependencies/build.gradle.kts | 11 +- gradle.properties | 4 - gradle/libs.versions.toml | 10 - indexation/build.gradle.kts | 54 --- .../src/main/kotlin/DescriptorsUtils.kt | 99 ----- .../src/main/kotlin/IndexationBuilder.kt | 14 - .../src/main/kotlin/JvmIndexationBuilder.kt | 31 -- .../kotlin/KotlinEnvironmentConfiguration.kt | 50 --- indexation/src/main/kotlin/Main.kt | 44 -- .../src/main/kotlin/WebIndexationBuilder.kt | 59 --- settings.gradle.kts | 1 - .../compiler/server/compiler/KotlinFile.kt | 53 --- .../server/compiler/KotlinPlatform.kt | 7 - .../server/compiler/KotlinResolutionFacade.kt | 67 --- .../server/compiler/components/CliUtils.kt | 15 +- .../compiler/components/CompletionProvider.kt | 295 -------------- .../compiler/components/ErrorAnalyzer.kt | 381 ------------------ .../compiler/components/IndexationProvider.kt | 74 ---- .../compiler/components/KotlinCompiler.kt | 303 +++++++------- .../components/KotlinToJSTranslator.kt | 348 ++++++++-------- .../server/executor/ExecutorMessages.kt | 1 - .../com/compiler/server/model/Analysis.kt | 21 - .../com/compiler/server/model/Project.kt | 5 - .../compiler/server/model/ProjectSeveriry.kt | 1 - .../server/service/KotlinProjectExecutor.kt | 203 +++++----- 31 files changed, 449 insertions(+), 1837 deletions(-) delete mode 100644 indexation/build.gradle.kts delete mode 100644 indexation/src/main/kotlin/DescriptorsUtils.kt delete mode 100644 indexation/src/main/kotlin/IndexationBuilder.kt delete mode 100644 indexation/src/main/kotlin/JvmIndexationBuilder.kt delete mode 100644 indexation/src/main/kotlin/KotlinEnvironmentConfiguration.kt delete mode 100644 indexation/src/main/kotlin/Main.kt delete mode 100644 indexation/src/main/kotlin/WebIndexationBuilder.kt delete mode 100644 src/main/kotlin/com/compiler/server/compiler/KotlinFile.kt delete mode 100644 src/main/kotlin/com/compiler/server/compiler/KotlinPlatform.kt delete mode 100644 src/main/kotlin/com/compiler/server/compiler/KotlinResolutionFacade.kt delete mode 100644 src/main/kotlin/com/compiler/server/compiler/components/CompletionProvider.kt delete mode 100644 src/main/kotlin/com/compiler/server/compiler/components/ErrorAnalyzer.kt delete mode 100644 src/main/kotlin/com/compiler/server/compiler/components/IndexationProvider.kt delete mode 100644 src/main/kotlin/com/compiler/server/model/Analysis.kt diff --git a/Dockerfile b/Dockerfile index 0e63828f2..d1d2bd081 100644 --- a/Dockerfile +++ b/Dockerfile @@ -36,10 +36,6 @@ COPY --from=build /kotlin-compiler-server/${KOTLIN_LIB_WASM} /kotlin-compiler-se COPY --from=build /kotlin-compiler-server/${KOTLIN_LIB_COMPOSE_WASM} /kotlin-compiler-server/${KOTLIN_LIB_COMPOSE_WASM} COPY --from=build /kotlin-compiler-server/${KOTLIN_COMPOSE_WASM_COMPILER_PLUGINS} /kotlin-compiler-server/${KOTLIN_COMPOSE_WASM_COMPILER_PLUGINS} COPY --from=build /kotlin-compiler-server/executor.policy /kotlin-compiler-server/ -COPY --from=build /kotlin-compiler-server/indexes.json /kotlin-compiler-server/ -COPY --from=build /kotlin-compiler-server/indexesJs.json /kotlin-compiler-server/ -COPY --from=build /kotlin-compiler-server/indexesWasm.json /kotlin-compiler-server/ -COPY --from=build /kotlin-compiler-server/indexesComposeWasm.json /kotlin-compiler-server/ ENV PORT=8080 diff --git a/build-settings-logic/src/main/kotlin/kotlin-compiler-server-version-catalog.settings.gradle.kts b/build-settings-logic/src/main/kotlin/kotlin-compiler-server-version-catalog.settings.gradle.kts index cf3c54a94..0c4fcab6b 100644 --- a/build-settings-logic/src/main/kotlin/kotlin-compiler-server-version-catalog.settings.gradle.kts +++ b/build-settings-logic/src/main/kotlin/kotlin-compiler-server-version-catalog.settings.gradle.kts @@ -34,12 +34,8 @@ dependencyResolutionManagement { maven("https://repo.spring.io/snapshot") maven("https://repo.spring.io/milestone") - maven("https://redirector.kotlinlang.org/maven/kotlin-ide") maven("https://redirector.kotlinlang.org/maven/dev") - maven("https://cache-redirector.jetbrains.com/jetbrains.bintray.com/intellij-third-party-dependencies") - maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-ide-plugin-dependencies") maven("https://www.myget.org/F/rd-snapshots/maven/") - maven("https://redirector.kotlinlang.org/maven/kotlin-ide") maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/bootstrap") maven("https://maven.pkg.jetbrains.space/kotlin/p/wasm/experimental") maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") diff --git a/build.gradle.kts b/build.gradle.kts index 727e8e698..a09ef7714 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -25,9 +25,6 @@ allprojects { dependencies { dependencies { implementation(libs.jackson.module.kotlin) - implementation(libs.kotlin.idea) { - isTransitive = false - } } } } @@ -46,17 +43,13 @@ dependencies { implementation(libs.aws.springboot.container) implementation(libs.junit) implementation(libs.logback.logstash.encoder) - implementation(libs.intellij.trove4j) implementation(libs.kotlin.reflect) implementation(libs.bundles.kotlin.stdlib) implementation(libs.kotlin.compiler) implementation(libs.kotlin.script.runtime) - implementation(libs.kotlin.compiler.ide) { - isTransitive = false - } - implementation(libs.kotlin.core) implementation(project(":executors", configuration = "default")) implementation(project(":common", configuration = "default")) + implementation(project(":dependencies")) testImplementation(libs.kotlin.test) testImplementation("org.springframework.boot:spring-boot-starter-test") { @@ -79,10 +72,6 @@ fun generateProperties(prefix: String = "") = """ # this file is autogenerated by build.gradle.kts kotlin.version=${kotlinVersion} policy.file=${prefix + policy} - indexes.file=${prefix + indexes} - indexesJs.file=${prefix + indexesJs} - indexesWasm.file=${prefix + indexesWasm} - indexesComposeWasm.file=${prefix + indexesComposeWasm} libraries.folder.jvm=${prefix + libJVM} libraries.folder.js=${prefix + libJS} libraries.folder.wasm=${prefix + libWasm} @@ -97,10 +86,12 @@ fun generateProperties(prefix: String = "") = """ tasks.withType { compilerOptions { - freeCompilerArgs.set(listOf("-Xjsr305=strict")) + freeCompilerArgs.addAll( + "-Xjsr305=strict", + ) + } dependsOn(":executors:jar") - dependsOn(":indexation:run") buildPropertyFile() } println("Using Kotlin compiler ${libs.versions.kotlin.get()}") @@ -123,15 +114,11 @@ val buildLambda by tasks.creating(Zip::class) { } } from(policy) - from(indexes) - from(indexesJs) - from(indexesWasm) - from(indexesComposeWasm) from(libJSFolder) { into(libJS) } from(libWasmFolder) { into(libWasm) } from(libComposeWasmFolder) { into(libComposeWasm) } from(libJVMFolder) { into(libJVM) } - from(compilerPluginsForJVMFolder) {into(compilerPluginsForJVM)} + from(compilerPluginsForJVMFolder) { into(compilerPluginsForJVM) } from(libComposeWasmCompilerPluginsFolder) { into(libComposeWasmCompilerPlugins) } into("lib") { from(configurations.compileClasspath) { exclude("tomcat-embed-*") } diff --git a/buildSrc/src/main/kotlin/base-kotlin-jvm-conventions.gradle.kts b/buildSrc/src/main/kotlin/base-kotlin-jvm-conventions.gradle.kts index f0052a48f..62f960ada 100644 --- a/buildSrc/src/main/kotlin/base-kotlin-jvm-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/base-kotlin-jvm-conventions.gradle.kts @@ -33,6 +33,8 @@ tasks.withType().configureEach freeCompilerArgs.addAll( "-Xreport-all-warnings", "-Xrender-internal-diagnostic-names", + "-Xuse-fir-experimental-checkers", + "-Xannotation-default-target=param-property" ) allWarningsAsErrors.set(false) diff --git a/common/build.gradle.kts b/common/build.gradle.kts index fc15358d0..8ee7fd2b7 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -4,6 +4,4 @@ plugins { dependencies { implementation(libs.kotlin.compiler) - implementation(libs.kotlin.gradle.plugin.idea) - implementation(libs.kotlin.base.fe10.analysis) } diff --git a/common/src/main/kotlin/component/KotlinEnvironment.kt b/common/src/main/kotlin/component/KotlinEnvironment.kt index f51a24f46..df1c65cc2 100644 --- a/common/src/main/kotlin/component/KotlinEnvironment.kt +++ b/common/src/main/kotlin/component/KotlinEnvironment.kt @@ -1,27 +1,6 @@ package component -import com.intellij.openapi.util.Disposer -import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments -import org.jetbrains.kotlin.cli.common.arguments.parseCommandLineArguments -import org.jetbrains.kotlin.cli.common.arguments.toLanguageVersionSettings -import org.jetbrains.kotlin.cli.common.messages.MessageCollector -import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles -import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment -import org.jetbrains.kotlin.cli.jvm.config.addJvmClasspathRoots -import org.jetbrains.kotlin.cli.jvm.config.configureJdkClasspathRoots -import org.jetbrains.kotlin.cli.jvm.configureAdvancedJvmOptions -import org.jetbrains.kotlin.cli.jvm.plugins.PluginCliParser -import org.jetbrains.kotlin.config.CommonConfigurationKeys -import org.jetbrains.kotlin.config.CompilerConfiguration -import org.jetbrains.kotlin.config.JVMConfigurationKeys -import org.jetbrains.kotlin.config.languageVersionSettings -import org.jetbrains.kotlin.js.config.JSConfigurationKeys -import org.jetbrains.kotlin.js.config.ModuleKind import org.jetbrains.kotlin.library.impl.isKotlinLibrary -import org.jetbrains.kotlin.serialization.js.JsModuleDescriptor -import org.jetbrains.kotlin.serialization.js.KotlinJavascriptSerializationUtil -import org.jetbrains.kotlin.utils.KotlinJavascriptMetadataUtils -import org.jetbrains.kotlin.wasm.config.WasmConfigurationKeys import java.io.File // NOTE: if new class paths are added, please add them to `JavaExec` task's inputs in build.gradle.kts as well @@ -60,14 +39,6 @@ class KotlinEnvironment( ) } - val JS_METADATA_CACHE = - additionalJsClasspath.flatMap { - KotlinJavascriptMetadataUtils.loadMetadata(it.absolutePath).map { metadata -> - val parts = KotlinJavascriptSerializationUtil.readModuleAsProto(metadata.body, metadata.version) - JsModuleDescriptor(metadata.moduleName, parts.kind, parts.importedModules, parts) - } - } - val JS_LIBRARIES = additionalJsClasspath .map { it.absolutePath } .filter { isKotlinLibrary(File(it)) } @@ -83,70 +54,9 @@ class KotlinEnvironment( val composeWasmCompilerPluginOptions = composeWasmCompilerPluginsOptions .map { "plugin:${it.id}:${it.option}=${it.value}" } - @Synchronized - fun environment(f: (KotlinCoreEnvironment) -> T): T { - return f(environment) - } - - private val configuration = createConfiguration() - val jsConfiguration: CompilerConfiguration = configuration.copy().apply { - put(CommonConfigurationKeys.MODULE_NAME, "playground") - put(JSConfigurationKeys.MODULE_KIND, ModuleKind.PLAIN) - put(JSConfigurationKeys.LIBRARIES, JS_LIBRARIES) - } - - val wasmConfiguration: CompilerConfiguration = configuration.copy().apply { - put(CommonConfigurationKeys.MODULE_NAME, "playground") - put(JSConfigurationKeys.LIBRARIES, WASM_LIBRARIES) - put(WasmConfigurationKeys.WASM_ENABLE_ARRAY_RANGE_CHECKS, false) - put(WasmConfigurationKeys.WASM_ENABLE_ASSERTS, false) - } - - val rootDisposable = Disposer.newDisposable() - - val composeWasmConfiguration: CompilerConfiguration = configuration.copy().apply { - put(CommonConfigurationKeys.MODULE_NAME, "playground") - put(JSConfigurationKeys.LIBRARIES, COMPOSE_WASM_LIBRARIES) - put(WasmConfigurationKeys.WASM_ENABLE_ARRAY_RANGE_CHECKS, false) - put(WasmConfigurationKeys.WASM_ENABLE_ASSERTS, false) - - PluginCliParser.loadPluginsSafe( - COMPOSE_WASM_COMPILER_PLUGINS, - composeWasmCompilerPluginOptions, - emptyList(), - this, - rootDisposable - ) - } - - private val environment = KotlinCoreEnvironment.createForProduction( - projectDisposable = rootDisposable, - configuration = configuration.copy(), - configFiles = EnvironmentConfigFiles.JVM_CONFIG_FILES - ) - - private fun createConfiguration(): CompilerConfiguration { - val arguments = K2JVMCompilerArguments() - parseCommandLineArguments(additionalCompilerArguments, arguments) - return CompilerConfiguration().apply { - addJvmClasspathRoots(classpath.filter { it.exists() && it.isFile && it.extension == "jar" }) - val messageCollector = MessageCollector.NONE - put(CommonConfigurationKeys.MESSAGE_COLLECTOR_KEY, messageCollector) - put(CommonConfigurationKeys.MODULE_NAME, "web-module") - put(JSConfigurationKeys.PROPERTY_LAZY_INITIALIZATION, true) - - languageVersionSettings = arguments.toLanguageVersionSettings(messageCollector) - - // it uses languageVersionSettings that was set above - configureAdvancedJvmOptions(arguments) - put(JVMConfigurationKeys.DO_NOT_CLEAR_BINDING_CONTEXT, true) - - configureJdkClasspathRoots() - val jdkHome = get(JVMConfigurationKeys.JDK_HOME) - if (jdkHome == null) { - val javaHome = File(System.getProperty("java.home")) - put(JVMConfigurationKeys.JDK_HOME, javaHome) - } + @Synchronized + fun synchronize(f: () -> T): T { + return f() } - } + } diff --git a/dependencies/build.gradle.kts b/dependencies/build.gradle.kts index fed600abd..51f6cce57 100644 --- a/dependencies/build.gradle.kts +++ b/dependencies/build.gradle.kts @@ -68,8 +68,6 @@ val composeWasmCompilerPlugins: Configuration by configurations.creating { isTransitive = false } -val composeRuntimeVersion = "1.6.0" - val copyDependencies by tasks.creating(Copy::class) { from(kotlinDependency) into(libJVMFolder) @@ -125,4 +123,13 @@ dependencies { kotlinComposeWasmDependency(libs.bundles.compose) composeWasmCompilerPlugins(libs.kotlin.compose.compiler.plugin) +} + +project.tasks.jar.configure { + dependsOn(copyDependencies) + dependsOn(copyCompilerPluginDependencies) + dependsOn(copyJSDependencies) + dependsOn(copyWasmDependencies) + dependsOn(copyComposeWasmDependencies) + dependsOn(copyComposeWasmCompilerPlugins) } \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 116440fc1..b99c1114c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1,3 @@ systemProp.policy=executor.policy -systemProp.indexes=indexes.json -systemProp.indexesJs=indexesJs.json -systemProp.indexesWasm=indexesWasm.json -systemProp.indexesComposeWasm=indexesComposeWasm.json org.gradle.configuration-cache=true \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index a335a523e..cd15444dc 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,14 +1,11 @@ [versions] kotlin = "2.3.0-dev-9317" -kotlinIdeVersion = "1.9.20-506" -kotlinIdeVersionWithSuffix = "231-1.9.20-506-IJ8109.175" spring-boot = "3.5.6" spring-dependency-managment = "1.1.7" springdoc = "2.8.13" aws-serverless-java-container-springboot3 = "2.1.5" junit = "4.13.2" logstash-logback-encoder = "8.1" -trove4j = "1.0.20221201" kotlinx-coroutines = "1.7.3" kotlinx-coroutines-test = "1.6.4" kotlinx-datetime = "0.7.1-0.6.x-compat" @@ -33,13 +30,8 @@ kotlin-test-junit = { group = "org.jetbrains.kotlin", name = "kotlin-test-junit" kotlin-compiler = { group = "org.jetbrains.kotlin", name = "kotlin-compiler", version.ref = "kotlin" } kotlin-script-runtime = { group = "org.jetbrains.kotlin", name = "kotlin-script-runtime", version.ref = "kotlin" } kotlin-gradlePlugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin" } -kotlin-gradle-plugin-idea = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin-idea", version.ref = "kotlin" } kotlin-dom-api-compat = { group = "org.jetbrains.kotlin", name = "kotlin-dom-api-compat", version.ref = "kotlin" } kotlin-compose-compiler-plugin = { group = "org.jetbrains.kotlin", name = "kotlin-compose-compiler-plugin", version.ref = "kotlin" } -kotlin-base-fe10-analysis = { group = "org.jetbrains.kotlin", name = "base-fe10-analysis", version.ref = "kotlinIdeVersionWithSuffix" } -kotlin-compiler-ide = { group = "org.jetbrains.kotlin", name = "kotlin-compiler-for-ide", version.ref = "kotlinIdeVersion" } -kotlin-idea = { group = "org.jetbrains.kotlin", name = "idea", version.ref = "kotlinIdeVersionWithSuffix" } -kotlin-core = { group = "org.jetbrains.kotlin", name = "core", version.ref = "kotlinIdeVersionWithSuffix" } kotlinx-coroutines-core-jvm = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core-jvm", version.ref = "kotlinx-coroutines" } kotlinx-coroutines-test = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-test", version.ref = "kotlinx-coroutines-test" } kotlinx-datetime = { group = "org.jetbrains.kotlinx", name = "kotlinx-datetime", version.ref = "kotlinx-datetime" } @@ -51,7 +43,6 @@ springdoc = { group = "org.springdoc", name = "springdoc-openapi-starter-webmvc- aws-springboot-container = { group = "com.amazonaws.serverless", name = "aws-serverless-java-container-springboot3", version.ref = "aws-serverless-java-container-springboot3" } junit = { group = "junit", name = "junit", version.ref = "junit" } logback-logstash-encoder = { group = "net.logstash.logback", name = "logstash-logback-encoder", version.ref = "logstash-logback-encoder" } -intellij-trove4j = { group = "org.jetbrains.intellij.deps", name = "trove4j", version.ref = "trove4j" } skiko-js-wasm-runtime = { group = "org.jetbrains.skiko", name = "skiko-js-wasm-runtime", version.ref = "skiko" } jackson-databind = { group = "com.fasterxml.jackson.core", name = "jackson-databind", version.ref = "jackson" } jackson-core = { group = "com.fasterxml.jackson.core", name = "jackson-core", version.ref = "jackson" } @@ -84,7 +75,6 @@ compose = [ ] [plugins] -kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } kotlin-plugin-spring = { id = "org.jetbrains.kotlin.plugin.spring", version.ref = "kotlin" } spring-boot = { id = "org.springframework.boot", version.ref = "spring-boot" } spring-dependency-management = { id = "io.spring.dependency-management", version.ref = "spring-dependency-managment" } \ No newline at end of file diff --git a/indexation/build.gradle.kts b/indexation/build.gradle.kts deleted file mode 100644 index d5c137065..000000000 --- a/indexation/build.gradle.kts +++ /dev/null @@ -1,54 +0,0 @@ -plugins { - id("base-kotlin-jvm-conventions") - application -} - -dependencies { - implementation(project(":common", configuration = "default")) - implementation(libs.kotlin.compiler.ide) { - isTransitive = false - } -} - -application { - mainClass.set("indexation.MainKt") -} - -tasks.withType { - dependsOn(":executors:jar") - dependsOn(":dependencies:copyDependencies") - dependsOn(":dependencies:copyCompilerPluginDependencies") - dependsOn(":dependencies:copyJSDependencies") - dependsOn(":dependencies:copyWasmDependencies") - dependsOn(":dependencies:copyComposeWasmCompilerPlugins") - dependsOn(":dependencies:copyComposeWasmDependencies") - - val rootName = project.rootProject.projectDir.toString() - - val kotlinVersion = libs.versions.kotlin.get() - inputs.property("kotlinVersion", kotlinVersion) - - // Adding classpath directories as task input for up-to-date checks - inputs.dir(libJVMFolder) - inputs.dir(compilerPluginsForJVMFolder) - inputs.dir(libJSFolder) - inputs.dir(libWasmFolder) - inputs.dir(libComposeWasmFolder) - inputs.dir(libComposeWasmCompilerPluginsFolder) - - // Adding resulting index files as output for up-to-date checks - val jvmIndicesJson = "$rootName${File.separator}$indexes" - val jsIndicesJson = "$rootName${File.separator}$indexesJs" - val wasmIndicesJson = "$rootName${File.separator}$indexesWasm" - val composeWasmIndicesJson = "$rootName${File.separator}$indexesComposeWasm" - outputs.files(jvmIndicesJson, jsIndicesJson, wasmIndicesJson, composeWasmIndicesJson) - - args = listOf( - kotlinVersion, - libJVMFolder.asFile.absolutePath, - jvmIndicesJson, - jsIndicesJson, - wasmIndicesJson, - composeWasmIndicesJson, - ) -} diff --git a/indexation/src/main/kotlin/DescriptorsUtils.kt b/indexation/src/main/kotlin/DescriptorsUtils.kt deleted file mode 100644 index 902445781..000000000 --- a/indexation/src/main/kotlin/DescriptorsUtils.kt +++ /dev/null @@ -1,99 +0,0 @@ -package indexation - -import model.ImportInfo -import model.Icon -import org.jetbrains.kotlin.descriptors.* -import org.jetbrains.kotlin.idea.imports.importableFqName -import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers -import org.jetbrains.kotlin.name.FqName -import org.jetbrains.kotlin.renderer.ClassifierNamePolicy -import org.jetbrains.kotlin.renderer.ParameterNameRenderingPolicy -import org.jetbrains.kotlin.resolve.DescriptorUtils -import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter -import org.jetbrains.kotlin.resolve.scopes.MemberScope -import org.jetbrains.kotlin.types.asFlexibleType -import org.jetbrains.kotlin.types.isFlexible - -internal val renderer = IdeDescriptorRenderers.SOURCE_CODE.withOptions { - classifierNamePolicy = ClassifierNamePolicy.SHORT - typeNormalizer = IdeDescriptorRenderers.APPROXIMATE_FLEXIBLE_TYPES - parameterNameRenderingPolicy = ParameterNameRenderingPolicy.ALL - typeNormalizer = { - if (it.isFlexible()) it.asFlexibleType().upperBound - else it - } -} - -internal fun DeclarationDescriptor.toImportInfo(): ImportInfo? { - val importName = importableFqName?.asString() ?: return null - if (name.asString() == "Companion") return null - return when (this) { - is FunctionDescriptor -> { - if (visibility.isPublicAPI) { - val returnTypeVal = if (returnType != null) renderer.renderType(returnType!!) - else {extensionReceiverParameter?.let { param -> - " for ${renderer.renderType(param.type)} in ${DescriptorUtils.getFqName(containingDeclaration)}" - } ?: "" } - ImportInfo( - importName = importName, - shortName = name.asString(), - fullName = name.asString() + renderer.renderFunctionParameters(this), - returnType = returnTypeVal, - icon = Icon.METHOD - ) } else null - } - - is ClassDescriptor -> { - if (visibility.isPublicAPI) { - ImportInfo( - importName = importName, - shortName = name.asString(), - fullName = name.asString(), - returnType = name.asString(), - icon = Icon.CLASS - ) - } else null - } - - is PropertyDescriptor -> { - ImportInfo( - importName = importName, - shortName = name.asString(), - fullName = name.asString(), - returnType = name.asString(), - icon = Icon.PROPERTY - ) - } - - else -> null - } -} - -internal fun DeclarationDescriptor.getInnerClassesAndAllStaticFunctions(): List? { - return if (this !is ClassDescriptor || !visibility.isPublicAPI) - null - else (unsubstitutedInnerClassesScope.getContributedDescriptors(DescriptorKindFilter.ALL, MemberScope.ALL_NAME_FILTER) + - staticScope.getContributedDescriptors(DescriptorKindFilter.ALL, MemberScope.ALL_NAME_FILTER)).distinct() -} - -internal fun ModuleDescriptor.allImportsInfo(): List { - val packages = allPackages() - return packages.flatMap { fqName -> - val packageViewDescriptor = getPackage(fqName) - val descriptors = packageViewDescriptor.memberScope - .getContributedDescriptors(DescriptorKindFilter.ALL, MemberScope.ALL_NAME_FILTER) - val allDescriptors = descriptors + descriptors.mapNotNull { it.getInnerClassesAndAllStaticFunctions() }.flatten() - allDescriptors.mapNotNull { it.toImportInfo() } - } -} - -internal fun ModuleDescriptor.allPackages(): Collection { - val result = mutableListOf() - fun impl(pkg: FqName) { - result += pkg - - getSubPackagesOf(pkg) { true }.forEach { impl(it) } - } - impl(FqName.ROOT) - return result -} diff --git a/indexation/src/main/kotlin/IndexationBuilder.kt b/indexation/src/main/kotlin/IndexationBuilder.kt deleted file mode 100644 index f0a8fca33..000000000 --- a/indexation/src/main/kotlin/IndexationBuilder.kt +++ /dev/null @@ -1,14 +0,0 @@ -package indexation - -import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper -import model.ImportInfo -import java.io.File - -abstract class IndexationBuilder { - fun writeIndexesToFile(outputFilename: String) { - val indexes = getAllIndexes().groupBy { it.shortName } - File(outputFilename).writeText(jacksonObjectMapper().writeValueAsString(indexes)) - } - - abstract fun getAllIndexes(): List -} diff --git a/indexation/src/main/kotlin/JvmIndexationBuilder.kt b/indexation/src/main/kotlin/JvmIndexationBuilder.kt deleted file mode 100644 index 153a89aca..000000000 --- a/indexation/src/main/kotlin/JvmIndexationBuilder.kt +++ /dev/null @@ -1,31 +0,0 @@ -package indexation - -import model.ImportInfo -import component.KotlinEnvironment -import org.jetbrains.kotlin.cli.jvm.compiler.CliBindingTrace -import org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM -import org.jetbrains.kotlin.container.getService -import org.jetbrains.kotlin.descriptors.ModuleDescriptor -import org.jetbrains.kotlin.resolve.lazy.declarations.FileBasedDeclarationProviderFactory - -class JvmIndexationBuilder(private val kotlinEnvironment: KotlinEnvironment): IndexationBuilder() { - override fun getAllIndexes(): List = - kotlinEnvironment.environment { coreEnvironment -> - val project = coreEnvironment.project - val trace = CliBindingTrace(project) - val componentProvider = TopDownAnalyzerFacadeForJVM.createContainer( - project = project, - files = emptyList(), - trace = trace, - configuration = coreEnvironment.configuration, - packagePartProvider = { globalSearchScope -> - coreEnvironment.createPackagePartProvider(globalSearchScope) - }, - declarationProviderFactory = { storageManager, ktFiles -> - FileBasedDeclarationProviderFactory(storageManager, ktFiles) - } - ) - val moduleDescriptor = componentProvider.getService(ModuleDescriptor::class.java) - return@environment moduleDescriptor.allImportsInfo().distinct() - } -} diff --git a/indexation/src/main/kotlin/KotlinEnvironmentConfiguration.kt b/indexation/src/main/kotlin/KotlinEnvironmentConfiguration.kt deleted file mode 100644 index 14ce88197..000000000 --- a/indexation/src/main/kotlin/KotlinEnvironmentConfiguration.kt +++ /dev/null @@ -1,50 +0,0 @@ -package indexation - -import component.CompilerPluginOption -import component.KotlinEnvironment -import java.io.File - -class KotlinEnvironmentConfiguration( - version: String, - fileName: String -) { - val kotlinEnvironment = run { - val jvmFile = File(fileName) - val jsFile = File("$fileName-js") - val wasmFile = File("$fileName-wasm") - val composeWasmFile = File("$fileName-compose-wasm") - val composeWasmCompilerPluginsFile = File("$fileName-compose-wasm-compiler-plugins") - val classPath = - listOfNotNull(jvmFile) - .flatMap { - it.listFiles()?.toList() - ?: error("No kotlin libraries found in: ${jvmFile.absolutePath}") - } - - val additionalJsClasspath = jsFile.listFiles()?.toList() ?: emptyList() - val additionalWasmClasspath = wasmFile.listFiles()?.toList() ?: emptyList() - val additionalComposeWasmClasspath = composeWasmFile.listFiles()?.toList() ?: emptyList() - val composeWasmCompilerPlugins = composeWasmCompilerPluginsFile.listFiles()?.toList() ?: emptyList() - - KotlinEnvironment( - classPath, - additionalJsClasspath, - additionalWasmClasspath, - additionalComposeWasmClasspath, - composeWasmCompilerPlugins, - emptyList(), - listOf( - CompilerPluginOption( - "androidx.compose.compiler.plugins.kotlin", - "generateDecoys", - "false" - ), - CompilerPluginOption( - "androidx.compose.compiler.plugins.kotlin", - "suppressKotlinVersionCompatibilityCheck", - version - ), - ) - ) - } -} diff --git a/indexation/src/main/kotlin/Main.kt b/indexation/src/main/kotlin/Main.kt deleted file mode 100644 index 3e3efa90d..000000000 --- a/indexation/src/main/kotlin/Main.kt +++ /dev/null @@ -1,44 +0,0 @@ -package indexation - -/** - * First argument is path to folder with jars - * Second argument is path to output file for jvm indexes - * Third argument is path to output file for js indexes - */ -fun main(args: Array) { - val version = args[0] - val directory = args[1] - val outputPathJvm = args[2] - val outputPathJs = args[3] - val outputPathWasm = args[4] - val outputPathComposeWasm = args[5] - val kotlinEnvironment = KotlinEnvironmentConfiguration(version, directory).kotlinEnvironment - JvmIndexationBuilder(kotlinEnvironment = kotlinEnvironment).writeIndexesToFile(outputPathJvm) - - WebIndexationBuilder( - kotlinEnvironment = kotlinEnvironment, - inputConfiguration = kotlinEnvironment.jsConfiguration, - libraries = kotlinEnvironment.JS_LIBRARIES, - compilerPlugins = emptyList(), - compilerPluginOptions = emptyList(), - platformConfiguration = kotlinEnvironment.jsConfiguration - ).writeIndexesToFile(outputPathJs) - - WebIndexationBuilder( - kotlinEnvironment = kotlinEnvironment, - inputConfiguration = kotlinEnvironment.wasmConfiguration, - libraries = kotlinEnvironment.WASM_LIBRARIES, - compilerPlugins = emptyList(), - compilerPluginOptions = emptyList(), - platformConfiguration = kotlinEnvironment.wasmConfiguration - ).writeIndexesToFile(outputPathWasm) - - WebIndexationBuilder( - kotlinEnvironment = kotlinEnvironment, - inputConfiguration = kotlinEnvironment.composeWasmConfiguration, - libraries = kotlinEnvironment.COMPOSE_WASM_LIBRARIES, - compilerPlugins = kotlinEnvironment.COMPOSE_WASM_COMPILER_PLUGINS, - compilerPluginOptions = kotlinEnvironment.composeWasmCompilerPluginOptions, - platformConfiguration = kotlinEnvironment.composeWasmConfiguration - ).writeIndexesToFile(outputPathComposeWasm) -} diff --git a/indexation/src/main/kotlin/WebIndexationBuilder.kt b/indexation/src/main/kotlin/WebIndexationBuilder.kt deleted file mode 100644 index 9754dacfd..000000000 --- a/indexation/src/main/kotlin/WebIndexationBuilder.kt +++ /dev/null @@ -1,59 +0,0 @@ -package indexation - -import model.ImportInfo -import component.KotlinEnvironment -import org.jetbrains.kotlin.backend.common.LoadedKlibs -import org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport -import org.jetbrains.kotlin.cli.jvm.plugins.PluginCliParser -import org.jetbrains.kotlin.config.CompilerConfiguration -import org.jetbrains.kotlin.ir.backend.js.prepareAnalyzedSourceModule -import org.jetbrains.kotlin.library.loader.KlibLoader - -class WebIndexationBuilder( - private val kotlinEnvironment: KotlinEnvironment, - inputConfiguration: CompilerConfiguration, - private val libraries: List, - private val compilerPlugins: List, - private val compilerPluginOptions: List, - private val platformConfiguration: CompilerConfiguration -): IndexationBuilder() { - - private val configuration = inputConfiguration.copy() - - override fun getAllIndexes(): List = - kotlinEnvironment.environment { coreEnvironment -> - val project = coreEnvironment.project - - if (compilerPlugins.isNotEmpty()) { - PluginCliParser.loadPluginsSafe( - compilerPlugins, - compilerPluginOptions, - emptyList(), - configuration, - kotlinEnvironment.rootDisposable - ) - } - - val klibs = LoadedKlibs( - all = KlibLoader { - libraryPaths(libraries) - }.load().librariesStdlibFirst - ) - - val sourceModule = prepareAnalyzedSourceModule( - project, - coreEnvironment.getSourceFiles(), - configuration, - klibs, - analyzer = AnalyzerWithCompilerReport(platformConfiguration), - ) - - val mds = sourceModule.klibs.all.map { - sourceModule.getModuleDescriptor(it) - } - - return@environment mds.flatMap { moduleDescriptor -> - moduleDescriptor.allImportsInfo() - }.distinct() - } -} \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index 6d04e9eea..37bea3080 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -9,6 +9,5 @@ plugins { } include(":executors") -include(":indexation") include(":common") include(":dependencies") \ No newline at end of file diff --git a/src/main/kotlin/com/compiler/server/compiler/KotlinFile.kt b/src/main/kotlin/com/compiler/server/compiler/KotlinFile.kt deleted file mode 100644 index ba1de6bac..000000000 --- a/src/main/kotlin/com/compiler/server/compiler/KotlinFile.kt +++ /dev/null @@ -1,53 +0,0 @@ -package com.compiler.server.compiler - -import com.intellij.openapi.project.Project -import com.intellij.openapi.vfs.CharsetToolkit -import com.intellij.psi.PsiElement -import com.intellij.psi.PsiFileFactory -import com.intellij.psi.impl.PsiFileFactoryImpl -import com.intellij.testFramework.LightVirtualFile -import org.jetbrains.kotlin.idea.KotlinLanguage -import org.jetbrains.kotlin.psi.KtExpression -import org.jetbrains.kotlin.psi.KtFile - -class KotlinFile(val kotlinFile: KtFile) { - - fun elementAt( - line: Int, - character: Int - ): PsiElement? = kotlinFile.findElementAt(offsetFor(line, character))?.let { expressionFor(it) } - - fun insert(content: String, atLine: Int, atCharacter: Int): KotlinFile { - val caretPositionOffset = offsetFor(atLine, atCharacter) - return if (caretPositionOffset != 0) { - from( - project = kotlinFile.project, - name = kotlinFile.name, - content = StringBuilder(kotlinFile.text.substring(0, caretPositionOffset)) - .append(content) - .append(kotlinFile.text.substring(caretPositionOffset)).toString() - ) - } else this - } - - private fun offsetFor(line: Int, character: Int) = - (kotlinFile.viewProvider.document?.getLineStartOffset(line) ?: 0) + character - - private tailrec fun expressionFor(element: PsiElement): PsiElement = - if (element is KtExpression) element else expressionFor(element.parent) - - companion object { - fun from(project: Project, name: String, content: String) = - KotlinFile( - (PsiFileFactory.getInstance(project) as PsiFileFactoryImpl) - .trySetupPsiForFile( - LightVirtualFile( - if (name.endsWith(".kt")) name else "$name.kt", - KotlinLanguage.INSTANCE, - content - ).apply { charset = CharsetToolkit.UTF8_CHARSET }, - KotlinLanguage.INSTANCE, true, false - ) as KtFile - ) - } -} diff --git a/src/main/kotlin/com/compiler/server/compiler/KotlinPlatform.kt b/src/main/kotlin/com/compiler/server/compiler/KotlinPlatform.kt deleted file mode 100644 index 84daae196..000000000 --- a/src/main/kotlin/com/compiler/server/compiler/KotlinPlatform.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.compiler.server.compiler - -enum class KotlinPlatform { - JS, - JVM, - WASM -} \ No newline at end of file diff --git a/src/main/kotlin/com/compiler/server/compiler/KotlinResolutionFacade.kt b/src/main/kotlin/com/compiler/server/compiler/KotlinResolutionFacade.kt deleted file mode 100644 index 36e92a2c0..000000000 --- a/src/main/kotlin/com/compiler/server/compiler/KotlinResolutionFacade.kt +++ /dev/null @@ -1,67 +0,0 @@ -package com.compiler.server.compiler - -import com.intellij.openapi.project.Project -import com.intellij.psi.PsiElement -import org.jetbrains.kotlin.analyzer.AnalysisResult -import org.jetbrains.kotlin.analyzer.ModuleInfo -import org.jetbrains.kotlin.analyzer.ResolverForProject -import org.jetbrains.kotlin.container.ComponentProvider -import org.jetbrains.kotlin.descriptors.DeclarationDescriptor -import org.jetbrains.kotlin.descriptors.ModuleDescriptor -import org.jetbrains.kotlin.diagnostics.DiagnosticSink -import org.jetbrains.kotlin.idea.FrontendInternals -import org.jetbrains.kotlin.idea.resolve.ResolutionFacade -import org.jetbrains.kotlin.psi.KtDeclaration -import org.jetbrains.kotlin.psi.KtElement -import org.jetbrains.kotlin.resolve.BindingContext -import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode - -@OptIn(FrontendInternals::class) -class KotlinResolutionFacade( - override val project: Project, - override val moduleDescriptor: ModuleDescriptor, - private val componentProvider: ComponentProvider -) : ResolutionFacade { - @Suppress("UNCHECKED_CAST") - override fun getFrontendService(serviceClass: Class) = - componentProvider.resolve(serviceClass)?.getValue() as T - - override fun analyze( - elements: Collection, - bodyResolveMode: BodyResolveMode - ): BindingContext = throw UnsupportedOperationException() - - override fun analyze( - element: KtElement, - bodyResolveMode: BodyResolveMode - ): BindingContext = throw UnsupportedOperationException() - - override fun analyzeWithAllCompilerChecks( - elements: Collection, - callback: DiagnosticSink.DiagnosticsCallback? - ): AnalysisResult = throw UnsupportedOperationException() - - override fun getFrontendService( - element: PsiElement, - serviceClass: Class - ): T = throw UnsupportedOperationException() - - override fun getFrontendService( - moduleDescriptor: ModuleDescriptor, - serviceClass: Class - ): T = throw UnsupportedOperationException() - - override fun getIdeService(serviceClass: Class): T = TODO("not implemented") - - override fun getResolverForProject(): ResolverForProject = throw UnsupportedOperationException() - - override fun resolveToDescriptor( - declaration: KtDeclaration, - bodyResolveMode: BodyResolveMode - ): DeclarationDescriptor = throw UnsupportedOperationException() - - override fun tryGetFrontendService( - element: PsiElement, - serviceClass: Class - ): T? = throw UnsupportedOperationException() -} \ No newline at end of file diff --git a/src/main/kotlin/com/compiler/server/compiler/components/CliUtils.kt b/src/main/kotlin/com/compiler/server/compiler/components/CliUtils.kt index 5b103098d..00fe6203d 100644 --- a/src/main/kotlin/com/compiler/server/compiler/components/CliUtils.kt +++ b/src/main/kotlin/com/compiler/server/compiler/components/CliUtils.kt @@ -1,17 +1,12 @@ package com.compiler.server.compiler.components -import com.compiler.server.compiler.components.IndexationProvider.Companion.UNRESOLVED_REFERENCE_PREFIX -import com.compiler.server.model.CompilerDiagnostics -import com.compiler.server.model.ErrorDescriptor -import com.compiler.server.model.ProjectSeveriry -import com.compiler.server.model.TextInterval +import com.compiler.server.model.* import org.jetbrains.kotlin.cli.common.CLICompiler import org.jetbrains.kotlin.cli.common.CLICompiler.Companion.doMainNoExit import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.* import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSourceLocation import org.jetbrains.kotlin.cli.common.messages.MessageRenderer -import org.jetbrains.kotlin.psi.KtFile import java.io.File import java.nio.file.Path import java.util.* @@ -19,6 +14,8 @@ import kotlin.io.path.* private fun minusOne(value: Int) = if (value > 0) value - 1 else value +private const val UNRESOLVED_REFERENCE_PREFIX = "Unresolved reference: " + sealed class CompilationResult { abstract val compilerDiagnostics: CompilerDiagnostics @@ -128,10 +125,10 @@ private fun getTempDirectory(): Path { return File(dir).canonicalFile.resolve(sessionId).toPath() } -fun List.writeToIoFiles(inputDir: Path): List { +fun List.writeToIoFiles(inputDir: Path): List { val ioFiles = map { inputDir / it.name } - for ((ioFile, ktFile) in ioFiles zip this) { - ioFile.writeText(ktFile.text) + for ((ioFile, projectFile) in ioFiles zip this) { + ioFile.writeText(projectFile.text) } return ioFiles } diff --git a/src/main/kotlin/com/compiler/server/compiler/components/CompletionProvider.kt b/src/main/kotlin/com/compiler/server/compiler/components/CompletionProvider.kt deleted file mode 100644 index 386f19262..000000000 --- a/src/main/kotlin/com/compiler/server/compiler/components/CompletionProvider.kt +++ /dev/null @@ -1,295 +0,0 @@ -package com.compiler.server.compiler.components - -import com.compiler.server.compiler.KotlinFile -import com.compiler.server.compiler.KotlinResolutionFacade -import com.compiler.server.model.Analysis -import com.compiler.server.model.CompilerDiagnostics -import com.compiler.server.model.ProjectType -import com.intellij.psi.PsiElement -import com.intellij.psi.tree.TokenSet -import model.Completion -import model.Icon -import model.completionTextFromFullName -import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment -import org.jetbrains.kotlin.descriptors.* -import org.jetbrains.kotlin.descriptors.impl.LocalVariableDescriptor -import org.jetbrains.kotlin.descriptors.impl.TypeParameterDescriptorImpl -import org.jetbrains.kotlin.idea.codeInsight.ReferenceVariantsHelper -import org.jetbrains.kotlin.idea.core.isVisible -import org.jetbrains.kotlin.idea.imports.importableFqName -import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers -import org.jetbrains.kotlin.idea.util.getResolutionScope -import org.jetbrains.kotlin.lexer.KtKeywordToken -import org.jetbrains.kotlin.lexer.KtTokens -import org.jetbrains.kotlin.name.Name -import org.jetbrains.kotlin.psi.* -import org.jetbrains.kotlin.renderer.ClassifierNamePolicy -import org.jetbrains.kotlin.renderer.ParameterNameRenderingPolicy -import org.jetbrains.kotlin.resolve.BindingContext -import org.jetbrains.kotlin.resolve.DescriptorUtils -import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter -import org.jetbrains.kotlin.resolve.scopes.MemberScope -import org.jetbrains.kotlin.types.asFlexibleType -import org.jetbrains.kotlin.types.isFlexible -import org.springframework.stereotype.Component - -@Component -class CompletionProvider( - private val errorAnalyzer: ErrorAnalyzer, - private val indexationProvider: IndexationProvider -) { - companion object { - private val excludedFromCompletion: List = listOf( - "kotlin.jvm.internal", - "kotlin.coroutines.experimental.intrinsics", - "kotlin.coroutines.intrinsics", - "kotlin.coroutines.experimental.jvm.internal", - "kotlin.coroutines.jvm.internal", - "kotlin.reflect.jvm.internal" - ) - private val NAME_FILTER = { name: Name -> !name.isSpecial } - private const val COMPLETION_SUFFIX = "IntellijIdeaRulezzz" - } - - private data class DescriptorInfo( - val isTipsManagerCompletion: Boolean, - val descriptors: List - ) - - fun complete( - file: KotlinFile, - line: Int, - character: Int, - projectType: ProjectType, - coreEnvironment: KotlinCoreEnvironment - ): List = with(file.insert("$COMPLETION_SUFFIX ", line, character)) { - elementAt(line, character)?.let { element -> - val descriptorInfo = descriptorsFrom(this, element, projectType, coreEnvironment) - val prefix = (if (descriptorInfo.isTipsManagerCompletion) element.text else element.parent.text) - .substringBefore(COMPLETION_SUFFIX).let { if (it.endsWith(".")) "" else it } - val importCompletionVariants = if (indexationProvider.hasIndexes(projectType)) { - val (errors, _) = errorAnalyzer.errorsFrom(listOf(file.kotlinFile), coreEnvironment, projectType) - importVariants(file, prefix, errors, line, character, projectType) - } else emptyList() - descriptorInfo.descriptors.toMutableList().apply { - sortWith { a, b -> - val (a1, a2) = a.presentableName() - val (b1, b2) = b.presentableName() - ("$a1$a2").compareTo("$b1$b2", true) - } - }.mapNotNull { descriptor -> completionVariantFor(prefix, descriptor, element) } + - keywordsCompletionVariants(KtTokens.KEYWORDS, prefix) + - keywordsCompletionVariants(KtTokens.SOFT_KEYWORDS, prefix) + - importCompletionVariants - } ?: emptyList() - } - - private fun DeclarationDescriptor.presentableName(isCallableReferenceCompletion: Boolean = false): Pair { - var presentableText = if (this is ConstructorDescriptor) - this.constructedClass.name.asString() - else - this.name.asString() - return when (this) { - is FunctionDescriptor -> { - if (!isCallableReferenceCompletion) - presentableText += renderer.renderFunctionParameters(this) - presentableText to when { - returnType != null -> renderer.renderType(returnType!!) - else -> (extensionReceiverParameter?.let { param -> - " for ${renderer.renderType(param.type)} in ${DescriptorUtils.getFqName(containingDeclaration)}" - } ?: "") - } - } - - else -> presentableText to when (this) { - is VariableDescriptor -> renderer.renderType(type) - is ClassDescriptor -> " (${DescriptorUtils.getFqName(containingDeclaration)})" - is TypeAliasDescriptor -> renderer.renderType(expandedType) - else -> renderer.render(this) - } - } - } - - private fun importVariants( - file: KotlinFile, - prefix: String, - compilerDiagnostics: CompilerDiagnostics, - line: Int, - character: Int, - projectType: ProjectType - ): List { - val importCompletionVariants = indexationProvider.getClassesByName(prefix, projectType) - ?.map { it.toCompletion() } ?: emptyList() - val currentErrors = compilerDiagnostics.map[file.kotlinFile.name]?.filter { - it.interval != null && - it.interval.start.line == line && - it.interval.start.ch <= character && - it.interval.end.line == line && - it.interval.end.ch >= character && - it.message.startsWith(IndexationProvider.UNRESOLVED_REFERENCE_PREFIX) - } ?: emptyList() - if (currentErrors.isNotEmpty()) return importCompletionVariants - val oldImports = file.kotlinFile.importList?.imports?.mapNotNull { it.importPath.toString() } ?: emptyList() - val suggestions = importCompletionVariants.filter { !oldImports.contains(it.import) } - return suggestions.onEach { completion -> completion.hasOtherImports = true } - } - - private fun completionVariantFor( - prefix: String, - descriptor: DeclarationDescriptor, - element: PsiElement - ): Completion? { - val isCallableReference = (element as? KtElement)?.isCallableReference() ?: false - val (fullName, type) = descriptor.presentableName(isCallableReference) - return if (prefix.isEmpty() || fullName.startsWith(prefix)) { - Completion( - text = completionTextFromFullName(fullName), - displayText = fullName, - tail = type, - icon = iconFrom(descriptor) - ) - } else null - } - - private val renderer = IdeDescriptorRenderers.SOURCE_CODE.withOptions { - classifierNamePolicy = ClassifierNamePolicy.SHORT - typeNormalizer = IdeDescriptorRenderers.APPROXIMATE_FLEXIBLE_TYPES - parameterNameRenderingPolicy = ParameterNameRenderingPolicy.ALL - typeNormalizer = { - if (it.isFlexible()) it.asFlexibleType().upperBound - else it - } - } - - private fun Analysis.referenceVariantsFrom( - element: PsiElement, - coreEnvironment: KotlinCoreEnvironment - ): List? { - val elementKt = element as? KtElement ?: return emptyList() - val bindingContext = analysisResult.bindingContext - val resolutionFacade = KotlinResolutionFacade( - project = coreEnvironment.project, - componentProvider = componentProvider, - moduleDescriptor = analysisResult.moduleDescriptor - ) - val inDescriptor: DeclarationDescriptor = - elementKt.getResolutionScope(bindingContext, resolutionFacade).ownerDescriptor - return when (element) { - is KtSimpleNameExpression -> ReferenceVariantsHelper( - bindingContext = analysisResult.bindingContext, - resolutionFacade = resolutionFacade, - moduleDescriptor = analysisResult.moduleDescriptor, - visibilityFilter = VisibilityFilter(inDescriptor, bindingContext, element, resolutionFacade) - ).getReferenceVariants( - expression = element, - kindFilter = DescriptorKindFilter.ALL, - nameFilter = NAME_FILTER, - filterOutJavaGettersAndSetters = true, - filterOutShadowed = true, - excludeNonInitializedVariable = true, - useReceiverType = null - ).toList() - - else -> null - } - } - - private fun descriptorsFrom( - file: KotlinFile, - element: PsiElement, - projectType: ProjectType, - coreEnvironment: KotlinCoreEnvironment - ): DescriptorInfo { - val files = listOf(file.kotlinFile) - val analysis = when { - projectType.isJvmRelated() -> errorAnalyzer.analysisOf(files, coreEnvironment) - projectType.isJsRelated() -> errorAnalyzer.analyzeFileForJs(files, coreEnvironment) - projectType == ProjectType.WASM -> errorAnalyzer.analyzeFileForWasm(files, coreEnvironment) - projectType == ProjectType.COMPOSE_WASM -> errorAnalyzer.analyzeFileForComposeWasm(files, coreEnvironment) - else -> throw IllegalArgumentException("Unknown project type $projectType") - } - return with(analysis) { - (referenceVariantsFrom(element, coreEnvironment) - ?: referenceVariantsFrom(element.parent, coreEnvironment))?.let { descriptors -> - DescriptorInfo(true, descriptors) - } ?: element.parent.let { parent -> - DescriptorInfo( - isTipsManagerCompletion = false, - descriptors = when (parent) { - is KtQualifiedExpression -> { - analysisResult.bindingContext.get(BindingContext.EXPRESSION_TYPE_INFO, parent.receiverExpression) - ?.type?.let { expressionType -> - analysisResult.bindingContext.get(BindingContext.LEXICAL_SCOPE, parent.receiverExpression)?.let { - expressionType.memberScope.getContributedDescriptors( - DescriptorKindFilter.ALL, - MemberScope.ALL_NAME_FILTER - ) - } - }?.toList() ?: emptyList() - } - - else -> analysisResult.bindingContext.get(BindingContext.LEXICAL_SCOPE, element as KtExpression) - ?.getContributedDescriptors(DescriptorKindFilter.ALL, MemberScope.ALL_NAME_FILTER) - ?.toList() ?: emptyList() - } - ) - } - } - } - - private fun keywordsCompletionVariants(keywords: TokenSet, prefix: String) = keywords.types.mapNotNull { - if (it is KtKeywordToken && it.value.startsWith(prefix)) - Completion(it.value, it.value) else null - } - - private fun iconFrom(descriptor: DeclarationDescriptor) = when (descriptor) { - is FunctionDescriptor -> Icon.METHOD - is PropertyDescriptor -> Icon.PROPERTY - is LocalVariableDescriptor -> Icon.PROPERTY - is ClassDescriptor -> Icon.CLASS - is PackageFragmentDescriptor -> Icon.PACKAGE - is PackageViewDescriptor -> Icon.PACKAGE - is ValueParameterDescriptor -> Icon.GENERIC_VALUE - is TypeParameterDescriptorImpl -> Icon.CLASS - else -> null - } - - private fun KtElement.isCallableReference() = - parent is KtCallableReferenceExpression && this == (parent as KtCallableReferenceExpression).callableReference - - // This code is a fragment of org.jetbrains.kotlin.idea.completion.CompletionSession from Kotlin IDE Plugin - // with a few simplifications which were possible because webdemo has very restricted environment (and well, - // because requirements on completion' quality in web-demo are lower) - private inner class VisibilityFilter( - private val inDescriptor: DeclarationDescriptor, - private val bindingContext: BindingContext, - private val element: KtElement, - private val resolutionFacade: KotlinResolutionFacade - ) : (DeclarationDescriptor) -> Boolean { - override fun invoke(descriptor: DeclarationDescriptor): Boolean { - if (descriptor is TypeParameterDescriptor && !isTypeParameterVisible(descriptor)) return false - - if (descriptor is DeclarationDescriptorWithVisibility) { - return descriptor.isVisible(element, null, bindingContext, resolutionFacade) - } - - if (descriptor.isInternalImplementationDetail()) return false - - return true - } - - private fun isTypeParameterVisible(typeParameter: TypeParameterDescriptor): Boolean { - val owner = typeParameter.containingDeclaration - var parent: DeclarationDescriptor? = inDescriptor - while (parent != null) { - if (parent == owner) return true - if (parent is ClassDescriptor && !parent.isInner) return false - parent = parent.containingDeclaration - } - return true - } - - private fun DeclarationDescriptor.isInternalImplementationDetail(): Boolean = - importableFqName?.asString() in excludedFromCompletion - } -} diff --git a/src/main/kotlin/com/compiler/server/compiler/components/ErrorAnalyzer.kt b/src/main/kotlin/com/compiler/server/compiler/components/ErrorAnalyzer.kt deleted file mode 100644 index 5ee33efdd..000000000 --- a/src/main/kotlin/com/compiler/server/compiler/components/ErrorAnalyzer.kt +++ /dev/null @@ -1,381 +0,0 @@ -package com.compiler.server.compiler.components - -import com.compiler.server.model.* -import com.intellij.openapi.util.Pair -import com.intellij.psi.PsiElement -import com.intellij.psi.PsiElementVisitor -import com.intellij.psi.PsiErrorElement -import com.intellij.psi.PsiFile -import component.KotlinEnvironment -import model.Completion -import org.jetbrains.kotlin.analyzer.AnalysisResult -import org.jetbrains.kotlin.backend.common.LoadedKlibs -import org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport -import org.jetbrains.kotlin.cli.js.klib.TopDownAnalyzerFacadeForJSIR -import org.jetbrains.kotlin.cli.js.klib.TopDownAnalyzerFacadeForWasmJs -import org.jetbrains.kotlin.cli.jvm.compiler.CliBindingTrace -import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment -import org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM -import org.jetbrains.kotlin.config.CompilerConfiguration -import org.jetbrains.kotlin.config.LanguageVersionSettingsImpl -import org.jetbrains.kotlin.config.moduleName -import org.jetbrains.kotlin.container.* -import org.jetbrains.kotlin.context.ContextForNewModule -import org.jetbrains.kotlin.context.ModuleContext -import org.jetbrains.kotlin.context.ProjectContext -import org.jetbrains.kotlin.descriptors.ModuleDescriptor -import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl -import org.jetbrains.kotlin.diagnostics.Diagnostic -import org.jetbrains.kotlin.diagnostics.Errors -import org.jetbrains.kotlin.diagnostics.Severity -import org.jetbrains.kotlin.diagnostics.rendering.DefaultErrorMessages -import org.jetbrains.kotlin.frontend.di.configureModule -import org.jetbrains.kotlin.incremental.components.InlineConstTracker -import org.jetbrains.kotlin.incremental.components.LookupTracker -import org.jetbrains.kotlin.ir.backend.js.MainModule -import org.jetbrains.kotlin.ir.backend.js.ModulesStructure -import org.jetbrains.kotlin.js.resolve.JsPlatformAnalyzerServices -import org.jetbrains.kotlin.library.loader.KlibLoader -import org.jetbrains.kotlin.library.loader.KlibPlatformChecker -import org.jetbrains.kotlin.name.Name -import org.jetbrains.kotlin.platform.TargetPlatform -import org.jetbrains.kotlin.platform.js.JsPlatforms -import org.jetbrains.kotlin.platform.wasm.WasmPlatforms -import org.jetbrains.kotlin.psi.KtFile -import org.jetbrains.kotlin.resolve.* -import org.jetbrains.kotlin.resolve.jvm.extensions.AnalysisHandlerExtension -import org.jetbrains.kotlin.resolve.lazy.FileScopeProviderImpl -import org.jetbrains.kotlin.resolve.lazy.KotlinCodeAnalyzer -import org.jetbrains.kotlin.resolve.lazy.ResolveSession -import org.jetbrains.kotlin.resolve.lazy.declarations.DeclarationProviderFactory -import org.jetbrains.kotlin.resolve.lazy.declarations.FileBasedDeclarationProviderFactory -import org.jetbrains.kotlin.wasm.resolve.WasmPlatformAnalyzerServices -import org.springframework.stereotype.Component - -@Component -class ErrorAnalyzer( - private val kotlinEnvironment: KotlinEnvironment, - private val indexationProvider: IndexationProvider -) { - fun errorsFrom( - files: List, - coreEnvironment: KotlinCoreEnvironment, - projectType: ProjectType - ): ErrorsAndAnalysis { - val analysis = when { - projectType.isJvmRelated() -> analysisOf(files, coreEnvironment) - projectType.isJsRelated() -> analyzeFileForJs(files, coreEnvironment) - projectType == ProjectType.WASM -> analyzeFileForWasm(files, coreEnvironment) - projectType == ProjectType.COMPOSE_WASM -> analyzeFileForComposeWasm(files, coreEnvironment) - else -> throw IllegalArgumentException("Unknown platform: $projectType") - } - return ErrorsAndAnalysis( - errorsFrom( - analysis.analysisResult.bindingContext.diagnostics.all(), - CompilerDiagnostics(files.associate { it.name to analyzeErrorsFrom(it, projectType) }), - projectType - ), - analysis - ) - } - - fun analysisOf(files: List, coreEnvironment: KotlinCoreEnvironment): Analysis { - val project = files.first().project - val trace = CliBindingTrace(project) - val componentProvider = TopDownAnalyzerFacadeForJVM.createContainer( - project = project, - files = files, - trace = trace, - configuration = coreEnvironment.configuration, - packagePartProvider = { globalSearchScope -> - coreEnvironment.createPackagePartProvider(globalSearchScope) - }, - declarationProviderFactory = { storageManager, ktFiles -> - FileBasedDeclarationProviderFactory(storageManager, ktFiles) - } - ) - componentProvider.getService(LazyTopDownAnalyzer::class.java) - .analyzeDeclarations( - topDownAnalysisMode = TopDownAnalysisMode.TopLevelDeclarations, - declarations = files - ) - val moduleDescriptor = componentProvider.getService(ModuleDescriptor::class.java) - AnalysisHandlerExtension.getInstances(project) - .find { - it.analysisCompleted( - project = project, - module = moduleDescriptor, - bindingTrace = trace, - files = files - ) != null - } - return AnalysisJvm( - componentProvider = componentProvider, - analysisResult = AnalysisResult.success(trace.bindingContext, moduleDescriptor) - ) - } - - fun analyzeFileForJs(files: List, coreEnvironment: KotlinCoreEnvironment): Analysis { - val project = coreEnvironment.project - val mainModule = MainModule.SourceFiles(files) - - val jsKlibs = LoadedKlibs( - all = KlibLoader { - libraryPaths(kotlinEnvironment.JS_LIBRARIES) - platformChecker(KlibPlatformChecker.JS) - }.load().librariesStdlibFirst - ) - - val sourceModule = ModulesStructure( - project, - mainModule, - kotlinEnvironment.jsConfiguration, - jsKlibs, - ) - - val mds = sourceModule.klibs.all.map { - sourceModule.getModuleDescriptor(it) as ModuleDescriptorImpl - } - - val builtInModuleDescriptor = sourceModule.builtInModuleDescriptor - - val analyzer = AnalyzerWithCompilerReport(kotlinEnvironment.jsConfiguration) - val analyzerFacade = TopDownAnalyzerFacadeForJSIR - val analysisResult = analyzerFacade.analyzeFiles( - mainModule.files, - project, - kotlinEnvironment.jsConfiguration, - mds, - emptyList(), - analyzer.targetEnvironment, - thisIsBuiltInsModule = builtInModuleDescriptor == null, - customBuiltInsModule = builtInModuleDescriptor - ) - - val context = ContextForNewModule( - projectContext = ProjectContext(project, "COMPILER-SERVER-JS"), - moduleName = Name.special("<" + kotlinEnvironment.jsConfiguration.moduleName + ">"), - builtIns = JsPlatformAnalyzerServices.builtIns, platform = null - ) - val dependencies = mutableSetOf(context.module) + mds + JsPlatformAnalyzerServices.builtIns.builtInsModule - context.module.setDependencies(dependencies.toList()) - val trace = CliBindingTrace(project) - val providerFactory = FileBasedDeclarationProviderFactory(context.storageManager, files) - val analyzerAndProvider = createContainerForTopDownAnalyzerForJs(context, trace, providerFactory, JsPlatforms.defaultJsPlatform, JsPlatformAnalyzerServices) - - val hasErrors = analyzer.hasErrors() - - sourceModule.jsFrontEndResult = ModulesStructure.JsFrontEndResult(analysisResult, hasErrors) - - return AnalysisJs( - sourceModule = sourceModule, - componentProvider = analyzerAndProvider.second, - analysisResult = analysisResult - ) - } - - fun analyzeFileForWasm( - files: List, - coreEnvironment: KotlinCoreEnvironment - ) = analyzeFileForWasmCommon( - files, - kotlinEnvironment.wasmConfiguration, - kotlinEnvironment.WASM_LIBRARIES, - coreEnvironment - ) - - fun analyzeFileForComposeWasm( - files: List, - coreEnvironment: KotlinCoreEnvironment - ) = analyzeFileForWasmCommon( - files, - kotlinEnvironment.composeWasmConfiguration, - kotlinEnvironment.COMPOSE_WASM_LIBRARIES, - coreEnvironment - ) - - private fun analyzeFileForWasmCommon( - files: List, - environmentConfiguration: CompilerConfiguration, - dependencies: List, - coreEnvironment: KotlinCoreEnvironment - ): Analysis { - val project = coreEnvironment.project - val mainModule = MainModule.SourceFiles(files) - - val wasmKlibs = LoadedKlibs( - all = KlibLoader { - libraryPaths(dependencies) - platformChecker(KlibPlatformChecker.Wasm()) - }.load().librariesStdlibFirst - ) - - val sourceModule = ModulesStructure( - project, - mainModule, - environmentConfiguration, - wasmKlibs, - ) - - val mds = sourceModule.klibs.all.map { - sourceModule.getModuleDescriptor(it) as ModuleDescriptorImpl - } - - val builtInModuleDescriptor = sourceModule.builtInModuleDescriptor - - val analyzer = AnalyzerWithCompilerReport(environmentConfiguration) - val analyzerFacade = TopDownAnalyzerFacadeForWasmJs - val analysisResult = analyzerFacade.analyzeFiles( - mainModule.files, - project, - environmentConfiguration, - mds, - emptyList(), - analyzer.targetEnvironment, - thisIsBuiltInsModule = builtInModuleDescriptor == null, - customBuiltInsModule = builtInModuleDescriptor - ) - - val context = ContextForNewModule( - projectContext = ProjectContext(project, "COMPILER-SERVER-JS"), - moduleName = Name.special("<" + kotlinEnvironment.jsConfiguration.moduleName + ">"), - builtIns = WasmPlatformAnalyzerServices.builtIns, platform = null - ) - val dependenciesDescriptors = mutableSetOf(context.module) + mds + WasmPlatformAnalyzerServices.builtIns.builtInsModule - context.module.setDependencies(dependenciesDescriptors.toList()) - val trace = CliBindingTrace(project) - val providerFactory = FileBasedDeclarationProviderFactory(context.storageManager, files) - val analyzerAndProvider = createContainerForTopDownAnalyzerForJs(context, trace, providerFactory, WasmPlatforms.Default, WasmPlatformAnalyzerServices) - - val hasErrors = analyzer.hasErrors() - - sourceModule.jsFrontEndResult = ModulesStructure.JsFrontEndResult(analysisResult, hasErrors) - - return AnalysisJs( - sourceModule = sourceModule, - componentProvider = analyzerAndProvider.second, - analysisResult = analysisResult - ) - } - - fun errorsFrom( - diagnostics: Collection, - compilerDiagnostics: CompilerDiagnostics, - projectType: ProjectType - ): CompilerDiagnostics = (compilerDiagnostics.map and errorsFrom(diagnostics, projectType)).map { (fileName, errors) -> - fileName to errors.sortedWith(Comparator.comparing({ it.interval?.start }, nullsFirst())) - }.toMap().let(::CompilerDiagnostics) - - private fun analyzeErrorsFrom(file: PsiFile, projectType: ProjectType): List { - class Visitor : PsiElementVisitor() { - val errors = mutableListOf() - override fun visitElement(element: PsiElement) { - element.acceptChildren(this) - } - - override fun visitErrorElement(element: PsiErrorElement) { - errors.add(element) - } - } - return Visitor().apply { visitFile(file) }.errors.map { - ErrorDescriptor( - interval = TextInterval.from( - start = it.textRange.startOffset, - end = it.textRange.endOffset, - currentDocument = file.viewProvider.document!! - ), - message = it.errorDescription, - severity = ProjectSeveriry.ERROR, - className = "red_wavy_line", - imports = completionsForErrorMessage(it.errorDescription, projectType) - ) - } - } - - private fun createContainerForTopDownAnalyzerForJs( - moduleContext: ModuleContext, - bindingTrace: BindingTrace, - declarationProviderFactory: DeclarationProviderFactory, - platform: TargetPlatform, - analyzerServices: PlatformDependentAnalyzerServices - ): Pair { - val container = composeContainer( - "TopDownAnalyzerForJs", - analyzerServices.platformConfigurator.platformSpecificContainer - ) { - configureModule( - moduleContext = moduleContext, - platform = platform, - analyzerServices = analyzerServices, - trace = bindingTrace, - languageVersionSettings = LanguageVersionSettingsImpl.DEFAULT, - optimizingOptions = null, - absentDescriptorHandlerClass = null - ) - useInstance(declarationProviderFactory) - registerSingleton(AnnotationResolverImpl::class.java) - registerSingleton(FileScopeProviderImpl::class.java) - CompilerEnvironment.configure(this) - useInstance(LookupTracker.DO_NOTHING) - useInstance(InlineConstTracker.DoNothing) - registerSingleton(ResolveSession::class.java) - registerSingleton(LazyTopDownAnalyzer::class.java) - } - - container.getService(ModuleDescriptorImpl::class.java) - .initialize(container.getService(KotlinCodeAnalyzer::class.java).packageFragmentProvider) - return Pair(container.getService(LazyTopDownAnalyzer::class.java), container) - } - - private fun errorsFrom( - diagnostics: Collection, - projectType: ProjectType - ) = diagnostics.mapNotNull { diagnostic -> - diagnostic.psiFile.virtualFile?.let { - val render = DefaultErrorMessages.render(diagnostic) - if (!render.contains("This cast can never succeed")) { - if (diagnostic.severity != Severity.INFO) { - val textRanges = diagnostic.textRanges.iterator() - if (textRanges.hasNext()) { - var className = diagnostic.severity.name - val imports = if (diagnostic.factory === Errors.UNRESOLVED_REFERENCE) { - completionsForErrorMessage(render, projectType) - } else null - if (!(diagnostic.factory === Errors.UNRESOLVED_REFERENCE) && diagnostic.severity == Severity.ERROR) { - className = "red_wavy_line" - } - val firstRange = textRanges.next() - val interval = TextInterval.from( - firstRange.startOffset, - firstRange.endOffset, - diagnostic.psiFile.viewProvider.document!! - ) - diagnostic.psiFile.name to ErrorDescriptor( - interval = interval, - message = render, - severity = ProjectSeveriry.from(diagnostic.severity), - className = className, - imports = imports - ) - } else null - } else null - } else null - } - }.groupBy { it.first }.map { it.key to it.value.map { (_, error) -> error } }.toMap() - - private infix fun Map>.and(errors: Map>) = - (this.toList() + errors.toList()) - .groupBy { it.first } - .map { it.key to it.value.fold(emptyList()) { acc, (_, errors) -> acc + errors } } - .toMap() - - private fun completionsForErrorMessage(message: String, projectType: ProjectType): List? { - if (!indexationProvider.hasIndexes(projectType) || - !message.startsWith(IndexationProvider.UNRESOLVED_REFERENCE_PREFIX) - ) return null - val name = message.removePrefix(IndexationProvider.UNRESOLVED_REFERENCE_PREFIX) - return indexationProvider.getClassesByName(name, projectType)?.map { suggest -> suggest.toCompletion() } - } -} - -data class ErrorsAndAnalysis(val compilerDiagnostics: CompilerDiagnostics, val analysis: Analysis) diff --git a/src/main/kotlin/com/compiler/server/compiler/components/IndexationProvider.kt b/src/main/kotlin/com/compiler/server/compiler/components/IndexationProvider.kt deleted file mode 100644 index 1c0b3dc69..000000000 --- a/src/main/kotlin/com/compiler/server/compiler/components/IndexationProvider.kt +++ /dev/null @@ -1,74 +0,0 @@ -package com.compiler.server.compiler.components - -import com.compiler.server.model.ProjectType -import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper -import com.fasterxml.jackson.module.kotlin.readValue -import model.ImportInfo -import org.apache.commons.logging.LogFactory -import org.springframework.beans.factory.annotation.Value -import org.springframework.stereotype.Component -import java.io.File - -@Component -class IndexationProvider( - @Value("\${indexes.file}") private val indexesFileName: String, - @Value("\${indexesJs.file}") private val indexesJsFileName: String, - @Value("\${indexesWasm.file}") private val indexesWasmFileName: String, - @Value("\${indexesComposeWasm.file}") private val indexesComposeWasmFileName: String, -) { - companion object { - const val UNRESOLVED_REFERENCE_PREFIX = "Unresolved reference " - private val log = LogFactory.getLog(IndexationProvider::class.java) - } - - private val jvmIndexes: Map>? by lazy { - initIndexes(indexesFileName) - } - - private val jsIndexes: Map>? by lazy { - initIndexes(indexesJsFileName) - } - - private val wasmIndexes: Map>? by lazy { - initIndexes(indexesWasmFileName) - } - - private val composeWasmIndexes: Map>? by lazy { - initIndexes(indexesComposeWasmFileName) - } - - fun hasIndexes(projectType: ProjectType) = when { - projectType.isJsRelated() -> jsIndexes != null - projectType.isJvmRelated() -> jvmIndexes != null - projectType == ProjectType.WASM -> wasmIndexes != null - projectType == ProjectType.COMPOSE_WASM -> composeWasmIndexes != null - else -> throw IllegalArgumentException("Platform $projectType not found") - } - - fun getClassesByName(name: String, projectType: ProjectType): List? { - val indexes = when { - projectType.isJsRelated() -> jsIndexes - projectType.isJvmRelated() -> jvmIndexes - projectType == ProjectType.WASM -> wasmIndexes - projectType == ProjectType.COMPOSE_WASM -> composeWasmIndexes - else -> throw IllegalArgumentException("Platform $projectType not found") - } - return indexes?.get(name) - } - - private fun initIndexes(fileName: String): Map>? { - val file = File(fileName) - if (file.exists().not()) { - log.warn("No file was found at path: $fileName") - return null - } - val indexes = runCatching { readIndexesFromJson(file) }.getOrNull() - if (indexes == null) { - log.warn("Can not parse file=$fileName with indexes") - } - return indexes - } - - private fun readIndexesFromJson(file: File): Map> = - jacksonObjectMapper().readValue(file.readText()) -} \ No newline at end of file diff --git a/src/main/kotlin/com/compiler/server/compiler/components/KotlinCompiler.kt b/src/main/kotlin/com/compiler/server/compiler/components/KotlinCompiler.kt index 47c8e66b2..3e7cb16f8 100644 --- a/src/main/kotlin/com/compiler/server/compiler/components/KotlinCompiler.kt +++ b/src/main/kotlin/com/compiler/server/compiler/components/KotlinCompiler.kt @@ -4,13 +4,13 @@ import com.compiler.server.executor.CommandLineArgument import com.compiler.server.executor.JavaExecutor import com.compiler.server.model.JvmExecutionResult import com.compiler.server.model.OutputDirectory +import com.compiler.server.model.ProjectFile import com.compiler.server.model.bean.LibrariesFile import com.compiler.server.model.toExceptionDescriptor import component.KotlinEnvironment import executors.JUnitExecutors import executors.JavaRunnerExecutor import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler -import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.org.objectweb.asm.ClassReader import org.jetbrains.org.objectweb.asm.ClassReader.* import org.jetbrains.org.objectweb.asm.ClassVisitor @@ -29,166 +29,169 @@ import kotlin.io.path.* @Component class KotlinCompiler( - private val kotlinEnvironment: KotlinEnvironment, - private val javaExecutor: JavaExecutor, - private val librariesFile: LibrariesFile, - @Value("\${policy.file}") private val policyFileName: String + private val kotlinEnvironment: KotlinEnvironment, + private val javaExecutor: JavaExecutor, + private val librariesFile: LibrariesFile, + @Value("\${policy.file}") private val policyFileName: String ) { - private val policyFile = File(policyFileName) - - data class JvmClasses( - val files: Map = emptyMap(), - val mainClasses: Set = emptySet() - ) - - private fun ByteArray.asHumanReadable(): String { - val classReader = ClassReader(this) - val stringWriter = StringWriter() - val printWriter = PrintWriter(stringWriter) - val traceClassVisitor = TraceClassVisitor(printWriter) - - classReader.accept(traceClassVisitor, 0) - - return stringWriter.toString() - } - - private fun JvmExecutionResult.addByteCode(compiled: JvmClasses) { - jvmByteCode = compiled.files - .mapNotNull { (_, bytes) -> runCatching { bytes.asHumanReadable() }.getOrNull() } - .takeUnless { it.isEmpty() } - ?.joinToString("\n\n") - } - - fun run(files: List, addByteCode: Boolean, args: String): JvmExecutionResult { - return execute(files, addByteCode) { output, compiled -> - val mainClass = JavaRunnerExecutor::class.java.name - val compiledMainClass = when (compiled.mainClasses.size) { - 0 -> return@execute JvmExecutionResult( - exception = IllegalArgumentException("No main method found in project").toExceptionDescriptor() - ) - - 1 -> compiled.mainClasses.single() - else -> return@execute JvmExecutionResult( - exception = IllegalArgumentException( - "Multiple classes in project contain main methods found: ${compiled.mainClasses.sorted().joinToString()}" - ).toExceptionDescriptor() - ) - } - val arguments = listOfNotNull(compiledMainClass) + args.split(" ") - javaExecutor.execute(argsFrom(mainClass, output, arguments)) - .asExecutionResult() + private val policyFile = File(policyFileName) + + data class JvmClasses( + val files: Map = emptyMap(), + val mainClasses: Set = emptySet() + ) + + private fun ByteArray.asHumanReadable(): String { + val classReader = ClassReader(this) + val stringWriter = StringWriter() + val printWriter = PrintWriter(stringWriter) + val traceClassVisitor = TraceClassVisitor(printWriter) + + classReader.accept(traceClassVisitor, 0) + + return stringWriter.toString() } - } - fun test(files: List, addByteCode: Boolean): JvmExecutionResult { - return execute(files, addByteCode) { output, _ -> - val mainClass = JUnitExecutors::class.java.name - javaExecutor.execute(argsFrom(mainClass, output, listOf(output.path.toString()))) - .asJUnitExecutionResult() + private fun JvmExecutionResult.addByteCode(compiled: JvmClasses) { + jvmByteCode = compiled.files + .mapNotNull { (_, bytes) -> runCatching { bytes.asHumanReadable() }.getOrNull() } + .takeUnless { it.isEmpty() } + ?.joinToString("\n\n") } - } - - @OptIn(ExperimentalPathApi::class) - fun compile(files: List): CompilationResult = usingTempDirectory { inputDir -> - val ioFiles = files.writeToIoFiles(inputDir) - usingTempDirectory { outputDir -> - val arguments = ioFiles.map { it.absolutePathString() } + KotlinEnvironment.additionalCompilerArguments + listOf( - "-cp", kotlinEnvironment.classpath.joinToString(PATH_SEPARATOR) { it.absolutePath }, - "-module-name", "web-module", - "-no-stdlib", "-no-reflect", - "-progressive", - "-d", outputDir.absolutePathString(), - ) + kotlinEnvironment.compilerPlugins.map { plugin -> "-Xplugin=${plugin.absolutePath}" } - K2JVMCompiler().tryCompilation(inputDir, ioFiles, arguments) { - val outputFiles = buildMap { - outputDir.visitFileTree { - onVisitFile { file, _ -> - put(file.relativeTo(outputDir).pathString, file.readBytes()) - FileVisitResult.CONTINUE + + fun run(files: List, addByteCode: Boolean, args: String): JvmExecutionResult { + return execute(files, addByteCode) { output, compiled -> + val mainClass = JavaRunnerExecutor::class.java.name + val compiledMainClass = when (compiled.mainClasses.size) { + 0 -> return@execute JvmExecutionResult( + exception = IllegalArgumentException("No main method found in project").toExceptionDescriptor() + ) + + 1 -> compiled.mainClasses.single() + else -> return@execute JvmExecutionResult( + exception = IllegalArgumentException( + "Multiple classes in project contain main methods found: ${ + compiled.mainClasses.sorted().joinToString() + }" + ).toExceptionDescriptor() + ) } - } + val arguments = listOfNotNull(compiledMainClass) + args.split(" ") + javaExecutor.execute(argsFrom(mainClass, output, arguments)) + .asExecutionResult() } - val mainClasses = findMainClasses(outputFiles) - JvmClasses( - files = outputFiles, - mainClasses = mainClasses, - ) - } } - } - - private fun findMainClasses(outputFiles: Map): Set = - outputFiles.mapNotNull { (name, bytes) -> - if (!name.endsWith(".class")) return@mapNotNull null - val reader = ClassReader(bytes) - var hasMain = false - val visitor = object : ClassVisitor(ASM9) { - override fun visitMethod( - access: Int, name: String?, descriptor: String?, signature: String?, exceptions: Array? - ): MethodVisitor? { - if (name == "main" && descriptor == "([Ljava/lang/String;)V" && (access and ACC_PUBLIC != 0) && (access and ACC_STATIC != 0)) { - hasMain = true - } - return null + + fun test(files: List, addByteCode: Boolean): JvmExecutionResult { + return execute(files, addByteCode) { output, _ -> + val mainClass = JUnitExecutors::class.java.name + javaExecutor.execute(argsFrom(mainClass, output, listOf(output.path.toString()))) + .asJUnitExecutionResult() } - } - reader.accept(visitor, SKIP_CODE or SKIP_DEBUG or SKIP_FRAMES) - if (hasMain) name.removeSuffix(".class").replace(File.separatorChar, '.') else null - }.toSet() - - private fun execute( - files: List, - addByteCode: Boolean, - block: (output: OutputDirectory, compilation: JvmClasses) -> JvmExecutionResult - ): JvmExecutionResult = try { - when (val compilationResult = compile(files)) { - is Compiled -> { + } + + @OptIn(ExperimentalPathApi::class) + fun compile(files: List): CompilationResult = usingTempDirectory { inputDir -> + val ioFiles = files.writeToIoFiles(inputDir) usingTempDirectory { outputDir -> - val output = write(compilationResult.result, outputDir) - block(output, compilationResult.result).also { - it.addWarnings(compilationResult.compilerDiagnostics) - if (addByteCode) { - it.addByteCode(compilationResult.result) + val arguments = + ioFiles.map { it.absolutePathString() } + KotlinEnvironment.additionalCompilerArguments + listOf( + "-cp", kotlinEnvironment.classpath.joinToString(PATH_SEPARATOR) { it.absolutePath }, + "-module-name", "web-module", + "-no-stdlib", "-no-reflect", + "-progressive", + "-d", outputDir.absolutePathString(), + ) + kotlinEnvironment.compilerPlugins.map { plugin -> "-Xplugin=${plugin.absolutePath}" } + K2JVMCompiler().tryCompilation(inputDir, ioFiles, arguments) { + val outputFiles = buildMap { + outputDir.visitFileTree { + onVisitFile { file, _ -> + put(file.relativeTo(outputDir).pathString, file.readBytes()) + FileVisitResult.CONTINUE + } + } + } + val mainClasses = findMainClasses(outputFiles) + JvmClasses( + files = outputFiles, + mainClasses = mainClasses, + ) + } + } + } + + private fun findMainClasses(outputFiles: Map): Set = + outputFiles.mapNotNull { (name, bytes) -> + if (!name.endsWith(".class")) return@mapNotNull null + val reader = ClassReader(bytes) + var hasMain = false + val visitor = object : ClassVisitor(ASM9) { + override fun visitMethod( + access: Int, name: String?, descriptor: String?, signature: String?, exceptions: Array? + ): MethodVisitor? { + if (name == "main" && descriptor == "([Ljava/lang/String;)V" && (access and ACC_PUBLIC != 0) && (access and ACC_STATIC != 0)) { + hasMain = true + } + return null + } + } + reader.accept(visitor, SKIP_CODE or SKIP_DEBUG or SKIP_FRAMES) + if (hasMain) name.removeSuffix(".class").replace(File.separatorChar, '.') else null + }.toSet() + + private fun execute( + files: List, + addByteCode: Boolean, + block: (output: OutputDirectory, compilation: JvmClasses) -> JvmExecutionResult + ): JvmExecutionResult = try { + when (val compilationResult = compile(files)) { + is Compiled -> { + usingTempDirectory { outputDir -> + val output = write(compilationResult.result, outputDir) + block(output, compilationResult.result).also { + it.addWarnings(compilationResult.compilerDiagnostics) + if (addByteCode) { + it.addByteCode(compilationResult.result) + } + } + } } - } + + is NotCompiled -> JvmExecutionResult(compilerDiagnostics = compilationResult.compilerDiagnostics) } - } + } catch (e: Exception) { + JvmExecutionResult(exception = e.toExceptionDescriptor()) + } + + private fun write(classes: JvmClasses, outputDir: Path): OutputDirectory { + val libDir = librariesFile.jvm.absolutePath + val policy = policyFile.readText() + .replace("%%GENERATED%%", outputDir.toString().replace('\\', '/')) + .replace("%%LIB_DIR%%", libDir.replace('\\', '/')) + (outputDir / policyFile.name).apply { parent.toFile().mkdirs() }.toFile().writeText(policy) + return OutputDirectory(outputDir, classes.files.map { (name, bytes) -> + (outputDir / name).let { path -> + path.parent.toFile().mkdirs() + Files.write(path, bytes) + } + }) + } - is NotCompiled -> JvmExecutionResult(compilerDiagnostics = compilationResult.compilerDiagnostics) + private fun argsFrom( + mainClass: String?, + outputDirectory: OutputDirectory, + args: List + ): List { + val classPaths = + (kotlinEnvironment.classpath.map { it.absolutePath } + outputDirectory.path.toAbsolutePath().toString()) + .joinToString(PATH_SEPARATOR) + val policy = (outputDirectory.path / policyFile.name).toAbsolutePath() + return CommandLineArgument( + classPaths = classPaths, + mainClass = mainClass, + policy = policy, + memoryLimit = 32, + arguments = args + ).toList() } - } catch (e: Exception) { - JvmExecutionResult(exception = e.toExceptionDescriptor()) - } - - private fun write(classes: JvmClasses, outputDir: Path): OutputDirectory { - val libDir = librariesFile.jvm.absolutePath - val policy = policyFile.readText() - .replace("%%GENERATED%%", outputDir.toString().replace('\\', '/')) - .replace("%%LIB_DIR%%", libDir.replace('\\', '/')) - (outputDir / policyFile.name).apply { parent.toFile().mkdirs() }.toFile().writeText(policy) - return OutputDirectory(outputDir, classes.files.map { (name, bytes) -> - (outputDir / name).let { path -> - path.parent.toFile().mkdirs() - Files.write(path, bytes) - } - }) - } - - private fun argsFrom( - mainClass: String?, - outputDirectory: OutputDirectory, - args: List - ): List { - val classPaths = - (kotlinEnvironment.classpath.map { it.absolutePath } + outputDirectory.path.toAbsolutePath().toString()) - .joinToString(PATH_SEPARATOR) - val policy = (outputDirectory.path / policyFile.name).toAbsolutePath() - return CommandLineArgument( - classPaths = classPaths, - mainClass = mainClass, - policy = policy, - memoryLimit = 32, - arguments = args - ).toList() - } } diff --git a/src/main/kotlin/com/compiler/server/compiler/components/KotlinToJSTranslator.kt b/src/main/kotlin/com/compiler/server/compiler/components/KotlinToJSTranslator.kt index e4d9747ab..d52f28899 100644 --- a/src/main/kotlin/com/compiler/server/compiler/components/KotlinToJSTranslator.kt +++ b/src/main/kotlin/com/compiler/server/compiler/components/KotlinToJSTranslator.kt @@ -4,7 +4,6 @@ import com.compiler.server.model.* import com.fasterxml.jackson.databind.ObjectMapper import component.KotlinEnvironment import org.jetbrains.kotlin.cli.js.K2JSCompiler -import org.jetbrains.kotlin.psi.KtFile import org.springframework.stereotype.Service import kotlin.io.path.div import kotlin.io.path.readBytes @@ -12,12 +11,12 @@ import kotlin.io.path.readText @Service class KotlinToJSTranslator( - private val kotlinEnvironment: KotlinEnvironment, + private val kotlinEnvironment: KotlinEnvironment, ) { - companion object { - internal const val JS_IR_CODE_BUFFER = "playground.output?.buffer_1;\n" + companion object { + internal const val JS_IR_CODE_BUFFER = "playground.output?.buffer_1;\n" - internal val JS_IR_OUTPUT_REWRITE = """ + internal val JS_IR_OUTPUT_REWRITE = """ if (typeof get_output !== "undefined") { get_output(); output = new BufferedOutput(); @@ -25,188 +24,193 @@ class KotlinToJSTranslator( } """.trimIndent() - const val BEFORE_MAIN_CALL_LINE = 4 - } - - fun translateJs( - files: List, - arguments: List, - translate: (List, List) -> CompilationResult - ): TranslationJSResult = try { - val compilationResult = translate(files, arguments) - val jsCode = when (compilationResult) { - is Compiled -> compilationResult.result - is NotCompiled -> null + const val BEFORE_MAIN_CALL_LINE = 4 } - TranslationJSResult(jsCode = jsCode, compilerDiagnostics = compilationResult.compilerDiagnostics) - } catch (e: Exception) { - TranslationJSResult(exception = e.toExceptionDescriptor()) - } - - fun translateWasm( - files: List, - debugInfo: Boolean, - projectType: ProjectType, - translate: (List, List, List, List, Boolean) -> CompilationResult - ): TranslationResultWithJsCode { - return try { - val (dependencies, compilerPlugins, compilerPluginOptions) = when (projectType) { - ProjectType.WASM -> listOf( - kotlinEnvironment.WASM_LIBRARIES, - emptyList(), - emptyList() - ) - ProjectType.COMPOSE_WASM -> listOf( - kotlinEnvironment.COMPOSE_WASM_LIBRARIES, - kotlinEnvironment.COMPOSE_WASM_COMPILER_PLUGINS, - kotlinEnvironment.composeWasmCompilerPluginOptions - ) - else -> throw IllegalStateException("Wasm should have wasm or compose-wasm project type") - } - val compilationResult = translate( - files, - dependencies, - compilerPlugins, - compilerPluginOptions, - debugInfo - ) - val wasmCompilationOutput = when (compilationResult) { - is Compiled -> compilationResult.result - is NotCompiled -> return TranslationJSResult(compilerDiagnostics = compilationResult.compilerDiagnostics) - } - TranslationWasmResult( - jsCode = wasmCompilationOutput.jsCode, - jsInstantiated = wasmCompilationOutput.jsInstantiated, - compilerDiagnostics = compilationResult.compilerDiagnostics, - wasm = wasmCompilationOutput.wasm, - wat = if (debugInfo) wasmCompilationOutput.wat else null - ) + + fun translateJs( + files: List, + arguments: List, + translate: (List, List) -> CompilationResult + ): TranslationJSResult = try { + val compilationResult = translate(files, arguments) + val jsCode = when (compilationResult) { + is Compiled -> compilationResult.result + is NotCompiled -> null + } + TranslationJSResult(jsCode = jsCode, compilerDiagnostics = compilationResult.compilerDiagnostics) } catch (e: Exception) { - TranslationJSResult(exception = e.toExceptionDescriptor()) - } - } - - fun doTranslateWithIr(files: List, arguments: List): CompilationResult = - usingTempDirectory { inputDir -> - val moduleName = "playground" - usingTempDirectory { outputDir -> - val ioFiles = files.writeToIoFiles(inputDir) - val k2JSCompiler = K2JSCompiler() - val filePaths = ioFiles.map { it.toFile().canonicalPath } - val klibPath = (outputDir / "klib").toFile().canonicalPath - val additionalCompilerArgumentsForKLib = listOf( - "-Xreport-all-warnings", - "-Wextra", - "-Xir-produce-klib-dir", - "-libraries=${kotlinEnvironment.JS_LIBRARIES.joinToString(PATH_SEPARATOR)}", - "-ir-output-dir=$klibPath", - "-ir-output-name=$moduleName", - ) - k2JSCompiler.tryCompilation(inputDir, ioFiles, filePaths + additionalCompilerArgumentsForKLib) - .flatMap { - k2JSCompiler.tryCompilation(inputDir, ioFiles, listOf( - "-Xreport-all-warnings", - "-Wextra", - "-Xir-produce-js", - "-Xir-dce", - "-Xinclude=$klibPath", - "-libraries=${kotlinEnvironment.JS_LIBRARIES.joinToString(PATH_SEPARATOR)}", - "-ir-output-dir=${(outputDir / "js").toFile().canonicalPath}", - "-ir-output-name=$moduleName", - )) - } - .map { (outputDir / "js" / "$moduleName.js").readText() } - .map { it.withMainArgumentsIr(arguments) } - .map(::redirectOutput) - } + TranslationJSResult(exception = e.toExceptionDescriptor()) } - private fun redirectOutput(code: String): String { - val listLines = code - .lineSequence() - .toMutableList() - - listLines.add(listLines.size - BEFORE_MAIN_CALL_LINE, JS_IR_OUTPUT_REWRITE) - listLines.add(listLines.size - 1, JS_IR_CODE_BUFFER) - return listLines.joinToString("\n") - } - - - fun doTranslateWithWasm( - files: List, - dependencies: List, - compilerPlugins: List, - compilerPluginOptions: List, - debugInfo: Boolean, - ): CompilationResult = - usingTempDirectory { inputDir -> - val moduleName = "playground" - usingTempDirectory { outputDir -> - val ioFiles = files.writeToIoFiles(inputDir) - val k2JSCompiler = K2JSCompiler() - val filePaths = ioFiles.map { it.toFile().canonicalPath } - val klibPath = (outputDir / "klib").toFile().canonicalPath - val compilerPluginsArgs: List = compilerPlugins - .takeIf { it.isNotEmpty() } - ?.let { plugins -> - plugins.map { - "-Xplugin=$it" - } + compilerPluginOptions.map { - "-P=$it" - } - } ?: emptyList() - val additionalCompilerArgumentsForKLib: List = listOf( - "-Xreport-all-warnings", - "-Wextra", - "-Xwasm", - "-Xir-produce-klib-dir", - "-libraries=${dependencies.joinToString(PATH_SEPARATOR)}", - "-ir-output-dir=$klibPath", - "-ir-output-name=$moduleName", - ) + compilerPluginsArgs - - k2JSCompiler.tryCompilation(inputDir, ioFiles, filePaths + additionalCompilerArgumentsForKLib) - .flatMap { - k2JSCompiler.tryCompilation(inputDir, ioFiles, mutableListOf( - "-Xreport-all-warnings", - "-Wextra", - "-Xwasm", - "-Xir-produce-js", - "-Xir-dce", - "-Xinclude=$klibPath", - "-libraries=${dependencies.joinToString(PATH_SEPARATOR)}", - "-ir-output-dir=${(outputDir / "wasm").toFile().canonicalPath}", - "-ir-output-name=$moduleName", - ).also { if (debugInfo) it.add("-Xwasm-generate-wat") }) - } - .map { - WasmTranslationSuccessfulOutput( - jsCode = (outputDir / "wasm" / "$moduleName.uninstantiated.mjs").readText(), - jsInstantiated = (outputDir / "wasm" / "$moduleName.mjs").readText(), - wasm = (outputDir / "wasm" / "$moduleName.wasm").readBytes(), - wat = if (debugInfo) (outputDir / "wasm" / "$moduleName.wat").readText() else null, + fun translateWasm( + files: List, + debugInfo: Boolean, + projectType: ProjectType, + translate: (List, List, List, List, Boolean) -> CompilationResult + ): TranslationResultWithJsCode { + return try { + val (dependencies, compilerPlugins, compilerPluginOptions) = when (projectType) { + ProjectType.WASM -> listOf( + kotlinEnvironment.WASM_LIBRARIES, + emptyList(), + emptyList() + ) + + ProjectType.COMPOSE_WASM -> listOf( + kotlinEnvironment.COMPOSE_WASM_LIBRARIES, + kotlinEnvironment.COMPOSE_WASM_COMPILER_PLUGINS, + kotlinEnvironment.composeWasmCompilerPluginOptions + ) + + else -> throw IllegalStateException("Wasm should have wasm or compose-wasm project type") + } + val compilationResult = translate( + files, + dependencies, + compilerPlugins, + compilerPluginOptions, + debugInfo + ) + val wasmCompilationOutput = when (compilationResult) { + is Compiled -> compilationResult.result + is NotCompiled -> return TranslationJSResult(compilerDiagnostics = compilationResult.compilerDiagnostics) + } + TranslationWasmResult( + jsCode = wasmCompilationOutput.jsCode, + jsInstantiated = wasmCompilationOutput.jsInstantiated, + compilerDiagnostics = compilationResult.compilerDiagnostics, + wasm = wasmCompilationOutput.wasm, + wat = if (debugInfo) wasmCompilationOutput.wat else null ) - } - } + } catch (e: Exception) { + TranslationJSResult(exception = e.toExceptionDescriptor()) + } + } + + fun doTranslateWithIr(files: List, arguments: List): CompilationResult = + usingTempDirectory { inputDir -> + val moduleName = "playground" + usingTempDirectory { outputDir -> + val ioFiles = files.writeToIoFiles(inputDir) + val k2JSCompiler = K2JSCompiler() + val filePaths = ioFiles.map { it.toFile().canonicalPath } + val klibPath = (outputDir / "klib").toFile().canonicalPath + val additionalCompilerArgumentsForKLib = listOf( + "-Xreport-all-warnings", + "-Wextra", + "-Xir-produce-klib-dir", + "-libraries=${kotlinEnvironment.JS_LIBRARIES.joinToString(PATH_SEPARATOR)}", + "-ir-output-dir=$klibPath", + "-ir-output-name=$moduleName", + ) + k2JSCompiler.tryCompilation(inputDir, ioFiles, filePaths + additionalCompilerArgumentsForKLib) + .flatMap { + k2JSCompiler.tryCompilation( + inputDir, ioFiles, listOf( + "-Xreport-all-warnings", + "-Wextra", + "-Xir-produce-js", + "-Xir-dce", + "-Xinclude=$klibPath", + "-libraries=${kotlinEnvironment.JS_LIBRARIES.joinToString(PATH_SEPARATOR)}", + "-ir-output-dir=${(outputDir / "js").toFile().canonicalPath}", + "-ir-output-name=$moduleName", + ) + ) + } + .map { (outputDir / "js" / "$moduleName.js").readText() } + .map { it.withMainArgumentsIr(arguments) } + .map(::redirectOutput) + } + } + + private fun redirectOutput(code: String): String { + val listLines = code + .lineSequence() + .toMutableList() + + listLines.add(listLines.size - BEFORE_MAIN_CALL_LINE, JS_IR_OUTPUT_REWRITE) + listLines.add(listLines.size - 1, JS_IR_CODE_BUFFER) + return listLines.joinToString("\n") } + + + fun doTranslateWithWasm( + files: List, + dependencies: List, + compilerPlugins: List, + compilerPluginOptions: List, + debugInfo: Boolean, + ): CompilationResult = + usingTempDirectory { inputDir -> + val moduleName = "playground" + usingTempDirectory { outputDir -> + val ioFiles = files.writeToIoFiles(inputDir) + val k2JSCompiler = K2JSCompiler() + val filePaths = ioFiles.map { it.toFile().canonicalPath } + val klibPath = (outputDir / "klib").toFile().canonicalPath + val compilerPluginsArgs: List = compilerPlugins + .takeIf { it.isNotEmpty() } + ?.let { plugins -> + plugins.map { + "-Xplugin=$it" + } + compilerPluginOptions.map { + "-P=$it" + } + } ?: emptyList() + val additionalCompilerArgumentsForKLib: List = listOf( + "-Xreport-all-warnings", + "-Wextra", + "-Xwasm", + "-Xir-produce-klib-dir", + "-libraries=${dependencies.joinToString(PATH_SEPARATOR)}", + "-ir-output-dir=$klibPath", + "-ir-output-name=$moduleName", + ) + compilerPluginsArgs + + k2JSCompiler.tryCompilation(inputDir, ioFiles, filePaths + additionalCompilerArgumentsForKLib) + .flatMap { + k2JSCompiler.tryCompilation( + inputDir, ioFiles, mutableListOf( + "-Xreport-all-warnings", + "-Wextra", + "-Xwasm", + "-Xir-produce-js", + "-Xir-dce", + "-Xinclude=$klibPath", + "-libraries=${dependencies.joinToString(PATH_SEPARATOR)}", + "-ir-output-dir=${(outputDir / "wasm").toFile().canonicalPath}", + "-ir-output-name=$moduleName", + ).also { if (debugInfo) it.add("-Xwasm-generate-wat") }) + } + .map { + WasmTranslationSuccessfulOutput( + jsCode = (outputDir / "wasm" / "$moduleName.uninstantiated.mjs").readText(), + jsInstantiated = (outputDir / "wasm" / "$moduleName.mjs").readText(), + wasm = (outputDir / "wasm" / "$moduleName.wasm").readBytes(), + wat = if (debugInfo) (outputDir / "wasm" / "$moduleName.wat").readText() else null, + ) + } + } + } } private fun String.withMainArgumentsIr(arguments: List): String { - val mainIrFunction = """ + val mainIrFunction = """ | function mainWrapper() { | main([%s]); | } """.trimMargin() - return replace( - String.format(mainIrFunction, ""), - String.format(mainIrFunction, arguments.joinToString { ObjectMapper().writeValueAsString(it) }) - ) + return replace( + String.format(mainIrFunction, ""), + String.format(mainIrFunction, arguments.joinToString { ObjectMapper().writeValueAsString(it) }) + ) } data class WasmTranslationSuccessfulOutput( - val jsCode: String, - val jsInstantiated: String, - val wasm: ByteArray, - val wat: String?, + val jsCode: String, + val jsInstantiated: String, + val wasm: ByteArray, + val wat: String?, ) diff --git a/src/main/kotlin/com/compiler/server/executor/ExecutorMessages.kt b/src/main/kotlin/com/compiler/server/executor/ExecutorMessages.kt index d0fbc6451..dcd5cade2 100644 --- a/src/main/kotlin/com/compiler/server/executor/ExecutorMessages.kt +++ b/src/main/kotlin/com/compiler/server/executor/ExecutorMessages.kt @@ -3,5 +3,4 @@ package com.compiler.server.executor object ExecutorMessages { const val TIMEOUT_MESSAGE = "Evaluation stopped while it's taking too long️" const val TOO_LONG_OUTPUT_MESSAGE = "Evaluation stopped while log size exceeded max size" - const val NO_COMPILERS_FILE_FOUND = "No compilation files found!" } \ No newline at end of file diff --git a/src/main/kotlin/com/compiler/server/model/Analysis.kt b/src/main/kotlin/com/compiler/server/model/Analysis.kt deleted file mode 100644 index 51a0a8f10..000000000 --- a/src/main/kotlin/com/compiler/server/model/Analysis.kt +++ /dev/null @@ -1,21 +0,0 @@ -package com.compiler.server.model - -import org.jetbrains.kotlin.analyzer.AnalysisResult -import org.jetbrains.kotlin.container.ComponentProvider -import org.jetbrains.kotlin.ir.backend.js.ModulesStructure - -interface Analysis { - val componentProvider: ComponentProvider - val analysisResult: AnalysisResult -} - -data class AnalysisJvm( - override val componentProvider: ComponentProvider, - override val analysisResult: AnalysisResult -) : Analysis - -data class AnalysisJs( - val sourceModule: ModulesStructure, - override val componentProvider: ComponentProvider, - override val analysisResult: AnalysisResult -) : Analysis \ No newline at end of file diff --git a/src/main/kotlin/com/compiler/server/model/Project.kt b/src/main/kotlin/com/compiler/server/model/Project.kt index b8afd6fee..ec259cf5c 100644 --- a/src/main/kotlin/com/compiler/server/model/Project.kt +++ b/src/main/kotlin/com/compiler/server/model/Project.kt @@ -22,9 +22,4 @@ enum class ProjectType(@JsonValue val id: String) { WASM("wasm"), COMPOSE_WASM("compose-wasm"); - fun isJvmRelated(): Boolean = this == JAVA || this == JUNIT - - fun isJsRelated(): Boolean = this == JS_IR || this == JS || this == CANVAS - - fun isWasmRelated(): Boolean = this == WASM || this == COMPOSE_WASM } \ No newline at end of file diff --git a/src/main/kotlin/com/compiler/server/model/ProjectSeveriry.kt b/src/main/kotlin/com/compiler/server/model/ProjectSeveriry.kt index 371d41c32..520262260 100644 --- a/src/main/kotlin/com/compiler/server/model/ProjectSeveriry.kt +++ b/src/main/kotlin/com/compiler/server/model/ProjectSeveriry.kt @@ -13,7 +13,6 @@ enum class ProjectSeveriry { Severity.ERROR -> ERROR Severity.INFO -> INFO Severity.WARNING, Severity.FIXED_WARNING -> WARNING - else -> WARNING } } } diff --git a/src/main/kotlin/com/compiler/server/service/KotlinProjectExecutor.kt b/src/main/kotlin/com/compiler/server/service/KotlinProjectExecutor.kt index d0177c4ff..6f398b150 100644 --- a/src/main/kotlin/com/compiler/server/service/KotlinProjectExecutor.kt +++ b/src/main/kotlin/com/compiler/server/service/KotlinProjectExecutor.kt @@ -1,128 +1,111 @@ package com.compiler.server.service -import com.compiler.server.compiler.KotlinFile import com.compiler.server.compiler.components.* import com.compiler.server.model.* import com.compiler.server.model.bean.VersionInfo import component.KotlinEnvironment import model.Completion -import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment -import org.jetbrains.kotlin.psi.KtFile +import org.junit.Ignore import org.slf4j.LoggerFactory import org.springframework.stereotype.Component @Component class KotlinProjectExecutor( - private val kotlinCompiler: KotlinCompiler, - private val completionProvider: CompletionProvider, - private val version: VersionInfo, - private val kotlinToJSTranslator: KotlinToJSTranslator, - private val kotlinEnvironment: KotlinEnvironment, - private val loggerDetailsStreamer: LoggerDetailsStreamer? = null, + private val kotlinCompiler: KotlinCompiler, + private val environment: KotlinEnvironment, + private val version: VersionInfo, + private val kotlinToJSTranslator: KotlinToJSTranslator, + private val loggerDetailsStreamer: LoggerDetailsStreamer? = null, ) { - private val log = LoggerFactory.getLogger(KotlinProjectExecutor::class.java) - - fun run(project: Project, addByteCode: Boolean): ExecutionResult { - return kotlinEnvironment.environment { environment -> - val files = getFilesFrom(project, environment).map { it.kotlinFile } - kotlinCompiler.run(files, addByteCode, project.args) - }.also { logExecutionResult(project, it) } - } - - fun test(project: Project, addByteCode: Boolean): ExecutionResult { - return kotlinEnvironment.environment { environment -> - val files = getFilesFrom(project, environment).map { it.kotlinFile } - kotlinCompiler.test(files, addByteCode) - }.also { logExecutionResult(project, it) } - } - - fun convertToJsIr(project: Project): TranslationJSResult { - return convertJsWithConverter(project, kotlinToJSTranslator::doTranslateWithIr) - } - - fun compileToJvm(project: Project): CompilationResult { - val files = kotlinEnvironment.environment { environment -> - getFilesFrom(project, environment).map { it.kotlinFile } + private val log = LoggerFactory.getLogger(KotlinProjectExecutor::class.java) + + fun run(project: Project, addByteCode: Boolean): ExecutionResult { + return environment.synchronize { kotlinCompiler.run(project.files, addByteCode, project.args) } + .also { logExecutionResult(project, it) } + } + + fun test(project: Project, addByteCode: Boolean): ExecutionResult { + return environment.synchronize { kotlinCompiler.test(project.files, addByteCode) } + .also { logExecutionResult(project, it) } } - return kotlinCompiler.compile(files) - } - - fun convertToWasm(project: Project, debugInfo: Boolean): TranslationResultWithJsCode { - return convertWasmWithConverter(project, debugInfo, kotlinToJSTranslator::doTranslateWithWasm) - } - - fun complete(project: Project, line: Int, character: Int): List { - return kotlinEnvironment.environment { - val file = getFilesFrom(project, it).first() - try { - completionProvider.complete(file, line, character, project.confType, it) - } catch (e: Exception) { - log.warn("Exception in getting completions. Project: $project", e) - emptyList() - } + + fun convertToJsIr(project: Project): TranslationJSResult { + return convertJsWithConverter(project, kotlinToJSTranslator::doTranslateWithIr) } - } - - fun highlight(project: Project): CompilerDiagnostics = try { - when (project.confType) { - ProjectType.JAVA, ProjectType.JUNIT -> compileToJvm(project).compilerDiagnostics - ProjectType.CANVAS, ProjectType.JS, ProjectType.JS_IR -> - convertToJsIr( - project, - ).compilerDiagnostics - ProjectType.WASM, ProjectType.COMPOSE_WASM -> - convertToWasm( - project, - debugInfo = false, - ).compilerDiagnostics + + fun compileToJvm(project: Project): CompilationResult { + return kotlinCompiler.compile(project.files) } - } catch (e: Exception) { - log.warn("Exception in getting highlight. Project: $project", e) - CompilerDiagnostics(emptyMap()) - } - - fun getVersion() = version - - private fun convertJsWithConverter( - project: Project, - converter: (List, List) -> CompilationResult - ): TranslationJSResult { - return kotlinEnvironment.environment { environment -> - val files = getFilesFrom(project, environment).map { it.kotlinFile } - kotlinToJSTranslator.translateJs( - files, - project.args.split(" "), - converter - ) - }.also { logExecutionResult(project, it) } - } - - private fun convertWasmWithConverter( - project: Project, - debugInfo: Boolean, - converter: (List, List, List, List, Boolean) -> CompilationResult - ): TranslationResultWithJsCode { - return kotlinEnvironment.environment { environment -> - val files = getFilesFrom(project, environment).map { it.kotlinFile } - kotlinToJSTranslator.translateWasm( - files, - debugInfo, - project.confType, - converter - ) - }.also { logExecutionResult(project, it) } - } - - private fun logExecutionResult(project: Project, executionResult: ExecutionResult) { - loggerDetailsStreamer?.logExecutionResult( - executionResult, - project.confType, - getVersion().version - ) - } - - private fun getFilesFrom(project: Project, coreEnvironment: KotlinCoreEnvironment) = project.files.map { - KotlinFile.from(coreEnvironment.project, it.name, it.text) - } + + fun convertToWasm(project: Project, debugInfo: Boolean): TranslationResultWithJsCode { + return convertWasmWithConverter(project, debugInfo, kotlinToJSTranslator::doTranslateWithWasm) + } + + // TODO(Dmitrii Krasnov): implement this method in KTL-2807 + @Ignore + fun complete(project: Project, line: Int, character: Int): List { + return emptyList() + } + + fun highlight(project: Project): CompilerDiagnostics = try { + when (project.confType) { + ProjectType.JAVA, ProjectType.JUNIT -> compileToJvm(project).compilerDiagnostics + ProjectType.CANVAS, ProjectType.JS, ProjectType.JS_IR -> + convertToJsIr( + project, + ).compilerDiagnostics + + ProjectType.WASM, ProjectType.COMPOSE_WASM -> + convertToWasm( + project, + debugInfo = false, + ).compilerDiagnostics + } + } catch (e: Exception) { + log.warn("Exception in getting highlight. Project: $project", e) + CompilerDiagnostics(emptyMap()) + } + + fun getVersion() = version + + private fun convertJsWithConverter( + project: Project, + converter: (List, List) -> CompilationResult + ): TranslationJSResult { + return environment.synchronize { + kotlinToJSTranslator.translateJs( + project.files, + project.args.split(" "), + converter + ) + } + .also { logExecutionResult(project, it) } + } + + private fun convertWasmWithConverter( + project: Project, + debugInfo: Boolean, + converter: (List, List, List, List, Boolean) -> CompilationResult + ): TranslationResultWithJsCode { + + return environment.synchronize { + kotlinToJSTranslator.translateWasm( + project.files, + debugInfo, + project.confType, + converter + ) + } + .also { logExecutionResult(project, it) } + } + + private fun logExecutionResult(project: Project, executionResult: ExecutionResult) { + loggerDetailsStreamer?.logExecutionResult( + executionResult, + project.confType, + getVersion().version + ) + } + } From 7b0f76d3ca7db28fe29686b3ef3ed3325fb99077 Mon Sep 17 00:00:00 2001 From: Dmitrii Krasnov Date: Thu, 7 Aug 2025 10:10:14 +0200 Subject: [PATCH 10/20] KTL-1220: Removed dev repositories They were necessary only for the idea dependencies --- ...ler-server-version-catalog.settings.gradle.kts | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/build-settings-logic/src/main/kotlin/kotlin-compiler-server-version-catalog.settings.gradle.kts b/build-settings-logic/src/main/kotlin/kotlin-compiler-server-version-catalog.settings.gradle.kts index 0c4fcab6b..9e4b89e2e 100644 --- a/build-settings-logic/src/main/kotlin/kotlin-compiler-server-version-catalog.settings.gradle.kts +++ b/build-settings-logic/src/main/kotlin/kotlin-compiler-server-version-catalog.settings.gradle.kts @@ -2,7 +2,6 @@ pluginManagement { repositories { gradlePluginPortal() mavenCentral() - mavenLocal() val additionalRepositoryProperty = providers.gradleProperty("kotlin_repo_url") if (additionalRepositoryProperty.isPresent) { @@ -11,9 +10,7 @@ pluginManagement { } logger.info("A custom Kotlin repository ${additionalRepositoryProperty.get()} was added") } - - maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/bootstrap") - maven("https://redirector.kotlinlang.org/maven/dev") + mavenLocal() } } @@ -22,7 +19,6 @@ dependencyResolutionManagement { repositories { mavenCentral() gradlePluginPortal() - mavenLocal() val additionalRepositoryProperty = providers.gradleProperty("kotlin_repo_url") if (additionalRepositoryProperty.isPresent) { @@ -31,14 +27,7 @@ dependencyResolutionManagement { } logger.info("A custom Kotlin repository ${additionalRepositoryProperty.get()} was added") } - - maven("https://repo.spring.io/snapshot") - maven("https://repo.spring.io/milestone") - maven("https://redirector.kotlinlang.org/maven/dev") - maven("https://www.myget.org/F/rd-snapshots/maven/") - maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/bootstrap") - maven("https://maven.pkg.jetbrains.space/kotlin/p/wasm/experimental") - maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") + mavenLocal() } versionCatalogs { From 7f11d229832d23fb1721742bf14df7519aa0c4eb Mon Sep 17 00:00:00 2001 From: Dmitrii Krasnov Date: Thu, 7 Aug 2025 10:44:28 +0200 Subject: [PATCH 11/20] Added running build with dev repository for kotlin-community/* branches --- .github/workflows/gradle.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index f364dbe4d..e52884b34 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -30,5 +30,9 @@ jobs: run: chmod +x gradlew - name: Setup Gradle uses: gradle/actions/setup-gradle@v4 - - name: Build with Gradle + - name: Build with Gradle (kotlin-community) + if: startsWith(github.ref, 'refs/heads/kotlin-community/') + run: ./gradlew build -Pkotlin_repo_url=https://redirector.kotlinlang.org/maven/dev + - name: Build with Gradle (default) + if: "!startsWith(github.ref, 'refs/heads/kotlin-community/')" run: ./gradlew build From 67d19bbb1faafd0d50bd492130fdbb1583fa9c77 Mon Sep 17 00:00:00 2001 From: Dmitrii Krasnov Date: Fri, 8 Aug 2025 13:31:00 +0200 Subject: [PATCH 12/20] KTL-1220: Ignored tests connected to completion. --- .../com/compiler/server/CompletionTest.kt | 3 + .../compiler/server/ConcurrencyRunnerTest.kt | 121 ++--- .../kotlin/com/compiler/server/ImportTest.kt | 424 +++++++++--------- 3 files changed, 281 insertions(+), 267 deletions(-) diff --git a/src/test/kotlin/com/compiler/server/CompletionTest.kt b/src/test/kotlin/com/compiler/server/CompletionTest.kt index 9737aae17..729183eb2 100644 --- a/src/test/kotlin/com/compiler/server/CompletionTest.kt +++ b/src/test/kotlin/com/compiler/server/CompletionTest.kt @@ -2,7 +2,10 @@ package com.compiler.server import com.compiler.server.base.BaseExecutorTest import org.junit.jupiter.api.Test +import kotlin.test.Ignore +// TODO(Dmitrii Krasnov): this test is disabled until KTL-2807 is fixed +@Ignore class CompletionTest : BaseExecutorTest() { @Test fun `variable completion test`() { diff --git a/src/test/kotlin/com/compiler/server/ConcurrencyRunnerTest.kt b/src/test/kotlin/com/compiler/server/ConcurrencyRunnerTest.kt index 0b5a8fecb..bc4c669ed 100644 --- a/src/test/kotlin/com/compiler/server/ConcurrencyRunnerTest.kt +++ b/src/test/kotlin/com/compiler/server/ConcurrencyRunnerTest.kt @@ -5,77 +5,82 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import kotlinx.coroutines.runBlocking import org.junit.jupiter.api.Test +import kotlin.test.Ignore class ConcurrencyRunnerTest : BaseExecutorTest() { - @Test - fun `a lot of hello word test JVM`() { - runManyTest { - run( - code = "fun main() {\n println(\"Hello, world!!!\")\n}", - contains = "Hello, world!!!" - ) + @Test + fun `a lot of hello word test JVM`() { + runManyTest { + run( + code = "fun main() {\n println(\"Hello, world!!!\")\n}", + contains = "Hello, world!!!" + ) + } } - } - @Test - fun `a lot of complete test`() { - runManyTest { - complete( - code = "fun main() {\n val alex = 1\n val alex1 = 1 + a\n}", - line = 2, - character = 21, - completions = listOf( - "alex" - ) - ) + // TODO(Dmitrii Krasnov): this test is disabled until KTL-2807 is fixed + @Ignore + @Test + fun `a lot of complete test`() { + runManyTest { + complete( + code = "fun main() {\n val alex = 1\n val alex1 = 1 + a\n}", + line = 2, + character = 21, + completions = listOf( + "alex" + ) + ) + } } - } - @Test - fun `a lot of complete test JS`() { - runManyTest { - complete( - code = "fun main() {\n val alex = 1\n val alex1 = 1 + a\n}", - line = 2, - character = 21, - completions = listOf( - "alex" - ), - isJs = true - ) + // TODO(Dmitrii Krasnov): this test is disabled until KTL-2807 is fixed + @Ignore + @Test + fun `a lot of complete test JS`() { + runManyTest { + complete( + code = "fun main() {\n val alex = 1\n val alex1 = 1 + a\n}", + line = 2, + character = 21, + completions = listOf( + "alex" + ), + isJs = true + ) + } } - } - @Test - fun `a lot of hello word test JS`() { - runManyTest { - runJsIr( - code = "fun main() {\n println(\"Hello, world!!!\")\n}", - contains = "println('Hello, world!!!');" - ) + @Test + fun `a lot of hello word test JS`() { + runManyTest { + runJsIr( + code = "fun main() {\n println(\"Hello, world!!!\")\n}", + contains = "println('Hello, world!!!');" + ) + } } - } - @Test - fun `a lot of hello word test JS IR`() { - runManyTest { - runJsIr( - code = "fun main() {\n println(\"Hello, world!!!\")\n}", - contains = "println('Hello, world!!!');" - ) + @Test + fun `a lot of hello word test JS IR`() { + runManyTest { + runJsIr( + code = "fun main() {\n println(\"Hello, world!!!\")\n}", + contains = "println('Hello, world!!!');" + ) + } } - } - private fun runManyTest(times: Int = 100, test: () -> Unit) { - runBlocking { - launch(Dispatchers.IO) { - for (i in 0 until times) { - launch(Dispatchers.IO) { - test() - } + private fun runManyTest(times: Int = 100, test: () -> Unit) { + runBlocking { + launch(Dispatchers.IO) { + for (i in 0 until times) { + launch(Dispatchers.IO) { + test() + } + } + }.join() } - }.join() } - } } \ No newline at end of file diff --git a/src/test/kotlin/com/compiler/server/ImportTest.kt b/src/test/kotlin/com/compiler/server/ImportTest.kt index 75271c999..84a6af387 100644 --- a/src/test/kotlin/com/compiler/server/ImportTest.kt +++ b/src/test/kotlin/com/compiler/server/ImportTest.kt @@ -4,243 +4,249 @@ import com.compiler.server.base.BaseExecutorTest import model.Completion import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test +import kotlin.test.Ignore +import kotlin.test.assertEquals +// TODO(Dmitrii Krasnov): this test is disabled until KTL-2807 is fixed +@Ignore class ImportTest : BaseExecutorTest() { - @Test - fun `import class`() { - complete( - code = "fun main() {\n val rand = Random\n}", - line = 1, - character = 21, - completions = listOf( - "Random (kotlin.random.Random)" - ) - ) - } + @Test + fun `import class`() { + complete( + code = "fun main() {\n val rand = Random\n}", + line = 1, + character = 21, + completions = listOf( + "Random (kotlin.random.Random)" + ) + ) + } - @Test - fun `import class with import`() { - val foundCompletions = getCompletions( - code = "import kotlin.math.sin\nimport java.util.Random\nfun main() {\n" + - " val rand = Random\n" + - "}", - line = 3, - character = 21 - ) - completionContainsCheckOtherImports( - foundCompletions = foundCompletions, - completions = listOf( - Pair("Random (kotlin.random.Random)", true) - ) - ) - } + @Test + fun `import class with import`() { + val foundCompletions = getCompletions( + code = "import kotlin.math.sin\nimport java.util.Random\nfun main() {\n" + + " val rand = Random\n" + + "}", + line = 3, + character = 21 + ) + completionContainsCheckOtherImports( + foundCompletions = foundCompletions, + completions = listOf( + Pair("Random (kotlin.random.Random)", true) + ) + ) + } - @Test - fun `import method with other import`() { - val foundCompletions = getCompletions( - code = "import kotlin.math.sin\nfun main() {\n" + - " val s = sin\n" + - "}", - line = 2, - character = 15 - ).map { it.displayText } - val completions = listOf( - "sin(x: Double) (kotlin.math.sin)", - "sin(x: Float) (kotlin.math.sin)" - ) - completions.forEach { - Assertions.assertFalse( - foundCompletions.contains(it), - "Suggests adding an import, even though it has already been added." - ) + @Test + fun `import method with other import`() { + val foundCompletions = getCompletions( + code = "import kotlin.math.sin\nfun main() {\n" + + " val s = sin\n" + + "}", + line = 2, + character = 15 + ).map { it.displayText } + val completions = listOf( + "sin(x: Double) (kotlin.math.sin)", + "sin(x: Float) (kotlin.math.sin)" + ) + assertEquals(1, foundCompletions.size) + completions.forEach { + Assertions.assertFalse( + foundCompletions.contains(it), + "Suggests adding an import, even though it has already been added." + ) + } } - } - @Test - fun `import class with parameters`() { - complete( - code = """fun main() { + @Test + fun `import class with parameters`() { + complete( + code = """fun main() { | randVal = Random(3) | println(randomVal.nextInt()) |} """.trimMargin(), - line = 1, - character = 20, - completions = listOf( - "Random (kotlin.random.Random)" - ) - ) - } + line = 1, + character = 20, + completions = listOf( + "Random (kotlin.random.Random)" + ) + ) + } - @Test - fun `import method`() { - complete( - code = "fun main() {\n" + - " val s = sin\n" + - "}", - line = 1, - character = 15, - completions = listOf( - "sin(x: Double) (kotlin.math.sin)", - "sin(x: Float) (kotlin.math.sin)" - ) - ) - } + @Test + fun `import method`() { + complete( + code = "fun main() {\n" + + " val s = sin\n" + + "}", + line = 1, + character = 15, + completions = listOf( + "sin(x: Double) (kotlin.math.sin)", + "sin(x: Float) (kotlin.math.sin)" + ) + ) + } - @Test - fun `open bracket after import completion`() { - val foundCompletionsTexts = getCompletions( - code = "fun main() {\n" + - " val s = sin\n" + - "}", - line = 1, - character = 15 - ).map { it.text } - val completions = listOf("kotlin.math.sin(") - completions.forEach { - Assertions.assertTrue( - foundCompletionsTexts.contains(it), - "Wrong completion text for import. Expected to find $it in $foundCompletionsTexts" - ) + @Test + fun `open bracket after import completion`() { + val foundCompletionsTexts = getCompletions( + code = "fun main() {\n" + + " val s = sin\n" + + "}", + line = 1, + character = 15 + ).map { it.text } + val completions = listOf("kotlin.math.sin(") + completions.forEach { + Assertions.assertTrue( + foundCompletionsTexts.contains(it), + "Wrong completion text for import. Expected to find $it in $foundCompletionsTexts" + ) + } } - } - @Test - fun `brackets after import completion`() { - val foundCompletionsTexts = getCompletions( - code = "fun main() {\n" + - " val timeZone = getDefaultTimeZone\n" + - "}", - line = 1, - character = 38 - ).map { it.text } - val completions = listOf( - "com.fasterxml.jackson.databind.util.StdDateFormat.getDefaultTimeZone()" - ) - completions.forEach { - Assertions.assertTrue( - foundCompletionsTexts.contains(it), - "Wrong completion text for import. Expected to find $it in $foundCompletionsTexts" - ) + @Test + fun `brackets after import completion`() { + val foundCompletionsTexts = getCompletions( + code = "fun main() {\n" + + " val timeZone = getDefaultTimeZone\n" + + "}", + line = 1, + character = 38 + ).map { it.text } + val completions = listOf( + "com.fasterxml.jackson.databind.util.StdDateFormat.getDefaultTimeZone()" + ) + completions.forEach { + Assertions.assertTrue( + foundCompletionsTexts.contains(it), + "Wrong completion text for import. Expected to find $it in $foundCompletionsTexts" + ) + } } - } - @Test - fun `import class js`() { - complete( - code = "fun main() {\n val rand = Random\n}", - line = 1, - character = 21, - completions = listOf( - "Random (kotlin.random.Random)" - ), - isJs = true - ) - } + @Test + fun `import class js`() { + complete( + code = "fun main() {\n val rand = Random\n}", + line = 1, + character = 21, + completions = listOf( + "Random (kotlin.random.Random)" + ), + isJs = true + ) + } - @Test - fun `import method with other import js`() { - val foundCompletions = getCompletions( - code = "import kotlin.math.sin\nfun main() {\n" + - " val s = sin\n" + - "}", - line = 2, - character = 15, - isJs = true - ).map { it.displayText } - val completions = listOf( - "sin(x: Double) (kotlin.math.sin)", - "sin(x: Float) (kotlin.math.sin)" - ) - completions.forEach { - Assertions.assertFalse( - foundCompletions.contains(it), - "Suggests adding an import, even though it has already been added." - ) + @Test + fun `import method with other import js`() { + val foundCompletions = getCompletions( + code = "import kotlin.math.sin\nfun main() {\n" + + " val s = sin\n" + + "}", + line = 2, + character = 15, + isJs = true + ).map { it.displayText } + val completions = listOf( + "sin(x: Double) (kotlin.math.sin)", + "sin(x: Float) (kotlin.math.sin)" + ) + assertEquals(1, foundCompletions.size) + completions.forEach { + Assertions.assertFalse( + foundCompletions.contains(it), + "Suggests adding an import, even though it has already been added." + ) + } } - } - @Test - fun `import class with parameters js`() { - complete( - code = """fun main() { + @Test + fun `import class with parameters js`() { + complete( + code = """fun main() { | randVal = Random(3) | println(randomVal.nextInt()) |} """.trimMargin(), - line = 1, - character = 20, - completions = listOf( - "Random (kotlin.random.Random)" - ), - isJs = true - ) - } + line = 1, + character = 20, + completions = listOf( + "Random (kotlin.random.Random)" + ), + isJs = true + ) + } - @Test - fun `import method js`() { - complete( - code = "fun main() {\n" + - " val s = sin\n" + - "}", - line = 1, - character = 15, - completions = listOf( - "sin(x: Double) (kotlin.math.sin)", - "sin(x: Float) (kotlin.math.sin)" - ), - isJs = true - ) - } + @Test + fun `import method js`() { + complete( + code = "fun main() {\n" + + " val s = sin\n" + + "}", + line = 1, + character = 15, + completions = listOf( + "sin(x: Double) (kotlin.math.sin)", + "sin(x: Float) (kotlin.math.sin)" + ), + isJs = true + ) + } - @Test - fun `open bracket after import completion js`() { - val foundCompletionsTexts = getCompletions( - code = "fun main() {\n" + - " val s = sin\n" + - "}", - line = 1, - character = 15, - isJs = true - ).map { it.text } - val completions = listOf("kotlin.math.sin(") - completions.forEach { - Assertions.assertTrue( - foundCompletionsTexts.contains(it), - "Wrong completion text for import. Expected to find $it in $foundCompletionsTexts" - ) + @Test + fun `open bracket after import completion js`() { + val foundCompletionsTexts = getCompletions( + code = "fun main() {\n" + + " val s = sin\n" + + "}", + line = 1, + character = 15, + isJs = true + ).map { it.text } + val completions = listOf("kotlin.math.sin(") + completions.forEach { + Assertions.assertTrue( + foundCompletionsTexts.contains(it), + "Wrong completion text for import. Expected to find $it in $foundCompletionsTexts" + ) + } } - } - @Test - fun `not jvm imports in js imports`() { - val foundCompletionsTexts = getCompletions( - code = "fun main() {\n" + - " val timeZone = getDefaultTimeZone\n" + - "}", - line = 1, - character = 38, - isJs = true - ).map { it.text } - val completions = listOf( - "com.fasterxml.jackson.databind.util.StdDateFormat.getDefaultTimeZone()" - ) - completions.forEach { - Assertions.assertFalse( - foundCompletionsTexts.contains(it), - "Wrong completion text for import. Expected not to find $it in $foundCompletionsTexts" - ) + @Test + fun `not jvm imports in js imports`() { + val foundCompletionsTexts = getCompletions( + code = "fun main() {\n" + + " val timeZone = getDefaultTimeZone\n" + + "}", + line = 1, + character = 38, + isJs = true + ).map { it.text } + val completions = listOf( + "com.fasterxml.jackson.databind.util.StdDateFormat.getDefaultTimeZone()" + ) + completions.forEach { + Assertions.assertFalse( + foundCompletionsTexts.contains(it), + "Wrong completion text for import. Expected not to find $it in $foundCompletionsTexts" + ) + } } - } - private fun completionContainsCheckOtherImports( - foundCompletions: List, - completions: List> - ) { - val result = foundCompletions.map { Pair(it.displayText, it.hasOtherImports) } - Assertions.assertTrue(result.isNotEmpty()) - completions.forEach { suggest -> - Assertions.assertTrue(result.contains(suggest)) + private fun completionContainsCheckOtherImports( + foundCompletions: List, + completions: List> + ) { + val result = foundCompletions.map { Pair(it.displayText, it.hasOtherImports) } + Assertions.assertTrue(result.isNotEmpty()) + completions.forEach { suggest -> + Assertions.assertTrue(result.contains(suggest)) + } } - } } \ No newline at end of file From a0f022e784111b3335af204bf0c05e5a8f695168 Mon Sep 17 00:00:00 2001 From: Dmitrii Krasnov Date: Fri, 8 Aug 2025 15:33:52 +0200 Subject: [PATCH 13/20] KTL-1220: Removed idea dependencies from dependabot ignore list --- .github/dependabot.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index f83472709..2a9043508 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -11,11 +11,8 @@ updates: - dependency-name: "org.jetbrains.kotlin:kotlin-compiler" - dependency-name: "org.jetbrains.kotlin:kotlin-reflect" - dependency-name: "org.jetbrains.kotlin:kotlin-stdlib-js" - - dependency-name: "org.jetbrains.kotlin:kotlin-compiler-for-ide" - dependency-name: "org.jetbrains.kotlin:kotlin-stdlib" - dependency-name: "org.jetbrains.kotlin:kotlin-script-runtime" - - dependency-name: "org.jetbrains.kotlin:ide" - - dependency-name: "org.jetbrains.kotlin:idea" - dependency-name: "org.jetbrains.kotlin:kotlin-test" - dependency-name: "org.jetbrains.kotlin:core" - dependency-name: "org.jetbrains.kotlin:common" From 4f2f724980c1717c5dd0d5c39d4d6e06a799cbbe Mon Sep 17 00:00:00 2001 From: Dmitrii Krasnov Date: Wed, 13 Aug 2025 13:59:03 +0200 Subject: [PATCH 14/20] KTL-1220: Removed jdk7 and jdk8 stdlib dependencies --- build.gradle.kts | 2 +- dependencies/build.gradle.kts | 2 +- gradle/libs.versions.toml | 3 --- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index a09ef7714..0ee27b76f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -44,7 +44,7 @@ dependencies { implementation(libs.junit) implementation(libs.logback.logstash.encoder) implementation(libs.kotlin.reflect) - implementation(libs.bundles.kotlin.stdlib) + implementation(libs.kotlin.stdlib) implementation(libs.kotlin.compiler) implementation(libs.kotlin.script.runtime) implementation(project(":executors", configuration = "default")) diff --git a/dependencies/build.gradle.kts b/dependencies/build.gradle.kts index 51f6cce57..bd58fc102 100644 --- a/dependencies/build.gradle.kts +++ b/dependencies/build.gradle.kts @@ -103,7 +103,7 @@ dependencies { kotlinDependency(libs.hamcrest) kotlinDependency(libs.bundles.jackson) // Kotlin libraries - kotlinDependency(libs.bundles.kotlin.stdlib) + kotlinDependency(libs.kotlin.stdlib) kotlinDependency(libs.kotlin.test) kotlinDependency(libs.kotlin.test.junit) kotlinDependency(libs.kotlinx.coroutines.core.jvm) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index cd15444dc..6328c835b 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -21,8 +21,6 @@ gradle-develocity = "3.17.5" [libraries] kotlin-reflect = { group = "org.jetbrains.kotlin", name = "kotlin-reflect", version.ref = "kotlin" } kotlin-stdlib = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib", version.ref = "kotlin" } -kotlin-stdlib-jdk7 = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib-jdk7", version.ref = "kotlin" } -kotlin-stdlib-jdk8 = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib-jdk8", version.ref = "kotlin" } kotlin-stdlib-js = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib-js", version.ref = "kotlin" } kotlin-stdlib-wasm-js = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib-wasm-js", version.ref = "kotlin" } kotlin-test = { group = "org.jetbrains.kotlin", name = "kotlin-test", version.ref = "kotlin" } @@ -61,7 +59,6 @@ kotlin-serialization-plugin = {group= "org.jetbrains.kotlin", name="kotlin-seria gradle-develocity = {group = "com.gradle", name= "develocity-gradle-plugin", version.ref = "gradle-develocity"} [bundles] -kotlin-stdlib = ["kotlin-stdlib", "kotlin-stdlib-jdk7", "kotlin-stdlib-jdk8"] jackson = ["jackson-databind", "jackson-core", "jackson-annotations"] compose = [ "compose-runtime", From 6a5cba7503a43b0f28c6a7be1ddb268da86dd88d Mon Sep 17 00:00:00 2001 From: Dmitrii Krasnov Date: Tue, 7 Oct 2025 11:44:49 +0200 Subject: [PATCH 15/20] Returned dev repository back for running kotlin-community branch --- .github/workflows/gradle.yml | 6 +----- ...tlin-compiler-server-version-catalog.settings.gradle.kts | 2 ++ 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index e52884b34..f364dbe4d 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -30,9 +30,5 @@ jobs: run: chmod +x gradlew - name: Setup Gradle uses: gradle/actions/setup-gradle@v4 - - name: Build with Gradle (kotlin-community) - if: startsWith(github.ref, 'refs/heads/kotlin-community/') - run: ./gradlew build -Pkotlin_repo_url=https://redirector.kotlinlang.org/maven/dev - - name: Build with Gradle (default) - if: "!startsWith(github.ref, 'refs/heads/kotlin-community/')" + - name: Build with Gradle run: ./gradlew build diff --git a/build-settings-logic/src/main/kotlin/kotlin-compiler-server-version-catalog.settings.gradle.kts b/build-settings-logic/src/main/kotlin/kotlin-compiler-server-version-catalog.settings.gradle.kts index 9e4b89e2e..54664d948 100644 --- a/build-settings-logic/src/main/kotlin/kotlin-compiler-server-version-catalog.settings.gradle.kts +++ b/build-settings-logic/src/main/kotlin/kotlin-compiler-server-version-catalog.settings.gradle.kts @@ -10,6 +10,7 @@ pluginManagement { } logger.info("A custom Kotlin repository ${additionalRepositoryProperty.get()} was added") } + maven("https://redirector.kotlinlang.org/maven/dev") mavenLocal() } } @@ -27,6 +28,7 @@ dependencyResolutionManagement { } logger.info("A custom Kotlin repository ${additionalRepositoryProperty.get()} was added") } + maven("https://redirector.kotlinlang.org/maven/dev") mavenLocal() } From d796c91a8d5b89b13af260f0d869e6f5a5c8a7c9 Mon Sep 17 00:00:00 2001 From: Dmitrii Krasnov Date: Tue, 7 Oct 2025 11:45:42 +0200 Subject: [PATCH 16/20] KTL-3739 Changed -XXLanguage:+ExplicitBackingFields to -Xexplicit-backing-fields flag --- common/src/main/kotlin/component/KotlinEnvironment.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/main/kotlin/component/KotlinEnvironment.kt b/common/src/main/kotlin/component/KotlinEnvironment.kt index df1c65cc2..7c7075998 100644 --- a/common/src/main/kotlin/component/KotlinEnvironment.kt +++ b/common/src/main/kotlin/component/KotlinEnvironment.kt @@ -35,7 +35,7 @@ class KotlinEnvironment( "-Xnested-type-aliases", "-Xreport-all-warnings", "-Wextra", - "-XXLanguage:+ExplicitBackingFields", + "-Xexplicit-backing-fields", ) } From 00a1ccbf3e93455b00d47ddeb7ce58c93bd05801 Mon Sep 17 00:00:00 2001 From: Dmitrii Krasnov Date: Fri, 29 Aug 2025 13:45:47 +0200 Subject: [PATCH 17/20] Remove unnecessary version fields --- .../compiler/components/KotlinEnvironment.kt | 1 - .../compiler/server/model/bean/VersionInfo.kt | 2 -- versions.json | 27 ------------------- 3 files changed, 30 deletions(-) delete mode 100644 versions.json diff --git a/src/main/kotlin/com/compiler/server/compiler/components/KotlinEnvironment.kt b/src/main/kotlin/com/compiler/server/compiler/components/KotlinEnvironment.kt index 4858bb6c7..5c3ab5e11 100644 --- a/src/main/kotlin/com/compiler/server/compiler/components/KotlinEnvironment.kt +++ b/src/main/kotlin/com/compiler/server/compiler/components/KotlinEnvironment.kt @@ -1,7 +1,6 @@ package com.compiler.server.compiler.components import com.compiler.server.model.bean.LibrariesFile -import com.compiler.server.model.bean.VersionInfo import component.CompilerPluginOption import component.KotlinEnvironment import org.springframework.context.annotation.Bean diff --git a/src/main/kotlin/com/compiler/server/model/bean/VersionInfo.kt b/src/main/kotlin/com/compiler/server/model/bean/VersionInfo.kt index 8fd0f471c..57e798a6e 100644 --- a/src/main/kotlin/com/compiler/server/model/bean/VersionInfo.kt +++ b/src/main/kotlin/com/compiler/server/model/bean/VersionInfo.kt @@ -3,6 +3,4 @@ package com.compiler.server.model.bean data class VersionInfo( val version: String, val stdlibVersion: String, - val latestStable: Boolean = true, - val unstable: Boolean = false ) \ No newline at end of file diff --git a/versions.json b/versions.json deleted file mode 100644 index 119e6031c..000000000 --- a/versions.json +++ /dev/null @@ -1,27 +0,0 @@ -[ - { - "version": "1.2.71" - }, - { - "version": "1.3.72" - }, - { - "version": "1.4.30" - }, - { - "version": "1.5.31" - }, - { - "version": "1.6.21" - }, - { - "version": "1.7.21" - }, - { - "version": "1.8.21" - }, - { - "version": "1.9.23", - "latestStable": true - } -] From f2ff86a736d740debb24b0d8b991ae1202dfd447 Mon Sep 17 00:00:00 2001 From: Dmitrii Krasnov Date: Fri, 29 Aug 2025 13:46:11 +0200 Subject: [PATCH 18/20] KTL-724 Added compiler arguments support We are using `kotlin-compiler-arguments-description` maven dependency for extracting all known compiler arguments for the current kotlin version. We've added an endpoint for getting all known compiler dependencies by the given platform. We've extended `run` and `translate` endpoints with the user's compiler args. --- ...server-version-catalog.settings.gradle.kts | 2 + build.gradle.kts | 23 +- gradle/libs.versions.toml | 11 +- .../server/api/CompilerArgumentResponse.kt | 18 + .../server/api/ProjectFileRequestDto.kt | 6 + .../com/compiler/server/api/RunRequest.kt | 13 + .../com/compiler/server/api/TestRequest.kt | 13 + .../server/api/TranslateComposeWasmRequest.kt | 15 + .../compiler/server/api/TranslateJsRequest.kt | 15 + .../server/api/TranslateWasmRequest.kt | 15 + .../compiler/components/KotlinCompiler.kt | 30 +- .../components/KotlinToJSTranslator.kt | 155 +- .../configuration/ApplicationConfiguration.kt | 1 + .../CompilerArgumentsConfiguration.kt | 82 + .../configuration/ControllersConverters.kt | 12 + .../controllers/CompilerRestController.kt | 181 +- .../controllers/VersionRestController.kt | 14 + .../server/model/ExtendedCompilerArgument.kt | 37 + .../server/model/JsCompilerArguments.kt | 6 + .../com/compiler/server/model/Project.kt | 6 +- .../service/CompilerArgumentsService.kt | 34 + .../server/service/KotlinProjectExecutor.kt | 22 +- .../server/utils/CompilerArgumentsUtil.kt | 549 +++++ .../AbstractCompilerArgumentsValidator.kt | 87 + .../validation/ProjectRequestValidation.kt | 51 + .../ComposeWasmCompilerArgumentsValidator.kt | 9 + .../impl/JsCompilerArgumentsValidator.kt | 9 + .../impl/JvmCompilerArgumentsValidator.kt | 9 + .../impl/WasmCompilerArgumentsValidator.kt | 9 + .../com/compiler/server/CompilerAPITest.kt | 5 +- .../CompilerArgumentsConfigurationTest.kt | 51 + .../server/CompilerArgumentsEndpointTest.kt | 77 + .../compiler/server/ResourceCompileTest.kt | 2 +- .../compiler/server/ResourceE2ECompileTest.kt | 23 +- .../compose-wasm-expected-compiler-args.json | 2022 ++++++++++++++++ .../js-expected-compiler-args.json | 2020 ++++++++++++++++ .../jvm-expected-compiler-args.json | 2116 +++++++++++++++++ .../wasm-expected-compiler-args.json | 2020 ++++++++++++++++ 38 files changed, 9600 insertions(+), 170 deletions(-) create mode 100644 src/main/kotlin/com/compiler/server/api/CompilerArgumentResponse.kt create mode 100644 src/main/kotlin/com/compiler/server/api/ProjectFileRequestDto.kt create mode 100644 src/main/kotlin/com/compiler/server/api/RunRequest.kt create mode 100644 src/main/kotlin/com/compiler/server/api/TestRequest.kt create mode 100644 src/main/kotlin/com/compiler/server/api/TranslateComposeWasmRequest.kt create mode 100644 src/main/kotlin/com/compiler/server/api/TranslateJsRequest.kt create mode 100644 src/main/kotlin/com/compiler/server/api/TranslateWasmRequest.kt create mode 100644 src/main/kotlin/com/compiler/server/configuration/CompilerArgumentsConfiguration.kt create mode 100644 src/main/kotlin/com/compiler/server/controllers/VersionRestController.kt create mode 100644 src/main/kotlin/com/compiler/server/model/ExtendedCompilerArgument.kt create mode 100644 src/main/kotlin/com/compiler/server/model/JsCompilerArguments.kt create mode 100644 src/main/kotlin/com/compiler/server/service/CompilerArgumentsService.kt create mode 100644 src/main/kotlin/com/compiler/server/utils/CompilerArgumentsUtil.kt create mode 100644 src/main/kotlin/com/compiler/server/validation/AbstractCompilerArgumentsValidator.kt create mode 100644 src/main/kotlin/com/compiler/server/validation/ProjectRequestValidation.kt create mode 100644 src/main/kotlin/com/compiler/server/validation/impl/ComposeWasmCompilerArgumentsValidator.kt create mode 100644 src/main/kotlin/com/compiler/server/validation/impl/JsCompilerArgumentsValidator.kt create mode 100644 src/main/kotlin/com/compiler/server/validation/impl/JvmCompilerArgumentsValidator.kt create mode 100644 src/main/kotlin/com/compiler/server/validation/impl/WasmCompilerArgumentsValidator.kt create mode 100644 src/test/kotlin/com/compiler/server/CompilerArgumentsConfigurationTest.kt create mode 100644 src/test/kotlin/com/compiler/server/CompilerArgumentsEndpointTest.kt create mode 100644 src/test/resources/compiler-arguments/compose-wasm-expected-compiler-args.json create mode 100644 src/test/resources/compiler-arguments/js-expected-compiler-args.json create mode 100644 src/test/resources/compiler-arguments/jvm-expected-compiler-args.json create mode 100644 src/test/resources/compiler-arguments/wasm-expected-compiler-args.json diff --git a/build-settings-logic/src/main/kotlin/kotlin-compiler-server-version-catalog.settings.gradle.kts b/build-settings-logic/src/main/kotlin/kotlin-compiler-server-version-catalog.settings.gradle.kts index 54664d948..4c2fe1ced 100644 --- a/build-settings-logic/src/main/kotlin/kotlin-compiler-server-version-catalog.settings.gradle.kts +++ b/build-settings-logic/src/main/kotlin/kotlin-compiler-server-version-catalog.settings.gradle.kts @@ -12,6 +12,7 @@ pluginManagement { } maven("https://redirector.kotlinlang.org/maven/dev") mavenLocal() + maven("https://redirector.kotlinlang.org/maven/dev") } } @@ -30,6 +31,7 @@ dependencyResolutionManagement { } maven("https://redirector.kotlinlang.org/maven/dev") mavenLocal() + maven("https://redirector.kotlinlang.org/maven/dev") } versionCatalogs { diff --git a/build.gradle.kts b/build.gradle.kts index 0ee27b76f..7dea54376 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -12,8 +12,8 @@ version = "${libs.versions.kotlin.get()}-SNAPSHOT" val propertyFile = "application.properties" plugins { - alias(libs.plugins.spring.dependency.management) alias(libs.plugins.spring.boot) + alias(libs.plugins.spring.dependency.management) alias(libs.plugins.kotlin.plugin.spring) id("base-kotlin-jvm-conventions") } @@ -36,11 +36,15 @@ val resourceDependency: Configuration by configurations.creating { } dependencies { - annotationProcessor("org.springframework:spring-context-indexer") - implementation("com.google.code.gson:gson") + annotationProcessor(libs.spring.context.indexer) implementation("org.springframework.boot:spring-boot-starter-web") - implementation(libs.springdoc) + implementation("org.springframework.boot:spring-boot-starter-validation") implementation(libs.aws.springboot.container) + implementation(libs.springdoc) + implementation(libs.gson) + implementation(libs.kotlinx.serialization.json) + implementation(libs.kotlin.compiler.arguments.description) + implementation(libs.kotlin.tooling.core) implementation(libs.junit) implementation(libs.logback.logstash.encoder) implementation(libs.kotlin.reflect) @@ -70,6 +74,8 @@ fun buildPropertyFile() { fun generateProperties(prefix: String = "") = """ # this file is autogenerated by build.gradle.kts + server.error.include-message=always + server.error.include-binding-errors=always kotlin.version=${kotlinVersion} policy.file=${prefix + policy} libraries.folder.jvm=${prefix + libJVM} @@ -147,4 +153,13 @@ tasks.withType { doFirst { this@withType.environment("kotlin.wasm.node.path", executablePath) } + + // We disable this on TeamCity, because we don't want to fail this test, + // when compiler server's test run as a K2 user project. + // But for our pull requests we still need to run this test, so we add it to our GitHub action. + if (System.getenv("TEAMCITY_VERSION") != null) { + filter { + excludeTestsMatching("com.compiler.server.CompilerArguments*") + } + } } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 6328c835b..39c69e386 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -26,6 +26,8 @@ kotlin-stdlib-wasm-js = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib- kotlin-test = { group = "org.jetbrains.kotlin", name = "kotlin-test", version.ref = "kotlin" } kotlin-test-junit = { group = "org.jetbrains.kotlin", name = "kotlin-test-junit", version.ref = "kotlin" } kotlin-compiler = { group = "org.jetbrains.kotlin", name = "kotlin-compiler", version.ref = "kotlin" } +kotlin-tooling-core = { group = "org.jetbrains.kotlin", name = "kotlin-tooling-core", version.ref = "kotlin" } +kotlin-compiler-arguments-description = { group = "org.jetbrains.kotlin", name = "kotlin-compiler-arguments-description", version.ref = "kotlin" } kotlin-script-runtime = { group = "org.jetbrains.kotlin", name = "kotlin-script-runtime", version.ref = "kotlin" } kotlin-gradlePlugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin" } kotlin-dom-api-compat = { group = "org.jetbrains.kotlin", name = "kotlin-dom-api-compat", version.ref = "kotlin" } @@ -35,10 +37,9 @@ kotlinx-coroutines-test = { group = "org.jetbrains.kotlinx", name = "kotlinx-cor kotlinx-datetime = { group = "org.jetbrains.kotlinx", name = "kotlinx-datetime", version.ref = "kotlinx-datetime" } kotlinx-io-bytestring = { group = "org.jetbrains.kotlinx", name = "kotlinx-io-bytestring", version.ref = "kotlinx-io" } kotlinx-io-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-io-core", version.ref = "kotlinx-io" } +kotlinx-serialization-json = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-json", version.ref = "kotlinx-serialization" } kotlinx-serialization-json-jvm = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-json-jvm", version.ref = "kotlinx-serialization" } kotlinx-serialization-core-jvm = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-core-jvm", version.ref = "kotlinx-serialization" } -springdoc = { group = "org.springdoc", name = "springdoc-openapi-starter-webmvc-ui", version.ref = "springdoc" } -aws-springboot-container = { group = "com.amazonaws.serverless", name = "aws-serverless-java-container-springboot3", version.ref = "aws-serverless-java-container-springboot3" } junit = { group = "junit", name = "junit", version.ref = "junit" } logback-logstash-encoder = { group = "net.logstash.logback", name = "logstash-logback-encoder", version.ref = "logstash-logback-encoder" } skiko-js-wasm-runtime = { group = "org.jetbrains.skiko", name = "skiko-js-wasm-runtime", version.ref = "skiko" } @@ -57,6 +58,12 @@ compose-material3 = { group = "org.jetbrains.compose.material3", name = "materia compose-components-resources = { group = "org.jetbrains.compose.components", name = "components-resources", version.ref = "compose" } kotlin-serialization-plugin = {group= "org.jetbrains.kotlin", name="kotlin-serialization-compiler-plugin", version.ref = "kotlin"} gradle-develocity = {group = "com.gradle", name= "develocity-gradle-plugin", version.ref = "gradle-develocity"} +gson = { group = "com.google.code.gson", name = "gson"} + +#spring stack dependencies +aws-springboot-container = { group = "com.amazonaws.serverless", name = "aws-serverless-java-container-springboot3", version.ref = "aws-serverless-java-container-springboot3" } +spring-context-indexer = { group = "org.springframework", name = "spring-context-indexer"} +springdoc = { group = "org.springdoc", name = "springdoc-openapi-starter-webmvc-ui", version.ref = "springdoc" } [bundles] jackson = ["jackson-databind", "jackson-core", "jackson-annotations"] diff --git a/src/main/kotlin/com/compiler/server/api/CompilerArgumentResponse.kt b/src/main/kotlin/com/compiler/server/api/CompilerArgumentResponse.kt new file mode 100644 index 000000000..84e157cb5 --- /dev/null +++ b/src/main/kotlin/com/compiler/server/api/CompilerArgumentResponse.kt @@ -0,0 +1,18 @@ +package com.compiler.server.api + +import com.compiler.server.model.ExtendedCompilerArgumentValue +import com.fasterxml.jackson.annotation.JsonTypeInfo + +data class CompilerArgumentResponse(val compilerArguments: Set) { + + data class CompilerArgument( + val name: String, + val shortName: String?, + val description: String?, + @field:JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "type") + val type: ExtendedCompilerArgumentValue<*>, + val disabled: Boolean, + val predefinedValues: Any? + ) +} + diff --git a/src/main/kotlin/com/compiler/server/api/ProjectFileRequestDto.kt b/src/main/kotlin/com/compiler/server/api/ProjectFileRequestDto.kt new file mode 100644 index 000000000..3619417f0 --- /dev/null +++ b/src/main/kotlin/com/compiler/server/api/ProjectFileRequestDto.kt @@ -0,0 +1,6 @@ +package com.compiler.server.api + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties + +@JsonIgnoreProperties(ignoreUnknown = true) +data class ProjectFileRequestDto(val text: String = "", val name: String = "") \ No newline at end of file diff --git a/src/main/kotlin/com/compiler/server/api/RunRequest.kt b/src/main/kotlin/com/compiler/server/api/RunRequest.kt new file mode 100644 index 000000000..5fb47f417 --- /dev/null +++ b/src/main/kotlin/com/compiler/server/api/RunRequest.kt @@ -0,0 +1,13 @@ +package com.compiler.server.api + +import com.compiler.server.model.ProjectType +import com.compiler.server.validation.CompilerArgumentsConstraint +import com.fasterxml.jackson.annotation.JsonIgnoreProperties + +@JsonIgnoreProperties(ignoreUnknown = true) +data class RunRequest( + val args: String = "", + val files: List = listOf(), + @CompilerArgumentsConstraint(ProjectType.JAVA) + val compilerArguments: Map = emptyMap() +) diff --git a/src/main/kotlin/com/compiler/server/api/TestRequest.kt b/src/main/kotlin/com/compiler/server/api/TestRequest.kt new file mode 100644 index 000000000..78859e103 --- /dev/null +++ b/src/main/kotlin/com/compiler/server/api/TestRequest.kt @@ -0,0 +1,13 @@ +package com.compiler.server.api + +import com.compiler.server.model.ProjectType +import com.compiler.server.validation.CompilerArgumentsConstraint +import com.fasterxml.jackson.annotation.JsonIgnoreProperties + +@JsonIgnoreProperties(ignoreUnknown = true) +data class TestRequest( + val args: String = "", + val files: List = listOf(), + @CompilerArgumentsConstraint(ProjectType.JAVA) + val compilerArguments: Map = emptyMap() +) diff --git a/src/main/kotlin/com/compiler/server/api/TranslateComposeWasmRequest.kt b/src/main/kotlin/com/compiler/server/api/TranslateComposeWasmRequest.kt new file mode 100644 index 000000000..7d92723f3 --- /dev/null +++ b/src/main/kotlin/com/compiler/server/api/TranslateComposeWasmRequest.kt @@ -0,0 +1,15 @@ +package com.compiler.server.api + +import com.compiler.server.model.ProjectType +import com.compiler.server.validation.CompilerArgumentsConstraint +import com.fasterxml.jackson.annotation.JsonIgnoreProperties + +@JsonIgnoreProperties(ignoreUnknown = true) +class TranslateComposeWasmRequest( + val args: String = "", + val files: List = listOf(), + @CompilerArgumentsConstraint(ProjectType.COMPOSE_WASM) + val firstPhaseCompilerArguments: Map = emptyMap(), + @CompilerArgumentsConstraint(ProjectType.COMPOSE_WASM) + val secondPhaseCompilerArguments: Map = emptyMap() +) \ No newline at end of file diff --git a/src/main/kotlin/com/compiler/server/api/TranslateJsRequest.kt b/src/main/kotlin/com/compiler/server/api/TranslateJsRequest.kt new file mode 100644 index 000000000..8f41c3272 --- /dev/null +++ b/src/main/kotlin/com/compiler/server/api/TranslateJsRequest.kt @@ -0,0 +1,15 @@ +package com.compiler.server.api + +import com.compiler.server.model.ProjectType +import com.compiler.server.validation.CompilerArgumentsConstraint +import com.fasterxml.jackson.annotation.JsonIgnoreProperties + +@JsonIgnoreProperties(ignoreUnknown = true) +data class TranslateJsRequest( + val args: String = "", + val files: List = listOf(), + @CompilerArgumentsConstraint(ProjectType.JS) + val firstPhaseCompilerArguments: Map = emptyMap(), + @CompilerArgumentsConstraint(ProjectType.JS) + val secondPhaseCompilerArguments: Map = emptyMap() +) diff --git a/src/main/kotlin/com/compiler/server/api/TranslateWasmRequest.kt b/src/main/kotlin/com/compiler/server/api/TranslateWasmRequest.kt new file mode 100644 index 000000000..61758f7bc --- /dev/null +++ b/src/main/kotlin/com/compiler/server/api/TranslateWasmRequest.kt @@ -0,0 +1,15 @@ +package com.compiler.server.api + +import com.compiler.server.model.ProjectType +import com.compiler.server.validation.CompilerArgumentsConstraint +import com.fasterxml.jackson.annotation.JsonIgnoreProperties + +@JsonIgnoreProperties(ignoreUnknown = true) +class TranslateWasmRequest( + val args: String = "", + val files: List = listOf(), + @CompilerArgumentsConstraint(ProjectType.WASM) + val firstPhaseCompilerArguments: Map = emptyMap(), + @CompilerArgumentsConstraint(ProjectType.WASM) + val secondPhaseCompilerArguments: Map = emptyMap() +) \ No newline at end of file diff --git a/src/main/kotlin/com/compiler/server/compiler/components/KotlinCompiler.kt b/src/main/kotlin/com/compiler/server/compiler/components/KotlinCompiler.kt index 3e7cb16f8..835282321 100644 --- a/src/main/kotlin/com/compiler/server/compiler/components/KotlinCompiler.kt +++ b/src/main/kotlin/com/compiler/server/compiler/components/KotlinCompiler.kt @@ -2,11 +2,13 @@ package com.compiler.server.compiler.components import com.compiler.server.executor.CommandLineArgument import com.compiler.server.executor.JavaExecutor +import com.compiler.server.model.ExtendedCompilerArgument import com.compiler.server.model.JvmExecutionResult import com.compiler.server.model.OutputDirectory import com.compiler.server.model.ProjectFile import com.compiler.server.model.bean.LibrariesFile import com.compiler.server.model.toExceptionDescriptor +import com.compiler.server.utils.CompilerArgumentsUtil import component.KotlinEnvironment import executors.JUnitExecutors import executors.JavaRunnerExecutor @@ -32,7 +34,9 @@ class KotlinCompiler( private val kotlinEnvironment: KotlinEnvironment, private val javaExecutor: JavaExecutor, private val librariesFile: LibrariesFile, - @Value("\${policy.file}") private val policyFileName: String + @Value("\${policy.file}") private val policyFileName: String, + private val compilerArgumentsUtil: CompilerArgumentsUtil, + private val jvmCompilerArguments: Set, ) { private val policyFile = File(policyFileName) @@ -59,8 +63,8 @@ class KotlinCompiler( ?.joinToString("\n\n") } - fun run(files: List, addByteCode: Boolean, args: String): JvmExecutionResult { - return execute(files, addByteCode) { output, compiled -> + fun run(files: List, addByteCode: Boolean, args: String, userCompilerArguments: Map): JvmExecutionResult { + return execute(files, addByteCode, userCompilerArguments) { output, compiled -> val mainClass = JavaRunnerExecutor::class.java.name val compiledMainClass = when (compiled.mainClasses.size) { 0 -> return@execute JvmExecutionResult( @@ -82,8 +86,8 @@ class KotlinCompiler( } } - fun test(files: List, addByteCode: Boolean): JvmExecutionResult { - return execute(files, addByteCode) { output, _ -> + fun test(files: List, addByteCode: Boolean, userCompilerArguments: Map): JvmExecutionResult { + return execute(files, addByteCode, userCompilerArguments) { output, _ -> val mainClass = JUnitExecutors::class.java.name javaExecutor.execute(argsFrom(mainClass, output, listOf(output.path.toString()))) .asJUnitExecutionResult() @@ -91,17 +95,12 @@ class KotlinCompiler( } @OptIn(ExperimentalPathApi::class) - fun compile(files: List): CompilationResult = usingTempDirectory { inputDir -> + fun compile(files: List, userCompilerArguments: Map): CompilationResult = usingTempDirectory { inputDir -> val ioFiles = files.writeToIoFiles(inputDir) usingTempDirectory { outputDir -> - val arguments = - ioFiles.map { it.absolutePathString() } + KotlinEnvironment.additionalCompilerArguments + listOf( - "-cp", kotlinEnvironment.classpath.joinToString(PATH_SEPARATOR) { it.absolutePath }, - "-module-name", "web-module", - "-no-stdlib", "-no-reflect", - "-progressive", - "-d", outputDir.absolutePathString(), - ) + kotlinEnvironment.compilerPlugins.map { plugin -> "-Xplugin=${plugin.absolutePath}" } + val arguments = ioFiles.map { it.absolutePathString() } + + compilerArgumentsUtil.convertCompilerArgumentsToCompilationString(jvmCompilerArguments, compilerArgumentsUtil.PREDEFINED_JVM_ARGUMENTS, userCompilerArguments) + + listOf("-d", outputDir.absolutePathString()) K2JVMCompiler().tryCompilation(inputDir, ioFiles, arguments) { val outputFiles = buildMap { outputDir.visitFileTree { @@ -142,9 +141,10 @@ class KotlinCompiler( private fun execute( files: List, addByteCode: Boolean, + userCompilerArguments: Map, block: (output: OutputDirectory, compilation: JvmClasses) -> JvmExecutionResult ): JvmExecutionResult = try { - when (val compilationResult = compile(files)) { + when (val compilationResult = compile(files, userCompilerArguments)) { is Compiled -> { usingTempDirectory { outputDir -> val output = write(compilationResult.result, outputDir) diff --git a/src/main/kotlin/com/compiler/server/compiler/components/KotlinToJSTranslator.kt b/src/main/kotlin/com/compiler/server/compiler/components/KotlinToJSTranslator.kt index d52f28899..33e38a5f5 100644 --- a/src/main/kotlin/com/compiler/server/compiler/components/KotlinToJSTranslator.kt +++ b/src/main/kotlin/com/compiler/server/compiler/components/KotlinToJSTranslator.kt @@ -1,8 +1,10 @@ package com.compiler.server.compiler.components import com.compiler.server.model.* +import com.compiler.server.utils.CompilerArgumentsUtil +import com.compiler.server.utils.JS_DEFAULT_MODULE_NAME +import com.compiler.server.utils.WASM_DEFAULT_MODULE_NAME import com.fasterxml.jackson.databind.ObjectMapper -import component.KotlinEnvironment import org.jetbrains.kotlin.cli.js.K2JSCompiler import org.springframework.stereotype.Service import kotlin.io.path.div @@ -11,7 +13,10 @@ import kotlin.io.path.readText @Service class KotlinToJSTranslator( - private val kotlinEnvironment: KotlinEnvironment, + private val compilerArgumentsUtil: CompilerArgumentsUtil, + private val jsCompilerArguments: Set, + private val wasmCompilerArguments: Set, + private val composeWasmCompilerArguments: Set ) { companion object { internal const val JS_IR_CODE_BUFFER = "playground.output?.buffer_1;\n" @@ -30,9 +35,10 @@ class KotlinToJSTranslator( fun translateJs( files: List, arguments: List, - translate: (List, List) -> CompilationResult + jsCompilerArguments: JsCompilerArguments, + translate: (List, List, JsCompilerArguments) -> CompilationResult ): TranslationJSResult = try { - val compilationResult = translate(files, arguments) + val compilationResult = translate(files, arguments, jsCompilerArguments) val jsCode = when (compilationResult) { is Compiled -> compilationResult.result is NotCompiled -> null @@ -46,30 +52,15 @@ class KotlinToJSTranslator( files: List, debugInfo: Boolean, projectType: ProjectType, - translate: (List, List, List, List, Boolean) -> CompilationResult + userCompilerArguments: JsCompilerArguments, + translate: (List, ProjectType, Boolean, JsCompilerArguments) -> CompilationResult ): TranslationResultWithJsCode { return try { - val (dependencies, compilerPlugins, compilerPluginOptions) = when (projectType) { - ProjectType.WASM -> listOf( - kotlinEnvironment.WASM_LIBRARIES, - emptyList(), - emptyList() - ) - - ProjectType.COMPOSE_WASM -> listOf( - kotlinEnvironment.COMPOSE_WASM_LIBRARIES, - kotlinEnvironment.COMPOSE_WASM_COMPILER_PLUGINS, - kotlinEnvironment.composeWasmCompilerPluginOptions - ) - - else -> throw IllegalStateException("Wasm should have wasm or compose-wasm project type") - } val compilationResult = translate( files, - dependencies, - compilerPlugins, - compilerPluginOptions, - debugInfo + projectType, + debugInfo, + userCompilerArguments ) val wasmCompilationOutput = when (compilationResult) { is Compiled -> compilationResult.result @@ -87,38 +78,33 @@ class KotlinToJSTranslator( } } - fun doTranslateWithIr(files: List, arguments: List): CompilationResult = + fun doTranslateWithIr( + files: List, + arguments: List, + userCompilerArguments: JsCompilerArguments): CompilationResult = usingTempDirectory { inputDir -> - val moduleName = "playground" usingTempDirectory { outputDir -> val ioFiles = files.writeToIoFiles(inputDir) val k2JSCompiler = K2JSCompiler() val filePaths = ioFiles.map { it.toFile().canonicalPath } val klibPath = (outputDir / "klib").toFile().canonicalPath - val additionalCompilerArgumentsForKLib = listOf( - "-Xreport-all-warnings", - "-Wextra", - "-Xir-produce-klib-dir", - "-libraries=${kotlinEnvironment.JS_LIBRARIES.joinToString(PATH_SEPARATOR)}", - "-ir-output-dir=$klibPath", - "-ir-output-name=$moduleName", - ) + val additionalCompilerArgumentsForKLib = + compilerArgumentsUtil.convertCompilerArgumentsToCompilationString( + jsCompilerArguments, + compilerArgumentsUtil.PREDEFINED_JS_FIRST_PHASE_ARGUMENTS, + userCompilerArguments.firstPhase + ) + "-ir-output-dir=$klibPath" k2JSCompiler.tryCompilation(inputDir, ioFiles, filePaths + additionalCompilerArgumentsForKLib) .flatMap { - k2JSCompiler.tryCompilation( - inputDir, ioFiles, listOf( - "-Xreport-all-warnings", - "-Wextra", - "-Xir-produce-js", - "-Xir-dce", - "-Xinclude=$klibPath", - "-libraries=${kotlinEnvironment.JS_LIBRARIES.joinToString(PATH_SEPARATOR)}", - "-ir-output-dir=${(outputDir / "js").toFile().canonicalPath}", - "-ir-output-name=$moduleName", - ) - ) + val secondPhaseArguments = + compilerArgumentsUtil.convertCompilerArgumentsToCompilationString( + jsCompilerArguments, + compilerArgumentsUtil.PREDEFINED_JS_SECOND_PHASE_ARGUMENTS, + userCompilerArguments.secondPhase + ) + "-ir-output-dir=${(outputDir / "js").toFile().canonicalPath}" + "-Xinclude=$klibPath" + k2JSCompiler.tryCompilation(inputDir, ioFiles, secondPhaseArguments) } - .map { (outputDir / "js" / "$moduleName.js").readText() } + .map { (outputDir / "js" / "$JS_DEFAULT_MODULE_NAME.js").readText() } .map { it.withMainArgumentsIr(arguments) } .map(::redirectOutput) } @@ -137,58 +123,57 @@ class KotlinToJSTranslator( fun doTranslateWithWasm( files: List, - dependencies: List, - compilerPlugins: List, - compilerPluginOptions: List, + projectType: ProjectType, debugInfo: Boolean, + userCompilerArguments: JsCompilerArguments ): CompilationResult = usingTempDirectory { inputDir -> - val moduleName = "playground" usingTempDirectory { outputDir -> + val (defaultCompilerArgs, firstPhasePredefinedArguments, secondPhasePredefinedArguments) = when (projectType) { + ProjectType.WASM -> Triple( + wasmCompilerArguments, + compilerArgumentsUtil.PREDEFINED_WASM_FIRST_PHASE_ARGUMENTS, + compilerArgumentsUtil.PREDEFINED_WASM_SECOND_PHASE_ARGUMENTS, + ) + + ProjectType.COMPOSE_WASM -> Triple( + composeWasmCompilerArguments, + compilerArgumentsUtil.PREDEFINED_COMPOSE_WASM_FIRST_PHASE_ARGUMENTS, + compilerArgumentsUtil.PREDEFINED_COMPOSE_WASM_SECOND_PHASE_ARGUMENTS + ) + + else -> throw IllegalStateException("Wasm should have wasm or compose-wasm project type") + } val ioFiles = files.writeToIoFiles(inputDir) val k2JSCompiler = K2JSCompiler() val filePaths = ioFiles.map { it.toFile().canonicalPath } val klibPath = (outputDir / "klib").toFile().canonicalPath - val compilerPluginsArgs: List = compilerPlugins - .takeIf { it.isNotEmpty() } - ?.let { plugins -> - plugins.map { - "-Xplugin=$it" - } + compilerPluginOptions.map { - "-P=$it" - } - } ?: emptyList() - val additionalCompilerArgumentsForKLib: List = listOf( - "-Xreport-all-warnings", - "-Wextra", - "-Xwasm", - "-Xir-produce-klib-dir", - "-libraries=${dependencies.joinToString(PATH_SEPARATOR)}", - "-ir-output-dir=$klibPath", - "-ir-output-name=$moduleName", - ) + compilerPluginsArgs + + val additionalCompilerArgumentsForKLib = + compilerArgumentsUtil.convertCompilerArgumentsToCompilationString( + defaultCompilerArgs, + firstPhasePredefinedArguments, + userCompilerArguments.firstPhase + ) + "-ir-output-dir=$klibPath" k2JSCompiler.tryCompilation(inputDir, ioFiles, filePaths + additionalCompilerArgumentsForKLib) .flatMap { - k2JSCompiler.tryCompilation( - inputDir, ioFiles, mutableListOf( - "-Xreport-all-warnings", - "-Wextra", - "-Xwasm", - "-Xir-produce-js", - "-Xir-dce", - "-Xinclude=$klibPath", - "-libraries=${dependencies.joinToString(PATH_SEPARATOR)}", - "-ir-output-dir=${(outputDir / "wasm").toFile().canonicalPath}", - "-ir-output-name=$moduleName", - ).also { if (debugInfo) it.add("-Xwasm-generate-wat") }) + val secondPhaseArguments = (compilerArgumentsUtil.convertCompilerArgumentsToCompilationString( + defaultCompilerArgs, + secondPhasePredefinedArguments, + userCompilerArguments.secondPhase + ) + "-ir-output-dir=${(outputDir / "wasm").toFile().canonicalPath}" + "-Xinclude=$klibPath").toMutableList() + + if (debugInfo) secondPhaseArguments.add("-Xwasm-generate-wat") + + k2JSCompiler.tryCompilation(inputDir, ioFiles, secondPhaseArguments) } .map { WasmTranslationSuccessfulOutput( - jsCode = (outputDir / "wasm" / "$moduleName.uninstantiated.mjs").readText(), - jsInstantiated = (outputDir / "wasm" / "$moduleName.mjs").readText(), - wasm = (outputDir / "wasm" / "$moduleName.wasm").readBytes(), - wat = if (debugInfo) (outputDir / "wasm" / "$moduleName.wat").readText() else null, + jsCode = (outputDir / "wasm" / "$WASM_DEFAULT_MODULE_NAME.uninstantiated.mjs").readText(), + jsInstantiated = (outputDir / "wasm" / "$WASM_DEFAULT_MODULE_NAME.mjs").readText(), + wasm = (outputDir / "wasm" / "$WASM_DEFAULT_MODULE_NAME.wasm").readBytes(), + wat = if (debugInfo) (outputDir / "wasm" / "$WASM_DEFAULT_MODULE_NAME.wat").readText() else null, ) } } diff --git a/src/main/kotlin/com/compiler/server/configuration/ApplicationConfiguration.kt b/src/main/kotlin/com/compiler/server/configuration/ApplicationConfiguration.kt index 0a3426694..6d752483d 100644 --- a/src/main/kotlin/com/compiler/server/configuration/ApplicationConfiguration.kt +++ b/src/main/kotlin/com/compiler/server/configuration/ApplicationConfiguration.kt @@ -19,6 +19,7 @@ class ApplicationConfiguration( ) : WebMvcConfigurer { override fun addFormatters(registry: FormatterRegistry) { registry.addConverter(ProjectConverter()) + registry.addConverter(ProjectTypeConverter()) } @Bean diff --git a/src/main/kotlin/com/compiler/server/configuration/CompilerArgumentsConfiguration.kt b/src/main/kotlin/com/compiler/server/configuration/CompilerArgumentsConfiguration.kt new file mode 100644 index 000000000..694455c15 --- /dev/null +++ b/src/main/kotlin/com/compiler/server/configuration/CompilerArgumentsConfiguration.kt @@ -0,0 +1,82 @@ +package com.compiler.server.configuration + +import com.compiler.server.model.ExtendedCompilerArgument +import com.compiler.server.model.ProjectType +import com.compiler.server.utils.COMPILER_ARGUMENTS_JSON +import com.compiler.server.utils.CompilerArgumentsUtil +import com.compiler.server.validation.AbstractCompilerArgumentsValidator +import kotlinx.serialization.json.Json +import org.jetbrains.kotlin.arguments.dsl.base.KotlinCompilerArguments +import org.jetbrains.kotlin.utils.keysToMap +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration + +@Configuration +class CompilerArgumentsConfiguration { + + @Bean + fun kotlinCompilerArguments() = collectCompilerArguments() + + @Bean + fun jvmCompilerArguments( + kotlinCompilerArguments: KotlinCompilerArguments, + compilerArgumentsUtil: CompilerArgumentsUtil + ): Set { + return compilerArgumentsUtil.collectJvmArguments(kotlinCompilerArguments) + } + + @Bean + fun jsCompilerArguments( + kotlinCompilerArguments: KotlinCompilerArguments, + compilerArgumentsUtil: CompilerArgumentsUtil + ): Set { + return compilerArgumentsUtil.collectJsArguments(kotlinCompilerArguments) + } + + @Bean + fun wasmCompilerArguments( + kotlinCompilerArguments: KotlinCompilerArguments, + compilerArgumentsUtil: CompilerArgumentsUtil + ): Set { + return compilerArgumentsUtil.collectWasmArguments(kotlinCompilerArguments) + } + + @Bean + fun composeWasmCompilerArguments( + kotlinCompilerArguments: KotlinCompilerArguments, + compilerArgumentsUtil: CompilerArgumentsUtil + ): Set { + return compilerArgumentsUtil.collectComposeWasmArguments(kotlinCompilerArguments) + } + + @Bean + fun compilerArgumentsValidators( + jvmCompilerArgumentsValidator: AbstractCompilerArgumentsValidator, + jsCompilerArgumentsValidator: AbstractCompilerArgumentsValidator, + wasmCompilerArgumentsValidator: AbstractCompilerArgumentsValidator, + composeWasmCompilerArgumentsValidator: AbstractCompilerArgumentsValidator + ): Map { + return ProjectType.entries.keysToMap { + when (it) { + ProjectType.JAVA, ProjectType.JUNIT -> jvmCompilerArgumentsValidator + ProjectType.JS, ProjectType.JS_IR, ProjectType.CANVAS -> jsCompilerArgumentsValidator + ProjectType.WASM -> wasmCompilerArgumentsValidator + ProjectType.COMPOSE_WASM -> composeWasmCompilerArgumentsValidator + } + } + } + + private fun collectCompilerArguments(): KotlinCompilerArguments { + val jsonConverter = Json { + prettyPrint = true + encodeDefaults = true + } + + val compilerArgumentsJsonString = + KotlinCompilerArguments::class.java.classLoader + .getResource(COMPILER_ARGUMENTS_JSON)?.readText() + ?: error("Can't find $COMPILER_ARGUMENTS_JSON in the classpath") + + return jsonConverter.decodeFromString(compilerArgumentsJsonString) + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/compiler/server/configuration/ControllersConverters.kt b/src/main/kotlin/com/compiler/server/configuration/ControllersConverters.kt index 05c42addc..b27025a33 100644 --- a/src/main/kotlin/com/compiler/server/configuration/ControllersConverters.kt +++ b/src/main/kotlin/com/compiler/server/configuration/ControllersConverters.kt @@ -1,9 +1,21 @@ package com.compiler.server.configuration import com.compiler.server.model.Project +import com.compiler.server.model.ProjectType import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper import org.springframework.core.convert.converter.Converter +import org.springframework.http.HttpStatus +import org.springframework.web.server.ResponseStatusException class ProjectConverter : Converter { override fun convert(source: String): Project = jacksonObjectMapper().readValue(source, Project::class.java) +} + +class ProjectTypeConverter : Converter { + override fun convert(source: String): ProjectType = + ProjectType.entries.firstOrNull { it.id == source } + ?: throw ResponseStatusException( + HttpStatus.BAD_REQUEST, + "Unknown projectType '$source'" + ) } \ No newline at end of file diff --git a/src/main/kotlin/com/compiler/server/controllers/CompilerRestController.kt b/src/main/kotlin/com/compiler/server/controllers/CompilerRestController.kt index 92c219c54..e6f5e8f9c 100644 --- a/src/main/kotlin/com/compiler/server/controllers/CompilerRestController.kt +++ b/src/main/kotlin/com/compiler/server/controllers/CompilerRestController.kt @@ -1,56 +1,143 @@ package com.compiler.server.controllers -import com.compiler.server.model.* -import com.compiler.server.model.bean.VersionInfo +import com.compiler.server.api.CompilerArgumentResponse +import com.compiler.server.api.RunRequest +import com.compiler.server.api.TestRequest +import com.compiler.server.api.TranslateComposeWasmRequest +import com.compiler.server.api.TranslateJsRequest +import com.compiler.server.api.TranslateWasmRequest +import com.compiler.server.model.CompilerDiagnostics +import com.compiler.server.model.ExecutionResult +import com.compiler.server.model.KotlinTranslatableCompiler +import com.compiler.server.model.Project +import com.compiler.server.model.ProjectFile +import com.compiler.server.model.ProjectType +import com.compiler.server.model.TranslationResultWithJsCode +import com.compiler.server.service.CompilerArgumentsService import com.compiler.server.service.KotlinProjectExecutor -import org.springframework.web.bind.annotation.* +import jakarta.validation.Valid +import org.jetbrains.kotlin.utils.mapToSetOrEmpty +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.PostMapping +import org.springframework.web.bind.annotation.RequestBody +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RequestParam +import org.springframework.web.bind.annotation.RestController @RestController @RequestMapping(value = ["/api/compiler", "/api/**/compiler"]) -class CompilerRestController(private val kotlinProjectExecutor: KotlinProjectExecutor) { - @PostMapping("/run") - fun executeKotlinProjectEndpoint( - @RequestBody project: Project, - @RequestParam(defaultValue = "false") addByteCode: Boolean, - ): ExecutionResult { - return kotlinProjectExecutor.run(project, addByteCode) - } - - @PostMapping("/test") - fun testKotlinProjectEndpoint( - @RequestBody project: Project, - @RequestParam(defaultValue = "false") addByteCode: Boolean, - ): ExecutionResult { - return kotlinProjectExecutor.test(project, addByteCode) - } - - @PostMapping("/translate") - fun translateKotlinProjectEndpoint( - @RequestBody project: Project, - @RequestParam(defaultValue = "js") compiler: String, - @RequestParam(defaultValue = "false") debugInfo: Boolean - ): TranslationResultWithJsCode { - return when (KotlinTranslatableCompiler.valueOf(compiler.uppercase().replace("-", "_"))) { - KotlinTranslatableCompiler.JS -> kotlinProjectExecutor.convertToJsIr(project) - KotlinTranslatableCompiler.WASM -> kotlinProjectExecutor.convertToWasm(project, debugInfo) - KotlinTranslatableCompiler.COMPOSE_WASM -> kotlinProjectExecutor.convertToWasm(project, debugInfo) +class CompilerRestController( + private val kotlinProjectExecutor: KotlinProjectExecutor, + private val compilerArgumentsService: CompilerArgumentsService +) { + + @PostMapping("/run") + fun executeKotlinProjectEndpoint( + @RequestBody @Valid request: RunRequest, + @RequestParam(defaultValue = "false") addByteCode: Boolean, + ): ExecutionResult { + return kotlinProjectExecutor.run( + Project( + args = request.args, + files = request.files.map { ProjectFile(name = it.name, text = it.text) }, + compilerArguments = listOf(request.compilerArguments) + ), addByteCode + ) } - } - - @PostMapping("/complete") - fun getKotlinCompleteEndpoint( - @RequestBody project: Project, - @RequestParam line: Int, - @RequestParam ch: Int - ) = kotlinProjectExecutor.complete(project, line, ch) - - @PostMapping("/highlight") - fun highlightEndpoint(@RequestBody project: Project): CompilerDiagnostics = - kotlinProjectExecutor.highlight(project) -} -@RestController -class VersionRestController(private val kotlinProjectExecutor: KotlinProjectExecutor) { - @GetMapping("/versions") - fun getKotlinVersionEndpoint(): List = listOf(kotlinProjectExecutor.getVersion()) + @PostMapping("/test") + fun testKotlinProjectEndpoint( + @RequestBody @Valid request: TestRequest, + @RequestParam(defaultValue = "false") addByteCode: Boolean, + ): ExecutionResult { + return kotlinProjectExecutor.test( + Project( + args = request.args, + files = request.files.map { ProjectFile(name = it.name, text = it.text) }, + compilerArguments = listOf(request.compilerArguments) + ), addByteCode + ) + } + + @PostMapping("/translate/js") + fun translateJs(@RequestBody @Valid request: TranslateJsRequest): TranslationResultWithJsCode { + return kotlinProjectExecutor.convertToJsIr( + Project( + args = request.args, + files = request.files.map { ProjectFile(name = it.name, text = it.text) }, + compilerArguments = listOf(request.firstPhaseCompilerArguments, request.secondPhaseCompilerArguments) + ) + ) + } + + @PostMapping("/translate/wasm") + fun translateWasm( + @RequestBody @Valid request: TranslateWasmRequest, + ): TranslationResultWithJsCode { + return kotlinProjectExecutor.convertToWasm( + Project( + args = request.args, + files = request.files.map { ProjectFile(name = it.name, text = it.text) }, + confType = ProjectType.WASM, + compilerArguments = listOf(request.firstPhaseCompilerArguments, request.secondPhaseCompilerArguments)) + ) + } + + @PostMapping("/translate/compose-wasm") + fun translateWasmCompose( + @RequestBody @Valid request: TranslateComposeWasmRequest, + ): TranslationResultWithJsCode { + return kotlinProjectExecutor.convertToWasm( + Project( + args = request.args, + files = request.files.map { ProjectFile(name = it.name, text = it.text) }, + confType = ProjectType.COMPOSE_WASM, + compilerArguments = listOf(request.firstPhaseCompilerArguments, request.secondPhaseCompilerArguments)) + ) + } + + @PostMapping("/complete") + fun getKotlinCompleteEndpoint( + @RequestBody project: Project, + @RequestParam line: Int, + @RequestParam ch: Int + ) = kotlinProjectExecutor.complete(project, line, ch) + + @PostMapping("/highlight") + fun highlightEndpoint(@RequestBody project: Project): CompilerDiagnostics = + kotlinProjectExecutor.highlight(project) + + + @GetMapping("/compiler-arguments") + fun getCompilerArguments( + @RequestParam projectType: ProjectType, + ): CompilerArgumentResponse = + CompilerArgumentResponse( + compilerArgumentsService.getCompilerArguments(projectType) + .mapToSetOrEmpty { + CompilerArgumentResponse.CompilerArgument( + it.name, + it.shortName, + it.description, + it.type, + it.disabled, + it.predefinedValues + ) + } + ) + + @PostMapping("/translate") + @Deprecated("Use /translate/wasm or /translate/js instead") + fun translate( + @RequestBody @Valid project: Project, + @RequestParam(defaultValue = "js") compiler: String, + @RequestParam(defaultValue = "false") debugInfo: Boolean + ): TranslationResultWithJsCode { + return when (KotlinTranslatableCompiler.valueOf(compiler.uppercase().replace("-", "_"))) { + KotlinTranslatableCompiler.JS -> kotlinProjectExecutor.convertToJsIr(project) + KotlinTranslatableCompiler.WASM -> kotlinProjectExecutor.convertToWasm(project, debugInfo) + KotlinTranslatableCompiler.COMPOSE_WASM -> kotlinProjectExecutor.convertToWasm(project, debugInfo) + } + } } + diff --git a/src/main/kotlin/com/compiler/server/controllers/VersionRestController.kt b/src/main/kotlin/com/compiler/server/controllers/VersionRestController.kt new file mode 100644 index 000000000..84a633b0e --- /dev/null +++ b/src/main/kotlin/com/compiler/server/controllers/VersionRestController.kt @@ -0,0 +1,14 @@ +package com.compiler.server.controllers + +import com.compiler.server.model.bean.VersionInfo +import com.compiler.server.service.KotlinProjectExecutor +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RestController + +@RestController +@RequestMapping("/versions") +class VersionRestController(private val kotlinProjectExecutor: KotlinProjectExecutor) { + @GetMapping + fun getKotlinVersionEndpoint(): List = listOf(kotlinProjectExecutor.getVersion()) +} \ No newline at end of file diff --git a/src/main/kotlin/com/compiler/server/model/ExtendedCompilerArgument.kt b/src/main/kotlin/com/compiler/server/model/ExtendedCompilerArgument.kt new file mode 100644 index 000000000..ae09c0d1e --- /dev/null +++ b/src/main/kotlin/com/compiler/server/model/ExtendedCompilerArgument.kt @@ -0,0 +1,37 @@ +package com.compiler.server.model + +/** + * This is a service layer representation of kotlin compiler arguments. + */ +data class ExtendedCompilerArgument( + val name: String, + val shortName: String?, + val description: String?, + val type: ExtendedCompilerArgumentValue<*>, + val disabled: Boolean, + val predefinedValues: Any?, + val supportedOnCurrentVersion: Boolean +) + +/** + * This sealed interface represents all possible types of compiler arguments. + */ +sealed interface ExtendedCompilerArgumentValue { + val isNullable: Boolean + val defaultValue: T? +} + +data class BooleanExtendedCompilerArgumentValue( + override val isNullable: Boolean, + override val defaultValue: Boolean? +) : ExtendedCompilerArgumentValue + +data class StringExtendedCompilerArgumentValue( + override val isNullable: Boolean, + override val defaultValue: String? +) : ExtendedCompilerArgumentValue + +data class ListExtendedCompilerArgumentValue( + override val isNullable: Boolean, + override val defaultValue: List<*> +) : ExtendedCompilerArgumentValue> diff --git a/src/main/kotlin/com/compiler/server/model/JsCompilerArguments.kt b/src/main/kotlin/com/compiler/server/model/JsCompilerArguments.kt new file mode 100644 index 000000000..597da7d5e --- /dev/null +++ b/src/main/kotlin/com/compiler/server/model/JsCompilerArguments.kt @@ -0,0 +1,6 @@ +package com.compiler.server.model + +data class JsCompilerArguments( + val firstPhase: Map, + val secondPhase: Map +) \ No newline at end of file diff --git a/src/main/kotlin/com/compiler/server/model/Project.kt b/src/main/kotlin/com/compiler/server/model/Project.kt index ec259cf5c..3dc4f7d65 100644 --- a/src/main/kotlin/com/compiler/server/model/Project.kt +++ b/src/main/kotlin/com/compiler/server/model/Project.kt @@ -7,9 +7,13 @@ import com.fasterxml.jackson.annotation.JsonValue data class Project( val args: String = "", val files: List = listOf(), - val confType: ProjectType = ProjectType.JAVA + val confType: ProjectType = ProjectType.JAVA, + val compilerArguments: List> = emptyList() ) +@JsonIgnoreProperties(ignoreUnknown = true) +data class CompilerArgument(val name: String = "", val value: String = "") + @JsonIgnoreProperties(ignoreUnknown = true) data class ProjectFile(val text: String = "", val name: String = "") diff --git a/src/main/kotlin/com/compiler/server/service/CompilerArgumentsService.kt b/src/main/kotlin/com/compiler/server/service/CompilerArgumentsService.kt new file mode 100644 index 000000000..03d15d175 --- /dev/null +++ b/src/main/kotlin/com/compiler/server/service/CompilerArgumentsService.kt @@ -0,0 +1,34 @@ +package com.compiler.server.service + +import com.compiler.server.model.ExtendedCompilerArgument +import com.compiler.server.model.ProjectType +import org.jetbrains.kotlin.utils.filterToSetOrEmpty +import org.springframework.http.HttpStatus +import org.springframework.stereotype.Service +import org.springframework.web.server.ResponseStatusException +import java.util.concurrent.ConcurrentHashMap + +@Service +class CompilerArgumentsService( + private val jvmCompilerArguments: Set, + private val wasmCompilerArguments: Set, + private val composeWasmCompilerArguments: Set, + private val jsCompilerArguments: Set, +) { + private val cache = ConcurrentHashMap>() + + fun getCompilerArguments(projectType: ProjectType): Set { + return cache.computeIfAbsent(projectType) { + when (it) { + ProjectType.JAVA, ProjectType.JUNIT -> jvmCompilerArguments + ProjectType.WASM -> wasmCompilerArguments + ProjectType.COMPOSE_WASM -> composeWasmCompilerArguments + ProjectType.JS_IR -> jsCompilerArguments + else -> throw ResponseStatusException( + HttpStatus.BAD_REQUEST, + "Unsupported projectType '$projectType' for compiler arguments discovery" + ) + }.filterToSetOrEmpty { arg -> arg.supportedOnCurrentVersion } + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/compiler/server/service/KotlinProjectExecutor.kt b/src/main/kotlin/com/compiler/server/service/KotlinProjectExecutor.kt index 6f398b150..aba17d5c5 100644 --- a/src/main/kotlin/com/compiler/server/service/KotlinProjectExecutor.kt +++ b/src/main/kotlin/com/compiler/server/service/KotlinProjectExecutor.kt @@ -1,7 +1,9 @@ package com.compiler.server.service import com.compiler.server.compiler.components.* +import com.compiler.server.compiler.components.WasmTranslationSuccessfulOutput import com.compiler.server.model.* +import com.compiler.server.model.JsCompilerArguments import com.compiler.server.model.bean.VersionInfo import component.KotlinEnvironment import model.Completion @@ -21,12 +23,12 @@ class KotlinProjectExecutor( private val log = LoggerFactory.getLogger(KotlinProjectExecutor::class.java) fun run(project: Project, addByteCode: Boolean): ExecutionResult { - return environment.synchronize { kotlinCompiler.run(project.files, addByteCode, project.args) } + return environment.synchronize { kotlinCompiler.run(project.files, addByteCode, project.args, project.compilerArguments.getOrElse(0, { emptyMap() })) } .also { logExecutionResult(project, it) } } fun test(project: Project, addByteCode: Boolean): ExecutionResult { - return environment.synchronize { kotlinCompiler.test(project.files, addByteCode) } + return environment.synchronize { kotlinCompiler.test(project.files, addByteCode, project.compilerArguments.getOrElse(0, { emptyMap() })) } .also { logExecutionResult(project, it) } } @@ -35,10 +37,10 @@ class KotlinProjectExecutor( } fun compileToJvm(project: Project): CompilationResult { - return kotlinCompiler.compile(project.files) + return kotlinCompiler.compile(project.files, project.compilerArguments.getOrElse(0, { emptyMap() })) } - fun convertToWasm(project: Project, debugInfo: Boolean): TranslationResultWithJsCode { + fun convertToWasm(project: Project, debugInfo: Boolean = false): TranslationResultWithJsCode { return convertWasmWithConverter(project, debugInfo, kotlinToJSTranslator::doTranslateWithWasm) } @@ -71,12 +73,16 @@ class KotlinProjectExecutor( private fun convertJsWithConverter( project: Project, - converter: (List, List) -> CompilationResult + converter: (List, List, JsCompilerArguments) -> CompilationResult ): TranslationJSResult { return environment.synchronize { kotlinToJSTranslator.translateJs( project.files, project.args.split(" "), + JsCompilerArguments( + project.compilerArguments.getOrElse(0, { emptyMap() }), + project.compilerArguments.getOrElse(1, { emptyMap() }) + ), converter ) } @@ -86,7 +92,7 @@ class KotlinProjectExecutor( private fun convertWasmWithConverter( project: Project, debugInfo: Boolean, - converter: (List, List, List, List, Boolean) -> CompilationResult + converter: (List, ProjectType, Boolean, JsCompilerArguments) -> CompilationResult ): TranslationResultWithJsCode { return environment.synchronize { @@ -94,6 +100,10 @@ class KotlinProjectExecutor( project.files, debugInfo, project.confType, + JsCompilerArguments( + project.compilerArguments.getOrElse(0, { emptyMap() }), + project.compilerArguments.getOrElse(1, { emptyMap() }) + ), converter ) } diff --git a/src/main/kotlin/com/compiler/server/utils/CompilerArgumentsUtil.kt b/src/main/kotlin/com/compiler/server/utils/CompilerArgumentsUtil.kt new file mode 100644 index 000000000..6878c32e1 --- /dev/null +++ b/src/main/kotlin/com/compiler/server/utils/CompilerArgumentsUtil.kt @@ -0,0 +1,549 @@ +package com.compiler.server.utils + +import com.compiler.server.compiler.components.PATH_SEPARATOR +import com.compiler.server.model.BooleanExtendedCompilerArgumentValue +import com.compiler.server.model.ExtendedCompilerArgument +import com.compiler.server.model.ExtendedCompilerArgumentValue +import com.compiler.server.model.ListExtendedCompilerArgumentValue +import com.compiler.server.model.StringExtendedCompilerArgumentValue +import com.compiler.server.model.bean.VersionInfo +import component.KotlinEnvironment +import org.jetbrains.kotlin.arguments.dsl.base.KotlinCompilerArgument +import org.jetbrains.kotlin.arguments.dsl.base.KotlinCompilerArguments +import org.jetbrains.kotlin.arguments.dsl.base.KotlinCompilerArgumentsLevel +import org.jetbrains.kotlin.arguments.dsl.types.BooleanType +import org.jetbrains.kotlin.arguments.dsl.types.IntType +import org.jetbrains.kotlin.arguments.dsl.types.KlibIrInlinerModeType +import org.jetbrains.kotlin.arguments.dsl.types.KotlinArgumentValueType +import org.jetbrains.kotlin.arguments.dsl.types.KotlinExplicitApiModeType +import org.jetbrains.kotlin.arguments.dsl.types.KotlinJvmTargetType +import org.jetbrains.kotlin.arguments.dsl.types.KotlinVersionType +import org.jetbrains.kotlin.arguments.dsl.types.ReturnValueCheckerModeType +import org.jetbrains.kotlin.arguments.dsl.types.StringArrayType +import org.jetbrains.kotlin.arguments.dsl.types.StringType +import org.jetbrains.kotlin.tooling.core.KotlinToolingVersion +import org.springframework.stereotype.Component + +internal const val COMPILER_ARGUMENTS_JSON = "kotlin-compiler-arguments.json" +internal const val COMMON_ARGUMENTS_NAME = "commonCompilerArguments" +internal const val JVM_ARGUMENTS_NAME = "jvmCompilerArguments" +internal const val COMMON_KLIB_BASED_ARGUMENTS_NAME = "commonKlibBasedArguments" +internal const val JS_ARGUMENTS_NAME = "jsArguments" +internal const val WASM_ARGUMENTS_NAME = "wasmArguments" +internal const val METADATA_ARGUMENTS_NAME = "metadataArguments" + +internal const val JS_DEFAULT_MODULE_NAME = "playground" +internal const val WASM_DEFAULT_MODULE_NAME = "playground" + +@Component +class CompilerArgumentsUtil( + private val versionInfo: VersionInfo, + kotlinEnvironment: KotlinEnvironment +) { + + private val ALLOWED_COMMON_TOOL_ARGUMENTS = setOf( + "nowarn", + "Werror", + "Wextra" + ) + + private val ALLOWED_COMMON_ARGUMENTS = setOf( + "XXLanguage", + "Xexplicit-backing-fields", + "progressive", + "opt-in", + "Xno-inline", + "Xskip-metadata-version-check", + "Xskip-prerelease-check", + "Xallow-kotlin-package", + "Xstdlib-compilation", + "Xno-check-actual", + "Xnew-inference", + "Xinline-classes", + "Xverify-ir", + "Xverify-ir-visibility", + "Xcheck-phase-conditions", + "Xuse-k2", + "Xuse-fir-experimental-checkers", + "Xuse-fir-ic", + "Xuse-fir-lt", + "Xdisable-default-scripting-plugin", + "Xexplicit-api", + "XXexplicit-return-types", + "Xreturn-value-checker", + "Xsuppress-version-warnings", + "Xsuppress-api-version-greater-than-language-version-error", + "Xexpect-actual-classes", + "Xconsistent-data-class-copy-visibility", + "Xunrestricted-builder-inference", + "Xcontext-receivers", + "Xcontext-parameters", + "Xcontext-sensitive-resolution", + "Xnon-local-break-continue", + "Xdata-flow-based-exhaustiveness", + "Xdirect-java-actualization", + "Xmulti-dollar-interpolation", + "Xenable-incremental-compilation", + "Xrender-internal-diagnostic-names", + "Xreport-all-warnings", + "Xignore-const-optimization-errors", + "Xdont-warn-on-error-suppression", + "Xwhen-guards", + "Xnested-type-aliases", + "Xsuppress-warning", + "Xwarning-level", + "Xannotation-default-target", + "Xannotation-target-all", + "XXlenient-mode", + "Xallow-reified-type-in-catch", + "Xallow-contracts-on-more-functions", + "Xallow-condition-implies-returns-contracts", + "Xallow-holdsin-contract" + ) + + private val ALLOWED_JVM_ARGUMENTS = setOf( + // file paths and environment settings + "include-runtime", + "no-jdk", + "no-stdlib", + "no-reflect", + "module-name", + "jvm-target", + "java-parameters", + "jvm-default", + "Xallow-unstable-dependencies", + "Xabi-stability", + "Xir-do-not-clear-binding-context", + "Xno-call-assertions", + "Xno-receiver-assertions", + "Xno-param-assertions", + "Xno-optimize", + "Xassertions", + "Xuse-type-table", + "Xuse-fast-jar-file-system", + "Xsuppress-missing-builtins-error", + "Xjsr305", + "Xnullability-annotations", + "Xsupport-compatqual-checker-framework-annotations", + "Xjspecify-annotations", + "Xjvm-default", + "Xgenerate-strict-metadata-version", + "Xsanitize-parentheses", + "Xemit-jvm-type-annotations", + "Xjvm-expose-boxed", + "Xstring-concat", + "Xsam-conversions", + "Xlambdas", + "Xindy-allow-annotated-lambdas", + "Xno-reset-jar-timestamps", + "Xno-unified-null-checks", + "Xno-source-debug-extension", + "Xjvm-enable-preview", + "Xsuppress-deprecated-jvm-target-warning", + "Xserialize-ir", + "Xtype-enhancement-improvements-strict-mode", + "Xvalidate-bytecode", + "Xenhance-type-parameter-types-to-def-not-null", + "Xlink-via-signatures", + "Xno-new-java-annotation-targets", + "Xvalue-classes", + "Xir-inliner", + "Xuse-inline-scopes-numbers", + "Xuse-k2-kapt", + "Xcompile-builtins-as-part-of-stdlib", + "Xannotations-in-metadata", + "Xwhen-expressions" + ) + + private val ALLOWED_COMMON_KLIB_BASED_ARGUMENTS = setOf( + "Xklib-enable-signature-clash-checks", + "Xpartial-linkage", + "Xpartial-linkage-loglevel", + "Xklib-duplicated-unique-name-strategy", + "Xklib-ir-inliner" + ) + + private val ALLOWED_JS_ARGUMENTS = setOf( + // file paths and environment settings + "module-name", + "Xir-keep", + "module-kind", + "main", + "Xir-dce", + "Xir-dce-runtime-diagnostic", + "Xir-dce-print-reachability-info", + "Xir-property-lazy-initialization", + "Xir-minimized-member-names", + "Xir-module-name", + "Xir-generate-inline-anonymous-functions", + "Xgenerate-polyfills", + "Xes-classes", + "Xplatform-arguments-in-main-function", + "Xes-generators", + "Xes-arrow-functions", + "Xes-long-as-bigint", + "Xtyped-arrays", + "Xenable-extension-functions-in-externals", + "Xfake-override-validator", + "Xoptimize-generated-js" + ) + + private val ALLOWED_WASM_ARGUMENTS = setOf( + // file paths and environment settings + "Xwasm", + "Xwasm-target", + "Xwasm-debug-info", + "Xwasm-debug-friendly", + "Xwasm-kclass-fqn", + "Xwasm-enable-array-range-checks", + "Xwasm-enable-asserts", + "Xwasm-use-traps-instead-of-exceptions", + "Xwasm-use-new-exception-proposal", + "Xwasm-no-jstag", + "Xwasm-debugger-custom-formatters", + "Xwasm-source-map-include-mappings-from-unavailable-sources", + "Xwasm-ic-cache-readonly", + "Xwasm-generate-dwarf" + ) + + // Use Pair if you want to provide different values for user and for actual use. + // For example, with XPlugin users need to see only plugins, without an actual path, + // but for the compiler we need to pass a full path to the plugin jar. + // In declared Pair the first element is for the user, the second is for actual use. + val PREDEFINED_JVM_ARGUMENTS = mapOf( + "classpath" to Pair( + kotlinEnvironment.classpath.joinToString(PATH_SEPARATOR) { it.name }, + kotlinEnvironment.classpath.joinToString(PATH_SEPARATOR) { it.absolutePath }), + "module-name" to "web-module", + "no-stdlib" to true, + "no-reflect" to true, + "progressive" to true, + "Xplugin" to Pair( + kotlinEnvironment.compilerPlugins.map { it.name }, + kotlinEnvironment.compilerPlugins.map { it.absolutePath }), + "opt-in" to listOf( + "kotlin.ExperimentalStdlibApi", + "kotlin.time.ExperimentalTime", + "kotlin.RequiresOptIn", + "kotlin.ExperimentalUnsignedTypes", + "kotlin.contracts.ExperimentalContracts", + "kotlin.experimental.ExperimentalTypeInference", + "kotlin.uuid.ExperimentalUuidApi", + "kotlin.io.encoding.ExperimentalEncodingApi", + "kotlin.concurrent.atomics.ExperimentalAtomicApi" + ), + "Xcontext-parameters" to true, + "Xnested-type-aliases" to true, + "Xreport-all-warnings" to true, + "Wextra" to true, + "Xexplicit-backing-fields" to true, + "XXLanguage" to "+ExplicitBackingFields" + ) + + val PREDEFINED_WASM_FIRST_PHASE_ARGUMENTS = mapOf( + "Xreport-all-warnings" to true, + "Wextra" to true, + "Xwasm" to true, + "Xir-produce-klib-dir" to true, + "libraries" to Pair( + kotlinEnvironment.WASM_LIBRARIES.sorted().joinToString(PATH_SEPARATOR) { it.split("/").last() }, + kotlinEnvironment.WASM_LIBRARIES.joinToString(PATH_SEPARATOR) + ), + "ir-output-name" to WASM_DEFAULT_MODULE_NAME, + ) + + val PREDEFINED_WASM_SECOND_PHASE_ARGUMENTS = mapOf( + "Xreport-all-warnings" to true, + "Wextra" to true, + "Xwasm" to true, + "Xir-produce-js" to true, + "Xir-dce" to true, + "libraries" to Pair( + kotlinEnvironment.WASM_LIBRARIES.sorted().joinToString(PATH_SEPARATOR) { it.split("/").last() }, + kotlinEnvironment.WASM_LIBRARIES.joinToString(PATH_SEPARATOR) + ), + "ir-output-name" to WASM_DEFAULT_MODULE_NAME, + ) + + val PREDEFINED_COMPOSE_WASM_FIRST_PHASE_ARGUMENTS = mapOf( + "Xreport-all-warnings" to true, + "Wextra" to true, + "Xwasm" to true, + "Xir-produce-klib-dir" to true, + "libraries" to Pair( + kotlinEnvironment.COMPOSE_WASM_LIBRARIES.sorted().joinToString(PATH_SEPARATOR) { it.split("/").last() }, + kotlinEnvironment.COMPOSE_WASM_LIBRARIES.joinToString(PATH_SEPARATOR) + ), + "ir-output-name" to WASM_DEFAULT_MODULE_NAME, + "XPlugin" to Pair( + kotlinEnvironment.COMPOSE_WASM_COMPILER_PLUGINS.map { it.split("/").last() }, + kotlinEnvironment.COMPOSE_WASM_COMPILER_PLUGINS + ), + "P" to Pair( + kotlinEnvironment.composeWasmCompilerPluginOptions, + kotlinEnvironment.composeWasmCompilerPluginOptions + ) + ) + + val PREDEFINED_COMPOSE_WASM_SECOND_PHASE_ARGUMENTS = mapOf( + "Xreport-all-warnings" to true, + "Wextra" to true, + "Xwasm" to true, + "Xir-produce-js" to true, + "Xir-dce" to true, + "libraries" to Pair( + kotlinEnvironment.COMPOSE_WASM_LIBRARIES.sorted().joinToString(PATH_SEPARATOR) { it.split("/").last() }, + kotlinEnvironment.COMPOSE_WASM_LIBRARIES.joinToString(PATH_SEPARATOR) + ), + "ir-output-name" to WASM_DEFAULT_MODULE_NAME, + ) + + val PREDEFINED_JS_FIRST_PHASE_ARGUMENTS = mapOf( + "Xreport-all-warnings" to true, + "Wextra" to true, + "Xir-produce-klib-dir" to true, + "libraries" to Pair( + kotlinEnvironment.JS_LIBRARIES.sorted().joinToString(PATH_SEPARATOR) { it.split("/").last() }, + kotlinEnvironment.JS_LIBRARIES.joinToString(PATH_SEPARATOR) + ), + "ir-output-name" to JS_DEFAULT_MODULE_NAME, + ) + + val PREDEFINED_JS_SECOND_PHASE_ARGUMENTS = mapOf( + "Xreport-all-warnings" to true, + "Wextra" to true, + "Xir-produce-js" to true, + "Xir-dce" to true, + "libraries" to Pair( + kotlinEnvironment.JS_LIBRARIES.sorted().joinToString(PATH_SEPARATOR) { it.split("/").last() }, + kotlinEnvironment.JS_LIBRARIES.joinToString(PATH_SEPARATOR) + ), + "ir-output-name" to JS_DEFAULT_MODULE_NAME, + ) + + fun convertCompilerArgumentsToCompilationString( + allArguments: Set, + predefinedArguments: Map, + userArguments: Map + ): List { + return allArguments + .flatMap { + if (it.name in (predefinedArguments.keys + userArguments.keys)) + if (!it.disabled && it.name in userArguments.keys) { + convertToCompilerArgumentsStringList(it.name, userArguments[it.name]!!) + } else { + convertToCompilerArgumentsStringList( + it.name, + (predefinedArguments[it.name] as? Pair<*, *>)?.second ?: predefinedArguments[it.name] + ) + } + else emptyList() + } + .map { it.filterNot { it.isWhitespace() } } + + } + + fun convertToCompilerArgumentsStringList(argumentName: String, argumentValue: Any?): List { + return when (argumentValue) { + is Boolean -> if (argumentValue) listOf("-$argumentName") else emptyList() + + is String -> { + if (argumentName == "XXLanguage") listOf("-$argumentName:$argumentValue".filterNot { it.isWhitespace() }) + else listOf("-$argumentName", argumentValue) + } + + is List<*> -> argumentValue.map { "-$argumentName=$it" } + else -> throw IllegalArgumentException("Unknown type of argument value: ${argumentValue?.javaClass?.name}") + } + } + + fun collectJvmArguments( + kotlinCompilerArguments: KotlinCompilerArguments + ): Set { + val commonArgumentsLevel = kotlinCompilerArguments.getCommonArgumentsLevel() + val jvmLevel = commonArgumentsLevel + .nestedLevels + .first { nestedArguments -> nestedArguments.name == JVM_ARGUMENTS_NAME } + return (kotlinCompilerArguments.topLevel.arguments + + commonArgumentsLevel.arguments + + jvmLevel.arguments) + .processCompilerArgs( + predefinedArguments = PREDEFINED_JVM_ARGUMENTS, + allowedArguments = ALLOWED_COMMON_TOOL_ARGUMENTS + ALLOWED_COMMON_ARGUMENTS + ALLOWED_JVM_ARGUMENTS, + ) + } + + fun collectWasmArguments( + kotlinCompilerArguments: KotlinCompilerArguments + ): Set { + val commonArgumentsLevel = kotlinCompilerArguments.getCommonArgumentsLevel() + val commonKlibBasedArgumentsLevel = getCommonKlibBasedArgumentsLevel(kotlinCompilerArguments) + val wasmLevel = getWasmLevel(commonKlibBasedArgumentsLevel) + val jsLevel = wasmLevel.nestedLevels.first { nestedArguments -> nestedArguments.name == JS_ARGUMENTS_NAME } + return (kotlinCompilerArguments.topLevel.arguments + + commonArgumentsLevel.arguments + + commonKlibBasedArgumentsLevel.arguments + + wasmLevel.arguments+ + jsLevel.arguments) + .processCompilerArgs( + predefinedArguments = PREDEFINED_WASM_FIRST_PHASE_ARGUMENTS, + allowedArguments = + ALLOWED_COMMON_TOOL_ARGUMENTS + + ALLOWED_COMMON_ARGUMENTS + + ALLOWED_COMMON_KLIB_BASED_ARGUMENTS + + ALLOWED_WASM_ARGUMENTS + + ALLOWED_JS_ARGUMENTS + ) + + } + + fun collectComposeWasmArguments( + kotlinCompilerArguments: KotlinCompilerArguments + ): Set { + val commonArgumentsLevel = kotlinCompilerArguments.getCommonArgumentsLevel() + val commonKlibBasedArgumentsLevel = getCommonKlibBasedArgumentsLevel(kotlinCompilerArguments) + val wasmLevel = getWasmLevel(commonKlibBasedArgumentsLevel) + val jsLevel = wasmLevel.nestedLevels.first { nestedArguments -> nestedArguments.name == JS_ARGUMENTS_NAME } + return (kotlinCompilerArguments.topLevel.arguments + + commonArgumentsLevel.arguments + + commonKlibBasedArgumentsLevel.arguments + + wasmLevel.arguments + + jsLevel.arguments) + .processCompilerArgs( + predefinedArguments = PREDEFINED_COMPOSE_WASM_FIRST_PHASE_ARGUMENTS, + allowedArguments = + ALLOWED_COMMON_TOOL_ARGUMENTS + + ALLOWED_COMMON_ARGUMENTS + + ALLOWED_COMMON_KLIB_BASED_ARGUMENTS + + ALLOWED_WASM_ARGUMENTS + + ALLOWED_JS_ARGUMENTS + ) + + } + + fun collectJsArguments( + kotlinCompilerArguments: KotlinCompilerArguments + ): Set { + val commonArgumentsLevel = kotlinCompilerArguments.getCommonArgumentsLevel() + val commonKlibBasedArgumentsLevel = getCommonKlibBasedArgumentsLevel(kotlinCompilerArguments) + + val wasmLevel = getWasmLevel(commonKlibBasedArgumentsLevel) + + val jsLevel = wasmLevel.nestedLevels.first { nestedArguments -> nestedArguments.name == JS_ARGUMENTS_NAME } + + return (kotlinCompilerArguments.topLevel.arguments + + commonArgumentsLevel.arguments + + commonKlibBasedArgumentsLevel.arguments + + wasmLevel.arguments + + jsLevel.arguments + ) + .processCompilerArgs( + predefinedArguments = PREDEFINED_JS_FIRST_PHASE_ARGUMENTS, + allowedArguments = + ALLOWED_COMMON_TOOL_ARGUMENTS + + ALLOWED_COMMON_ARGUMENTS + + ALLOWED_COMMON_KLIB_BASED_ARGUMENTS + + ALLOWED_WASM_ARGUMENTS + + ALLOWED_JS_ARGUMENTS + ) + + } + + private fun getWasmLevel(commonKlibBasedArgumentsLevel: KotlinCompilerArgumentsLevel): KotlinCompilerArgumentsLevel = + commonKlibBasedArgumentsLevel + .nestedLevels + .first { nestedArguments -> nestedArguments.name == WASM_ARGUMENTS_NAME } + + private fun getCommonKlibBasedArgumentsLevel(kotlinCompilerArguments: KotlinCompilerArguments): KotlinCompilerArgumentsLevel { + val commonArgumentsLayer = kotlinCompilerArguments.getCommonArgumentsLevel() + val commonKlibBasedArgumentsLayer = + commonArgumentsLayer.nestedLevels.first { nestedArguments -> nestedArguments.name == COMMON_KLIB_BASED_ARGUMENTS_NAME } + return commonKlibBasedArgumentsLayer + } + + private fun KotlinCompilerArguments.getCommonArgumentsLevel() = this.topLevel.nestedLevels.first() + + private fun Collection.processCompilerArgs( + allowedArguments: Set = emptySet(), + predefinedArguments: Map = emptyMap() + ): Set = + map { arg -> + val disabled = arg.name !in allowedArguments + ExtendedCompilerArgument( + name = arg.name, + shortName = arg.shortName, + description = arg.description.current, + type = convertKotlinArgumentValueTypeToExtendedCompilerArgumentValue(arg.valueType), + disabled = disabled, + predefinedValues = (predefinedArguments[arg.name] as? Pair<*, *>)?.first + ?: predefinedArguments[arg.name] as? List<*>, + supportedOnCurrentVersion = arg.isSupportedOnCurrentVersion() + ) + }.toSet() + + private fun convertKotlinArgumentValueTypeToExtendedCompilerArgumentValue(type: KotlinArgumentValueType<*>): ExtendedCompilerArgumentValue<*> { + return when (type) { + is BooleanType -> { + BooleanExtendedCompilerArgumentValue( + isNullable = type.isNullable.current, + defaultValue = type.defaultValue.current + ) + } + + is StringType, is IntType -> { + StringExtendedCompilerArgumentValue( + isNullable = type.isNullable.current, + defaultValue = type.defaultValue.current?.toString() + ) + } + + is KotlinJvmTargetType -> { + StringExtendedCompilerArgumentValue( + isNullable = type.isNullable.current, + defaultValue = type.defaultValue.current?.targetName + ) + } + + is ReturnValueCheckerModeType -> { + StringExtendedCompilerArgumentValue( + isNullable = type.isNullable.current, + defaultValue = type.defaultValue.current?.modeState + ) + } + + is KotlinExplicitApiModeType -> { + StringExtendedCompilerArgumentValue( + isNullable = type.isNullable.current, + defaultValue = type.defaultValue.current?.modeName + ) + } + + is KotlinVersionType -> { + StringExtendedCompilerArgumentValue( + isNullable = type.isNullable.current, + defaultValue = type.defaultValue.current?.versionName + ) + } + + is KlibIrInlinerModeType -> { + StringExtendedCompilerArgumentValue( + isNullable = type.isNullable.current, + defaultValue = type.defaultValue.current?.modeState + ) + } + + is StringArrayType -> { + ListExtendedCompilerArgumentValue( + isNullable = type.isNullable.current, + defaultValue = type.defaultValue.current?.toList() ?: emptyList() + ) + } + } + } + + private fun KotlinCompilerArgument.isSupportedOnCurrentVersion(): Boolean { + return releaseVersionsMetadata.removedVersion?.releaseName?.let { releaseVersion -> + KotlinToolingVersion(versionInfo.version) < KotlinToolingVersion(releaseVersion) + } ?: true + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/compiler/server/validation/AbstractCompilerArgumentsValidator.kt b/src/main/kotlin/com/compiler/server/validation/AbstractCompilerArgumentsValidator.kt new file mode 100644 index 000000000..50e7e2e91 --- /dev/null +++ b/src/main/kotlin/com/compiler/server/validation/AbstractCompilerArgumentsValidator.kt @@ -0,0 +1,87 @@ +package com.compiler.server.validation + +import com.compiler.server.model.BooleanExtendedCompilerArgumentValue +import com.compiler.server.model.ExtendedCompilerArgument +import com.compiler.server.model.ExtendedCompilerArgumentValue +import com.compiler.server.model.ListExtendedCompilerArgumentValue +import com.compiler.server.model.StringExtendedCompilerArgumentValue +import jakarta.validation.ConstraintValidatorContext + +/** + * @param knownCompilerArguments The set of predefined compiler arguments that are + * recognized and supported. + */ +abstract class AbstractCompilerArgumentsValidator(private val knownCompilerArguments: Set) { + private val STRING_ARGUMENT_REGEX = Regex("^[}{A-Za-z0-9+-.,:=]+\$") + + fun validateCompilerArguments( + compilerArguments: Map, + ): Boolean { + if (compilerArguments.isEmpty()) return true + + if (isCompilerArgumentsKeysValid(compilerArguments.keys).not()) { + return false + } + if (isCompilerArgumentsValuesValid(compilerArguments).not()) { + return false + } + return true + } + + private fun isCompilerArgumentsValuesValid(compilerArguments: Map): Boolean { + for ((argumentName, argumentValue) in compilerArguments) { + if (isCompilerArgumentValueValid(argumentName, argumentValue).not()) { + return false + } + } + return true + } + + private fun isCompilerArgumentValueValid(argumentName: String, argumentValue: Any): Boolean { + val expectedArgumentType = knownCompilerArguments + .find { it.name == argumentName } + ?.type ?: throw IllegalArgumentException("Unknown compiler argument: $argumentName") + + return when (argumentValue) { + is Boolean -> expectedArgumentType is BooleanExtendedCompilerArgumentValue + + is List<*> -> expectedArgumentType is ListExtendedCompilerArgumentValue && + checkListJvmCompilerArgument(argumentName, argumentValue) + + is String -> expectedArgumentType is StringExtendedCompilerArgumentValue && + checkStringJvmCompilerArgument(argumentName, argumentValue) + + else -> false // unsupported type + } + } + + private fun isCompilerArgumentsKeysValid( + keys: Set, + ): Boolean { + for (argumentKey in keys) { + val knownCompilerArgument = knownCompilerArguments.find { it.name == argumentKey } + if (knownCompilerArgument == null) { + return false + } + if (knownCompilerArgument.disabled) { + return false + } + } + return true + } + + fun checkListJvmCompilerArgument(argumentName: String, argumentValues: List<*>): Boolean { + argumentValues.forEach { argumentValue -> + if (argumentValue !is String) return false + if (checkStringJvmCompilerArgument(argumentName, argumentValue).not()) return false + } + return true + } + + fun checkStringJvmCompilerArgument(argumentName: String, argumentValue: String): Boolean { + if (!STRING_ARGUMENT_REGEX.matches(argumentValue)) return false + if (argumentValue.any { it.isWhitespace() }) return false + if (argumentName != "XXLanguage" && argumentValue.startsWith("-")) return false + return true + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/compiler/server/validation/ProjectRequestValidation.kt b/src/main/kotlin/com/compiler/server/validation/ProjectRequestValidation.kt new file mode 100644 index 000000000..62492b896 --- /dev/null +++ b/src/main/kotlin/com/compiler/server/validation/ProjectRequestValidation.kt @@ -0,0 +1,51 @@ +package com.compiler.server.validation + +import com.compiler.server.model.ProjectType +import jakarta.validation.Constraint +import jakarta.validation.ConstraintValidator +import jakarta.validation.ConstraintValidatorContext +import jakarta.validation.Payload +import org.springframework.beans.factory.annotation.Autowired +import kotlin.reflect.KClass + +/** + * Annotation representing a validation constraint for a project run request. + * + * This constraint validates the compiler arguments associated with a project + * to ensure they meet specific validity requirements based on the project's configuration. + * The validation is performed using a custom validator, `ProjectRunRequestValidator`. + * + * Properties: + * @property message The error message returned when the validation fails. Defaults to a standard message. + * @property groups Associates this constraint with specific validation groups, if needed. + * @property payload Provides additional metadata about the constraint for advanced use cases. + */ +@Constraint(validatedBy = [ProjectRunRequestValidator::class]) +@Target(AnnotationTarget.FIELD) +annotation class CompilerArgumentsConstraint( + val projectType: ProjectType, + val message: String = "Invalid compiler arguments passed.", + val groups: Array> = [], + vararg val payload: KClass = [] +) + +class ProjectRunRequestValidator : ConstraintValidator> { + @Autowired + private lateinit var compilerArgumentsValidators: Map + + private var projectType: ProjectType = ProjectType.JAVA + + override fun initialize(constraintAnnotation: CompilerArgumentsConstraint?) { + projectType = constraintAnnotation?.projectType + ?: throw IllegalArgumentException("Project type must be provided for compiler args validation.") + } + + override fun isValid( + compilerArguments: Map, + cxt: ConstraintValidatorContext + ): Boolean { + return compilerArgumentsValidators[projectType] + ?.validateCompilerArguments(compilerArguments) + ?: false + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/compiler/server/validation/impl/ComposeWasmCompilerArgumentsValidator.kt b/src/main/kotlin/com/compiler/server/validation/impl/ComposeWasmCompilerArgumentsValidator.kt new file mode 100644 index 000000000..0c02facaf --- /dev/null +++ b/src/main/kotlin/com/compiler/server/validation/impl/ComposeWasmCompilerArgumentsValidator.kt @@ -0,0 +1,9 @@ +package com.compiler.server.validation.impl + +import com.compiler.server.model.ExtendedCompilerArgument +import com.compiler.server.validation.AbstractCompilerArgumentsValidator +import org.springframework.stereotype.Component + +@Component +class ComposeWasmCompilerArgumentsValidator(composeWasmCompilerArguments: Set) : + AbstractCompilerArgumentsValidator(composeWasmCompilerArguments) \ No newline at end of file diff --git a/src/main/kotlin/com/compiler/server/validation/impl/JsCompilerArgumentsValidator.kt b/src/main/kotlin/com/compiler/server/validation/impl/JsCompilerArgumentsValidator.kt new file mode 100644 index 000000000..1e0071e82 --- /dev/null +++ b/src/main/kotlin/com/compiler/server/validation/impl/JsCompilerArgumentsValidator.kt @@ -0,0 +1,9 @@ +package com.compiler.server.validation.impl + +import com.compiler.server.model.ExtendedCompilerArgument +import com.compiler.server.validation.AbstractCompilerArgumentsValidator +import org.springframework.stereotype.Component + +@Component +class JsCompilerArgumentsValidator(jsCompilerArguments: Set) : + AbstractCompilerArgumentsValidator(jsCompilerArguments) \ No newline at end of file diff --git a/src/main/kotlin/com/compiler/server/validation/impl/JvmCompilerArgumentsValidator.kt b/src/main/kotlin/com/compiler/server/validation/impl/JvmCompilerArgumentsValidator.kt new file mode 100644 index 000000000..ee08c7821 --- /dev/null +++ b/src/main/kotlin/com/compiler/server/validation/impl/JvmCompilerArgumentsValidator.kt @@ -0,0 +1,9 @@ +package com.compiler.server.validation.impl + +import com.compiler.server.model.ExtendedCompilerArgument +import com.compiler.server.validation.AbstractCompilerArgumentsValidator +import org.springframework.stereotype.Component + +@Component +class JvmCompilerArgumentsValidator(jvmCompilerArguments: Set) : + AbstractCompilerArgumentsValidator(jvmCompilerArguments) \ No newline at end of file diff --git a/src/main/kotlin/com/compiler/server/validation/impl/WasmCompilerArgumentsValidator.kt b/src/main/kotlin/com/compiler/server/validation/impl/WasmCompilerArgumentsValidator.kt new file mode 100644 index 000000000..acc9e8464 --- /dev/null +++ b/src/main/kotlin/com/compiler/server/validation/impl/WasmCompilerArgumentsValidator.kt @@ -0,0 +1,9 @@ +package com.compiler.server.validation.impl + +import com.compiler.server.model.ExtendedCompilerArgument +import com.compiler.server.validation.AbstractCompilerArgumentsValidator +import org.springframework.stereotype.Component + +@Component +class WasmCompilerArgumentsValidator(wasmCompilerArguments: Set) : + AbstractCompilerArgumentsValidator(wasmCompilerArguments) \ No newline at end of file diff --git a/src/test/kotlin/com/compiler/server/CompilerAPITest.kt b/src/test/kotlin/com/compiler/server/CompilerAPITest.kt index 9418ab395..d1781a94b 100644 --- a/src/test/kotlin/com/compiler/server/CompilerAPITest.kt +++ b/src/test/kotlin/com/compiler/server/CompilerAPITest.kt @@ -1,6 +1,7 @@ package com.compiler.server -import com.compiler.server.generator.generateSingleProject +import com.compiler.server.api.ProjectFileRequestDto +import com.compiler.server.api.RunRequest import com.compiler.server.model.JvmExecutionResult import com.compiler.server.model.bean.VersionInfo import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper @@ -47,7 +48,7 @@ class CompilerAPITest { getHost() + url, HttpEntity( jacksonObjectMapper().writeValueAsString( - generateSingleProject(PROGRAM_RUN) + RunRequest(files = listOf(ProjectFileRequestDto(text = PROGRAM_RUN, name = "File.kt")),) ), headers ), diff --git a/src/test/kotlin/com/compiler/server/CompilerArgumentsConfigurationTest.kt b/src/test/kotlin/com/compiler/server/CompilerArgumentsConfigurationTest.kt new file mode 100644 index 000000000..46b34f498 --- /dev/null +++ b/src/test/kotlin/com/compiler/server/CompilerArgumentsConfigurationTest.kt @@ -0,0 +1,51 @@ +package com.compiler.server + +import com.compiler.server.configuration.CompilerArgumentsConfiguration +import com.compiler.server.utils.COMMON_ARGUMENTS_NAME +import com.compiler.server.utils.COMMON_KLIB_BASED_ARGUMENTS_NAME +import com.compiler.server.utils.COMPILER_ARGUMENTS_JSON +import com.compiler.server.utils.JVM_ARGUMENTS_NAME +import com.compiler.server.utils.METADATA_ARGUMENTS_NAME +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertTrue + +class CompilerArgumentsConfigurationTest { + + private val compilerArgumentsConfiguration: CompilerArgumentsConfiguration = CompilerArgumentsConfiguration() + + + @Test + fun validateKotlinCompilerArgumentsJsonFile() { + val kotlinCompilerArguments = compilerArgumentsConfiguration.kotlinCompilerArguments() + + assertEquals( + 2, kotlinCompilerArguments.schemaVersion, + "Unsupported schema version of $COMPILER_ARGUMENTS_JSON" + ) + + assertEquals("commonToolArguments", kotlinCompilerArguments.topLevel.name) + + assertEquals( + 1, + kotlinCompilerArguments.topLevel.nestedLevels.size, + "Unexpected top-level's nested levels count" + ) + + val argumentsFirstLayer = kotlinCompilerArguments + .topLevel + .nestedLevels + .first() + assertEquals(COMMON_ARGUMENTS_NAME, argumentsFirstLayer.name) + + assertEquals(3, argumentsFirstLayer.nestedLevels.size) + + val actualSecondLevelArgumentNames = argumentsFirstLayer.nestedLevels.map { it.name } + val expectedSecondLevelArgumentNames = + listOf(JVM_ARGUMENTS_NAME, COMMON_KLIB_BASED_ARGUMENTS_NAME, METADATA_ARGUMENTS_NAME) + assertTrue( + actualSecondLevelArgumentNames.containsAll(expectedSecondLevelArgumentNames), + "Unexpected second-level's arguments names. Expected: $expectedSecondLevelArgumentNames, got: $actualSecondLevelArgumentNames" + ) + } +} \ No newline at end of file diff --git a/src/test/kotlin/com/compiler/server/CompilerArgumentsEndpointTest.kt b/src/test/kotlin/com/compiler/server/CompilerArgumentsEndpointTest.kt new file mode 100644 index 000000000..bdfa0bd93 --- /dev/null +++ b/src/test/kotlin/com/compiler/server/CompilerArgumentsEndpointTest.kt @@ -0,0 +1,77 @@ +package com.compiler.server + +import com.compiler.server.model.ProjectType +import com.compiler.server.model.bean.VersionInfo +import com.fasterxml.jackson.databind.ObjectMapper +import component.KotlinEnvironment +import org.junit.jupiter.api.Test +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.beans.factory.annotation.Value +import org.springframework.boot.test.context.SpringBootTest +import org.springframework.http.HttpMethod +import org.springframework.http.RequestEntity +import org.springframework.web.client.RestTemplate +import java.net.InetAddress +import java.net.URI +import java.nio.file.Paths +import kotlin.io.path.readText +import kotlin.test.assertEquals + +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +class CompilerArgumentsEndpointTest { + + @Autowired + private lateinit var versionInfo: VersionInfo + + @Autowired + private lateinit var kotlinEnvironment: KotlinEnvironment + + @Autowired + private lateinit var objectMapper: ObjectMapper + + @Value("\${local.server.port}") + private var port = 0 + + private val host: String = InetAddress.getLocalHost().hostAddress + + private fun baseUrl(): String = "http://$host:$port" + + @ParameterizedTest + @EnumSource(ProjectType::class, mode = EnumSource.Mode.EXCLUDE, names = ["JS", "CANVAS"]) + fun `compiler arguments endpoint returns flattened data without nested argument`(projectType: ProjectType) { + val version = versionInfo.version + val urls = listOf( + "/api/compiler/compiler-arguments?projectType=${projectType.id}", + "/api/$version/compiler/compiler-arguments?projectType=${projectType.id}" + ) + + val client = RestTemplate() + + val projectTypeId = when (projectType) { + ProjectType.JAVA, ProjectType.JUNIT -> "jvm" + ProjectType.JS_IR, ProjectType.JS, ProjectType.CANVAS -> "js" + ProjectType.WASM -> "wasm" + ProjectType.COMPOSE_WASM -> "compose-wasm" + } + + val expectedResponseBody = Paths.get("src/test/resources/compiler-arguments/$projectTypeId-expected-compiler-args.json").readText() + .replace( + "{{PLUGIN_PLACEHOLDER}}", + kotlinEnvironment.compilerPlugins.joinToString(",") { "\"" + it.name } + "\"") + .replace("{{CLASSPATH_PLACEHOLDER}}", kotlinEnvironment.classpath.joinToString(":") { it.name }) + .replace("{{KOTLIN_VERSION_PLACEHOLDER}}", version) + + urls.forEach { path -> + val response = client.exchange( + RequestEntity(HttpMethod.GET, URI.create(baseUrl() + path)), + String::class.java + ) + + val body = response.body + + assertEquals(objectMapper.readTree(expectedResponseBody), objectMapper.readTree(body)) + } + } +} diff --git a/src/test/kotlin/com/compiler/server/ResourceCompileTest.kt b/src/test/kotlin/com/compiler/server/ResourceCompileTest.kt index aad0a059b..a4fb4edac 100644 --- a/src/test/kotlin/com/compiler/server/ResourceCompileTest.kt +++ b/src/test/kotlin/com/compiler/server/ResourceCompileTest.kt @@ -9,7 +9,7 @@ import org.junit.jupiter.api.Test class ResourceCompileTest : BaseExecutorTest(), BaseResourceCompileTest { override fun request(code: String, platform: ProjectType) = when (platform) { ProjectType.JAVA -> run(code, "") - ProjectType.JS_IR, ProjectType.JS -> translateToJsIr(code) + ProjectType.JS_IR -> translateToJsIr(code) else -> throw IllegalArgumentException("Unknown type $platform") } diff --git a/src/test/kotlin/com/compiler/server/ResourceE2ECompileTest.kt b/src/test/kotlin/com/compiler/server/ResourceE2ECompileTest.kt index b33e9de70..326487205 100644 --- a/src/test/kotlin/com/compiler/server/ResourceE2ECompileTest.kt +++ b/src/test/kotlin/com/compiler/server/ResourceE2ECompileTest.kt @@ -1,9 +1,11 @@ package com.compiler.server +import com.compiler.server.api.ProjectFileRequestDto +import com.compiler.server.api.RunRequest +import com.compiler.server.api.TranslateJsRequest import com.compiler.server.base.startNodeJsApp import com.compiler.server.compiler.components.KotlinToJSTranslator.Companion.JS_IR_CODE_BUFFER import com.compiler.server.compiler.components.KotlinToJSTranslator.Companion.JS_IR_OUTPUT_REWRITE -import com.compiler.server.generator.generateSingleProject import com.compiler.server.model.ExecutionResult import com.compiler.server.model.JunitExecutionResult import com.compiler.server.model.JvmExecutionResult @@ -38,16 +40,23 @@ class ResourceE2ECompileTest : BaseResourceCompileTest { private fun getHost(): String = "http://$host:$port" override fun request(code: String, platform: ProjectType): ExecutionResult { - val url = when (platform) { - ProjectType.JS, ProjectType.JS_IR -> "/api/compiler/translate?ir=true" - else -> "/api/compiler/run" + val (url, requestBody) = when (platform) { + ProjectType.JS_IR -> Pair( + "/api/compiler/translate?ir=true", + TranslateJsRequest(files = listOf(ProjectFileRequestDto(text = code, name = "File.kt"))) + ) + + ProjectType.JAVA -> Pair( + "/api/compiler/run", + RunRequest(files = listOf(ProjectFileRequestDto(text = code, name = "File.kt"))) + ) + + else -> throw IllegalArgumentException("Unsupported type $platform") } val headers = HttpHeaders().apply { contentType = MediaType.APPLICATION_JSON } - val body = jacksonObjectMapper().writeValueAsString( - generateSingleProject(code, projectType = platform) - ) + val body = jacksonObjectMapper().writeValueAsString(requestBody) val resultClass = when (platform) { ProjectType.JUNIT -> JunitExecutionResult::class.java diff --git a/src/test/resources/compiler-arguments/compose-wasm-expected-compiler-args.json b/src/test/resources/compiler-arguments/compose-wasm-expected-compiler-args.json new file mode 100644 index 000000000..3e8ab3356 --- /dev/null +++ b/src/test/resources/compiler-arguments/compose-wasm-expected-compiler-args.json @@ -0,0 +1,2022 @@ +{ + "compilerArguments": [ + { + "name": "help", + "shortName": "h", + "description": "Print a synopsis of standard options.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "X", + "shortName": null, + "description": "Print a synopsis of advanced options.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "version", + "shortName": null, + "description": "Display the compiler version.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "verbose", + "shortName": null, + "description": "Enable verbose logging output.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "nowarn", + "shortName": null, + "description": "Don't generate any warnings.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Werror", + "shortName": null, + "description": "Report an error if there are any warnings.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Wextra", + "shortName": null, + "description": "Enable extra checkers for K2.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "language-version", + "shortName": null, + "description": "Provide source compatibility with the specified version of Kotlin.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "api-version", + "shortName": null, + "description": "Allow using declarations from only the specified version of bundled libraries.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "kotlin-home", + "shortName": null, + "description": "Path to the Kotlin compiler home directory used for the discovery of runtime libraries.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "progressive", + "shortName": null, + "description": "Enable progressive compiler mode.\nIn this mode, deprecations and bug fixes for unstable code take effect immediately\ninstead of going through a graceful migration cycle.\nCode written in progressive mode is backward compatible; however, code written without\nprogressive mode enabled may cause compilation errors in progressive mode.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "script", + "shortName": null, + "description": "Evaluate the given Kotlin script (*.kts) file.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xrepl", + "shortName": null, + "description": "Run Kotlin REPL (deprecated)", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "opt-in", + "shortName": null, + "description": "Enable API usages that require opt-in with an opt-in requirement marker with the given fully qualified name.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xno-inline", + "shortName": null, + "description": "Disable method inlining.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xskip-metadata-version-check", + "shortName": null, + "description": "Allow loading classes with bad metadata versions and pre-release classes.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xskip-prerelease-check", + "shortName": null, + "description": "Allow loading pre-release classes.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xallow-kotlin-package", + "shortName": null, + "description": "Allow compiling code in the 'kotlin' package, and allow not requiring 'kotlin.stdlib' in 'module-info'.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xstdlib-compilation", + "shortName": null, + "description": "Enables special features which are relevant only for stdlib compilation.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xreport-output-files", + "shortName": null, + "description": "Report the source-to-output file mapping.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xplugin", + "shortName": null, + "description": "Load plugins from the given classpath.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "P", + "shortName": null, + "description": "Pass an option to a plugin.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": [ + "plugin:androidx.compose.compiler.plugins.kotlin:generateDecoys=false" + ] + }, + { + "name": "Xcompiler-plugin", + "shortName": null, + "description": "Register a compiler plugin.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xcompiler-plugin-order", + "shortName": null, + "description": "Specify an execution order constraint for compiler plugins.\nOrder constraint can be specified using the 'pluginId' of compiler plugins.\nThe first specified plugin will be executed before the second plugin.\nMultiple constraints can be specified by repeating this option. Cycles in constraints will cause an error.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xmulti-platform", + "shortName": null, + "description": "Enable language support for multiplatform projects.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xno-check-actual", + "shortName": null, + "description": "Do not check for the presence of the 'actual' modifier in multiplatform projects.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xintellij-plugin-root", + "shortName": null, + "description": "Path to 'kotlin-compiler.jar' or the directory where the IntelliJ IDEA configuration files can be found.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xnew-inference", + "shortName": null, + "description": "Enable the new experimental generic type inference algorithm.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xinline-classes", + "shortName": null, + "description": "Enable experimental inline classes.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xreport-perf", + "shortName": null, + "description": "Report detailed performance statistics.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xdetailed-perf", + "shortName": null, + "description": "Enable more detailed performance statistics (Experimental).\nFor Native, the performance report includes execution time and lines processed per second for every individual lowering.\nFor WASM and JS, the performance report includes execution time and lines per second for each lowering of the first stage of compilation.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xdump-perf", + "shortName": null, + "description": "Dump detailed performance statistics to the specified file in plain text, JSON or markdown format (it's detected by the file's extension).\nAlso, it supports the placeholder `*` and directory for generating file names based on the module being compiled and the current time stamp.\nExample: `path/to/dir/*.log` creates logs like `path/to/dir/my-module_2025-06-20-12-22-32.log` in plain text format, `path/to/dir/` creates logs like `path/to/dir/my-log_2025-06-20-12-22-32.json`.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "XXdump-model", + "shortName": null, + "description": "Dump compilation model to specified directory for use in modularized tests.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xmetadata-version", + "shortName": null, + "description": "Change the metadata version of the generated binary files.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xcommon-sources", + "shortName": null, + "description": "Sources of the common module that need to be compiled together with this module in multiplatform mode.\nThey should be a subset of sources passed as free arguments.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xlist-phases", + "shortName": null, + "description": "List backend phases.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xdisable-phases", + "shortName": null, + "description": "Disable backend phases.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xverbose-phases", + "shortName": null, + "description": "Be verbose while performing the given backend phases.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xphases-to-dump-before", + "shortName": null, + "description": "Dump the backend's state before these phases.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xphases-to-dump-after", + "shortName": null, + "description": "Dump the backend's state after these phases.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xphases-to-dump", + "shortName": null, + "description": "Dump the backend's state both before and after these phases.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xdump-directory", + "shortName": null, + "description": "Dump the backend state into this directory.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xdump-fqname", + "shortName": null, + "description": "Dump the declaration with the given FqName.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xphases-to-validate-before", + "shortName": null, + "description": "Validate the backend's state before these phases.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xphases-to-validate-after", + "shortName": null, + "description": "Validate the backend's state after these phases.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xphases-to-validate", + "shortName": null, + "description": "Validate the backend's state both before and after these phases.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xverify-ir", + "shortName": null, + "description": "IR verification mode (no verification by default).", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xverify-ir-visibility", + "shortName": null, + "description": "Check for visibility violations in IR when validating it before running any lowerings. Only has effect if '-Xverify-ir' is not 'none'.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xprofile-phases", + "shortName": null, + "description": "Profile backend phases.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xcheck-phase-conditions", + "shortName": null, + "description": "Check pre- and postconditions of IR lowering phases.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xuse-fir-experimental-checkers", + "shortName": null, + "description": "Enable experimental frontend IR checkers that are not yet ready for production.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xuse-fir-ic", + "shortName": null, + "description": "Compile using frontend IR internal incremental compilation.\nWarning: This feature is not yet production-ready.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xuse-fir-lt", + "shortName": null, + "description": "Compile using the LightTree parser with the frontend IR.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": true + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xmetadata-klib", + "shortName": null, + "description": "Produce a klib that only contains the metadata of declarations.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xdisable-default-scripting-plugin", + "shortName": null, + "description": "Don't enable the scripting plugin by default.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xexplicit-api", + "shortName": null, + "description": "Force the compiler to report errors on all public API declarations without an explicit visibility or a return type.\nUse the 'warning' level to issue warnings instead of errors.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": "disable" + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "XXexplicit-return-types", + "shortName": null, + "description": "Force the compiler to report errors on all public API declarations without an explicit return type.\nUse the 'warning' level to issue warnings instead of errors.\nThis flag partially enables functionality of `-Xexplicit-api` flag, so please don't use them altogether", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": "disable" + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xreturn-value-checker", + "shortName": null, + "description": "Set improved unused return value checker mode. Use 'check' to run checker only and use 'full' to also enable automatic annotation insertion.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": "disable" + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xsuppress-version-warnings", + "shortName": null, + "description": "Suppress warnings about outdated, inconsistent, or experimental language or API versions.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xsuppress-api-version-greater-than-language-version-error", + "shortName": null, + "description": "Suppress error about API version greater than language version.\nWarning: This is temporary solution (see KT-63712) intended to be used only for stdlib build.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xexpect-actual-classes", + "shortName": null, + "description": "'expect'/'actual' classes (including interfaces, objects, annotations, enums, and 'actual' typealiases) are in Beta.\nKotlin reports a warning every time you use one of them. You can use this flag to mute the warning.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xconsistent-data-class-copy-visibility", + "shortName": null, + "description": "The effect of this compiler flag is the same as applying @ConsistentCopyVisibility annotation to all data classes in the module. See https://youtrack.jetbrains.com/issue/KT-11914", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xunrestricted-builder-inference", + "shortName": null, + "description": "Eliminate builder inference restrictions, for example by allowing type variables to be returned from builder inference calls.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xcontext-receivers", + "shortName": null, + "description": "Enable experimental context receivers.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xcontext-parameters", + "shortName": null, + "description": "Enable experimental context parameters.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xcontext-sensitive-resolution", + "shortName": null, + "description": "Enable experimental context-sensitive resolution.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xnon-local-break-continue", + "shortName": null, + "description": "Enable experimental non-local break and continue.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xdata-flow-based-exhaustiveness", + "shortName": null, + "description": "Enable `when` exhaustiveness improvements that rely on data-flow analysis.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xexplicit-backing-fields", + "shortName": null, + "description": "Enable experimental language support for explicit backing fields.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xdirect-java-actualization", + "shortName": null, + "description": "Enable experimental direct Java actualization support.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xmulti-dollar-interpolation", + "shortName": null, + "description": "Enable experimental multi-dollar interpolation.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xenable-incremental-compilation", + "shortName": null, + "description": "Enable incremental compilation.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xrender-internal-diagnostic-names", + "shortName": null, + "description": "Render the internal names of warnings and errors.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xallow-any-scripts-in-source-roots", + "shortName": null, + "description": "Allow compiling scripts along with regular Kotlin sources.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xreport-all-warnings", + "shortName": null, + "description": "Report all warnings even if errors are found.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xfragments", + "shortName": null, + "description": "Declare all known fragments of a multiplatform compilation.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xfragment-sources", + "shortName": null, + "description": "Add sources to a specific fragment of a multiplatform compilation.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xfragment-refines", + "shortName": null, + "description": "Declare that refines with the dependsOn/refines relation.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xfragment-dependency", + "shortName": null, + "description": "Declare common klib dependencies for the specific fragment.\nThis argument is required for any HMPP module except the platform leaf module: it takes dependencies from -cp/-libraries.\nThe argument should be used only if the new compilation scheme is enabled with -Xseparate-kmp-compilation\n", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xfragment-friend-dependency", + "shortName": null, + "description": "Declare common klib friend dependencies for the specific fragment.\nThis argument can be specified for any HMPP module except the platform leaf module: it takes dependencies from the platform specific friend module arguments.\nThe argument should be used only if the new compilation scheme is enabled with -Xseparate-kmp-compilation\n", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xseparate-kmp-compilation", + "shortName": null, + "description": "Enables the separated compilation scheme, in which common source sets are analyzed against their own dependencies", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xignore-const-optimization-errors", + "shortName": null, + "description": "Ignore all compilation exceptions while optimizing some constant expressions.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xdont-warn-on-error-suppression", + "shortName": null, + "description": "Don't report warnings when errors are suppressed. This only affects K2.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xwhen-guards", + "shortName": null, + "description": "Enable experimental language support for when guards.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xnested-type-aliases", + "shortName": null, + "description": "Enable experimental language support for nested type aliases.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xsuppress-warning", + "shortName": null, + "description": "Suppress specified warning module-wide. This option is deprecated in favor of \"-Xwarning-level\" flag", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xwarning-level", + "shortName": null, + "description": "Set the severity of the given warning.\n- `error` level raises the severity of a warning to error level (similar to -Werror but more granular)\n- `disabled` level suppresses reporting of a warning (similar to -nowarn but more granular)\n- `warning` level overrides -nowarn and -Werror for this specific warning (the warning will be reported/won't be considered as an error)", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xannotation-default-target", + "shortName": null, + "description": "Change the default annotation targets for constructor properties:\n-Xannotation-default-target=first-only: use the first of the following allowed targets: '@param:', '@property:', '@field:';\n-Xannotation-default-target=first-only-warn: same as first-only, and raise warnings when both '@param:' and either '@property:' or '@field:' are allowed;\n-Xannotation-default-target=param-property: use '@param:' target if applicable, and also use the first of either '@property:' or '@field:';\ndefault: 'first-only-warn' in language version 2.2+, 'first-only' in version 2.1 and before.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "XXdebug-level-compiler-checks", + "shortName": null, + "description": "Enable debug level compiler checks. ATTENTION: these checks can slow compiler down or even crash it.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xannotation-target-all", + "shortName": null, + "description": "Enable experimental language support for @all: annotation use-site target.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "XXlenient-mode", + "shortName": null, + "description": "Lenient compiler mode. When actuals are missing, placeholder declarations are generated.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xallow-reified-type-in-catch", + "shortName": null, + "description": "Allow 'catch' parameters to have reified types.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xallow-contracts-on-more-functions", + "shortName": null, + "description": "Allow contracts on some operators and accessors, and allow checks for erased types.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xallow-condition-implies-returns-contracts", + "shortName": null, + "description": "Allow contracts that specify a limited conditional returns postcondition.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xallow-holdsin-contract", + "shortName": null, + "description": "Allow contracts that specify a condition that holds true inside a lambda argument.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xname-based-destructuring", + "shortName": null, + "description": "Enables the following destructuring features:\n-Xname-based-destructuring=only-syntax: Enables syntax for positional destructuring with square brackets and the full form of name-based destructuring with parentheses;\n-Xname-based-destructuring=name-mismatch: Reports warnings when short form positional destructuring of data classes uses names that don't match the property names;\n-Xname-based-destructuring=complete: Enables short-form name-based destructuring with parentheses;", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "XXLanguage", + "shortName": null, + "description": "Enables/disables specified language feature.\nWarning: this flag is not intended for production use. If you want to configure the language behaviour use the\n-language-version or corresponding experimental feature flags.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xklib-relative-path-base", + "shortName": null, + "description": "Provide a base path to compute the source's relative paths in klib (default is empty).", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xklib-normalize-absolute-path", + "shortName": null, + "description": "Normalize absolute paths in klibs.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xklib-enable-signature-clash-checks", + "shortName": null, + "description": "Enable signature uniqueness checks.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": true + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xpartial-linkage", + "shortName": null, + "description": "Use partial linkage mode.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xpartial-linkage-loglevel", + "shortName": null, + "description": "Define the compile-time log level for partial linkage.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xklib-duplicated-unique-name-strategy", + "shortName": null, + "description": "Klib dependencies usage strategy when multiple KLIBs has same `unique_name` property value.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xklib-ir-inliner", + "shortName": null, + "description": "Set the mode of the experimental IR inliner on the first compilation stage.\n- `intra-module` mode enforces inlining of the functions only from the compiled module\n- `full` mode enforces inlining of all functions (from the compiled module and from all dependencies)\n Warning: This mode will trigger setting the `pre-release` flag for the compiled library.\n- `disabled` mode completely disables the IR inliner\n- `default` mode lets the IR inliner run in `intra-module`, `full` or `disabled` mode based on the current language version\n ", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": "default" + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xklib-abi-version", + "shortName": null, + "description": "Specify the custom ABI version to be written in KLIB. This option is intended only for tests.\nWarning: This option does not affect KLIB ABI. Neither allows it making a KLIB backward-compatible with older ABI versions.\nThe only observable effect is that a custom ABI version is written to KLIB manifest file.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xklib-zip-file-accessor-cache-limit", + "shortName": null, + "description": "Maximum number of klibs that can be cached during compilation. Default is 64.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": "64" + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xwasm", + "shortName": null, + "description": "Use the WebAssembly compiler backend.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xwasm-target", + "shortName": null, + "description": "Set up the Wasm target (wasm-js or wasm-wasi).", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xwasm-debug-info", + "shortName": null, + "description": "Add debug info to the compiled WebAssembly module.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": true + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xwasm-debug-friendly", + "shortName": null, + "description": "Avoid optimizations that can break debugging.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xwasm-generate-wat", + "shortName": null, + "description": "Generate a .wat file.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xwasm-kclass-fqn", + "shortName": null, + "description": "Enable support for 'KClass.qualifiedName'.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": true + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xwasm-enable-array-range-checks", + "shortName": null, + "description": "Turn on range checks for array access functions.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xwasm-enable-asserts", + "shortName": null, + "description": "Turn on asserts.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xwasm-use-traps-instead-of-exceptions", + "shortName": null, + "description": "Use traps instead of throwing exceptions.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xwasm-use-new-exception-proposal", + "shortName": null, + "description": "Use an updated version of the exception proposal with try_table.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xwasm-no-jstag", + "shortName": null, + "description": "Don't use WebAssembly.JSTag for throwing and catching exceptions", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xwasm-debugger-custom-formatters", + "shortName": null, + "description": "Generates devtools custom formatters (https://firefox-source-docs.mozilla.org/devtools-user/custom_formatters) for Kotlin/Wasm values", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xwasm-source-map-include-mappings-from-unavailable-sources", + "shortName": null, + "description": "Insert source mappings from libraries even if their sources are unavailable on the end-user machine.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xwasm-preserve-ic-order", + "shortName": null, + "description": "Preserve wasm file structure between IC runs.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xwasm-ic-cache-readonly", + "shortName": null, + "description": "Do not commit IC cache updates.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xwasm-generate-dwarf", + "shortName": null, + "description": "Generate DWARF debug information.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xir-dce-dump-reachability-info-to-file", + "shortName": null, + "description": "Dump reachability information collected about declarations while performing DCE to a file. The format will be chosen automatically based on the file extension. Supported output formats include JSON for .json, a JS const initialized with a plain object containing information for .js, and plain text for all other file types.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xir-dump-declaration-ir-sizes-to-file", + "shortName": null, + "description": "Dump the IR size of each declaration into a file. The format will be chosen automatically depending on the file extension. Supported output formats include JSON for .json, a JS const initialized with a plain object containing information for .js, and plain text for all other file types.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "ir-output-dir", + "shortName": null, + "description": "Destination for generated files.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "ir-output-name", + "shortName": null, + "description": "Base name of generated files.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "libraries", + "shortName": null, + "description": "Paths to Kotlin libraries with .meta.js and .kjsm files, separated by the system path separator.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": "animation-core-wasm-js-1.7.0.klib:animation-graphics-wasm-js-1.7.0.klib:animation-wasm-js-1.7.0.klib:annotation-wasm-js-1.7.0.klib:atomicfu-wasm-js-0.23.2.klib:collection-wasm-js-1.7.0.klib:foundation-layout-wasm-js-1.7.0.klib:foundation-wasm-js-1.7.0.klib:kotlin-stdlib-wasm-js-{{KOTLIN_VERSION_PLACEHOLDER}}.klib:kotlinx-browser-wasm-js-0.1-javadoc.klib:kotlinx-coroutines-core-wasm-js-1.8.0.klib:kotlinx-datetime-wasm-js-0.6.0.klib:kotlinx-serialization-core-wasm-js-1.6.2.klib:library-wasm-js-1.7.0.klib:lifecycle-common-wasm-js-2.8.3.klib:lifecycle-runtime-compose-wasm-js-2.8.3.klib:lifecycle-runtime-wasm-js-2.8.3.klib:lifecycle-viewmodel-wasm-js-2.8.3.klib:material-icons-core-wasm-js-1.7.0.klib:material-ripple-wasm-js-1.7.0.klib:material-wasm-js-1.7.0.klib:material3-wasm-js-1.7.0.klib:runtime-saveable-wasm-js-1.7.0.klib:runtime-wasm-js-1.7.0.klib:skiko-wasm-js-0.8.15.klib:ui-geometry-wasm-js-1.7.0.klib:ui-graphics-wasm-js-1.7.0.klib:ui-text-wasm-js-1.7.0.klib:ui-unit-wasm-js-1.7.0.klib:ui-util-wasm-js-1.7.0.klib:ui-wasm-js-1.7.0.klib" + }, + { + "name": "source-map", + "shortName": null, + "description": "Generate a source map.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "source-map-prefix", + "shortName": null, + "description": "Add the specified prefix to the paths in the source map.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "source-map-base-dirs", + "shortName": null, + "description": "Base directories for calculating relative paths to source files in the source map.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "source-map-embed-sources", + "shortName": null, + "description": "Embed source files into the source map.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "source-map-names-policy", + "shortName": null, + "description": "Mode for mapping generated names to original names.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "target", + "shortName": null, + "description": "Generate JS files for the specified ECMA version.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xir-keep", + "shortName": null, + "description": "Comma-separated list of fully qualified names not to be eliminated by DCE (if it can be reached), and for which to keep non-minified names.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "module-kind", + "shortName": null, + "description": "The kind of JS module generated by the compiler. ES modules are enabled by default in case of ES2015 target usage", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "main", + "shortName": null, + "description": "Specify whether the 'main' function should be called upon execution.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xir-produce-klib-dir", + "shortName": null, + "description": "Generate an unpacked klib into the parent directory of the output JS file.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xir-produce-klib-file", + "shortName": null, + "description": "Generate a packed klib into the directory specified by '-ir-output-dir'.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xir-produce-js", + "shortName": null, + "description": "Generate a JS file using the IR backend.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xir-dce", + "shortName": null, + "description": "Perform experimental dead code elimination.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xir-dce-runtime-diagnostic", + "shortName": null, + "description": "Enable runtime diagnostics instead of removing declarations when performing DCE.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xir-dce-print-reachability-info", + "shortName": null, + "description": "Print reachability information about declarations to 'stdout' while performing DCE.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xir-property-lazy-initialization", + "shortName": null, + "description": "Perform lazy initialization for properties.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": true + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xir-minimized-member-names", + "shortName": null, + "description": "Minimize the names of members.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xir-module-name", + "shortName": null, + "description": "Specify the name of the compilation module for the IR backend.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xir-safe-external-boolean", + "shortName": null, + "description": "Wrap access to external 'Boolean' properties with an explicit conversion to 'Boolean'.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xir-safe-external-boolean-diagnostic", + "shortName": null, + "description": "Enable runtime diagnostics when accessing external 'Boolean' properties.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xir-per-module", + "shortName": null, + "description": "Generate one .js file per module.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xir-per-module-output-name", + "shortName": null, + "description": "Add a custom output name to the split .js files.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xir-per-file", + "shortName": null, + "description": "Generate one .js file per source file.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xir-generate-inline-anonymous-functions", + "shortName": null, + "description": "Lambda expressions that capture values are translated into in-line anonymous JavaScript functions.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xinclude", + "shortName": null, + "description": "Path to an intermediate library that should be processed in the same manner as source files.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xcache-directory", + "shortName": null, + "description": "Path to the cache directory.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xir-build-cache", + "shortName": null, + "description": "Use the compiler to build the cache.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xgenerate-dts", + "shortName": null, + "description": "Generate a TypeScript declaration .d.ts file alongside the JS file.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xgenerate-polyfills", + "shortName": null, + "description": "Generate polyfills for features from the ES6+ standards.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": true + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xstrict-implicit-export-types", + "shortName": null, + "description": "Generate strict types for implicitly exported entities inside d.ts files.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xes-classes", + "shortName": null, + "description": "Let generated JavaScript code use ES2015 classes. Enabled by default in case of ES2015 target usage", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xplatform-arguments-in-main-function", + "shortName": null, + "description": "JS expression that will be executed in runtime and be put as an Array parameter of the main function", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xes-generators", + "shortName": null, + "description": "Enable ES2015 generator functions usage inside the compiled code. Enabled by default in case of ES2015 target usage", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xes-arrow-functions", + "shortName": null, + "description": "Use ES2015 arrow functions in the JavaScript code generated for Kotlin lambdas. Enabled by default in case of ES2015 target usage", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xes-long-as-bigint", + "shortName": null, + "description": "Compile Long values as ES2020 bigint instead of object.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xtyped-arrays", + "shortName": null, + "description": "This option does nothing and is left for compatibility with the legacy backend.\nIt is deprecated and will be removed in a future release.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xfriend-modules-disabled", + "shortName": null, + "description": "Disable internal declaration export.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xfriend-modules", + "shortName": null, + "description": "Paths to friend modules.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xenable-extension-functions-in-externals", + "shortName": null, + "description": "Enable extension function members in external interfaces.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xfake-override-validator", + "shortName": null, + "description": "Enable the IR fake override validator.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xoptimize-generated-js", + "shortName": null, + "description": "Perform additional optimizations on the generated JS code.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": true + }, + "disabled": false, + "predefinedValues": null + } + ] +} \ No newline at end of file diff --git a/src/test/resources/compiler-arguments/js-expected-compiler-args.json b/src/test/resources/compiler-arguments/js-expected-compiler-args.json new file mode 100644 index 000000000..73d87cf67 --- /dev/null +++ b/src/test/resources/compiler-arguments/js-expected-compiler-args.json @@ -0,0 +1,2020 @@ +{ + "compilerArguments": [ + { + "name": "help", + "shortName": "h", + "description": "Print a synopsis of standard options.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "X", + "shortName": null, + "description": "Print a synopsis of advanced options.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "version", + "shortName": null, + "description": "Display the compiler version.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "verbose", + "shortName": null, + "description": "Enable verbose logging output.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "nowarn", + "shortName": null, + "description": "Don't generate any warnings.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Werror", + "shortName": null, + "description": "Report an error if there are any warnings.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Wextra", + "shortName": null, + "description": "Enable extra checkers for K2.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "language-version", + "shortName": null, + "description": "Provide source compatibility with the specified version of Kotlin.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "api-version", + "shortName": null, + "description": "Allow using declarations from only the specified version of bundled libraries.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "kotlin-home", + "shortName": null, + "description": "Path to the Kotlin compiler home directory used for the discovery of runtime libraries.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "progressive", + "shortName": null, + "description": "Enable progressive compiler mode.\nIn this mode, deprecations and bug fixes for unstable code take effect immediately\ninstead of going through a graceful migration cycle.\nCode written in progressive mode is backward compatible; however, code written without\nprogressive mode enabled may cause compilation errors in progressive mode.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "script", + "shortName": null, + "description": "Evaluate the given Kotlin script (*.kts) file.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xrepl", + "shortName": null, + "description": "Run Kotlin REPL (deprecated)", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "opt-in", + "shortName": null, + "description": "Enable API usages that require opt-in with an opt-in requirement marker with the given fully qualified name.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xno-inline", + "shortName": null, + "description": "Disable method inlining.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xskip-metadata-version-check", + "shortName": null, + "description": "Allow loading classes with bad metadata versions and pre-release classes.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xskip-prerelease-check", + "shortName": null, + "description": "Allow loading pre-release classes.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xallow-kotlin-package", + "shortName": null, + "description": "Allow compiling code in the 'kotlin' package, and allow not requiring 'kotlin.stdlib' in 'module-info'.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xstdlib-compilation", + "shortName": null, + "description": "Enables special features which are relevant only for stdlib compilation.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xreport-output-files", + "shortName": null, + "description": "Report the source-to-output file mapping.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xplugin", + "shortName": null, + "description": "Load plugins from the given classpath.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "P", + "shortName": null, + "description": "Pass an option to a plugin.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xcompiler-plugin", + "shortName": null, + "description": "Register a compiler plugin.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xcompiler-plugin-order", + "shortName": null, + "description": "Specify an execution order constraint for compiler plugins.\nOrder constraint can be specified using the 'pluginId' of compiler plugins.\nThe first specified plugin will be executed before the second plugin.\nMultiple constraints can be specified by repeating this option. Cycles in constraints will cause an error.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xmulti-platform", + "shortName": null, + "description": "Enable language support for multiplatform projects.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xno-check-actual", + "shortName": null, + "description": "Do not check for the presence of the 'actual' modifier in multiplatform projects.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xintellij-plugin-root", + "shortName": null, + "description": "Path to 'kotlin-compiler.jar' or the directory where the IntelliJ IDEA configuration files can be found.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xnew-inference", + "shortName": null, + "description": "Enable the new experimental generic type inference algorithm.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xinline-classes", + "shortName": null, + "description": "Enable experimental inline classes.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xreport-perf", + "shortName": null, + "description": "Report detailed performance statistics.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xdetailed-perf", + "shortName": null, + "description": "Enable more detailed performance statistics (Experimental).\nFor Native, the performance report includes execution time and lines processed per second for every individual lowering.\nFor WASM and JS, the performance report includes execution time and lines per second for each lowering of the first stage of compilation.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xdump-perf", + "shortName": null, + "description": "Dump detailed performance statistics to the specified file in plain text, JSON or markdown format (it's detected by the file's extension).\nAlso, it supports the placeholder `*` and directory for generating file names based on the module being compiled and the current time stamp.\nExample: `path/to/dir/*.log` creates logs like `path/to/dir/my-module_2025-06-20-12-22-32.log` in plain text format, `path/to/dir/` creates logs like `path/to/dir/my-log_2025-06-20-12-22-32.json`.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "XXdump-model", + "shortName": null, + "description": "Dump compilation model to specified directory for use in modularized tests.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xmetadata-version", + "shortName": null, + "description": "Change the metadata version of the generated binary files.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xcommon-sources", + "shortName": null, + "description": "Sources of the common module that need to be compiled together with this module in multiplatform mode.\nThey should be a subset of sources passed as free arguments.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xlist-phases", + "shortName": null, + "description": "List backend phases.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xdisable-phases", + "shortName": null, + "description": "Disable backend phases.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xverbose-phases", + "shortName": null, + "description": "Be verbose while performing the given backend phases.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xphases-to-dump-before", + "shortName": null, + "description": "Dump the backend's state before these phases.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xphases-to-dump-after", + "shortName": null, + "description": "Dump the backend's state after these phases.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xphases-to-dump", + "shortName": null, + "description": "Dump the backend's state both before and after these phases.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xdump-directory", + "shortName": null, + "description": "Dump the backend state into this directory.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xdump-fqname", + "shortName": null, + "description": "Dump the declaration with the given FqName.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xphases-to-validate-before", + "shortName": null, + "description": "Validate the backend's state before these phases.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xphases-to-validate-after", + "shortName": null, + "description": "Validate the backend's state after these phases.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xphases-to-validate", + "shortName": null, + "description": "Validate the backend's state both before and after these phases.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xverify-ir", + "shortName": null, + "description": "IR verification mode (no verification by default).", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xverify-ir-visibility", + "shortName": null, + "description": "Check for visibility violations in IR when validating it before running any lowerings. Only has effect if '-Xverify-ir' is not 'none'.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xprofile-phases", + "shortName": null, + "description": "Profile backend phases.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xcheck-phase-conditions", + "shortName": null, + "description": "Check pre- and postconditions of IR lowering phases.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xuse-fir-experimental-checkers", + "shortName": null, + "description": "Enable experimental frontend IR checkers that are not yet ready for production.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xuse-fir-ic", + "shortName": null, + "description": "Compile using frontend IR internal incremental compilation.\nWarning: This feature is not yet production-ready.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xuse-fir-lt", + "shortName": null, + "description": "Compile using the LightTree parser with the frontend IR.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": true + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xmetadata-klib", + "shortName": null, + "description": "Produce a klib that only contains the metadata of declarations.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xdisable-default-scripting-plugin", + "shortName": null, + "description": "Don't enable the scripting plugin by default.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xexplicit-api", + "shortName": null, + "description": "Force the compiler to report errors on all public API declarations without an explicit visibility or a return type.\nUse the 'warning' level to issue warnings instead of errors.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": "disable" + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "XXexplicit-return-types", + "shortName": null, + "description": "Force the compiler to report errors on all public API declarations without an explicit return type.\nUse the 'warning' level to issue warnings instead of errors.\nThis flag partially enables functionality of `-Xexplicit-api` flag, so please don't use them altogether", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": "disable" + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xreturn-value-checker", + "shortName": null, + "description": "Set improved unused return value checker mode. Use 'check' to run checker only and use 'full' to also enable automatic annotation insertion.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": "disable" + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xsuppress-version-warnings", + "shortName": null, + "description": "Suppress warnings about outdated, inconsistent, or experimental language or API versions.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xsuppress-api-version-greater-than-language-version-error", + "shortName": null, + "description": "Suppress error about API version greater than language version.\nWarning: This is temporary solution (see KT-63712) intended to be used only for stdlib build.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xexpect-actual-classes", + "shortName": null, + "description": "'expect'/'actual' classes (including interfaces, objects, annotations, enums, and 'actual' typealiases) are in Beta.\nKotlin reports a warning every time you use one of them. You can use this flag to mute the warning.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xconsistent-data-class-copy-visibility", + "shortName": null, + "description": "The effect of this compiler flag is the same as applying @ConsistentCopyVisibility annotation to all data classes in the module. See https://youtrack.jetbrains.com/issue/KT-11914", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xunrestricted-builder-inference", + "shortName": null, + "description": "Eliminate builder inference restrictions, for example by allowing type variables to be returned from builder inference calls.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xcontext-receivers", + "shortName": null, + "description": "Enable experimental context receivers.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xcontext-parameters", + "shortName": null, + "description": "Enable experimental context parameters.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xcontext-sensitive-resolution", + "shortName": null, + "description": "Enable experimental context-sensitive resolution.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xnon-local-break-continue", + "shortName": null, + "description": "Enable experimental non-local break and continue.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xdata-flow-based-exhaustiveness", + "shortName": null, + "description": "Enable `when` exhaustiveness improvements that rely on data-flow analysis.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xexplicit-backing-fields", + "shortName": null, + "description": "Enable experimental language support for explicit backing fields.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xdirect-java-actualization", + "shortName": null, + "description": "Enable experimental direct Java actualization support.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xmulti-dollar-interpolation", + "shortName": null, + "description": "Enable experimental multi-dollar interpolation.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xenable-incremental-compilation", + "shortName": null, + "description": "Enable incremental compilation.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xrender-internal-diagnostic-names", + "shortName": null, + "description": "Render the internal names of warnings and errors.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xallow-any-scripts-in-source-roots", + "shortName": null, + "description": "Allow compiling scripts along with regular Kotlin sources.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xreport-all-warnings", + "shortName": null, + "description": "Report all warnings even if errors are found.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xfragments", + "shortName": null, + "description": "Declare all known fragments of a multiplatform compilation.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xfragment-sources", + "shortName": null, + "description": "Add sources to a specific fragment of a multiplatform compilation.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xfragment-refines", + "shortName": null, + "description": "Declare that refines with the dependsOn/refines relation.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xfragment-dependency", + "shortName": null, + "description": "Declare common klib dependencies for the specific fragment.\nThis argument is required for any HMPP module except the platform leaf module: it takes dependencies from -cp/-libraries.\nThe argument should be used only if the new compilation scheme is enabled with -Xseparate-kmp-compilation\n", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xfragment-friend-dependency", + "shortName": null, + "description": "Declare common klib friend dependencies for the specific fragment.\nThis argument can be specified for any HMPP module except the platform leaf module: it takes dependencies from the platform specific friend module arguments.\nThe argument should be used only if the new compilation scheme is enabled with -Xseparate-kmp-compilation\n", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xseparate-kmp-compilation", + "shortName": null, + "description": "Enables the separated compilation scheme, in which common source sets are analyzed against their own dependencies", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xignore-const-optimization-errors", + "shortName": null, + "description": "Ignore all compilation exceptions while optimizing some constant expressions.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xdont-warn-on-error-suppression", + "shortName": null, + "description": "Don't report warnings when errors are suppressed. This only affects K2.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xwhen-guards", + "shortName": null, + "description": "Enable experimental language support for when guards.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xnested-type-aliases", + "shortName": null, + "description": "Enable experimental language support for nested type aliases.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xsuppress-warning", + "shortName": null, + "description": "Suppress specified warning module-wide. This option is deprecated in favor of \"-Xwarning-level\" flag", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xwarning-level", + "shortName": null, + "description": "Set the severity of the given warning.\n- `error` level raises the severity of a warning to error level (similar to -Werror but more granular)\n- `disabled` level suppresses reporting of a warning (similar to -nowarn but more granular)\n- `warning` level overrides -nowarn and -Werror for this specific warning (the warning will be reported/won't be considered as an error)", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xannotation-default-target", + "shortName": null, + "description": "Change the default annotation targets for constructor properties:\n-Xannotation-default-target=first-only: use the first of the following allowed targets: '@param:', '@property:', '@field:';\n-Xannotation-default-target=first-only-warn: same as first-only, and raise warnings when both '@param:' and either '@property:' or '@field:' are allowed;\n-Xannotation-default-target=param-property: use '@param:' target if applicable, and also use the first of either '@property:' or '@field:';\ndefault: 'first-only-warn' in language version 2.2+, 'first-only' in version 2.1 and before.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "XXdebug-level-compiler-checks", + "shortName": null, + "description": "Enable debug level compiler checks. ATTENTION: these checks can slow compiler down or even crash it.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xannotation-target-all", + "shortName": null, + "description": "Enable experimental language support for @all: annotation use-site target.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "XXlenient-mode", + "shortName": null, + "description": "Lenient compiler mode. When actuals are missing, placeholder declarations are generated.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xallow-reified-type-in-catch", + "shortName": null, + "description": "Allow 'catch' parameters to have reified types.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xallow-contracts-on-more-functions", + "shortName": null, + "description": "Allow contracts on some operators and accessors, and allow checks for erased types.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xallow-condition-implies-returns-contracts", + "shortName": null, + "description": "Allow contracts that specify a limited conditional returns postcondition.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xallow-holdsin-contract", + "shortName": null, + "description": "Allow contracts that specify a condition that holds true inside a lambda argument.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xname-based-destructuring", + "shortName": null, + "description": "Enables the following destructuring features:\n-Xname-based-destructuring=only-syntax: Enables syntax for positional destructuring with square brackets and the full form of name-based destructuring with parentheses;\n-Xname-based-destructuring=name-mismatch: Reports warnings when short form positional destructuring of data classes uses names that don't match the property names;\n-Xname-based-destructuring=complete: Enables short-form name-based destructuring with parentheses;", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "XXLanguage", + "shortName": null, + "description": "Enables/disables specified language feature.\nWarning: this flag is not intended for production use. If you want to configure the language behaviour use the\n-language-version or corresponding experimental feature flags.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xklib-relative-path-base", + "shortName": null, + "description": "Provide a base path to compute the source's relative paths in klib (default is empty).", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xklib-normalize-absolute-path", + "shortName": null, + "description": "Normalize absolute paths in klibs.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xklib-enable-signature-clash-checks", + "shortName": null, + "description": "Enable signature uniqueness checks.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": true + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xpartial-linkage", + "shortName": null, + "description": "Use partial linkage mode.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xpartial-linkage-loglevel", + "shortName": null, + "description": "Define the compile-time log level for partial linkage.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xklib-duplicated-unique-name-strategy", + "shortName": null, + "description": "Klib dependencies usage strategy when multiple KLIBs has same `unique_name` property value.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xklib-ir-inliner", + "shortName": null, + "description": "Set the mode of the experimental IR inliner on the first compilation stage.\n- `intra-module` mode enforces inlining of the functions only from the compiled module\n- `full` mode enforces inlining of all functions (from the compiled module and from all dependencies)\n Warning: This mode will trigger setting the `pre-release` flag for the compiled library.\n- `disabled` mode completely disables the IR inliner\n- `default` mode lets the IR inliner run in `intra-module`, `full` or `disabled` mode based on the current language version\n ", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": "default" + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xklib-abi-version", + "shortName": null, + "description": "Specify the custom ABI version to be written in KLIB. This option is intended only for tests.\nWarning: This option does not affect KLIB ABI. Neither allows it making a KLIB backward-compatible with older ABI versions.\nThe only observable effect is that a custom ABI version is written to KLIB manifest file.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xklib-zip-file-accessor-cache-limit", + "shortName": null, + "description": "Maximum number of klibs that can be cached during compilation. Default is 64.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": "64" + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xwasm", + "shortName": null, + "description": "Use the WebAssembly compiler backend.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xwasm-target", + "shortName": null, + "description": "Set up the Wasm target (wasm-js or wasm-wasi).", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xwasm-debug-info", + "shortName": null, + "description": "Add debug info to the compiled WebAssembly module.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": true + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xwasm-debug-friendly", + "shortName": null, + "description": "Avoid optimizations that can break debugging.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xwasm-generate-wat", + "shortName": null, + "description": "Generate a .wat file.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xwasm-kclass-fqn", + "shortName": null, + "description": "Enable support for 'KClass.qualifiedName'.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": true + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xwasm-enable-array-range-checks", + "shortName": null, + "description": "Turn on range checks for array access functions.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xwasm-enable-asserts", + "shortName": null, + "description": "Turn on asserts.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xwasm-use-traps-instead-of-exceptions", + "shortName": null, + "description": "Use traps instead of throwing exceptions.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xwasm-use-new-exception-proposal", + "shortName": null, + "description": "Use an updated version of the exception proposal with try_table.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xwasm-no-jstag", + "shortName": null, + "description": "Don't use WebAssembly.JSTag for throwing and catching exceptions", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xwasm-debugger-custom-formatters", + "shortName": null, + "description": "Generates devtools custom formatters (https://firefox-source-docs.mozilla.org/devtools-user/custom_formatters) for Kotlin/Wasm values", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xwasm-source-map-include-mappings-from-unavailable-sources", + "shortName": null, + "description": "Insert source mappings from libraries even if their sources are unavailable on the end-user machine.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xwasm-preserve-ic-order", + "shortName": null, + "description": "Preserve wasm file structure between IC runs.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xwasm-ic-cache-readonly", + "shortName": null, + "description": "Do not commit IC cache updates.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xwasm-generate-dwarf", + "shortName": null, + "description": "Generate DWARF debug information.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xir-dce-dump-reachability-info-to-file", + "shortName": null, + "description": "Dump reachability information collected about declarations while performing DCE to a file. The format will be chosen automatically based on the file extension. Supported output formats include JSON for .json, a JS const initialized with a plain object containing information for .js, and plain text for all other file types.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xir-dump-declaration-ir-sizes-to-file", + "shortName": null, + "description": "Dump the IR size of each declaration into a file. The format will be chosen automatically depending on the file extension. Supported output formats include JSON for .json, a JS const initialized with a plain object containing information for .js, and plain text for all other file types.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "ir-output-dir", + "shortName": null, + "description": "Destination for generated files.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "ir-output-name", + "shortName": null, + "description": "Base name of generated files.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "libraries", + "shortName": null, + "description": "Paths to Kotlin libraries with .meta.js and .kjsm files, separated by the system path separator.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": "kotlin-dom-api-compat-{{KOTLIN_VERSION_PLACEHOLDER}}.klib:kotlin-stdlib-js-{{KOTLIN_VERSION_PLACEHOLDER}}.klib" + }, + { + "name": "source-map", + "shortName": null, + "description": "Generate a source map.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "source-map-prefix", + "shortName": null, + "description": "Add the specified prefix to the paths in the source map.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "source-map-base-dirs", + "shortName": null, + "description": "Base directories for calculating relative paths to source files in the source map.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "source-map-embed-sources", + "shortName": null, + "description": "Embed source files into the source map.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "source-map-names-policy", + "shortName": null, + "description": "Mode for mapping generated names to original names.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "target", + "shortName": null, + "description": "Generate JS files for the specified ECMA version.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xir-keep", + "shortName": null, + "description": "Comma-separated list of fully qualified names not to be eliminated by DCE (if it can be reached), and for which to keep non-minified names.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "module-kind", + "shortName": null, + "description": "The kind of JS module generated by the compiler. ES modules are enabled by default in case of ES2015 target usage", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "main", + "shortName": null, + "description": "Specify whether the 'main' function should be called upon execution.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xir-produce-klib-dir", + "shortName": null, + "description": "Generate an unpacked klib into the parent directory of the output JS file.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xir-produce-klib-file", + "shortName": null, + "description": "Generate a packed klib into the directory specified by '-ir-output-dir'.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xir-produce-js", + "shortName": null, + "description": "Generate a JS file using the IR backend.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xir-dce", + "shortName": null, + "description": "Perform experimental dead code elimination.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xir-dce-runtime-diagnostic", + "shortName": null, + "description": "Enable runtime diagnostics instead of removing declarations when performing DCE.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xir-dce-print-reachability-info", + "shortName": null, + "description": "Print reachability information about declarations to 'stdout' while performing DCE.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xir-property-lazy-initialization", + "shortName": null, + "description": "Perform lazy initialization for properties.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": true + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xir-minimized-member-names", + "shortName": null, + "description": "Minimize the names of members.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xir-module-name", + "shortName": null, + "description": "Specify the name of the compilation module for the IR backend.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xir-safe-external-boolean", + "shortName": null, + "description": "Wrap access to external 'Boolean' properties with an explicit conversion to 'Boolean'.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xir-safe-external-boolean-diagnostic", + "shortName": null, + "description": "Enable runtime diagnostics when accessing external 'Boolean' properties.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xir-per-module", + "shortName": null, + "description": "Generate one .js file per module.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xir-per-module-output-name", + "shortName": null, + "description": "Add a custom output name to the split .js files.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xir-per-file", + "shortName": null, + "description": "Generate one .js file per source file.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xir-generate-inline-anonymous-functions", + "shortName": null, + "description": "Lambda expressions that capture values are translated into in-line anonymous JavaScript functions.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xinclude", + "shortName": null, + "description": "Path to an intermediate library that should be processed in the same manner as source files.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xcache-directory", + "shortName": null, + "description": "Path to the cache directory.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xir-build-cache", + "shortName": null, + "description": "Use the compiler to build the cache.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xgenerate-dts", + "shortName": null, + "description": "Generate a TypeScript declaration .d.ts file alongside the JS file.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xgenerate-polyfills", + "shortName": null, + "description": "Generate polyfills for features from the ES6+ standards.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": true + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xstrict-implicit-export-types", + "shortName": null, + "description": "Generate strict types for implicitly exported entities inside d.ts files.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xes-classes", + "shortName": null, + "description": "Let generated JavaScript code use ES2015 classes. Enabled by default in case of ES2015 target usage", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xplatform-arguments-in-main-function", + "shortName": null, + "description": "JS expression that will be executed in runtime and be put as an Array parameter of the main function", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xes-generators", + "shortName": null, + "description": "Enable ES2015 generator functions usage inside the compiled code. Enabled by default in case of ES2015 target usage", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xes-arrow-functions", + "shortName": null, + "description": "Use ES2015 arrow functions in the JavaScript code generated for Kotlin lambdas. Enabled by default in case of ES2015 target usage", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xes-long-as-bigint", + "shortName": null, + "description": "Compile Long values as ES2020 bigint instead of object.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xtyped-arrays", + "shortName": null, + "description": "This option does nothing and is left for compatibility with the legacy backend.\nIt is deprecated and will be removed in a future release.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xfriend-modules-disabled", + "shortName": null, + "description": "Disable internal declaration export.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xfriend-modules", + "shortName": null, + "description": "Paths to friend modules.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xenable-extension-functions-in-externals", + "shortName": null, + "description": "Enable extension function members in external interfaces.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xfake-override-validator", + "shortName": null, + "description": "Enable the IR fake override validator.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xoptimize-generated-js", + "shortName": null, + "description": "Perform additional optimizations on the generated JS code.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": true + }, + "disabled": false, + "predefinedValues": null + } + ] +} \ No newline at end of file diff --git a/src/test/resources/compiler-arguments/jvm-expected-compiler-args.json b/src/test/resources/compiler-arguments/jvm-expected-compiler-args.json new file mode 100644 index 000000000..86620d64f --- /dev/null +++ b/src/test/resources/compiler-arguments/jvm-expected-compiler-args.json @@ -0,0 +1,2116 @@ +{ + "compilerArguments": [ + { + "name": "help", + "shortName": "h", + "description": "Print a synopsis of standard options.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "X", + "shortName": null, + "description": "Print a synopsis of advanced options.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "version", + "shortName": null, + "description": "Display the compiler version.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "verbose", + "shortName": null, + "description": "Enable verbose logging output.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "nowarn", + "shortName": null, + "description": "Don't generate any warnings.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Werror", + "shortName": null, + "description": "Report an error if there are any warnings.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Wextra", + "shortName": null, + "description": "Enable extra checkers for K2.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "language-version", + "shortName": null, + "description": "Provide source compatibility with the specified version of Kotlin.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "api-version", + "shortName": null, + "description": "Allow using declarations from only the specified version of bundled libraries.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "kotlin-home", + "shortName": null, + "description": "Path to the Kotlin compiler home directory used for the discovery of runtime libraries.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "progressive", + "shortName": null, + "description": "Enable progressive compiler mode.\nIn this mode, deprecations and bug fixes for unstable code take effect immediately\ninstead of going through a graceful migration cycle.\nCode written in progressive mode is backward compatible; however, code written without\nprogressive mode enabled may cause compilation errors in progressive mode.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "script", + "shortName": null, + "description": "Evaluate the given Kotlin script (*.kts) file.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xrepl", + "shortName": null, + "description": "Run Kotlin REPL (deprecated)", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "opt-in", + "shortName": null, + "description": "Enable API usages that require opt-in with an opt-in requirement marker with the given fully qualified name.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": false, + "predefinedValues": [ + "kotlin.ExperimentalStdlibApi", + "kotlin.time.ExperimentalTime", + "kotlin.RequiresOptIn", + "kotlin.ExperimentalUnsignedTypes", + "kotlin.contracts.ExperimentalContracts", + "kotlin.experimental.ExperimentalTypeInference", + "kotlin.uuid.ExperimentalUuidApi", + "kotlin.io.encoding.ExperimentalEncodingApi", + "kotlin.concurrent.atomics.ExperimentalAtomicApi" + ] + }, + { + "name": "Xno-inline", + "shortName": null, + "description": "Disable method inlining.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xskip-metadata-version-check", + "shortName": null, + "description": "Allow loading classes with bad metadata versions and pre-release classes.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xskip-prerelease-check", + "shortName": null, + "description": "Allow loading pre-release classes.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xallow-kotlin-package", + "shortName": null, + "description": "Allow compiling code in the 'kotlin' package, and allow not requiring 'kotlin.stdlib' in 'module-info'.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xstdlib-compilation", + "shortName": null, + "description": "Enables special features which are relevant only for stdlib compilation.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xreport-output-files", + "shortName": null, + "description": "Report the source-to-output file mapping.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xplugin", + "shortName": null, + "description": "Load plugins from the given classpath.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": [ + {{PLUGIN_PLACEHOLDER}} + ] + }, + { + "name": "P", + "shortName": null, + "description": "Pass an option to a plugin.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xcompiler-plugin", + "shortName": null, + "description": "Register a compiler plugin.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xcompiler-plugin-order", + "shortName": null, + "description": "Specify an execution order constraint for compiler plugins.\nOrder constraint can be specified using the 'pluginId' of compiler plugins.\nThe first specified plugin will be executed before the second plugin.\nMultiple constraints can be specified by repeating this option. Cycles in constraints will cause an error.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xmulti-platform", + "shortName": null, + "description": "Enable language support for multiplatform projects.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xno-check-actual", + "shortName": null, + "description": "Do not check for the presence of the 'actual' modifier in multiplatform projects.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xintellij-plugin-root", + "shortName": null, + "description": "Path to 'kotlin-compiler.jar' or the directory where the IntelliJ IDEA configuration files can be found.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xnew-inference", + "shortName": null, + "description": "Enable the new experimental generic type inference algorithm.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xinline-classes", + "shortName": null, + "description": "Enable experimental inline classes.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xreport-perf", + "shortName": null, + "description": "Report detailed performance statistics.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xdetailed-perf", + "shortName": null, + "description": "Enable more detailed performance statistics (Experimental).\nFor Native, the performance report includes execution time and lines processed per second for every individual lowering.\nFor WASM and JS, the performance report includes execution time and lines per second for each lowering of the first stage of compilation.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xdump-perf", + "shortName": null, + "description": "Dump detailed performance statistics to the specified file in plain text, JSON or markdown format (it's detected by the file's extension).\nAlso, it supports the placeholder `*` and directory for generating file names based on the module being compiled and the current time stamp.\nExample: `path/to/dir/*.log` creates logs like `path/to/dir/my-module_2025-06-20-12-22-32.log` in plain text format, `path/to/dir/` creates logs like `path/to/dir/my-log_2025-06-20-12-22-32.json`.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "XXdump-model", + "shortName": null, + "description": "Dump compilation model to specified directory for use in modularized tests.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xmetadata-version", + "shortName": null, + "description": "Change the metadata version of the generated binary files.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xcommon-sources", + "shortName": null, + "description": "Sources of the common module that need to be compiled together with this module in multiplatform mode.\nThey should be a subset of sources passed as free arguments.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xlist-phases", + "shortName": null, + "description": "List backend phases.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xdisable-phases", + "shortName": null, + "description": "Disable backend phases.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xverbose-phases", + "shortName": null, + "description": "Be verbose while performing the given backend phases.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xphases-to-dump-before", + "shortName": null, + "description": "Dump the backend's state before these phases.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xphases-to-dump-after", + "shortName": null, + "description": "Dump the backend's state after these phases.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xphases-to-dump", + "shortName": null, + "description": "Dump the backend's state both before and after these phases.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xdump-directory", + "shortName": null, + "description": "Dump the backend state into this directory.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xdump-fqname", + "shortName": null, + "description": "Dump the declaration with the given FqName.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xphases-to-validate-before", + "shortName": null, + "description": "Validate the backend's state before these phases.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xphases-to-validate-after", + "shortName": null, + "description": "Validate the backend's state after these phases.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xphases-to-validate", + "shortName": null, + "description": "Validate the backend's state both before and after these phases.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xverify-ir", + "shortName": null, + "description": "IR verification mode (no verification by default).", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xverify-ir-visibility", + "shortName": null, + "description": "Check for visibility violations in IR when validating it before running any lowerings. Only has effect if '-Xverify-ir' is not 'none'.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xprofile-phases", + "shortName": null, + "description": "Profile backend phases.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xcheck-phase-conditions", + "shortName": null, + "description": "Check pre- and postconditions of IR lowering phases.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xuse-fir-experimental-checkers", + "shortName": null, + "description": "Enable experimental frontend IR checkers that are not yet ready for production.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xuse-fir-ic", + "shortName": null, + "description": "Compile using frontend IR internal incremental compilation.\nWarning: This feature is not yet production-ready.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xuse-fir-lt", + "shortName": null, + "description": "Compile using the LightTree parser with the frontend IR.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": true + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xmetadata-klib", + "shortName": null, + "description": "Produce a klib that only contains the metadata of declarations.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xdisable-default-scripting-plugin", + "shortName": null, + "description": "Don't enable the scripting plugin by default.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xexplicit-api", + "shortName": null, + "description": "Force the compiler to report errors on all public API declarations without an explicit visibility or a return type.\nUse the 'warning' level to issue warnings instead of errors.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": "disable" + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "XXexplicit-return-types", + "shortName": null, + "description": "Force the compiler to report errors on all public API declarations without an explicit return type.\nUse the 'warning' level to issue warnings instead of errors.\nThis flag partially enables functionality of `-Xexplicit-api` flag, so please don't use them altogether", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": "disable" + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xreturn-value-checker", + "shortName": null, + "description": "Set improved unused return value checker mode. Use 'check' to run checker only and use 'full' to also enable automatic annotation insertion.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": "disable" + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xsuppress-version-warnings", + "shortName": null, + "description": "Suppress warnings about outdated, inconsistent, or experimental language or API versions.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xsuppress-api-version-greater-than-language-version-error", + "shortName": null, + "description": "Suppress error about API version greater than language version.\nWarning: This is temporary solution (see KT-63712) intended to be used only for stdlib build.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xexpect-actual-classes", + "shortName": null, + "description": "'expect'/'actual' classes (including interfaces, objects, annotations, enums, and 'actual' typealiases) are in Beta.\nKotlin reports a warning every time you use one of them. You can use this flag to mute the warning.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xconsistent-data-class-copy-visibility", + "shortName": null, + "description": "The effect of this compiler flag is the same as applying @ConsistentCopyVisibility annotation to all data classes in the module. See https://youtrack.jetbrains.com/issue/KT-11914", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xunrestricted-builder-inference", + "shortName": null, + "description": "Eliminate builder inference restrictions, for example by allowing type variables to be returned from builder inference calls.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xcontext-receivers", + "shortName": null, + "description": "Enable experimental context receivers.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xcontext-parameters", + "shortName": null, + "description": "Enable experimental context parameters.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xcontext-sensitive-resolution", + "shortName": null, + "description": "Enable experimental context-sensitive resolution.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xnon-local-break-continue", + "shortName": null, + "description": "Enable experimental non-local break and continue.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xdata-flow-based-exhaustiveness", + "shortName": null, + "description": "Enable `when` exhaustiveness improvements that rely on data-flow analysis.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xexplicit-backing-fields", + "shortName": null, + "description": "Enable experimental language support for explicit backing fields.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xdirect-java-actualization", + "shortName": null, + "description": "Enable experimental direct Java actualization support.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xmulti-dollar-interpolation", + "shortName": null, + "description": "Enable experimental multi-dollar interpolation.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xenable-incremental-compilation", + "shortName": null, + "description": "Enable incremental compilation.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xrender-internal-diagnostic-names", + "shortName": null, + "description": "Render the internal names of warnings and errors.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xallow-any-scripts-in-source-roots", + "shortName": null, + "description": "Allow compiling scripts along with regular Kotlin sources.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xreport-all-warnings", + "shortName": null, + "description": "Report all warnings even if errors are found.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xfragments", + "shortName": null, + "description": "Declare all known fragments of a multiplatform compilation.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xfragment-sources", + "shortName": null, + "description": "Add sources to a specific fragment of a multiplatform compilation.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xfragment-refines", + "shortName": null, + "description": "Declare that refines with the dependsOn/refines relation.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xfragment-dependency", + "shortName": null, + "description": "Declare common klib dependencies for the specific fragment.\nThis argument is required for any HMPP module except the platform leaf module: it takes dependencies from -cp/-libraries.\nThe argument should be used only if the new compilation scheme is enabled with -Xseparate-kmp-compilation\n", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xfragment-friend-dependency", + "shortName": null, + "description": "Declare common klib friend dependencies for the specific fragment.\nThis argument can be specified for any HMPP module except the platform leaf module: it takes dependencies from the platform specific friend module arguments.\nThe argument should be used only if the new compilation scheme is enabled with -Xseparate-kmp-compilation\n", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xseparate-kmp-compilation", + "shortName": null, + "description": "Enables the separated compilation scheme, in which common source sets are analyzed against their own dependencies", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xignore-const-optimization-errors", + "shortName": null, + "description": "Ignore all compilation exceptions while optimizing some constant expressions.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xdont-warn-on-error-suppression", + "shortName": null, + "description": "Don't report warnings when errors are suppressed. This only affects K2.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xwhen-guards", + "shortName": null, + "description": "Enable experimental language support for when guards.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xnested-type-aliases", + "shortName": null, + "description": "Enable experimental language support for nested type aliases.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xsuppress-warning", + "shortName": null, + "description": "Suppress specified warning module-wide. This option is deprecated in favor of \"-Xwarning-level\" flag", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xwarning-level", + "shortName": null, + "description": "Set the severity of the given warning.\n- `error` level raises the severity of a warning to error level (similar to -Werror but more granular)\n- `disabled` level suppresses reporting of a warning (similar to -nowarn but more granular)\n- `warning` level overrides -nowarn and -Werror for this specific warning (the warning will be reported/won't be considered as an error)", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xannotation-default-target", + "shortName": null, + "description": "Change the default annotation targets for constructor properties:\n-Xannotation-default-target=first-only: use the first of the following allowed targets: '@param:', '@property:', '@field:';\n-Xannotation-default-target=first-only-warn: same as first-only, and raise warnings when both '@param:' and either '@property:' or '@field:' are allowed;\n-Xannotation-default-target=param-property: use '@param:' target if applicable, and also use the first of either '@property:' or '@field:';\ndefault: 'first-only-warn' in language version 2.2+, 'first-only' in version 2.1 and before.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "XXdebug-level-compiler-checks", + "shortName": null, + "description": "Enable debug level compiler checks. ATTENTION: these checks can slow compiler down or even crash it.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xannotation-target-all", + "shortName": null, + "description": "Enable experimental language support for @all: annotation use-site target.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "XXlenient-mode", + "shortName": null, + "description": "Lenient compiler mode. When actuals are missing, placeholder declarations are generated.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xallow-reified-type-in-catch", + "shortName": null, + "description": "Allow 'catch' parameters to have reified types.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xallow-contracts-on-more-functions", + "shortName": null, + "description": "Allow contracts on some operators and accessors, and allow checks for erased types.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xallow-condition-implies-returns-contracts", + "shortName": null, + "description": "Allow contracts that specify a limited conditional returns postcondition.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xallow-holdsin-contract", + "shortName": null, + "description": "Allow contracts that specify a condition that holds true inside a lambda argument.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xname-based-destructuring", + "shortName": null, + "description": "Enables the following destructuring features:\n-Xname-based-destructuring=only-syntax: Enables syntax for positional destructuring with square brackets and the full form of name-based destructuring with parentheses;\n-Xname-based-destructuring=name-mismatch: Reports warnings when short form positional destructuring of data classes uses names that don't match the property names;\n-Xname-based-destructuring=complete: Enables short-form name-based destructuring with parentheses;", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "XXLanguage", + "shortName": null, + "description": "Enables/disables specified language feature.\nWarning: this flag is not intended for production use. If you want to configure the language behaviour use the\n-language-version or corresponding experimental feature flags.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "d", + "shortName": null, + "description": "Destination for generated class files.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "classpath", + "shortName": "cp", + "description": "List of directories and JAR/ZIP archives to search for user class files.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": "{{CLASSPATH_PLACEHOLDER}}" + }, + { + "name": "include-runtime", + "shortName": null, + "description": "Include the Kotlin runtime in the resulting JAR.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "jdk-home", + "shortName": null, + "description": "Include a custom JDK from the specified location in the classpath instead of the default 'JAVA_HOME'.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "no-jdk", + "shortName": null, + "description": "Don't automatically include the Java runtime in the classpath.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "no-stdlib", + "shortName": null, + "description": "Don't automatically include the Kotlin/JVM stdlib and Kotlin reflection dependencies in the classpath.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "no-reflect", + "shortName": null, + "description": "Don't automatically include the Kotlin reflection dependency in the classpath.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "expression", + "shortName": "e", + "description": "Evaluate the given string as a Kotlin script.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "script-templates", + "shortName": null, + "description": "Script definition template classes.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "module-name", + "shortName": null, + "description": "Name of the generated '.kotlin_module' file.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "jvm-target", + "shortName": null, + "description": "The target version of the generated JVM bytecode (1.8 and 9–24), with 1.8 as the default.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "java-parameters", + "shortName": null, + "description": "Generate metadata for Java 1.8 reflection on method parameters.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "jvm-default", + "shortName": null, + "description": "Emit JVM default methods for interface declarations with bodies. The default is 'enable'.\n-jvm-default=enable Generate default methods for non-abstract interface declarations, as well as 'DefaultImpls' classes with\n static methods for compatibility with code compiled in the 'disable' mode.\n This is the default behavior since language version 2.2.\n-jvm-default=no-compatibility Generate default methods for non-abstract interface declarations. Do not generate 'DefaultImpls' classes.\n-jvm-default=disable Do not generate JVM default methods. This is the default behavior up to language version 2.1.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xallow-unstable-dependencies", + "shortName": null, + "description": "Do not report errors on classes in dependencies that were compiled by an unstable version of the Kotlin compiler.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xabi-stability", + "shortName": null, + "description": "When using unstable compiler features such as FIR, use 'stable' to mark generated class files as stable\nto prevent diagnostics from being reported when using stable compilers at the call site.\nWhen using the JVM IR backend, conversely, use 'unstable' to mark generated class files as unstable\nto force diagnostics to be reported.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xir-do-not-clear-binding-context", + "shortName": null, + "description": "When using the IR backend, do not clear BindingContext between 'psi2ir' and lowerings.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xbackend-threads", + "shortName": null, + "description": "Run codegen phase in N parallel threads.\n0 means use one thread per processor core.\nThe default value is 1.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": "1" + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xmodule-path", + "shortName": null, + "description": "Paths to Java 9+ modules.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xadd-modules", + "shortName": null, + "description": "Root modules to resolve in addition to the initial modules, or all modules on the module path if is ALL-MODULE-PATH.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xno-call-assertions", + "shortName": null, + "description": "Don't generate not-null assertions for arguments of platform types.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xno-receiver-assertions", + "shortName": null, + "description": "Don't generate not-null assertions for extension receiver arguments of platform types.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xno-param-assertions", + "shortName": null, + "description": "Don't generate not-null assertions on parameters of methods accessible from Java.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xno-optimize", + "shortName": null, + "description": "Disable optimizations.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xassertions", + "shortName": null, + "description": "'kotlin.assert' call behavior:\n-Xassertions=always-enable: enable, ignore JVM assertion settings;\n-Xassertions=always-disable: disable, ignore JVM assertion settings;\n-Xassertions=jvm: enable, depend on JVM assertion settings;\n-Xassertions=legacy: calculate the condition on each call, the behavior depends on JVM assertion settings in the kotlin package;\ndefault: legacy", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": "legacy" + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xbuild-file", + "shortName": null, + "description": "Path to the .xml build file to compile.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xmultifile-parts-inherit", + "shortName": null, + "description": "Compile multifile classes as a hierarchy of parts and a facade.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xuse-type-table", + "shortName": null, + "description": "Use a type table in metadata serialization.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xuse-old-class-files-reading", + "shortName": null, + "description": "Use the old implementation for reading class files. This may slow down the compilation and cause problems with Groovy interop.\nThis can be used in the event of problems with the new implementation.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xuse-fast-jar-file-system", + "shortName": null, + "description": "Use the fast implementation of Jar FS. This may speed up compilation time, but it is experimental.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xsuppress-missing-builtins-error", + "shortName": null, + "description": "Suppress the \"cannot access built-in declaration\" error (useful with '-no-stdlib').", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xscript-resolver-environment", + "shortName": null, + "description": "Set the script resolver environment in key-value pairs (the value can be quoted and escaped).", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xuse-javac", + "shortName": null, + "description": "Use javac for Java source and class file analysis.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xcompile-java", + "shortName": null, + "description": "Reuse 'javac' analysis and compile Java source files.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xjavac-arguments", + "shortName": null, + "description": "Java compiler arguments.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xjava-source-roots", + "shortName": null, + "description": "Paths to directories with Java source files.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xjava-package-prefix", + "shortName": null, + "description": "Package prefix for Java files.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xjsr305", + "shortName": null, + "description": "Specify the behavior of 'JSR-305' nullability annotations:\n-Xjsr305={ignore/strict/warn} global (all non-@UnderMigration annotations)\n-Xjsr305=under-migration:{ignore/strict/warn} all @UnderMigration annotations\n-Xjsr305=@:{ignore/strict/warn} annotation with the given fully qualified class name\nModes:\n* ignore\n* strict (experimental; treat like other supported nullability annotations)\n* warn (report a warning)", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xnullability-annotations", + "shortName": null, + "description": "Specify the behavior for specific Java nullability annotations (provided with fully qualified package name).\nModes:\n* ignore\n* strict\n* warn (report a warning)", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xsupport-compatqual-checker-framework-annotations", + "shortName": null, + "description": "Specify the behavior for Checker Framework 'compatqual' annotations ('NullableDecl'/'NonNullDecl').\nThe default value is 'enable'.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xjspecify-annotations", + "shortName": null, + "description": "Specify the behavior of 'jspecify' annotations.\nThe default value is 'strict'.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xjvm-default", + "shortName": null, + "description": "This option is deprecated. Migrate to -jvm-default as follows:\n-Xjvm-default=disable -> -jvm-default=disable\n-Xjvm-default=all-compatibility -> -jvm-default=enable\n-Xjvm-default=all -> -jvm-default=no-compatibility", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xdefault-script-extension", + "shortName": null, + "description": "Compile expressions and unrecognized scripts passed with the -script argument as scripts with the given filename extension.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xdisable-standard-script", + "shortName": null, + "description": "Disable standard Kotlin scripting support.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xgenerate-strict-metadata-version", + "shortName": null, + "description": "Generate metadata with strict version semantics (see the KDoc entry on 'Metadata.extraInt').", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xsanitize-parentheses", + "shortName": null, + "description": "Transform '(' and ')' in method names to some other character sequence.\nThis mode can BREAK BINARY COMPATIBILITY and should only be used as a workaround for\nproblems with parentheses in identifiers on certain platforms.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xfriend-paths", + "shortName": null, + "description": "Paths to output directories for friend modules (modules whose internals should be visible).", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xallow-no-source-files", + "shortName": null, + "description": "Allow the set of source files to be empty.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xemit-jvm-type-annotations", + "shortName": null, + "description": "Emit JVM type annotations in bytecode.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xjvm-expose-boxed", + "shortName": null, + "description": "Expose inline classes and functions, accepting and returning them, to Java.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xstring-concat", + "shortName": null, + "description": "Select the code generation scheme for string concatenation:\n-Xstring-concat=indy-with-constants Concatenate strings using 'invokedynamic' and 'makeConcatWithConstants'. This requires '-jvm-target 9' or greater.\n-Xstring-concat=indy Concatenate strings using 'invokedynamic' and 'makeConcat'. This requires '-jvm-target 9' or greater.\n-Xstring-concat=inline Concatenate strings using 'StringBuilder'\ndefault: 'indy-with-constants' for JVM targets 9 or greater, 'inline' otherwise.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xjdk-release", + "shortName": null, + "description": "Compile against the specified JDK API version, similarly to javac's '-release'. This requires JDK 9 or newer.\nThe supported versions depend on the JDK used; for JDK 17+, the supported versions are 1.8 and 9–24.\nThis also sets the value of '-jvm-target' to be equal to the selected JDK version.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xsam-conversions", + "shortName": null, + "description": "Select the code generation scheme for SAM conversions.\n-Xsam-conversions=indy Generate SAM conversions using 'invokedynamic' with 'LambdaMetafactory.metafactory'.\n-Xsam-conversions=class Generate SAM conversions as explicit classes.\nThe default value is 'indy'.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xlambdas", + "shortName": null, + "description": "Select the code generation scheme for lambdas.\n-Xlambdas=indy Generate lambdas using 'invokedynamic' with 'LambdaMetafactory.metafactory'.\n A lambda object created using 'LambdaMetafactory.metafactory' will have a different 'toString()'.\n-Xlambdas=class Generate lambdas as explicit classes.\nThe default value is 'indy' if language version is 2.0+, and 'class' otherwise.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xindy-allow-annotated-lambdas", + "shortName": null, + "description": "Allow using 'invokedynamic' for lambda expressions with annotations", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xklib", + "shortName": null, + "description": "Paths to cross-platform libraries in the .klib format.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xno-reset-jar-timestamps", + "shortName": null, + "description": "Don't reset jar entry timestamps to a fixed date.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xno-unified-null-checks", + "shortName": null, + "description": "Use pre-1.4 exception types instead of 'java.lang.NPE' in null checks. See KT-22275 for more details.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xno-source-debug-extension", + "shortName": null, + "description": "Don't generate the '@kotlin.jvm.internal.SourceDebugExtension' annotation with an SMAP copy on classes.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xprofile", + "shortName": null, + "description": "Debug option: Run the compiler with the async profiler and save snapshots to `outputDir`; `command` is passed to the async profiler on start.\n`profilerPath` is the path to libasyncProfiler.so; async-profiler.jar should be on the compiler classpath.\nIf it's not on the classpath, the compiler will attempt to load async-profiler.jar from the containing directory of profilerPath.\nExample: -Xprofile=/async-profiler/build/libasyncProfiler.so:event=cpu,interval=1ms,threads,start:", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xuse-14-inline-classes-mangling-scheme", + "shortName": null, + "description": "Use the scheme for inline class mangling from version 1.4 instead of the one from 1.4.30.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xjvm-enable-preview", + "shortName": null, + "description": "Allow using Java features that are in the preview phase.\nThis works like '--enable-preview' in Java. All class files are marked as compiled with preview features, meaning it won't be possible to use them in release environments.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xsuppress-deprecated-jvm-target-warning", + "shortName": null, + "description": "Suppress warnings about deprecated JVM target versions.\nThis option has no effect and will be deleted in a future version.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xtype-enhancement-improvements-strict-mode", + "shortName": null, + "description": "Enable strict mode for improvements to type enhancement for loaded Java types based on nullability annotations,\nincluding the ability to read type-use annotations from class files.\nSee KT-45671 for more details.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xserialize-ir", + "shortName": null, + "description": "Save the IR to metadata (Experimental).", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": "none" + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xvalidate-bytecode", + "shortName": null, + "description": "Validate generated JVM bytecode before and after optimizations.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xenhance-type-parameter-types-to-def-not-null", + "shortName": null, + "description": "Enhance not-null-annotated type parameter types to definitely-non-nullable types ('@NotNull T' => 'T & Any').", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xlink-via-signatures", + "shortName": null, + "description": "Link JVM IR symbols via signatures instead of descriptors.\nThis mode is slower, but it can be useful for troubleshooting problems with the JVM IR backend.\nThis option is deprecated and will be deleted in future versions.\nIt has no effect when -language-version is 2.0 or higher.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xdebug", + "shortName": null, + "description": "Enable debug mode for compilation.\nCurrently this includes spilling all variables in a suspending context regardless of whether they are alive.\nIf API Level >= 2.2 -- no-op.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xenhanced-coroutines-debugging", + "shortName": null, + "description": "Generate additional linenumber instruction for compiler-generated code\ninside suspend functions and lambdas to distinguish them from user code by debugger.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xno-new-java-annotation-targets", + "shortName": null, + "description": "Don't generate Java 1.8+ targets for Kotlin annotation classes.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xvalue-classes", + "shortName": null, + "description": "Enable experimental value classes.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xir-inliner", + "shortName": null, + "description": "Inline functions using the IR inliner instead of the bytecode inliner.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xuse-inline-scopes-numbers", + "shortName": null, + "description": "Use inline scopes numbers for inline marker variables.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xuse-k2-kapt", + "shortName": null, + "description": "Enable the experimental support for K2 KAPT.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xcompile-builtins-as-part-of-stdlib", + "shortName": null, + "description": "Enable behaviour needed to compile builtins as part of JVM stdlib", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xoutput-builtins-metadata", + "shortName": null, + "description": "Output builtins metadata as .kotlin_builtins files", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xannotations-in-metadata", + "shortName": null, + "description": "Write annotations on declarations into the metadata (in addition to the JVM bytecode), and read annotations from the metadata if they are present.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xwhen-expressions", + "shortName": null, + "description": "Select the code generation scheme for type-checking 'when' expressions:\n-Xwhen-expressions=indy Generate type-checking 'when' expressions using 'invokedynamic' with 'SwitchBootstraps.typeSwitch(..)' and \n following 'tableswitch' or 'lookupswitch'. This requires '-jvm-target 21' or greater.\n-Xwhen-expressions=inline Generate type-checking 'when' expressions as a chain of type checks.\nThe default value is 'inline'.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + } + ] +} \ No newline at end of file diff --git a/src/test/resources/compiler-arguments/wasm-expected-compiler-args.json b/src/test/resources/compiler-arguments/wasm-expected-compiler-args.json new file mode 100644 index 000000000..faf4ab12f --- /dev/null +++ b/src/test/resources/compiler-arguments/wasm-expected-compiler-args.json @@ -0,0 +1,2020 @@ +{ + "compilerArguments": [ + { + "name": "help", + "shortName": "h", + "description": "Print a synopsis of standard options.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "X", + "shortName": null, + "description": "Print a synopsis of advanced options.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "version", + "shortName": null, + "description": "Display the compiler version.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "verbose", + "shortName": null, + "description": "Enable verbose logging output.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "nowarn", + "shortName": null, + "description": "Don't generate any warnings.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Werror", + "shortName": null, + "description": "Report an error if there are any warnings.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Wextra", + "shortName": null, + "description": "Enable extra checkers for K2.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "language-version", + "shortName": null, + "description": "Provide source compatibility with the specified version of Kotlin.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "api-version", + "shortName": null, + "description": "Allow using declarations from only the specified version of bundled libraries.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "kotlin-home", + "shortName": null, + "description": "Path to the Kotlin compiler home directory used for the discovery of runtime libraries.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "progressive", + "shortName": null, + "description": "Enable progressive compiler mode.\nIn this mode, deprecations and bug fixes for unstable code take effect immediately\ninstead of going through a graceful migration cycle.\nCode written in progressive mode is backward compatible; however, code written without\nprogressive mode enabled may cause compilation errors in progressive mode.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "script", + "shortName": null, + "description": "Evaluate the given Kotlin script (*.kts) file.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xrepl", + "shortName": null, + "description": "Run Kotlin REPL (deprecated)", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "opt-in", + "shortName": null, + "description": "Enable API usages that require opt-in with an opt-in requirement marker with the given fully qualified name.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xno-inline", + "shortName": null, + "description": "Disable method inlining.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xskip-metadata-version-check", + "shortName": null, + "description": "Allow loading classes with bad metadata versions and pre-release classes.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xskip-prerelease-check", + "shortName": null, + "description": "Allow loading pre-release classes.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xallow-kotlin-package", + "shortName": null, + "description": "Allow compiling code in the 'kotlin' package, and allow not requiring 'kotlin.stdlib' in 'module-info'.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xstdlib-compilation", + "shortName": null, + "description": "Enables special features which are relevant only for stdlib compilation.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xreport-output-files", + "shortName": null, + "description": "Report the source-to-output file mapping.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xplugin", + "shortName": null, + "description": "Load plugins from the given classpath.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "P", + "shortName": null, + "description": "Pass an option to a plugin.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xcompiler-plugin", + "shortName": null, + "description": "Register a compiler plugin.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xcompiler-plugin-order", + "shortName": null, + "description": "Specify an execution order constraint for compiler plugins.\nOrder constraint can be specified using the 'pluginId' of compiler plugins.\nThe first specified plugin will be executed before the second plugin.\nMultiple constraints can be specified by repeating this option. Cycles in constraints will cause an error.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xmulti-platform", + "shortName": null, + "description": "Enable language support for multiplatform projects.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xno-check-actual", + "shortName": null, + "description": "Do not check for the presence of the 'actual' modifier in multiplatform projects.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xintellij-plugin-root", + "shortName": null, + "description": "Path to 'kotlin-compiler.jar' or the directory where the IntelliJ IDEA configuration files can be found.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xnew-inference", + "shortName": null, + "description": "Enable the new experimental generic type inference algorithm.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xinline-classes", + "shortName": null, + "description": "Enable experimental inline classes.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xreport-perf", + "shortName": null, + "description": "Report detailed performance statistics.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xdetailed-perf", + "shortName": null, + "description": "Enable more detailed performance statistics (Experimental).\nFor Native, the performance report includes execution time and lines processed per second for every individual lowering.\nFor WASM and JS, the performance report includes execution time and lines per second for each lowering of the first stage of compilation.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xdump-perf", + "shortName": null, + "description": "Dump detailed performance statistics to the specified file in plain text, JSON or markdown format (it's detected by the file's extension).\nAlso, it supports the placeholder `*` and directory for generating file names based on the module being compiled and the current time stamp.\nExample: `path/to/dir/*.log` creates logs like `path/to/dir/my-module_2025-06-20-12-22-32.log` in plain text format, `path/to/dir/` creates logs like `path/to/dir/my-log_2025-06-20-12-22-32.json`.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "XXdump-model", + "shortName": null, + "description": "Dump compilation model to specified directory for use in modularized tests.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xmetadata-version", + "shortName": null, + "description": "Change the metadata version of the generated binary files.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xcommon-sources", + "shortName": null, + "description": "Sources of the common module that need to be compiled together with this module in multiplatform mode.\nThey should be a subset of sources passed as free arguments.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xlist-phases", + "shortName": null, + "description": "List backend phases.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xdisable-phases", + "shortName": null, + "description": "Disable backend phases.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xverbose-phases", + "shortName": null, + "description": "Be verbose while performing the given backend phases.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xphases-to-dump-before", + "shortName": null, + "description": "Dump the backend's state before these phases.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xphases-to-dump-after", + "shortName": null, + "description": "Dump the backend's state after these phases.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xphases-to-dump", + "shortName": null, + "description": "Dump the backend's state both before and after these phases.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xdump-directory", + "shortName": null, + "description": "Dump the backend state into this directory.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xdump-fqname", + "shortName": null, + "description": "Dump the declaration with the given FqName.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xphases-to-validate-before", + "shortName": null, + "description": "Validate the backend's state before these phases.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xphases-to-validate-after", + "shortName": null, + "description": "Validate the backend's state after these phases.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xphases-to-validate", + "shortName": null, + "description": "Validate the backend's state both before and after these phases.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xverify-ir", + "shortName": null, + "description": "IR verification mode (no verification by default).", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xverify-ir-visibility", + "shortName": null, + "description": "Check for visibility violations in IR when validating it before running any lowerings. Only has effect if '-Xverify-ir' is not 'none'.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xprofile-phases", + "shortName": null, + "description": "Profile backend phases.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xcheck-phase-conditions", + "shortName": null, + "description": "Check pre- and postconditions of IR lowering phases.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xuse-fir-experimental-checkers", + "shortName": null, + "description": "Enable experimental frontend IR checkers that are not yet ready for production.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xuse-fir-ic", + "shortName": null, + "description": "Compile using frontend IR internal incremental compilation.\nWarning: This feature is not yet production-ready.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xuse-fir-lt", + "shortName": null, + "description": "Compile using the LightTree parser with the frontend IR.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": true + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xmetadata-klib", + "shortName": null, + "description": "Produce a klib that only contains the metadata of declarations.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xdisable-default-scripting-plugin", + "shortName": null, + "description": "Don't enable the scripting plugin by default.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xexplicit-api", + "shortName": null, + "description": "Force the compiler to report errors on all public API declarations without an explicit visibility or a return type.\nUse the 'warning' level to issue warnings instead of errors.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": "disable" + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "XXexplicit-return-types", + "shortName": null, + "description": "Force the compiler to report errors on all public API declarations without an explicit return type.\nUse the 'warning' level to issue warnings instead of errors.\nThis flag partially enables functionality of `-Xexplicit-api` flag, so please don't use them altogether", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": "disable" + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xreturn-value-checker", + "shortName": null, + "description": "Set improved unused return value checker mode. Use 'check' to run checker only and use 'full' to also enable automatic annotation insertion.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": "disable" + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xsuppress-version-warnings", + "shortName": null, + "description": "Suppress warnings about outdated, inconsistent, or experimental language or API versions.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xsuppress-api-version-greater-than-language-version-error", + "shortName": null, + "description": "Suppress error about API version greater than language version.\nWarning: This is temporary solution (see KT-63712) intended to be used only for stdlib build.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xexpect-actual-classes", + "shortName": null, + "description": "'expect'/'actual' classes (including interfaces, objects, annotations, enums, and 'actual' typealiases) are in Beta.\nKotlin reports a warning every time you use one of them. You can use this flag to mute the warning.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xconsistent-data-class-copy-visibility", + "shortName": null, + "description": "The effect of this compiler flag is the same as applying @ConsistentCopyVisibility annotation to all data classes in the module. See https://youtrack.jetbrains.com/issue/KT-11914", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xunrestricted-builder-inference", + "shortName": null, + "description": "Eliminate builder inference restrictions, for example by allowing type variables to be returned from builder inference calls.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xcontext-receivers", + "shortName": null, + "description": "Enable experimental context receivers.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xcontext-parameters", + "shortName": null, + "description": "Enable experimental context parameters.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xcontext-sensitive-resolution", + "shortName": null, + "description": "Enable experimental context-sensitive resolution.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xnon-local-break-continue", + "shortName": null, + "description": "Enable experimental non-local break and continue.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xdata-flow-based-exhaustiveness", + "shortName": null, + "description": "Enable `when` exhaustiveness improvements that rely on data-flow analysis.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xexplicit-backing-fields", + "shortName": null, + "description": "Enable experimental language support for explicit backing fields.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xdirect-java-actualization", + "shortName": null, + "description": "Enable experimental direct Java actualization support.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xmulti-dollar-interpolation", + "shortName": null, + "description": "Enable experimental multi-dollar interpolation.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xenable-incremental-compilation", + "shortName": null, + "description": "Enable incremental compilation.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xrender-internal-diagnostic-names", + "shortName": null, + "description": "Render the internal names of warnings and errors.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xallow-any-scripts-in-source-roots", + "shortName": null, + "description": "Allow compiling scripts along with regular Kotlin sources.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xreport-all-warnings", + "shortName": null, + "description": "Report all warnings even if errors are found.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xfragments", + "shortName": null, + "description": "Declare all known fragments of a multiplatform compilation.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xfragment-sources", + "shortName": null, + "description": "Add sources to a specific fragment of a multiplatform compilation.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xfragment-refines", + "shortName": null, + "description": "Declare that refines with the dependsOn/refines relation.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xfragment-dependency", + "shortName": null, + "description": "Declare common klib dependencies for the specific fragment.\nThis argument is required for any HMPP module except the platform leaf module: it takes dependencies from -cp/-libraries.\nThe argument should be used only if the new compilation scheme is enabled with -Xseparate-kmp-compilation\n", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xfragment-friend-dependency", + "shortName": null, + "description": "Declare common klib friend dependencies for the specific fragment.\nThis argument can be specified for any HMPP module except the platform leaf module: it takes dependencies from the platform specific friend module arguments.\nThe argument should be used only if the new compilation scheme is enabled with -Xseparate-kmp-compilation\n", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xseparate-kmp-compilation", + "shortName": null, + "description": "Enables the separated compilation scheme, in which common source sets are analyzed against their own dependencies", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xignore-const-optimization-errors", + "shortName": null, + "description": "Ignore all compilation exceptions while optimizing some constant expressions.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xdont-warn-on-error-suppression", + "shortName": null, + "description": "Don't report warnings when errors are suppressed. This only affects K2.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xwhen-guards", + "shortName": null, + "description": "Enable experimental language support for when guards.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xnested-type-aliases", + "shortName": null, + "description": "Enable experimental language support for nested type aliases.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xsuppress-warning", + "shortName": null, + "description": "Suppress specified warning module-wide. This option is deprecated in favor of \"-Xwarning-level\" flag", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xwarning-level", + "shortName": null, + "description": "Set the severity of the given warning.\n- `error` level raises the severity of a warning to error level (similar to -Werror but more granular)\n- `disabled` level suppresses reporting of a warning (similar to -nowarn but more granular)\n- `warning` level overrides -nowarn and -Werror for this specific warning (the warning will be reported/won't be considered as an error)", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xannotation-default-target", + "shortName": null, + "description": "Change the default annotation targets for constructor properties:\n-Xannotation-default-target=first-only: use the first of the following allowed targets: '@param:', '@property:', '@field:';\n-Xannotation-default-target=first-only-warn: same as first-only, and raise warnings when both '@param:' and either '@property:' or '@field:' are allowed;\n-Xannotation-default-target=param-property: use '@param:' target if applicable, and also use the first of either '@property:' or '@field:';\ndefault: 'first-only-warn' in language version 2.2+, 'first-only' in version 2.1 and before.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "XXdebug-level-compiler-checks", + "shortName": null, + "description": "Enable debug level compiler checks. ATTENTION: these checks can slow compiler down or even crash it.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xannotation-target-all", + "shortName": null, + "description": "Enable experimental language support for @all: annotation use-site target.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "XXlenient-mode", + "shortName": null, + "description": "Lenient compiler mode. When actuals are missing, placeholder declarations are generated.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xallow-reified-type-in-catch", + "shortName": null, + "description": "Allow 'catch' parameters to have reified types.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xallow-contracts-on-more-functions", + "shortName": null, + "description": "Allow contracts on some operators and accessors, and allow checks for erased types.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xallow-condition-implies-returns-contracts", + "shortName": null, + "description": "Allow contracts that specify a limited conditional returns postcondition.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xallow-holdsin-contract", + "shortName": null, + "description": "Allow contracts that specify a condition that holds true inside a lambda argument.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xname-based-destructuring", + "shortName": null, + "description": "Enables the following destructuring features:\n-Xname-based-destructuring=only-syntax: Enables syntax for positional destructuring with square brackets and the full form of name-based destructuring with parentheses;\n-Xname-based-destructuring=name-mismatch: Reports warnings when short form positional destructuring of data classes uses names that don't match the property names;\n-Xname-based-destructuring=complete: Enables short-form name-based destructuring with parentheses;", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "XXLanguage", + "shortName": null, + "description": "Enables/disables specified language feature.\nWarning: this flag is not intended for production use. If you want to configure the language behaviour use the\n-language-version or corresponding experimental feature flags.", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xklib-relative-path-base", + "shortName": null, + "description": "Provide a base path to compute the source's relative paths in klib (default is empty).", + "type": { + "type": "com.compiler.server.model.ListExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": [] + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xklib-normalize-absolute-path", + "shortName": null, + "description": "Normalize absolute paths in klibs.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xklib-enable-signature-clash-checks", + "shortName": null, + "description": "Enable signature uniqueness checks.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": true + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xpartial-linkage", + "shortName": null, + "description": "Use partial linkage mode.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xpartial-linkage-loglevel", + "shortName": null, + "description": "Define the compile-time log level for partial linkage.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xklib-duplicated-unique-name-strategy", + "shortName": null, + "description": "Klib dependencies usage strategy when multiple KLIBs has same `unique_name` property value.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xklib-ir-inliner", + "shortName": null, + "description": "Set the mode of the experimental IR inliner on the first compilation stage.\n- `intra-module` mode enforces inlining of the functions only from the compiled module\n- `full` mode enforces inlining of all functions (from the compiled module and from all dependencies)\n Warning: This mode will trigger setting the `pre-release` flag for the compiled library.\n- `disabled` mode completely disables the IR inliner\n- `default` mode lets the IR inliner run in `intra-module`, `full` or `disabled` mode based on the current language version\n ", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": "default" + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xklib-abi-version", + "shortName": null, + "description": "Specify the custom ABI version to be written in KLIB. This option is intended only for tests.\nWarning: This option does not affect KLIB ABI. Neither allows it making a KLIB backward-compatible with older ABI versions.\nThe only observable effect is that a custom ABI version is written to KLIB manifest file.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xklib-zip-file-accessor-cache-limit", + "shortName": null, + "description": "Maximum number of klibs that can be cached during compilation. Default is 64.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": "64" + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xwasm", + "shortName": null, + "description": "Use the WebAssembly compiler backend.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xwasm-target", + "shortName": null, + "description": "Set up the Wasm target (wasm-js or wasm-wasi).", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xwasm-debug-info", + "shortName": null, + "description": "Add debug info to the compiled WebAssembly module.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": true + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xwasm-debug-friendly", + "shortName": null, + "description": "Avoid optimizations that can break debugging.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xwasm-generate-wat", + "shortName": null, + "description": "Generate a .wat file.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xwasm-kclass-fqn", + "shortName": null, + "description": "Enable support for 'KClass.qualifiedName'.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": true + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xwasm-enable-array-range-checks", + "shortName": null, + "description": "Turn on range checks for array access functions.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xwasm-enable-asserts", + "shortName": null, + "description": "Turn on asserts.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xwasm-use-traps-instead-of-exceptions", + "shortName": null, + "description": "Use traps instead of throwing exceptions.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xwasm-use-new-exception-proposal", + "shortName": null, + "description": "Use an updated version of the exception proposal with try_table.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xwasm-no-jstag", + "shortName": null, + "description": "Don't use WebAssembly.JSTag for throwing and catching exceptions", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xwasm-debugger-custom-formatters", + "shortName": null, + "description": "Generates devtools custom formatters (https://firefox-source-docs.mozilla.org/devtools-user/custom_formatters) for Kotlin/Wasm values", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xwasm-source-map-include-mappings-from-unavailable-sources", + "shortName": null, + "description": "Insert source mappings from libraries even if their sources are unavailable on the end-user machine.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xwasm-preserve-ic-order", + "shortName": null, + "description": "Preserve wasm file structure between IC runs.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xwasm-ic-cache-readonly", + "shortName": null, + "description": "Do not commit IC cache updates.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xwasm-generate-dwarf", + "shortName": null, + "description": "Generate DWARF debug information.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xir-dce-dump-reachability-info-to-file", + "shortName": null, + "description": "Dump reachability information collected about declarations while performing DCE to a file. The format will be chosen automatically based on the file extension. Supported output formats include JSON for .json, a JS const initialized with a plain object containing information for .js, and plain text for all other file types.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xir-dump-declaration-ir-sizes-to-file", + "shortName": null, + "description": "Dump the IR size of each declaration into a file. The format will be chosen automatically depending on the file extension. Supported output formats include JSON for .json, a JS const initialized with a plain object containing information for .js, and plain text for all other file types.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "ir-output-dir", + "shortName": null, + "description": "Destination for generated files.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "ir-output-name", + "shortName": null, + "description": "Base name of generated files.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "libraries", + "shortName": null, + "description": "Paths to Kotlin libraries with .meta.js and .kjsm files, separated by the system path separator.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": "kotlin-stdlib-wasm-js-{{KOTLIN_VERSION_PLACEHOLDER}}.klib" + }, + { + "name": "source-map", + "shortName": null, + "description": "Generate a source map.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "source-map-prefix", + "shortName": null, + "description": "Add the specified prefix to the paths in the source map.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "source-map-base-dirs", + "shortName": null, + "description": "Base directories for calculating relative paths to source files in the source map.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "source-map-embed-sources", + "shortName": null, + "description": "Embed source files into the source map.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "source-map-names-policy", + "shortName": null, + "description": "Mode for mapping generated names to original names.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "target", + "shortName": null, + "description": "Generate JS files for the specified ECMA version.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xir-keep", + "shortName": null, + "description": "Comma-separated list of fully qualified names not to be eliminated by DCE (if it can be reached), and for which to keep non-minified names.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "module-kind", + "shortName": null, + "description": "The kind of JS module generated by the compiler. ES modules are enabled by default in case of ES2015 target usage", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "main", + "shortName": null, + "description": "Specify whether the 'main' function should be called upon execution.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xir-produce-klib-dir", + "shortName": null, + "description": "Generate an unpacked klib into the parent directory of the output JS file.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xir-produce-klib-file", + "shortName": null, + "description": "Generate a packed klib into the directory specified by '-ir-output-dir'.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xir-produce-js", + "shortName": null, + "description": "Generate a JS file using the IR backend.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xir-dce", + "shortName": null, + "description": "Perform experimental dead code elimination.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xir-dce-runtime-diagnostic", + "shortName": null, + "description": "Enable runtime diagnostics instead of removing declarations when performing DCE.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xir-dce-print-reachability-info", + "shortName": null, + "description": "Print reachability information about declarations to 'stdout' while performing DCE.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xir-property-lazy-initialization", + "shortName": null, + "description": "Perform lazy initialization for properties.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": true + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xir-minimized-member-names", + "shortName": null, + "description": "Minimize the names of members.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xir-module-name", + "shortName": null, + "description": "Specify the name of the compilation module for the IR backend.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xir-safe-external-boolean", + "shortName": null, + "description": "Wrap access to external 'Boolean' properties with an explicit conversion to 'Boolean'.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xir-safe-external-boolean-diagnostic", + "shortName": null, + "description": "Enable runtime diagnostics when accessing external 'Boolean' properties.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xir-per-module", + "shortName": null, + "description": "Generate one .js file per module.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xir-per-module-output-name", + "shortName": null, + "description": "Add a custom output name to the split .js files.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xir-per-file", + "shortName": null, + "description": "Generate one .js file per source file.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xir-generate-inline-anonymous-functions", + "shortName": null, + "description": "Lambda expressions that capture values are translated into in-line anonymous JavaScript functions.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xinclude", + "shortName": null, + "description": "Path to an intermediate library that should be processed in the same manner as source files.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xcache-directory", + "shortName": null, + "description": "Path to the cache directory.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xir-build-cache", + "shortName": null, + "description": "Use the compiler to build the cache.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xgenerate-dts", + "shortName": null, + "description": "Generate a TypeScript declaration .d.ts file alongside the JS file.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xgenerate-polyfills", + "shortName": null, + "description": "Generate polyfills for features from the ES6+ standards.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": true + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xstrict-implicit-export-types", + "shortName": null, + "description": "Generate strict types for implicitly exported entities inside d.ts files.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xes-classes", + "shortName": null, + "description": "Let generated JavaScript code use ES2015 classes. Enabled by default in case of ES2015 target usage", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xplatform-arguments-in-main-function", + "shortName": null, + "description": "JS expression that will be executed in runtime and be put as an Array parameter of the main function", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xes-generators", + "shortName": null, + "description": "Enable ES2015 generator functions usage inside the compiled code. Enabled by default in case of ES2015 target usage", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xes-arrow-functions", + "shortName": null, + "description": "Use ES2015 arrow functions in the JavaScript code generated for Kotlin lambdas. Enabled by default in case of ES2015 target usage", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xes-long-as-bigint", + "shortName": null, + "description": "Compile Long values as ES2020 bigint instead of object.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xtyped-arrays", + "shortName": null, + "description": "This option does nothing and is left for compatibility with the legacy backend.\nIt is deprecated and will be removed in a future release.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xfriend-modules-disabled", + "shortName": null, + "description": "Disable internal declaration export.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xfriend-modules", + "shortName": null, + "description": "Paths to friend modules.", + "type": { + "type": "com.compiler.server.model.StringExtendedCompilerArgumentValue", + "isNullable": true, + "defaultValue": null + }, + "disabled": true, + "predefinedValues": null + }, + { + "name": "Xenable-extension-functions-in-externals", + "shortName": null, + "description": "Enable extension function members in external interfaces.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xfake-override-validator", + "shortName": null, + "description": "Enable the IR fake override validator.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": false + }, + "disabled": false, + "predefinedValues": null + }, + { + "name": "Xoptimize-generated-js", + "shortName": null, + "description": "Perform additional optimizations on the generated JS code.", + "type": { + "type": "com.compiler.server.model.BooleanExtendedCompilerArgumentValue", + "isNullable": false, + "defaultValue": true + }, + "disabled": false, + "predefinedValues": null + } + ] +} \ No newline at end of file From e1b4e20099d1366b645fbe77fb00bd992593da4f Mon Sep 17 00:00:00 2001 From: Dmitrii Krasnov Date: Tue, 14 Oct 2025 11:19:20 +0200 Subject: [PATCH 19/20] KTL-724 Removed unnecessary js and wasm arguments from the whitelist --- .../server/utils/CompilerArgumentsUtil.kt | 15 +++------------ .../compose-wasm-expected-compiler-args.json | 16 ++++++++-------- .../js-expected-compiler-args.json | 16 ++++++++-------- .../wasm-expected-compiler-args.json | 16 ++++++++-------- 4 files changed, 27 insertions(+), 36 deletions(-) diff --git a/src/main/kotlin/com/compiler/server/utils/CompilerArgumentsUtil.kt b/src/main/kotlin/com/compiler/server/utils/CompilerArgumentsUtil.kt index 6878c32e1..9e97ee048 100644 --- a/src/main/kotlin/com/compiler/server/utils/CompilerArgumentsUtil.kt +++ b/src/main/kotlin/com/compiler/server/utils/CompilerArgumentsUtil.kt @@ -165,16 +165,12 @@ class CompilerArgumentsUtil( private val ALLOWED_JS_ARGUMENTS = setOf( // file paths and environment settings - "module-name", "Xir-keep", - "module-kind", "main", "Xir-dce", "Xir-dce-runtime-diagnostic", - "Xir-dce-print-reachability-info", "Xir-property-lazy-initialization", "Xir-minimized-member-names", - "Xir-module-name", "Xir-generate-inline-anonymous-functions", "Xgenerate-polyfills", "Xes-classes", @@ -190,8 +186,6 @@ class CompilerArgumentsUtil( private val ALLOWED_WASM_ARGUMENTS = setOf( // file paths and environment settings - "Xwasm", - "Xwasm-target", "Xwasm-debug-info", "Xwasm-debug-friendly", "Xwasm-kclass-fqn", @@ -200,10 +194,7 @@ class CompilerArgumentsUtil( "Xwasm-use-traps-instead-of-exceptions", "Xwasm-use-new-exception-proposal", "Xwasm-no-jstag", - "Xwasm-debugger-custom-formatters", - "Xwasm-source-map-include-mappings-from-unavailable-sources", - "Xwasm-ic-cache-readonly", - "Xwasm-generate-dwarf" + "Xwasm-source-map-include-mappings-from-unavailable-sources" ) // Use Pair if you want to provide different values for user and for actual use. @@ -277,7 +268,7 @@ class CompilerArgumentsUtil( "ir-output-name" to WASM_DEFAULT_MODULE_NAME, "XPlugin" to Pair( kotlinEnvironment.COMPOSE_WASM_COMPILER_PLUGINS.map { it.split("/").last() }, - kotlinEnvironment.COMPOSE_WASM_COMPILER_PLUGINS + kotlinEnvironment.COMPOSE_WASM_COMPILER_PLUGINS ), "P" to Pair( kotlinEnvironment.composeWasmCompilerPluginOptions, @@ -383,7 +374,7 @@ class CompilerArgumentsUtil( return (kotlinCompilerArguments.topLevel.arguments + commonArgumentsLevel.arguments + commonKlibBasedArgumentsLevel.arguments + - wasmLevel.arguments+ + wasmLevel.arguments + jsLevel.arguments) .processCompilerArgs( predefinedArguments = PREDEFINED_WASM_FIRST_PHASE_ARGUMENTS, diff --git a/src/test/resources/compiler-arguments/compose-wasm-expected-compiler-args.json b/src/test/resources/compiler-arguments/compose-wasm-expected-compiler-args.json index 3e8ab3356..af04c2b44 100644 --- a/src/test/resources/compiler-arguments/compose-wasm-expected-compiler-args.json +++ b/src/test/resources/compiler-arguments/compose-wasm-expected-compiler-args.json @@ -1283,7 +1283,7 @@ "isNullable": false, "defaultValue": false }, - "disabled": false, + "disabled": true, "predefinedValues": null }, { @@ -1295,7 +1295,7 @@ "isNullable": true, "defaultValue": null }, - "disabled": false, + "disabled": true, "predefinedValues": null }, { @@ -1415,7 +1415,7 @@ "isNullable": false, "defaultValue": false }, - "disabled": false, + "disabled": true, "predefinedValues": null }, { @@ -1451,7 +1451,7 @@ "isNullable": false, "defaultValue": false }, - "disabled": false, + "disabled": true, "predefinedValues": null }, { @@ -1463,7 +1463,7 @@ "isNullable": false, "defaultValue": false }, - "disabled": false, + "disabled": true, "predefinedValues": null }, { @@ -1619,7 +1619,7 @@ "isNullable": true, "defaultValue": null }, - "disabled": false, + "disabled": true, "predefinedValues": null }, { @@ -1703,7 +1703,7 @@ "isNullable": false, "defaultValue": false }, - "disabled": false, + "disabled": true, "predefinedValues": null }, { @@ -1739,7 +1739,7 @@ "isNullable": true, "defaultValue": null }, - "disabled": false, + "disabled": true, "predefinedValues": null }, { diff --git a/src/test/resources/compiler-arguments/js-expected-compiler-args.json b/src/test/resources/compiler-arguments/js-expected-compiler-args.json index 73d87cf67..e07972f9a 100644 --- a/src/test/resources/compiler-arguments/js-expected-compiler-args.json +++ b/src/test/resources/compiler-arguments/js-expected-compiler-args.json @@ -1281,7 +1281,7 @@ "isNullable": false, "defaultValue": false }, - "disabled": false, + "disabled": true, "predefinedValues": null }, { @@ -1293,7 +1293,7 @@ "isNullable": true, "defaultValue": null }, - "disabled": false, + "disabled": true, "predefinedValues": null }, { @@ -1413,7 +1413,7 @@ "isNullable": false, "defaultValue": false }, - "disabled": false, + "disabled": true, "predefinedValues": null }, { @@ -1449,7 +1449,7 @@ "isNullable": false, "defaultValue": false }, - "disabled": false, + "disabled": true, "predefinedValues": null }, { @@ -1461,7 +1461,7 @@ "isNullable": false, "defaultValue": false }, - "disabled": false, + "disabled": true, "predefinedValues": null }, { @@ -1617,7 +1617,7 @@ "isNullable": true, "defaultValue": null }, - "disabled": false, + "disabled": true, "predefinedValues": null }, { @@ -1701,7 +1701,7 @@ "isNullable": false, "defaultValue": false }, - "disabled": false, + "disabled": true, "predefinedValues": null }, { @@ -1737,7 +1737,7 @@ "isNullable": true, "defaultValue": null }, - "disabled": false, + "disabled": true, "predefinedValues": null }, { diff --git a/src/test/resources/compiler-arguments/wasm-expected-compiler-args.json b/src/test/resources/compiler-arguments/wasm-expected-compiler-args.json index faf4ab12f..66957a971 100644 --- a/src/test/resources/compiler-arguments/wasm-expected-compiler-args.json +++ b/src/test/resources/compiler-arguments/wasm-expected-compiler-args.json @@ -1281,7 +1281,7 @@ "isNullable": false, "defaultValue": false }, - "disabled": false, + "disabled": true, "predefinedValues": null }, { @@ -1293,7 +1293,7 @@ "isNullable": true, "defaultValue": null }, - "disabled": false, + "disabled": true, "predefinedValues": null }, { @@ -1413,7 +1413,7 @@ "isNullable": false, "defaultValue": false }, - "disabled": false, + "disabled": true, "predefinedValues": null }, { @@ -1449,7 +1449,7 @@ "isNullable": false, "defaultValue": false }, - "disabled": false, + "disabled": true, "predefinedValues": null }, { @@ -1461,7 +1461,7 @@ "isNullable": false, "defaultValue": false }, - "disabled": false, + "disabled": true, "predefinedValues": null }, { @@ -1617,7 +1617,7 @@ "isNullable": true, "defaultValue": null }, - "disabled": false, + "disabled": true, "predefinedValues": null }, { @@ -1701,7 +1701,7 @@ "isNullable": false, "defaultValue": false }, - "disabled": false, + "disabled": true, "predefinedValues": null }, { @@ -1737,7 +1737,7 @@ "isNullable": true, "defaultValue": null }, - "disabled": false, + "disabled": true, "predefinedValues": null }, { From ec4cf75a16076d55ddf40f2c42be529e1a7e366a Mon Sep 17 00:00:00 2001 From: Dmitrii Krasnov Date: Thu, 16 Oct 2025 15:26:29 +0200 Subject: [PATCH 20/20] KTL-2973 Deprecated old compilation endpoint. --- ...server-version-catalog.settings.gradle.kts | 2 - .../KotlinPlaygroundRestController.kt | 87 +++++++------------ 2 files changed, 32 insertions(+), 57 deletions(-) diff --git a/build-settings-logic/src/main/kotlin/kotlin-compiler-server-version-catalog.settings.gradle.kts b/build-settings-logic/src/main/kotlin/kotlin-compiler-server-version-catalog.settings.gradle.kts index 4c2fe1ced..54664d948 100644 --- a/build-settings-logic/src/main/kotlin/kotlin-compiler-server-version-catalog.settings.gradle.kts +++ b/build-settings-logic/src/main/kotlin/kotlin-compiler-server-version-catalog.settings.gradle.kts @@ -12,7 +12,6 @@ pluginManagement { } maven("https://redirector.kotlinlang.org/maven/dev") mavenLocal() - maven("https://redirector.kotlinlang.org/maven/dev") } } @@ -31,7 +30,6 @@ dependencyResolutionManagement { } maven("https://redirector.kotlinlang.org/maven/dev") mavenLocal() - maven("https://redirector.kotlinlang.org/maven/dev") } versionCatalogs { diff --git a/src/main/kotlin/com/compiler/server/controllers/KotlinPlaygroundRestController.kt b/src/main/kotlin/com/compiler/server/controllers/KotlinPlaygroundRestController.kt index ffcc3d6f2..3fafecaf0 100644 --- a/src/main/kotlin/com/compiler/server/controllers/KotlinPlaygroundRestController.kt +++ b/src/main/kotlin/com/compiler/server/controllers/KotlinPlaygroundRestController.kt @@ -12,59 +12,36 @@ import org.springframework.web.bind.annotation.RequestParam import org.springframework.web.bind.annotation.RestController @RestController -class KotlinPlaygroundRestController(private val kotlinProjectExecutor: KotlinProjectExecutor) { +@Deprecated( + "Use only for old kotlin playground widget. " + + "Should be removed in KTL-2974 around 2.5.0" +) +class KotlinPlaygroundRestController() { - /** - * Endpoint for support requests from kotlin playground client. - * Kotlin Playground component see: https://github.com/JetBrains/kotlin-playground - * Old server see: https://github.com/JetBrains/kotlin-web-demo - */ - @RequestMapping( - value = ["/kotlinServer"], - method = [RequestMethod.GET, RequestMethod.POST], - consumes = [MediaType.ALL_VALUE], - produces = [MediaType.APPLICATION_JSON_VALUE] - ) - @Suppress("IMPLICIT_CAST_TO_ANY") - fun tryKotlinLangObsoleteEndpoint( - @RequestParam type: String, - @RequestParam(required = false) line: Int?, - @RequestParam(required = false) ch: Int?, - @RequestParam(required = false) project: Project?, - @RequestParam(defaultValue = "false") addByteCode: Boolean, - ): ResponseEntity<*> { - val result = when (type) { - "getKotlinVersions" -> listOf(kotlinProjectExecutor.getVersion()) - else -> { - if (project == null) error("No parameter 'project' found") - when (type) { - "run" -> { - when (project.confType) { - ProjectType.JAVA -> kotlinProjectExecutor.run(project, addByteCode) - ProjectType.JS -> throw LegacyJsException() - ProjectType.JS_IR, ProjectType.CANVAS -> - kotlinProjectExecutor.convertToJsIr( - project, - ) - ProjectType.WASM, ProjectType.COMPOSE_WASM -> kotlinProjectExecutor.convertToWasm( - project, - debugInfo = false, - ) - ProjectType.JUNIT -> kotlinProjectExecutor.test(project, addByteCode) - } - } - - "highlight" -> kotlinProjectExecutor.highlight(project) - "complete" -> { - if (line != null && ch != null) { - kotlinProjectExecutor.complete(project, line, ch) - } else error("No parameters 'line' or 'ch'") - } - - else -> error("No parameter 'type' found") - } - } - } - return ResponseEntity.ok(result) - } -} \ No newline at end of file + /** + * Endpoint for support requests from kotlin playground client. + * Kotlin Playground component see: https://github.com/JetBrains/kotlin-playground + * Old server see: https://github.com/JetBrains/kotlin-web-demo + */ + @RequestMapping( + value = ["/kotlinServer"], + method = [RequestMethod.GET, RequestMethod.POST], + consumes = [MediaType.ALL_VALUE], + ) + @Suppress("IMPLICIT_CAST_TO_ANY") + fun tryKotlinLangObsoleteEndpoint( + @RequestParam type: String, + @RequestParam(required = false) line: Int?, + @RequestParam(required = false) ch: Int?, + @RequestParam(required = false) project: Project?, + @RequestParam(defaultValue = "false") addByteCode: Boolean, + ): ResponseEntity = + ResponseEntity + .badRequest() + .body( + "This endpoint is not available anymore.\n" + + "And will be soon removed from the Kotlin Playground.\n" + + "If you are using playground widget, then update to the new version: https://github.com/JetBrains/kotlin-playground \n" + + "Otherwise, use the new api available at: https://api.kotlinlang.org/api//compiler/run .\n" + ) +}