diff --git a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/codeInsight/OutOfBlockModificationTestGenerated.java b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/codeInsight/OutOfBlockModificationTestGenerated.java index 70761348b9b4..e51891b2d071 100644 --- a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/codeInsight/OutOfBlockModificationTestGenerated.java +++ b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/codeInsight/OutOfBlockModificationTestGenerated.java @@ -468,6 +468,11 @@ public class OutOfBlockModificationTestGenerated extends AbstractOutOfBlockModif runTest("testData/codeInsight/outOfBlock/StringInSuperConstroctorCall.kt"); } + @TestMetadata("Suppression.kt") + public void testSuppression() throws Exception { + runTest("testData/codeInsight/outOfBlock/Suppression.kt"); + } + @TestMetadata("Uncomment.kt") public void testUncomment() throws Exception { runTest("testData/codeInsight/outOfBlock/Uncomment.kt"); diff --git a/plugins/kotlin/idea/tests/testData/codeInsight/outOfBlock/Suppression.kt b/plugins/kotlin/idea/tests/testData/codeInsight/outOfBlock/Suppression.kt new file mode 100644 index 000000000000..ff91d880ebe6 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/codeInsight/outOfBlock/Suppression.kt @@ -0,0 +1,19 @@ +// WITH_STDLIB +// OUT_OF_CODE_BLOCK: FALSE +// SKIP_ANALYZE_CHECK +// TYPE: '"' +// INSPECTION-CLASS: org.jetbrains.kotlin.idea.inspections.KotlinRedundantDiagnosticSuppressInspection +// NO-INSPECTION-OUTPUT +// inspection message `[GENERIC_ERROR_OR_WARNING:8] Redundant suppression` should not appear, therefore `NO-INSPECTION-OUTPUT` +fun convertToMap(converted: Map<*, *>): Map? { + @Suppress("UNCHECKED_CAST") + return converted as Map? +} + +fun main() { + val s = "hello + when (s) { + "hello" -> println(s) + else -> {} + } +} \ No newline at end of file diff --git a/plugins/kotlin/test-framework/test/org/jetbrains/kotlin/idea/test/DirectiveBasedActionUtils.kt b/plugins/kotlin/test-framework/test/org/jetbrains/kotlin/idea/test/DirectiveBasedActionUtils.kt index 7466ba525b88..dd63ac947013 100644 --- a/plugins/kotlin/test-framework/test/org/jetbrains/kotlin/idea/test/DirectiveBasedActionUtils.kt +++ b/plugins/kotlin/test-framework/test/org/jetbrains/kotlin/idea/test/DirectiveBasedActionUtils.kt @@ -18,6 +18,7 @@ import org.jetbrains.kotlin.idea.inspections.AbstractKotlinInspection import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.resolve.diagnostics.Diagnostics import java.io.File +import kotlin.test.assertTrue object DirectiveBasedActionUtils { @@ -97,17 +98,23 @@ object DirectiveBasedActionUtils { /* progress = */ DaemonProgressIndicator(), ) - val directive = "// INSPECTION:" - val expected = InTextDirectivesUtils.findLinesWithPrefixesRemoved(file.text, directive) + val directive = "INSPECTION" + val expected = InTextDirectivesUtils.findLinesWithPrefixesRemoved(file.text, "// $directive:") .sorted() .map { "$directive $it" } + val noInspectionOutputDirective = "NO-INSPECTION-OUTPUT" + val noInspectionOutput = InTextDirectivesUtils.isDirectiveDefined(file.text, "// $noInspectionOutputDirective") + val actual = problems // lineNumber is 0-based .map { "$directive [${it.highlightType.name}:${it.lineNumber + 1}] $it" } .sorted() - if (actual.isEmpty() && expected.isEmpty()) return + if (actual.isEmpty() && expected.isEmpty()) { + assertTrue(noInspectionOutput, "`$noInspectionOutputDirective` directive has to be defined if there is nothing to report") + return + } KotlinLightCodeInsightFixtureTestCaseBase.assertOrderedEquals( "All actual $name should be mentioned in test data with '$directive' directive. " +