From 4901cdb11ff4d25ab516ca79f0983dc3dde05c9b Mon Sep 17 00:00:00 2001 From: Toshiaki Kameyama Date: Mon, 20 Jul 2020 17:07:33 +0900 Subject: [PATCH] ConvertCallChainIntoSequence: support functions added in Kotlin 1.4 #KT-40448 Fixed --- .../ConvertCallChainIntoSequenceInspection.kt | 27 +++- .../allTransformations.kt | 1 + .../allTransformations.kt.after | 1 + .../termination/maxByOrNull.kt | 5 + .../termination/maxByOrNull.kt.after | 5 + .../termination/maxOf.kt | 5 + .../termination/maxOf.kt.after | 5 + .../termination/maxOfOrNull.kt | 5 + .../termination/maxOfOrNull.kt.after | 5 + .../termination/maxOfWith.kt | 5 + .../termination/maxOfWith.kt.after | 5 + .../termination/maxOfWithOrNull.kt | 5 + .../termination/maxOfWithOrNull.kt.after | 5 + .../termination/maxOrNull.kt | 5 + .../termination/maxOrNull.kt.after | 5 + .../termination/maxWithOrNull.kt | 5 + .../termination/maxWithOrNull.kt.after | 5 + .../termination/minByOrNull.kt | 5 + .../termination/minByOrNull.kt.after | 5 + .../termination/minOf.kt | 5 + .../termination/minOf.kt.after | 5 + .../termination/minOfOrNull.kt | 5 + .../termination/minOfOrNull.kt.after | 5 + .../termination/minOfWith.kt | 5 + .../termination/minOfWith.kt.after | 5 + .../termination/minOfWithOrNull.kt | 5 + .../termination/minOfWithOrNull.kt.after | 5 + .../termination/minOrNull.kt | 5 + .../termination/minOrNull.kt.after | 5 + .../termination/minWithOrNull.kt | 5 + .../termination/minWithOrNull.kt.after | 5 + .../termination/reduceIndexedOrNull.kt | 5 + .../termination/reduceIndexedOrNull.kt.after | 5 + .../termination/reduceOrNull.kt | 5 + .../termination/reduceOrNull.kt.after | 5 + .../termination/runningFold.kt | 5 + .../termination/runningFold.kt.after | 5 + .../termination/runningFoldIndexed.kt | 5 + .../termination/runningFoldIndexed.kt.after | 5 + .../termination/runningReduce.kt | 5 + .../termination/runningReduce.kt.after | 5 + .../termination/runningReduceIndexed.kt | 5 + .../termination/runningReduceIndexed.kt.after | 5 + .../termination/scan.kt | 5 + .../termination/scan.kt.after | 5 + .../termination/scanIndexed.kt | 5 + .../termination/scanIndexed.kt.after | 5 + .../termination/sumOf.kt | 5 + .../termination/sumOf.kt.after | 5 + .../LocalInspectionTestGenerated.java | 115 ++++++++++++++++++ 50 files changed, 371 insertions(+), 3 deletions(-) create mode 100644 idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxByOrNull.kt create mode 100644 idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxByOrNull.kt.after create mode 100644 idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxOf.kt create mode 100644 idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxOf.kt.after create mode 100644 idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxOfOrNull.kt create mode 100644 idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxOfOrNull.kt.after create mode 100644 idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxOfWith.kt create mode 100644 idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxOfWith.kt.after create mode 100644 idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxOfWithOrNull.kt create mode 100644 idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxOfWithOrNull.kt.after create mode 100644 idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxOrNull.kt create mode 100644 idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxOrNull.kt.after create mode 100644 idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxWithOrNull.kt create mode 100644 idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxWithOrNull.kt.after create mode 100644 idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minByOrNull.kt create mode 100644 idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minByOrNull.kt.after create mode 100644 idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minOf.kt create mode 100644 idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minOf.kt.after create mode 100644 idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minOfOrNull.kt create mode 100644 idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minOfOrNull.kt.after create mode 100644 idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minOfWith.kt create mode 100644 idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minOfWith.kt.after create mode 100644 idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minOfWithOrNull.kt create mode 100644 idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minOfWithOrNull.kt.after create mode 100644 idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minOrNull.kt create mode 100644 idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minOrNull.kt.after create mode 100644 idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minWithOrNull.kt create mode 100644 idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minWithOrNull.kt.after create mode 100644 idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/reduceIndexedOrNull.kt create mode 100644 idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/reduceIndexedOrNull.kt.after create mode 100644 idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/reduceOrNull.kt create mode 100644 idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/reduceOrNull.kt.after create mode 100644 idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/runningFold.kt create mode 100644 idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/runningFold.kt.after create mode 100644 idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/runningFoldIndexed.kt create mode 100644 idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/runningFoldIndexed.kt.after create mode 100644 idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/runningReduce.kt create mode 100644 idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/runningReduce.kt.after create mode 100644 idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/runningReduceIndexed.kt create mode 100644 idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/runningReduceIndexed.kt.after create mode 100644 idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/scan.kt create mode 100644 idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/scan.kt.after create mode 100644 idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/scanIndexed.kt create mode 100644 idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/scanIndexed.kt.after create mode 100644 idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/sumOf.kt create mode 100644 idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/sumOf.kt.after diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/collections/ConvertCallChainIntoSequenceInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/collections/ConvertCallChainIntoSequenceInspection.kt index 9ac3299aa8e..85f5f564e8f 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/collections/ConvertCallChainIntoSequenceInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/collections/ConvertCallChainIntoSequenceInspection.kt @@ -27,10 +27,7 @@ import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.* import org.jetbrains.kotlin.resolve.BindingContext -import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall -import org.jetbrains.kotlin.resolve.calls.resolvedCallUtil.getImplicitReceiverValue import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode -import org.jetbrains.kotlin.resolve.scopes.receivers.ImplicitReceiver import java.awt.BorderLayout import javax.swing.JPanel @@ -223,6 +220,7 @@ private val transformations = listOf( "minus", "minusElement", "onEach", + "onEachIndexed", "plus", "plusElement", "requireNoNulls", @@ -282,18 +280,41 @@ internal val collectionTerminationFunctionNames = listOf( "max", "maxBy", "maxWith", + "maxOrNull", + "maxByOrNull", + "maxWithOrNull", + "maxOf", + "maxOfOrNull", + "maxOfWith", + "maxOfWithOrNull", "min", "minBy", "minWith", + "minOrNull", + "minByOrNull", + "minWithOrNull", + "minOf", + "minOfOrNull", + "minOfWith", + "minOfWithOrNull", "none", "partition", "reduce", "reduceIndexed", + "reduceIndexedOrNull", + "reduceOrNull", + "runningFold", + "runningFoldIndexed", + "runningReduce", + "runningReduceIndexed", + "scan", + "scanIndexed", "single", "singleOrNull", "sum", "sumBy", "sumByDouble", + "sumOf", "toCollection", "toHashSet", "toList", diff --git a/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/allTransformations.kt b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/allTransformations.kt index 1564d5be2ed..b4fbe42e8f8 100644 --- a/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/allTransformations.kt +++ b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/allTransformations.kt @@ -19,6 +19,7 @@ fun test(list: List): List>, IndexedValue } .plus(1) .plusElement(1) .requireNoNulls() diff --git a/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/allTransformations.kt.after b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/allTransformations.kt.after index ee94afdd3a2..0d1b0a682f8 100644 --- a/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/allTransformations.kt.after +++ b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/allTransformations.kt.after @@ -20,6 +20,7 @@ fun test(list: List): List>, IndexedValue } .plus(1) .plusElement(1) .requireNoNulls() diff --git a/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxByOrNull.kt b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxByOrNull.kt new file mode 100644 index 00000000000..adb19efb2da --- /dev/null +++ b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxByOrNull.kt @@ -0,0 +1,5 @@ +// WITH_RUNTIME + +fun test(list: List) { + list.filter { it > 1 }.maxByOrNull { true } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxByOrNull.kt.after b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxByOrNull.kt.after new file mode 100644 index 00000000000..a6482a0389e --- /dev/null +++ b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxByOrNull.kt.after @@ -0,0 +1,5 @@ +// WITH_RUNTIME + +fun test(list: List) { + list.asSequence().filter { it > 1 }.maxByOrNull { true } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxOf.kt b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxOf.kt new file mode 100644 index 00000000000..903b90538bf --- /dev/null +++ b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxOf.kt @@ -0,0 +1,5 @@ +// WITH_RUNTIME + +fun test(list: List) { + list.filter { it > 1 }.maxOf { it } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxOf.kt.after b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxOf.kt.after new file mode 100644 index 00000000000..86874ed5b9c --- /dev/null +++ b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxOf.kt.after @@ -0,0 +1,5 @@ +// WITH_RUNTIME + +fun test(list: List) { + list.asSequence().filter { it > 1 }.maxOf { it } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxOfOrNull.kt b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxOfOrNull.kt new file mode 100644 index 00000000000..b586cea5753 --- /dev/null +++ b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxOfOrNull.kt @@ -0,0 +1,5 @@ +// WITH_RUNTIME + +fun test(list: List) { + list.filter { it > 1 }.maxOfOrNull { it } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxOfOrNull.kt.after b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxOfOrNull.kt.after new file mode 100644 index 00000000000..a3ebff06ec8 --- /dev/null +++ b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxOfOrNull.kt.after @@ -0,0 +1,5 @@ +// WITH_RUNTIME + +fun test(list: List) { + list.asSequence().filter { it > 1 }.maxOfOrNull { it } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxOfWith.kt b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxOfWith.kt new file mode 100644 index 00000000000..3552c44ad84 --- /dev/null +++ b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxOfWith.kt @@ -0,0 +1,5 @@ +// WITH_RUNTIME + +fun test(list: List) { + list.filter { it > 1 }.maxOfWith({ _, _ -> 0 }) { it } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxOfWith.kt.after b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxOfWith.kt.after new file mode 100644 index 00000000000..cb3a348fe6a --- /dev/null +++ b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxOfWith.kt.after @@ -0,0 +1,5 @@ +// WITH_RUNTIME + +fun test(list: List) { + list.asSequence().filter { it > 1 }.maxOfWith({ _, _ -> 0 }) { it } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxOfWithOrNull.kt b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxOfWithOrNull.kt new file mode 100644 index 00000000000..f880756d6e8 --- /dev/null +++ b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxOfWithOrNull.kt @@ -0,0 +1,5 @@ +// WITH_RUNTIME + +fun test(list: List) { + list.filter { it > 1 }.maxOfWithOrNull({ _, _ -> 0 }) { it } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxOfWithOrNull.kt.after b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxOfWithOrNull.kt.after new file mode 100644 index 00000000000..d3650e6c1ea --- /dev/null +++ b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxOfWithOrNull.kt.after @@ -0,0 +1,5 @@ +// WITH_RUNTIME + +fun test(list: List) { + list.asSequence().filter { it > 1 }.maxOfWithOrNull({ _, _ -> 0 }) { it } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxOrNull.kt b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxOrNull.kt new file mode 100644 index 00000000000..6475242fd45 --- /dev/null +++ b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxOrNull.kt @@ -0,0 +1,5 @@ +// WITH_RUNTIME + +fun test(list: List) { + list.filter { it > 1 }.maxOrNull() +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxOrNull.kt.after b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxOrNull.kt.after new file mode 100644 index 00000000000..a44a0e9707d --- /dev/null +++ b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxOrNull.kt.after @@ -0,0 +1,5 @@ +// WITH_RUNTIME + +fun test(list: List) { + list.asSequence().filter { it > 1 }.maxOrNull() +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxWithOrNull.kt b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxWithOrNull.kt new file mode 100644 index 00000000000..be83bb7ae94 --- /dev/null +++ b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxWithOrNull.kt @@ -0,0 +1,5 @@ +// WITH_RUNTIME + +fun test(list: List) { + list.filter { it > 1 }.maxWithOrNull { _, _ -> 0 } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxWithOrNull.kt.after b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxWithOrNull.kt.after new file mode 100644 index 00000000000..a8d7a62e501 --- /dev/null +++ b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxWithOrNull.kt.after @@ -0,0 +1,5 @@ +// WITH_RUNTIME + +fun test(list: List) { + list.asSequence().filter { it > 1 }.maxWithOrNull { _, _ -> 0 } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minByOrNull.kt b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minByOrNull.kt new file mode 100644 index 00000000000..8c052bd3ae2 --- /dev/null +++ b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minByOrNull.kt @@ -0,0 +1,5 @@ +// WITH_RUNTIME + +fun test(list: List) { + list.filter { it > 1 }.minByOrNull { true } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minByOrNull.kt.after b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minByOrNull.kt.after new file mode 100644 index 00000000000..7a5cc4da357 --- /dev/null +++ b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minByOrNull.kt.after @@ -0,0 +1,5 @@ +// WITH_RUNTIME + +fun test(list: List) { + list.asSequence().filter { it > 1 }.minByOrNull { true } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minOf.kt b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minOf.kt new file mode 100644 index 00000000000..1b7c447f756 --- /dev/null +++ b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minOf.kt @@ -0,0 +1,5 @@ +// WITH_RUNTIME + +fun test(list: List) { + list.filter { it > 1 }.minOf { it } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minOf.kt.after b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minOf.kt.after new file mode 100644 index 00000000000..1f7b61f3421 --- /dev/null +++ b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minOf.kt.after @@ -0,0 +1,5 @@ +// WITH_RUNTIME + +fun test(list: List) { + list.asSequence().filter { it > 1 }.minOf { it } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minOfOrNull.kt b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minOfOrNull.kt new file mode 100644 index 00000000000..ac4f6e8086f --- /dev/null +++ b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minOfOrNull.kt @@ -0,0 +1,5 @@ +// WITH_RUNTIME + +fun test(list: List) { + list.filter { it > 1 }.minOfOrNull { it } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minOfOrNull.kt.after b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minOfOrNull.kt.after new file mode 100644 index 00000000000..6314ff706cf --- /dev/null +++ b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minOfOrNull.kt.after @@ -0,0 +1,5 @@ +// WITH_RUNTIME + +fun test(list: List) { + list.asSequence().filter { it > 1 }.minOfOrNull { it } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minOfWith.kt b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minOfWith.kt new file mode 100644 index 00000000000..5e99dfaafd9 --- /dev/null +++ b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minOfWith.kt @@ -0,0 +1,5 @@ +// WITH_RUNTIME + +fun test(list: List) { + list.filter { it > 1 }.minOfWith({ _, _ -> 0 }) { it } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minOfWith.kt.after b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minOfWith.kt.after new file mode 100644 index 00000000000..a16d715e998 --- /dev/null +++ b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minOfWith.kt.after @@ -0,0 +1,5 @@ +// WITH_RUNTIME + +fun test(list: List) { + list.asSequence().filter { it > 1 }.minOfWith({ _, _ -> 0 }) { it } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minOfWithOrNull.kt b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minOfWithOrNull.kt new file mode 100644 index 00000000000..ac7a7f0d437 --- /dev/null +++ b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minOfWithOrNull.kt @@ -0,0 +1,5 @@ +// WITH_RUNTIME + +fun test(list: List) { + list.filter { it > 1 }.minOfWithOrNull({ _, _ -> 0 }) { it } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minOfWithOrNull.kt.after b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minOfWithOrNull.kt.after new file mode 100644 index 00000000000..a3c36c10ac6 --- /dev/null +++ b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minOfWithOrNull.kt.after @@ -0,0 +1,5 @@ +// WITH_RUNTIME + +fun test(list: List) { + list.asSequence().filter { it > 1 }.minOfWithOrNull({ _, _ -> 0 }) { it } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minOrNull.kt b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minOrNull.kt new file mode 100644 index 00000000000..3d54eeb60b5 --- /dev/null +++ b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minOrNull.kt @@ -0,0 +1,5 @@ +// WITH_RUNTIME + +fun test(list: List) { + list.filter { it > 1 }.minOrNull() +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minOrNull.kt.after b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minOrNull.kt.after new file mode 100644 index 00000000000..8fd6c11d595 --- /dev/null +++ b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minOrNull.kt.after @@ -0,0 +1,5 @@ +// WITH_RUNTIME + +fun test(list: List) { + list.asSequence().filter { it > 1 }.minOrNull() +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minWithOrNull.kt b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minWithOrNull.kt new file mode 100644 index 00000000000..587ae1dd5f7 --- /dev/null +++ b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minWithOrNull.kt @@ -0,0 +1,5 @@ +// WITH_RUNTIME + +fun test(list: List) { + list.filter { it > 1 }.minWithOrNull { _, _ -> 0 } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minWithOrNull.kt.after b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minWithOrNull.kt.after new file mode 100644 index 00000000000..566a87f190b --- /dev/null +++ b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minWithOrNull.kt.after @@ -0,0 +1,5 @@ +// WITH_RUNTIME + +fun test(list: List) { + list.asSequence().filter { it > 1 }.minWithOrNull { _, _ -> 0 } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/reduceIndexedOrNull.kt b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/reduceIndexedOrNull.kt new file mode 100644 index 00000000000..b5b024e42ab --- /dev/null +++ b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/reduceIndexedOrNull.kt @@ -0,0 +1,5 @@ +// WITH_RUNTIME + +fun test(list: List) { + list.filter { it > 1 }.reduceIndexedOrNull { _, acc, i -> acc + i } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/reduceIndexedOrNull.kt.after b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/reduceIndexedOrNull.kt.after new file mode 100644 index 00000000000..b51d139f986 --- /dev/null +++ b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/reduceIndexedOrNull.kt.after @@ -0,0 +1,5 @@ +// WITH_RUNTIME + +fun test(list: List) { + list.asSequence().filter { it > 1 }.reduceIndexedOrNull { _, acc, i -> acc + i } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/reduceOrNull.kt b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/reduceOrNull.kt new file mode 100644 index 00000000000..3ac2c24afb5 --- /dev/null +++ b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/reduceOrNull.kt @@ -0,0 +1,5 @@ +// WITH_RUNTIME + +fun test(list: List) { + list.filter { it > 1 }.reduceOrNull { acc, i -> acc + i } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/reduceOrNull.kt.after b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/reduceOrNull.kt.after new file mode 100644 index 00000000000..2f22224b0d2 --- /dev/null +++ b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/reduceOrNull.kt.after @@ -0,0 +1,5 @@ +// WITH_RUNTIME + +fun test(list: List) { + list.asSequence().filter { it > 1 }.reduceOrNull { acc, i -> acc + i } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/runningFold.kt b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/runningFold.kt new file mode 100644 index 00000000000..0782c9414df --- /dev/null +++ b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/runningFold.kt @@ -0,0 +1,5 @@ +// WITH_RUNTIME + +fun test(list: List) { + list.filter { it > 1 }.runningFold(0) { acc, i -> acc + i } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/runningFold.kt.after b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/runningFold.kt.after new file mode 100644 index 00000000000..e53fb1953f7 --- /dev/null +++ b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/runningFold.kt.after @@ -0,0 +1,5 @@ +// WITH_RUNTIME + +fun test(list: List) { + list.asSequence().filter { it > 1 }.runningFold(0) { acc, i -> acc + i } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/runningFoldIndexed.kt b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/runningFoldIndexed.kt new file mode 100644 index 00000000000..929cc7a2b63 --- /dev/null +++ b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/runningFoldIndexed.kt @@ -0,0 +1,5 @@ +// WITH_RUNTIME + +fun test(list: List) { + list.filter { it > 1 }.runningFoldIndexed(0) { _, acc, i -> acc + i } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/runningFoldIndexed.kt.after b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/runningFoldIndexed.kt.after new file mode 100644 index 00000000000..f7347a1f269 --- /dev/null +++ b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/runningFoldIndexed.kt.after @@ -0,0 +1,5 @@ +// WITH_RUNTIME + +fun test(list: List) { + list.asSequence().filter { it > 1 }.runningFoldIndexed(0) { _, acc, i -> acc + i } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/runningReduce.kt b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/runningReduce.kt new file mode 100644 index 00000000000..53bdbd1a3cb --- /dev/null +++ b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/runningReduce.kt @@ -0,0 +1,5 @@ +// WITH_RUNTIME + +fun test(list: List) { + list.filter { it > 1 }.runningReduce { acc, i -> acc + i } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/runningReduce.kt.after b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/runningReduce.kt.after new file mode 100644 index 00000000000..0d6e9557cae --- /dev/null +++ b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/runningReduce.kt.after @@ -0,0 +1,5 @@ +// WITH_RUNTIME + +fun test(list: List) { + list.asSequence().filter { it > 1 }.runningReduce { acc, i -> acc + i } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/runningReduceIndexed.kt b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/runningReduceIndexed.kt new file mode 100644 index 00000000000..b0a6912e3b2 --- /dev/null +++ b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/runningReduceIndexed.kt @@ -0,0 +1,5 @@ +// WITH_RUNTIME + +fun test(list: List) { + list.filter { it > 1 }.runningReduceIndexed { _, acc, i -> acc + i } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/runningReduceIndexed.kt.after b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/runningReduceIndexed.kt.after new file mode 100644 index 00000000000..34fa1481aa3 --- /dev/null +++ b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/runningReduceIndexed.kt.after @@ -0,0 +1,5 @@ +// WITH_RUNTIME + +fun test(list: List) { + list.asSequence().filter { it > 1 }.runningReduceIndexed { _, acc, i -> acc + i } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/scan.kt b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/scan.kt new file mode 100644 index 00000000000..bee645129e8 --- /dev/null +++ b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/scan.kt @@ -0,0 +1,5 @@ +// WITH_RUNTIME + +fun test(list: List) { + list.filter { it > 1 }.scan(0) { acc, i -> acc + i } +} diff --git a/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/scan.kt.after b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/scan.kt.after new file mode 100644 index 00000000000..da77addf5d9 --- /dev/null +++ b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/scan.kt.after @@ -0,0 +1,5 @@ +// WITH_RUNTIME + +fun test(list: List) { + list.asSequence().filter { it > 1 }.scan(0) { acc, i -> acc + i } +} diff --git a/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/scanIndexed.kt b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/scanIndexed.kt new file mode 100644 index 00000000000..c90860e6a74 --- /dev/null +++ b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/scanIndexed.kt @@ -0,0 +1,5 @@ +// WITH_RUNTIME + +fun test(list: List) { + list.filter { it > 1 }.scanIndexed(0) { _, acc, i -> acc + i } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/scanIndexed.kt.after b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/scanIndexed.kt.after new file mode 100644 index 00000000000..d6a5e2c88f3 --- /dev/null +++ b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/scanIndexed.kt.after @@ -0,0 +1,5 @@ +// WITH_RUNTIME + +fun test(list: List) { + list.asSequence().filter { it > 1 }.scanIndexed(0) { _, acc, i -> acc + i } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/sumOf.kt b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/sumOf.kt new file mode 100644 index 00000000000..f75a40fa270 --- /dev/null +++ b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/sumOf.kt @@ -0,0 +1,5 @@ +// WITH_RUNTIME + +fun test(list: List) { + list.filter { it > 1 }.sumOf { it } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/sumOf.kt.after b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/sumOf.kt.after new file mode 100644 index 00000000000..81564b13447 --- /dev/null +++ b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/sumOf.kt.after @@ -0,0 +1,5 @@ +// WITH_RUNTIME + +fun test(list: List) { + list.asSequence().filter { it > 1 }.sumOf { it } +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/inspections/LocalInspectionTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/inspections/LocalInspectionTestGenerated.java index ed0d8c4a360..65661ac5ca2 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/inspections/LocalInspectionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/inspections/LocalInspectionTestGenerated.java @@ -1372,11 +1372,46 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest { runTest("idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxBy.kt"); } + @TestMetadata("maxByOrNull.kt") + public void testMaxByOrNull() throws Exception { + runTest("idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxByOrNull.kt"); + } + + @TestMetadata("maxOf.kt") + public void testMaxOf() throws Exception { + runTest("idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxOf.kt"); + } + + @TestMetadata("maxOfOrNull.kt") + public void testMaxOfOrNull() throws Exception { + runTest("idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxOfOrNull.kt"); + } + + @TestMetadata("maxOfWith.kt") + public void testMaxOfWith() throws Exception { + runTest("idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxOfWith.kt"); + } + + @TestMetadata("maxOfWithOrNull.kt") + public void testMaxOfWithOrNull() throws Exception { + runTest("idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxOfWithOrNull.kt"); + } + + @TestMetadata("maxOrNull.kt") + public void testMaxOrNull() throws Exception { + runTest("idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxOrNull.kt"); + } + @TestMetadata("maxWith.kt") public void testMaxWith() throws Exception { runTest("idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxWith.kt"); } + @TestMetadata("maxWithOrNull.kt") + public void testMaxWithOrNull() throws Exception { + runTest("idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/maxWithOrNull.kt"); + } + @TestMetadata("min.kt") public void testMin() throws Exception { runTest("idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/min.kt"); @@ -1387,11 +1422,46 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest { runTest("idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minBy.kt"); } + @TestMetadata("minByOrNull.kt") + public void testMinByOrNull() throws Exception { + runTest("idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minByOrNull.kt"); + } + + @TestMetadata("minOf.kt") + public void testMinOf() throws Exception { + runTest("idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minOf.kt"); + } + + @TestMetadata("minOfOrNull.kt") + public void testMinOfOrNull() throws Exception { + runTest("idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minOfOrNull.kt"); + } + + @TestMetadata("minOfWith.kt") + public void testMinOfWith() throws Exception { + runTest("idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minOfWith.kt"); + } + + @TestMetadata("minOfWithOrNull.kt") + public void testMinOfWithOrNull() throws Exception { + runTest("idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minOfWithOrNull.kt"); + } + + @TestMetadata("minOrNull.kt") + public void testMinOrNull() throws Exception { + runTest("idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minOrNull.kt"); + } + @TestMetadata("minWith.kt") public void testMinWith() throws Exception { runTest("idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minWith.kt"); } + @TestMetadata("minWithOrNull.kt") + public void testMinWithOrNull() throws Exception { + runTest("idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/minWithOrNull.kt"); + } + @TestMetadata("none.kt") public void testNone() throws Exception { runTest("idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/none.kt"); @@ -1412,6 +1482,46 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest { runTest("idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/reduceIndexed.kt"); } + @TestMetadata("reduceIndexedOrNull.kt") + public void testReduceIndexedOrNull() throws Exception { + runTest("idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/reduceIndexedOrNull.kt"); + } + + @TestMetadata("reduceOrNull.kt") + public void testReduceOrNull() throws Exception { + runTest("idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/reduceOrNull.kt"); + } + + @TestMetadata("runningFold.kt") + public void testRunningFold() throws Exception { + runTest("idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/runningFold.kt"); + } + + @TestMetadata("runningFoldIndexed.kt") + public void testRunningFoldIndexed() throws Exception { + runTest("idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/runningFoldIndexed.kt"); + } + + @TestMetadata("runningReduce.kt") + public void testRunningReduce() throws Exception { + runTest("idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/runningReduce.kt"); + } + + @TestMetadata("runningReduceIndexed.kt") + public void testRunningReduceIndexed() throws Exception { + runTest("idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/runningReduceIndexed.kt"); + } + + @TestMetadata("scan.kt") + public void testScan() throws Exception { + runTest("idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/scan.kt"); + } + + @TestMetadata("scanIndexed.kt") + public void testScanIndexed() throws Exception { + runTest("idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/scanIndexed.kt"); + } + @TestMetadata("single.kt") public void testSingle() throws Exception { runTest("idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/single.kt"); @@ -1437,6 +1547,11 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest { runTest("idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/sumByDouble.kt"); } + @TestMetadata("sumOf.kt") + public void testSumOf() throws Exception { + runTest("idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/sumOf.kt"); + } + @TestMetadata("toCollection.kt") public void testToCollection() throws Exception { runTest("idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/toCollection.kt");