11package com.github.codeql
22
33import com.intellij.mock.MockProject
4- import com.intellij.openapi.extensions.LoadingOrder
54import org.jetbrains.kotlin.backend.common.extensions.IrGenerationExtension
6- import org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar
75import org.jetbrains.kotlin.compiler.plugin.CompilerPluginRegistrar
86import org.jetbrains.kotlin.compiler.plugin.ExperimentalCompilerApi
97import org.jetbrains.kotlin.config.CompilerConfiguration
108
119@OptIn(ExperimentalCompilerApi ::class )
1210@Suppress(" DEPRECATION" , " DEPRECATION_ERROR" )
13- abstract class Kotlin2ComponentRegistrar : CompilerPluginRegistrar (), ComponentRegistrar {
11+ abstract class Kotlin2ComponentRegistrar :
12+ CompilerPluginRegistrar (),
13+ org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar {
1414 override val supportsK2: Boolean
1515 get() = true
1616
@@ -22,11 +22,10 @@ abstract class Kotlin2ComponentRegistrar : CompilerPluginRegistrar(), ComponentR
2222 project : MockProject ,
2323 configuration : CompilerConfiguration
2424 ) {
25- this .project = project
26- doRegisterExtensions(configuration)
25+ // Registration is done via ExtensionStorage in Kotlin 2.4+.
26+ // This legacy entry point remains for compatibility with service discovery.
2727 }
2828
29- private var project: MockProject ? = null
3029 private var extensionStorage: CompilerPluginRegistrar .ExtensionStorage ? = null
3130
3231 override fun ExtensionStorage.registerExtensions (configuration : CompilerConfiguration ) {
@@ -37,15 +36,10 @@ abstract class Kotlin2ComponentRegistrar : CompilerPluginRegistrar(), ComponentR
3736 abstract fun doRegisterExtensions (configuration : CompilerConfiguration )
3837
3938 protected fun registerExtractorExtension (extension : IrGenerationExtension ) {
40- extensionStorage?.let { storage ->
41- with (storage) {
42- IrGenerationExtension .registerExtension(extension)
43- }
44- return
39+ val storage = extensionStorage
40+ ? : throw IllegalStateException (" registerExtractorExtension called before registerExtensions" )
41+ with (storage) {
42+ IrGenerationExtension .registerExtension(extension)
4543 }
46- // Fallback for ComponentRegistrar-based registration to keep legacy ordering semantics.
47- val p = project ? : throw IllegalStateException (" registerExtractorExtension called before registration" )
48- val extensionPoint = p.extensionArea.getExtensionPoint(IrGenerationExtension .extensionPointName)
49- extensionPoint.registerExtension(extension, LoadingOrder .LAST , p)
5044 }
5145}
0 commit comments