Unnecessary parentheses in function call with lambda: don't report for function named 'suspend'

#KT-22878 Fixed
This commit is contained in:
Toshiaki Kameyama
2020-01-27 18:16:25 +09:00
committed by Yan Zhulanow
parent 777995a3a0
commit 581f83421a
3 changed files with 12 additions and 0 deletions
@@ -31,6 +31,7 @@ class RemoveEmptyParenthesesFromLambdaCallIntention : SelfTargetingRangeIntentio
override fun applicabilityRange(element: KtValueArgumentList): TextRange? {
if (element.arguments.isNotEmpty()) return null
val parent = element.parent as? KtCallExpression ?: return null
if (parent.calleeExpression?.text == "suspend") return null
val singleLambdaArgument = parent.lambdaArguments.singleOrNull() ?: return null
if (element.getLineNumber(start = false) != singleLambdaArgument.getLineNumber(start = true)) return null
val prev = element.getPrevSiblingIgnoringWhitespaceAndComments()
@@ -0,0 +1,6 @@
// IS_APPLICABLE: false
fun suspend(body: () -> Int) {}
fun main() {
val wInvokeCall = suspend()<caret> { 42 }
}
@@ -13520,6 +13520,11 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
public void testSimple() throws Exception {
runTest("idea/testData/intentions/removeEmptyParenthesesFromLambdaCall/simple.kt");
}
@TestMetadata("suspend.kt")
public void testSuspend() throws Exception {
runTest("idea/testData/intentions/removeEmptyParenthesesFromLambdaCall/suspend.kt");
}
}
@TestMetadata("idea/testData/intentions/removeEmptyPrimaryConstructor")