diff --git a/intellij-plugin-structure/structure-intellij/src/main/java/com/jetbrains/plugin/structure/intellij/problems/LevelRemappingPluginCreationResultResolver.kt b/intellij-plugin-structure/structure-intellij/src/main/java/com/jetbrains/plugin/structure/intellij/problems/LevelRemappingPluginCreationResultResolver.kt index 3c4f51476c..316a37e76a 100644 --- a/intellij-plugin-structure/structure-intellij/src/main/java/com/jetbrains/plugin/structure/intellij/problems/LevelRemappingPluginCreationResultResolver.kt +++ b/intellij-plugin-structure/structure-intellij/src/main/java/com/jetbrains/plugin/structure/intellij/problems/LevelRemappingPluginCreationResultResolver.kt @@ -58,31 +58,22 @@ class LevelRemappingPluginCreationResultResolver(private val delegatedResolver: } private fun remapPluginProblemLevel(pluginProblem: PluginProblem): PluginProblem? { - return remapPluginProblemLevel(pluginProblem, unwrapRemappedProblems) - } - - private fun remapPluginProblemLevel(pluginProblem: PluginProblem, unwrapRemappedProblems: Boolean): PluginProblem? { - val problem = if (unwrapRemappedProblems) { - pluginProblem.unwrapped - } else { - pluginProblem - } - - return when (val remappedLevel = remappedLevel[problem::class]) { - is StandardLevel -> ReclassifiedPluginProblem(remappedLevel.originalLevel, pluginProblem) - is IgnoredLevel -> null - null -> pluginProblem - } + return classify(pluginProblem) } override fun classify(plugin: IdePlugin, problems: List): List { return delegatedResolver.classify(plugin, problems).mapNotNull { - classify(it.unwrapped) + classify(it) } } private fun classify(pluginProblem: PluginProblem): PluginProblem? { - return when (val remappedLevel = remappedLevel[pluginProblem::class]) { + val problem = if (unwrapRemappedProblems) { + pluginProblem.unwrapped + } else { + pluginProblem + } + return when (val remappedLevel = remappedLevel[problem::class]) { is StandardLevel -> ReclassifiedPluginProblem(remappedLevel.originalLevel, pluginProblem) is IgnoredLevel -> null null -> pluginProblem diff --git a/intellij-plugin-verifier/verifier-test/src/test/java/com/jetbrains/pluginverifier/tests/LevelRemappingTest.kt b/intellij-plugin-verifier/verifier-test/src/test/java/com/jetbrains/pluginverifier/tests/LevelRemappingTest.kt index 4ac7881b3b..e08d6958f0 100644 --- a/intellij-plugin-verifier/verifier-test/src/test/java/com/jetbrains/pluginverifier/tests/LevelRemappingTest.kt +++ b/intellij-plugin-verifier/verifier-test/src/test/java/com/jetbrains/pluginverifier/tests/LevelRemappingTest.kt @@ -2,9 +2,7 @@ package com.jetbrains.pluginverifier.tests import com.jetbrains.plugin.structure.base.problems.PluginProblem import com.jetbrains.plugin.structure.intellij.plugin.IdePluginImpl -import com.jetbrains.plugin.structure.intellij.problems.LevelRemappingPluginCreationResultResolver -import com.jetbrains.plugin.structure.intellij.problems.ReleaseVersionAndPluginVersionMismatch -import com.jetbrains.plugin.structure.intellij.problems.ignore +import com.jetbrains.plugin.structure.intellij.problems.* import com.jetbrains.plugin.structure.intellij.problems.remapping.JsonUrlProblemLevelRemappingManager import com.jetbrains.plugin.structure.intellij.problems.remapping.RemappingSet import com.jetbrains.plugin.structure.intellij.version.ProductReleaseVersion @@ -28,6 +26,21 @@ class LevelRemappingTest { assertEmpty(remappedProblems) } + @Test + fun `problem is remapped according to JSON rules and not remapped again`() { + val existingPluginResolver = JsonUrlProblemLevelRemappingManager + .fromClassPathJson() + .newDefaultResolver(RemappingSet.EXISTING_PLUGIN_REMAPPING_SET) + val ignoringProblemResolver = LevelRemappingPluginCreationResultResolver(existingPluginResolver, ignore()) + + val problems = listOf( + ReleaseVersionWrongFormat(PLUGIN_XML, "1") + ) + + val remappedProblems = ignoringProblemResolver.classify(IdePluginImpl(), problems).filter { it.level == PluginProblem.Level.ERROR } + assertEmpty(remappedProblems) + } + private fun assertEmpty(problems: List) { if (problems.isNotEmpty()) { fail("No problems were expected, but found ${problems.size}: " + problems.joinToString { it.message })