Remove redundant backticks: fix false positive for multiple underscores

#KT-37496 Fixed
This commit is contained in:
Toshiaki Kameyama
2020-03-14 15:27:26 +09:00
committed by Ilya Kirillov
parent 34cfe7dfdb
commit 6eebe21897
4 changed files with 20 additions and 3 deletions
@@ -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
@@ -0,0 +1,4 @@
// PROBLEM: none
fun test() {
val <caret>`__` = ""
}
@@ -0,0 +1,4 @@
// PROBLEM: none
fun test() {
val <caret>`__________` = ""
}
@@ -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");