ComplexRedundantLetInspection: fix highlight for multiple line receiver
#KT-31278 Fixed
This commit is contained in:
@@ -224,12 +224,12 @@ private fun KtFunctionLiteral.valueParameterReferences(callExpression: KtCallExp
|
||||
|
||||
private fun isSingleLine(element: KtCallExpression): Boolean {
|
||||
val qualifiedExpression = element.getQualifiedExpressionForSelector() ?: return true
|
||||
var receiver = qualifiedExpression.receiverExpression as? KtQualifiedExpression ?: return true
|
||||
var receiver = qualifiedExpression.receiverExpression
|
||||
if (receiver.lineCount() > 1) return false
|
||||
var count = 1
|
||||
while (true) {
|
||||
if (count > 2) return false
|
||||
receiver = receiver.receiverExpression as? KtQualifiedExpression ?: break
|
||||
receiver = (receiver as? KtQualifiedExpression)?.receiverExpression ?: break
|
||||
count++
|
||||
}
|
||||
return true
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
// WITH_RUNTIME
|
||||
// HIGHLIGHT: INFORMATION
|
||||
|
||||
fun test() {
|
||||
runCatching {
|
||||
/* lots of code*/
|
||||
}.let<caret> { println(it) }
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// WITH_RUNTIME
|
||||
// HIGHLIGHT: INFORMATION
|
||||
|
||||
fun test() {
|
||||
println(runCatching {
|
||||
/* lots of code*/
|
||||
})
|
||||
}
|
||||
+5
@@ -2313,6 +2313,11 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest {
|
||||
runTest("idea/testData/inspectionsLocal/complexRedundantLet/longCallChain.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("multipleLines.kt")
|
||||
public void testMultipleLines() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/complexRedundantLet/multipleLines.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("multipleReceiver.kt")
|
||||
public void testMultipleReceiver() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/complexRedundantLet/multipleReceiver.kt");
|
||||
|
||||
Reference in New Issue
Block a user