Remove redundant backticks: fix false positive for multiple underscores
#KT-37496 Fixed
This commit is contained in:
committed by
Ilya Kirillov
parent
34cfe7dfdb
commit
6eebe21897
+2
-3
@@ -46,9 +46,8 @@ class RemoveRedundantBackticksInspection : AbstractKotlinInspection() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun isKeyword(text: String): Boolean {
|
private fun isKeyword(text: String): Boolean =
|
||||||
return text == "yield" || text == "_" || (KtTokens.KEYWORDS.types + KtTokens.SOFT_KEYWORDS.types).any { it.toString() == text }
|
text == "yield" || text.all { it == '_' } || (KtTokens.KEYWORDS.types + KtTokens.SOFT_KEYWORDS.types).any { it.toString() == text }
|
||||||
}
|
|
||||||
|
|
||||||
private fun isRedundantBackticks(node: ASTNode): Boolean {
|
private fun isRedundantBackticks(node: ASTNode): Boolean {
|
||||||
val text = node.text
|
val text = node.text
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
// PROBLEM: none
|
||||||
|
fun test() {
|
||||||
|
val <caret>`__` = ""
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
// PROBLEM: none
|
||||||
|
fun test() {
|
||||||
|
val <caret>`__________` = ""
|
||||||
|
}
|
||||||
+10
@@ -8819,6 +8819,16 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest {
|
|||||||
runTest("idea/testData/inspectionsLocal/removeRedundantBackticks/underscore.kt");
|
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")
|
@TestMetadata("yield.kt")
|
||||||
public void testYield() throws Exception {
|
public void testYield() throws Exception {
|
||||||
runTest("idea/testData/inspectionsLocal/removeRedundantBackticks/yield.kt");
|
runTest("idea/testData/inspectionsLocal/removeRedundantBackticks/yield.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user