"Remove redundant backticks": Fix false positive for underscore

#KT-28592 Fixed
This commit is contained in:
Toshiaki Kameyama
2018-12-25 10:51:05 +09:00
committed by Mikhail Glukhikh
parent 84222afe2f
commit d00236d366
3 changed files with 14 additions and 1 deletions
@@ -46,7 +46,7 @@ class RemoveRedundantBackticksInspection : AbstractKotlinInspection() {
}
private fun isKeyword(text: String): Boolean {
return text == "yield" || (KtTokens.KEYWORDS.types + KtTokens.SOFT_KEYWORDS.types).any { it.toString() == text }
return text == "yield" || text == "_" || (KtTokens.KEYWORDS.types + KtTokens.SOFT_KEYWORDS.types).any { it.toString() == text }
}
private fun isRedundantBackticks(node: ASTNode): Boolean {
@@ -0,0 +1,8 @@
// PROBLEM: none
fun test() {
try {
} catch (_: Throwable) {
<caret>`_`.printStackTrace()
}
}
@@ -5474,6 +5474,11 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest {
runTest("idea/testData/inspectionsLocal/removeRedundantBackticks/property.kt");
}
@TestMetadata("underscore.kt")
public void testUnderscore() throws Exception {
runTest("idea/testData/inspectionsLocal/removeRedundantBackticks/underscore.kt");
}
@TestMetadata("yield.kt")
public void testYield() throws Exception {
runTest("idea/testData/inspectionsLocal/removeRedundantBackticks/yield.kt");