package org.jetbrains.skiko

import org.jetbrains.kotlin.backend.common.extensions.IrGenerationExtension
import org.jetbrains.kotlin.compiler.plugin.CompilerPluginRegistrar
import org.jetbrains.kotlin.compiler.plugin.ExperimentalCompilerApi
import org.jetbrains.kotlin.config.CompilerConfiguration

@OptIn(ExperimentalCompilerApi::class)
class ImportGeneratorRegistrar : CompilerPluginRegistrar() {
    override val supportsK2: Boolean = true

    override fun ExtensionStorage.registerExtensions(
        configuration: CompilerConfiguration,
    ) {
        IrGenerationExtension.registerExtension(
            ImportGeneratorExtension(
                configuration.get(ImportGeneratorConfigurationKeys.PATH)!!,
                configuration.get(ImportGeneratorConfigurationKeys.PREFIX),
                configuration.get(ImportGeneratorConfigurationKeys.REEXPORT_PATH)
            )
        )
    }
}