[Plugins] Introduce new API for registering compiler plugins

Original `ComponentRegistrar` exposes Project to its registration method,
  so plugins should manually register extensions to it. To prepare for
  possible unbound compiler from Project API in future new  `K2ComponentRegistrar`
  introduced which provides registration method without Project at all
This commit is contained in:
Dmitriy Novozhilov
2022-06-07 10:23:09 +03:00
committed by teamcity
parent bb996c1b27
commit 8b42638afa
56 changed files with 392 additions and 191 deletions
@@ -30,12 +30,15 @@ class TestCommandLineProcessor : CommandLineProcessor {
}
}
class TestKotlinPluginRegistrar : ComponentRegistrar {
override fun registerProjectComponents(project: MockProject, configuration: CompilerConfiguration) {
class TestKotlinPluginRegistrar : CompilerPluginRegistrar() {
override fun ExtensionStorage.registerExtensions(configuration: CompilerConfiguration) {
val collector = configuration.get(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY)!!
val option = configuration.get(TestPluginKeys.TestOption)!!
collector.report(CompilerMessageSeverity.INFO, "Plugin applied")
collector.report(CompilerMessageSeverity.INFO, "Option value: $option")
}
override val supportsK2: Boolean
get() = true
}