com.jetbrains.plugin.structure.intellij.problems.JetBrainsPluginCreationResultResolver.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of structure-intellij Show documentation
Show all versions of structure-intellij Show documentation
Library for parsing JetBrains IDE plugins. Can be used to verify that plugin complies with the JetBrains Marketplace requirements.
package com.jetbrains.plugin.structure.intellij.problems
import com.jetbrains.plugin.structure.base.plugin.PluginCreationResult
import com.jetbrains.plugin.structure.base.problems.PluginProblem
import com.jetbrains.plugin.structure.intellij.plugin.IdePlugin
import com.jetbrains.plugin.structure.intellij.plugin.PluginVendors
import com.jetbrains.plugin.structure.intellij.problems.remapping.JsonUrlProblemLevelRemappingManager
import com.jetbrains.plugin.structure.intellij.problems.remapping.RemappingSet
import java.io.IOException
import kotlin.reflect.KClass
class JetBrainsPluginCreationResultResolver(private val delegatedResolver: PluginCreationResultResolver,
levelRemapping: Map, RemappedLevel> = emptyMap()
) : PluginCreationResultResolver {
private val jetBrainsResolver = LevelRemappingPluginCreationResultResolver(delegatedResolver,
levelRemapping, unwrapRemappedProblems = true)
override fun resolve(plugin: IdePlugin, problems: List): PluginCreationResult {
return getCreationResultResolver(plugin).resolve(plugin, problems)
}
override fun classify(plugin: IdePlugin, problems: List): List {
return getCreationResultResolver(plugin).classify(plugin, problems)
}
private fun getCreationResultResolver(plugin: IdePlugin): PluginCreationResultResolver {
return if (PluginVendors.isDevelopedByJetBrains(plugin)) {
jetBrainsResolver
} else {
delegatedResolver
}
}
companion object {
@Throws(IOException::class)
fun fromClassPathJson(delegatedResolver: PluginCreationResultResolver): JetBrainsPluginCreationResultResolver {
val levelRemappingManager = JsonUrlProblemLevelRemappingManager.fromClassPathJson()
val levelRemapping = levelRemappingManager.getLevelRemapping(RemappingSet.JETBRAINS_PLUGIN_REMAPPING_SET)
return JetBrainsPluginCreationResultResolver(delegatedResolver, levelRemapping)
}
}
}