Tóth István Zoltán
11/06/2023, 12:30 PMclass Z2CompilerPluginRegistrar : CompilerPluginRegistrar() {
override val supportsK2 = true
override fun ExtensionStorage.registerExtensions(configuration: CompilerConfiguration) {
val options = Z2Options(
resourceOutputDir = configuration.get(Z2Options.CONFIG_KEY_RESOURCE_DIR)!!
)
FirExtensionRegistrarAdapter.registerExtension(Z2PluginRegistrar())
IrGenerationExtension.registerExtension(Z2GenerationExtension(options))
}
}
The Z2PluginRegistrar is also very simple:
class Z2PluginRegistrar : FirExtensionRegistrar() {
init {
debug("Z2PluginRegistrar")
}
override fun ExtensionRegistrarContext.configurePlugin() {
debug("configurePlugin")
+::SchematicDeclarationGenerator
}
}
The debug interestingly contains the init
part but it does not contain the configurePlugin
part. What do I do wrong? The FIR part worked well before, I might made a mistake during some refactoring but I can't figure out where the problem is.
The source code is public (this library is not officially published yet, so it's not even close to clean): https://github.com/spxbhuhb/z2/tree/main/z2-kotlin-plugin
Any help would be appreciated, thanks in advance.Javier
11/06/2023, 12:55 PMJavier
11/06/2023, 12:56 PMJavier
11/06/2023, 12:57 PMTóth István Zoltán
11/06/2023, 1:00 PMhfhbd
11/20/2023, 2:50 PMconfigurePlugin
is never called. Or do we need to call it somehow by ourself?Javier
11/20/2023, 3:11 PMCompilerPluginRegistrar
to add it to the services
• inside fun ExtensionStorage.registerExtensions(configuration: CompilerConfiguration)
, call FirExtensionRegistrarAdapter.registerExtension(SomeFirExtension())
• SomeFirExtension
extends FirExtensionRegistrar
, and fun ExtensionRegistrarContext.configurePlugin()
adds extensions, mainly I am using FirDeclarationGenerationExtension
.
The previous setup is working in both, tests with the official test framework, and in IDEA, building it from IntelliJ Community sources.hfhbd
11/20/2023, 3:32 PMdev.zacsweers.kctfork
but this framework does not support 2.0.0-Beta1Javier
11/20/2023, 3:35 PMtest
, testData
and test-gen
.
About kctfork, I have no idea, I haven’t used it before.Javier
11/20/2023, 3:40 PMtest
you register the extensions and config everything
• Inside testData
you put the Kotlin files to compile
• Inside test-gen
the tests are generated based on the content of testData
. To generate the tests you need to run a Gradle taskhfhbd
11/20/2023, 3:44 PMTóth István Zoltán
12/05/2023, 12:55 PMTóth István Zoltán
12/06/2023, 1:18 PM