diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/RemoveRedundantBackticksInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/RemoveRedundantBackticksInspection.kt index 42668584e23..67e2d4648a3 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/RemoveRedundantBackticksInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/RemoveRedundantBackticksInspection.kt @@ -46,9 +46,8 @@ class RemoveRedundantBackticksInspection : AbstractKotlinInspection() { } } - private fun isKeyword(text: String): Boolean { - return text == "yield" || text == "_" || (KtTokens.KEYWORDS.types + KtTokens.SOFT_KEYWORDS.types).any { it.toString() == text } - } + private fun isKeyword(text: String): Boolean = + text == "yield" || text.all { it == '_' } || (KtTokens.KEYWORDS.types + KtTokens.SOFT_KEYWORDS.types).any { it.toString() == text } private fun isRedundantBackticks(node: ASTNode): Boolean { val text = node.text diff --git a/idea/testData/inspectionsLocal/removeRedundantBackticks/underscores.kt b/idea/testData/inspectionsLocal/removeRedundantBackticks/underscores.kt new file mode 100644 index 00000000000..16207e24a88 --- /dev/null +++ b/idea/testData/inspectionsLocal/removeRedundantBackticks/underscores.kt @@ -0,0 +1,4 @@ +// PROBLEM: none +fun test() { + val `__` = "" +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/removeRedundantBackticks/underscores2.kt b/idea/testData/inspectionsLocal/removeRedundantBackticks/underscores2.kt new file mode 100644 index 00000000000..4b5ced0955e --- /dev/null +++ b/idea/testData/inspectionsLocal/removeRedundantBackticks/underscores2.kt @@ -0,0 +1,4 @@ +// PROBLEM: none +fun test() { + val `__________` = "" +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/inspections/LocalInspectionTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/inspections/LocalInspectionTestGenerated.java index 90879b66bf9..6a07491616d 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/inspections/LocalInspectionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/inspections/LocalInspectionTestGenerated.java @@ -8819,6 +8819,16 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest { runTest("idea/testData/inspectionsLocal/removeRedundantBackticks/underscore.kt"); } + @TestMetadata("underscores.kt") + public void testUnderscores() throws Exception { + runTest("idea/testData/inspectionsLocal/removeRedundantBackticks/underscores.kt"); + } + + @TestMetadata("underscores2.kt") + public void testUnderscores2() throws Exception { + runTest("idea/testData/inspectionsLocal/removeRedundantBackticks/underscores2.kt"); + } + @TestMetadata("yield.kt") public void testYield() throws Exception { runTest("idea/testData/inspectionsLocal/removeRedundantBackticks/yield.kt");