Compiler plugins: Refactor Maven import handlers in order to support other plugin options

This commit is contained in:
Yan Zhulanow
2017-12-15 18:32:02 +09:00
parent a85b4ddb0f
commit 3512675d96
6 changed files with 28 additions and 27 deletions
@@ -17,6 +17,8 @@
package org.jetbrains.kotlin.samWithReceiver.ide
import org.jetbrains.kotlin.annotation.plugin.ide.AbstractMavenImportHandler
import org.jetbrains.kotlin.annotation.plugin.ide.AnnotationBasedCompilerPluginSetup
import org.jetbrains.kotlin.annotation.plugin.ide.AnnotationBasedCompilerPluginSetup.PluginOption
import org.jetbrains.kotlin.samWithReceiver.SamWithReceiverCommandLineProcessor
import org.jetbrains.kotlin.utils.PathUtil
@@ -27,11 +29,10 @@ class SamWithReceiverMavenProjectImportHandler : AbstractMavenImportHandler() {
override val compilerPluginId = SamWithReceiverCommandLineProcessor.PLUGIN_ID
override val pluginName = "samWithReceiver"
override val annotationOptionName = SamWithReceiverCommandLineProcessor.ANNOTATION_OPTION.name
override val mavenPluginArtifactName = "kotlin-maven-sam-with-receiver"
override val pluginJarFileFromIdea = PathUtil.kotlinPathsForIdeaPlugin.allOpenPluginJarPath
override fun getAnnotations(enabledCompilerPlugins: List<String>, compilerPluginOptions: List<String>): List<String>? {
override fun getOptions(enabledCompilerPlugins: List<String>, compilerPluginOptions: List<String>): List<PluginOption>? {
if ("sam-with-receiver" !in enabledCompilerPlugins) {
return null
}
@@ -49,6 +50,6 @@ class SamWithReceiverMavenProjectImportHandler : AbstractMavenImportHandler() {
text.substring(ANNOTATION_PARAMETER_PREFIX.length)
})
return annotations
return annotations.map { PluginOption(SamWithReceiverCommandLineProcessor.ANNOTATION_OPTION.name, it) }
}
}