Rewrite IDE check whether serialization plugin is enabled
In a such way so it wouldn't check for actual JAR file and wouldn't touch filesystem. Fixes KT-32346
This commit is contained in:
+8
-2
@@ -16,14 +16,20 @@
|
||||
|
||||
package org.jetbrains.kotlinx.serialization.idea
|
||||
|
||||
import org.jetbrains.kotlin.utils.PathUtil
|
||||
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
||||
import org.jetbrains.kotlin.idea.facet.KotlinFacet
|
||||
import org.jetbrains.kotlin.utils.PathUtil
|
||||
import java.io.File
|
||||
|
||||
internal object KotlinSerializationImportHandler {
|
||||
private const val pluginJpsJarName = "kotlinx-serialization-compiler-plugin.jar"
|
||||
|
||||
val PLUGIN_JPS_JAR: String
|
||||
get() = File(PathUtil.kotlinPathsForIdeaPlugin.libPath, "kotlinx-serialization-compiler-plugin.jar").absolutePath
|
||||
get() = File(PathUtil.kotlinPathsForIdeaPlugin.libPath, pluginJpsJarName).absolutePath
|
||||
|
||||
fun isPluginJarPath(path: String): Boolean {
|
||||
return path.endsWith(pluginJpsJarName)
|
||||
}
|
||||
|
||||
fun modifyCompilerArguments(facet: KotlinFacet, buildSystemPluginJar: String) {
|
||||
val facetSettings = facet.configuration.settings
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ fun <T> getIfEnabledOn(clazz: ClassDescriptor, body: () -> T): T? {
|
||||
val module = clazz.module.getCapability(ModuleInfo.Capability)?.unwrapModuleSourceInfo()?.module ?: return null
|
||||
val facet = KotlinFacet.get(module) ?: return null
|
||||
val pluginClasspath = facet.configuration.settings.compilerArguments?.pluginClasspaths ?: return null
|
||||
if (pluginClasspath.none { it == KotlinSerializationImportHandler.PLUGIN_JPS_JAR }) return null
|
||||
if (pluginClasspath.none(KotlinSerializationImportHandler::isPluginJarPath)) return null
|
||||
return body()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user