Kotlin: address reviewer feedback on versioning and registrar wiring

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Anders Fugmann
2026-06-12 14:20:01 +02:00
parent 4723dfc76c
commit e5cb6b4496
4 changed files with 33 additions and 12 deletions

View File

@@ -53,6 +53,9 @@ _extractor_name_prefix = "%s-%s" % (
"embeddable" if _for_embeddable else "standalone",
)
_compiler_plugin_registrar_service_source = "src/main/resources/META-INF/services/org.jetbrains.kotlin.compiler.plugin.CompilerPluginRegistrar"
_compiler_plugin_registrar_service_target = "META-INF/services/org.jetbrains.kotlin.compiler.plugin.CompilerPluginRegistrar"
py_binary(
name = "generate_dbscheme",
srcs = ["generate_dbscheme.py"],
@@ -64,12 +67,12 @@ _resources = [
r[len("src/main/resources/"):],
)
for r in glob(["src/main/resources/**"])
if r != "src/main/resources/META-INF/services/org.jetbrains.kotlin.compiler.plugin.CompilerPluginRegistrar"
if r != _compiler_plugin_registrar_service_source
]
_compiler_plugin_registrar_service = (
"src/main/resources/META-INF/services/org.jetbrains.kotlin.compiler.plugin.CompilerPluginRegistrar",
"META-INF/services/org.jetbrains.kotlin.compiler.plugin.CompilerPluginRegistrar",
_compiler_plugin_registrar_service_source,
_compiler_plugin_registrar_service_target,
)
kt_javac_options(

View File

@@ -1,15 +1,15 @@
@file:Suppress("DEPRECATION", "DEPRECATION_ERROR")
@file:OptIn(ExperimentalCompilerApi::class)
package com.github.codeql
import com.intellij.mock.MockProject
import com.intellij.openapi.extensions.LoadingOrder
import org.jetbrains.kotlin.backend.common.extensions.IrGenerationExtension
import org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar
import org.jetbrains.kotlin.compiler.plugin.CompilerPluginRegistrar
import org.jetbrains.kotlin.compiler.plugin.ExperimentalCompilerApi
import org.jetbrains.kotlin.config.CompilerConfiguration
@OptIn(ExperimentalCompilerApi::class)
@Suppress("DEPRECATION", "DEPRECATION_ERROR")
abstract class Kotlin2ComponentRegistrar : CompilerPluginRegistrar(), ComponentRegistrar {
override val supportsK2: Boolean
get() = true
@@ -22,11 +22,11 @@ abstract class Kotlin2ComponentRegistrar : CompilerPluginRegistrar(), ComponentR
project: MockProject,
configuration: CompilerConfiguration
) {
// In 2.4.0, we use CompilerPluginRegistrar path instead.
// This is only called if the compiler uses the ComponentRegistrar service file.
// We do nothing here since registerExtensions will be called separately.
this.project = project
doRegisterExtensions(configuration)
}
private var project: MockProject? = null
private var extensionStorage: CompilerPluginRegistrar.ExtensionStorage? = null
override fun ExtensionStorage.registerExtensions(configuration: CompilerConfiguration) {
@@ -37,9 +37,15 @@ abstract class Kotlin2ComponentRegistrar : CompilerPluginRegistrar(), ComponentR
abstract fun doRegisterExtensions(configuration: CompilerConfiguration)
protected fun registerExtractorExtension(extension: IrGenerationExtension) {
val storage = extensionStorage ?: throw IllegalStateException("registerExtractorExtension called before registerExtensions")
with(storage) {
IrGenerationExtension.registerExtension(extension)
extensionStorage?.let { storage ->
with(storage) {
IrGenerationExtension.registerExtension(extension)
}
return
}
// Fallback for ComponentRegistrar-based registration to keep legacy ordering semantics.
val p = project ?: throw IllegalStateException("registerExtractorExtension called before registration")
val extensionPoint = p.extensionArea.getExtensionPoint(IrGenerationExtension.extensionPointName)
extensionPoint.registerExtension(extension, LoadingOrder.LAST, p)
}
}

View File

@@ -1,5 +1,8 @@
# when updating this list, `bazel mod tidy` should be run from `codeql` to update `MODULE.bazel`
VERSIONS = [
"1.8.0",
"1.9.0-Beta",
"1.9.20-Beta",
"2.0.0-RC1",
"2.0.20-Beta2",
"2.1.0-Beta1",