mirror of
https://github.com/github/codeql.git
synced 2026-06-13 08:51:20 +02:00
Kotlin: fix 2.4 registrar build regression
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
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 {
|
||||
abstract class Kotlin2ComponentRegistrar :
|
||||
CompilerPluginRegistrar(),
|
||||
org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar {
|
||||
override val supportsK2: Boolean
|
||||
get() = true
|
||||
|
||||
@@ -22,11 +22,10 @@ abstract class Kotlin2ComponentRegistrar : CompilerPluginRegistrar(), ComponentR
|
||||
project: MockProject,
|
||||
configuration: CompilerConfiguration
|
||||
) {
|
||||
this.project = project
|
||||
doRegisterExtensions(configuration)
|
||||
// Registration is done via ExtensionStorage in Kotlin 2.4+.
|
||||
// This legacy entry point remains for compatibility with service discovery.
|
||||
}
|
||||
|
||||
private var project: MockProject? = null
|
||||
private var extensionStorage: CompilerPluginRegistrar.ExtensionStorage? = null
|
||||
|
||||
override fun ExtensionStorage.registerExtensions(configuration: CompilerConfiguration) {
|
||||
@@ -37,15 +36,10 @@ abstract class Kotlin2ComponentRegistrar : CompilerPluginRegistrar(), ComponentR
|
||||
abstract fun doRegisterExtensions(configuration: CompilerConfiguration)
|
||||
|
||||
protected fun registerExtractorExtension(extension: IrGenerationExtension) {
|
||||
extensionStorage?.let { storage ->
|
||||
with(storage) {
|
||||
IrGenerationExtension.registerExtension(extension)
|
||||
}
|
||||
return
|
||||
val storage = extensionStorage
|
||||
?: throw IllegalStateException("registerExtractorExtension called before registerExtensions")
|
||||
with(storage) {
|
||||
IrGenerationExtension.registerExtension(extension)
|
||||
}
|
||||
// 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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user