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 {
|
private fun isSingleLine(element: KtCallExpression): Boolean {
|
||||||
val qualifiedExpression = element.getQualifiedExpressionForSelector() ?: return true
|
val qualifiedExpression = element.getQualifiedExpressionForSelector() ?: return true
|
||||||
var receiver = qualifiedExpression.receiverExpression as? KtQualifiedExpression ?: return true
|
var receiver = qualifiedExpression.receiverExpression
|
||||||
if (receiver.lineCount() > 1) return false
|
if (receiver.lineCount() > 1) return false
|
||||||
var count = 1
|
var count = 1
|
||||||
while (true) {
|
while (true) {
|
||||||
if (count > 2) return false
|
if (count > 2) return false
|
||||||
receiver = receiver.receiverExpression as? KtQualifiedExpression ?: break
|
receiver = (receiver as? KtQualifiedExpression)?.receiverExpression ?: break
|
||||||
count++
|
count++
|
||||||
}
|
}
|
||||||
return true
|
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");
|
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")
|
@TestMetadata("multipleReceiver.kt")
|
||||||
public void testMultipleReceiver() throws Exception {
|
public void testMultipleReceiver() throws Exception {
|
||||||
runTest("idea/testData/inspectionsLocal/complexRedundantLet/multipleReceiver.kt");
|
runTest("idea/testData/inspectionsLocal/complexRedundantLet/multipleReceiver.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user