"Remove redundant backticks": Fix false positive for yield #KT-25968 Fixed

This commit is contained in:
Toshiaki Kameyama
2018-08-17 22:40:41 +09:00
committed by Mikhail Glukhikh
parent 362e6863ac
commit b34f32d4f3
3 changed files with 19 additions and 5 deletions
@@ -46,7 +46,7 @@ class RemoveRedundantBackticksInspection : AbstractKotlinInspection() {
} }
private fun isKeyword(text: String): Boolean { private fun isKeyword(text: String): Boolean {
return (KtTokens.KEYWORDS.types + KtTokens.SOFT_KEYWORDS.types).any { it.toString() == text } return text == "yield" || (KtTokens.KEYWORDS.types + KtTokens.SOFT_KEYWORDS.types).any { it.toString() == text }
} }
private fun isRedundantBackticks(node: ASTNode): Boolean { private fun isRedundantBackticks(node: ASTNode): Boolean {
@@ -57,10 +57,12 @@ class RemoveRedundantBackticksInspection : AbstractKotlinInspection() {
} }
private fun registerProblem(holder: ProblemsHolder, element: PsiElement) { private fun registerProblem(holder: ProblemsHolder, element: PsiElement) {
holder.registerProblem(element, holder.registerProblem(
"Remove redundant backticks", element,
ProblemHighlightType.GENERIC_ERROR_OR_WARNING, "Remove redundant backticks",
RemoveRedundantBackticksQuickFix()) ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
RemoveRedundantBackticksQuickFix()
)
} }
} }
@@ -0,0 +1,7 @@
// PROBLEM: none
fun test() {
foo(<caret>`yield` = 1)
}
fun foo(yield: Int) {}
@@ -4586,6 +4586,11 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest {
public void testProperty() throws Exception { public void testProperty() throws Exception {
runTest("idea/testData/inspectionsLocal/removeRedundantBackticks/property.kt"); runTest("idea/testData/inspectionsLocal/removeRedundantBackticks/property.kt");
} }
@TestMetadata("yield.kt")
public void testYield() throws Exception {
runTest("idea/testData/inspectionsLocal/removeRedundantBackticks/yield.kt");
}
} }
@TestMetadata("idea/testData/inspectionsLocal/removeRedundantSpreadOperator") @TestMetadata("idea/testData/inspectionsLocal/removeRedundantSpreadOperator")