diff --git a/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt b/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt index 1d813f9687a..700169f3ced 100644 --- a/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt +++ b/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt @@ -84,6 +84,7 @@ import org.jetbrains.kotlin.idea.hierarchy.AbstractHierarchyWithLibTest import org.jetbrains.kotlin.idea.highlighter.* import org.jetbrains.kotlin.idea.imports.AbstractOptimizeImportsTest import org.jetbrains.kotlin.idea.intentions.AbstractIntentionTest +import org.jetbrains.kotlin.idea.intentions.AbstractIntentionTest2 import org.jetbrains.kotlin.idea.intentions.AbstractMultiFileIntentionTest import org.jetbrains.kotlin.idea.intentions.declarations.AbstractJoinLinesTest import org.jetbrains.kotlin.idea.internal.AbstractBytecodeToolWindowTest @@ -508,6 +509,10 @@ fun main(args: Array) { model("intentions", pattern = "^([\\w\\-_]+)\\.kt$") } + testClass() { + model("intentions/loopToCallChain", pattern = "^([\\w\\-_]+)\\.kt$") + } + testClass() { model("intentions", pattern = "^(inspections\\.test)$", singleClass = true) model("inspections", pattern = "^(inspections\\.test)$", singleClass = true) diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/inspections/IntentionBasedInspection.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/inspections/IntentionBasedInspection.kt index 583e0946615..0a312ec24f9 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/inspections/IntentionBasedInspection.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/inspections/IntentionBasedInspection.kt @@ -16,7 +16,9 @@ package org.jetbrains.kotlin.idea.inspections +import com.intellij.codeInsight.intention.HighPriorityAction import com.intellij.codeInsight.intention.IntentionAction +import com.intellij.codeInsight.intention.LowPriorityAction import com.intellij.codeInspection.* import com.intellij.openapi.editor.Editor import com.intellij.openapi.editor.EditorFactory @@ -88,7 +90,7 @@ abstract class IntentionBasedInspection( if (fixes == null) { fixes = SmartList() } - fixes!!.add(IntentionBasedQuickFix(intention, intention.text, additionalChecker, targetElement)) + fixes!!.add(createQuickFix(intention, additionalChecker, targetElement)) } } } @@ -109,14 +111,27 @@ abstract class IntentionBasedInspection( protected open val problemHighlightType: ProblemHighlightType get() = ProblemHighlightType.GENERIC_ERROR_OR_WARNING + private fun createQuickFix( + intention: SelfTargetingRangeIntention, + additionalChecker: (TElement, IntentionBasedInspection) -> Boolean, + targetElement: TElement + ): IntentionBasedQuickFix { + return when (intention) { + is LowPriorityAction -> LowPriorityIntentionBasedQuickFix(intention, additionalChecker, targetElement) + is HighPriorityAction -> HighPriorityIntentionBasedQuickFix(intention, additionalChecker, targetElement) + else -> IntentionBasedQuickFix(intention, additionalChecker, targetElement) + } + } + /* we implement IntentionAction to provide isAvailable which will be used to hide outdated items and make sure we never call 'invoke' for such item */ - private inner class IntentionBasedQuickFix( + private open inner class IntentionBasedQuickFix( private val intention: SelfTargetingRangeIntention, - private val text: String, private val additionalChecker: (TElement, IntentionBasedInspection) -> Boolean, targetElement: TElement ) : LocalQuickFixOnPsiElement(targetElement), IntentionAction { + private val text = intention.text + // store text into variable because intention instance is shared and may change its text later override fun getFamilyName() = intention.familyName @@ -145,6 +160,18 @@ abstract class IntentionBasedInspection( intention.applyTo(startElement as TElement, editor) } } + + private inner class LowPriorityIntentionBasedQuickFix( + intention: SelfTargetingRangeIntention, + additionalChecker: (TElement, IntentionBasedInspection) -> Boolean, + targetElement: TElement + ) : IntentionBasedQuickFix(intention, additionalChecker, targetElement), LowPriorityAction + + private inner class HighPriorityIntentionBasedQuickFix( + intention: SelfTargetingRangeIntention, + additionalChecker: (TElement, IntentionBasedInspection) -> Boolean, + targetElement: TElement + ) : IntentionBasedQuickFix(intention, additionalChecker, targetElement), HighPriorityAction } fun PsiElement.findExistingEditor(): Editor? { diff --git a/idea/resources/intentionDescriptions/LoopToLazyCallChainIntention/after.kt.template b/idea/resources/intentionDescriptions/LoopToLazyCallChainIntention/after.kt.template new file mode 100644 index 00000000000..b007c74f7d4 --- /dev/null +++ b/idea/resources/intentionDescriptions/LoopToLazyCallChainIntention/after.kt.template @@ -0,0 +1,7 @@ +fun foo(list: List) { + val sum = list + .asSequence() + .map { it.calcSomething() } + .filter { it > 0 } + .sumBy { it } +} \ No newline at end of file diff --git a/idea/resources/intentionDescriptions/LoopToLazyCallChainIntention/before.kt.template b/idea/resources/intentionDescriptions/LoopToLazyCallChainIntention/before.kt.template new file mode 100644 index 00000000000..ac9a6724b7d --- /dev/null +++ b/idea/resources/intentionDescriptions/LoopToLazyCallChainIntention/before.kt.template @@ -0,0 +1,9 @@ +fun foo(list: List) { + val sum = 0 + for (s in list) { + val x = s.calcSomething() + if (x > 0) { + sum += x + } + } +} \ No newline at end of file diff --git a/idea/resources/intentionDescriptions/LoopToLazyCallChainIntention/description.html b/idea/resources/intentionDescriptions/LoopToLazyCallChainIntention/description.html new file mode 100644 index 00000000000..d00f61d09f2 --- /dev/null +++ b/idea/resources/intentionDescriptions/LoopToLazyCallChainIntention/description.html @@ -0,0 +1,5 @@ + + +This intention converts a for-loop into a sequence of stdlib-operations (like "map", "filter" etc) with lazy evaluation (using 'asSequence()' method) + + diff --git a/idea/src/META-INF/plugin.xml b/idea/src/META-INF/plugin.xml index 44edeab90ae..a2ea5319343 100644 --- a/idea/src/META-INF/plugin.xml +++ b/idea/src/META-INF/plugin.xml @@ -1018,6 +1018,11 @@ Kotlin + + org.jetbrains.kotlin.idea.intentions.loopToCallChain.LoopToLazyCallChainIntention + Kotlin + + org.jetbrains.kotlin.idea.intentions.loopToCallChain.UseWithIndexIntention Kotlin diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/loopToCallChain/LoopToCallChainIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/loopToCallChain/LoopToCallChainIntention.kt index 07693cbf3f7..f12e70b4a15 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/loopToCallChain/LoopToCallChainIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/loopToCallChain/LoopToCallChainIntention.kt @@ -16,6 +16,7 @@ package org.jetbrains.kotlin.idea.intentions.loopToCallChain +import com.intellij.codeInsight.intention.LowPriorityAction import com.intellij.openapi.editor.Editor import com.intellij.openapi.util.TextRange import org.jetbrains.kotlin.idea.core.moveCaret @@ -26,27 +27,39 @@ import org.jetbrains.kotlin.psi.KtProperty import org.jetbrains.kotlin.psi.psiUtil.startOffset class LoopToCallChainInspection : IntentionBasedInspection( - LoopToCallChainIntention(), - problemText = "Loop can be replaced with stdlib operations") + listOf(IntentionData(LoopToCallChainIntention()), IntentionData(LoopToLazyCallChainIntention())), + problemText = "Loop can be replaced with stdlib operations", + elementType = KtForExpression::class.java) -class LoopToCallChainIntention : SelfTargetingRangeIntention( +class LoopToCallChainIntention : AbstractLoopToCallChainIntention(lazy = false, text = "Replace with stdlib operations") + +class LoopToLazyCallChainIntention : AbstractLoopToCallChainIntention(lazy = true, text = "Replace with stdlib operations with use of 'asSequence()'"), LowPriorityAction + +abstract class AbstractLoopToCallChainIntention(private val lazy: Boolean, text: String) : SelfTargetingRangeIntention( KtForExpression::class.java, - "Replace with stdlib operations" + text ) { override fun applicabilityRange(element: KtForExpression): TextRange? { - val match = match(element) + val match = match(element, lazy) text = if (match != null) "Replace with '${match.transformationMatch.buildPresentation()}'" else defaultText return if (match != null) element.forKeyword.textRange else null } private fun TransformationMatch.Result.buildPresentation(): String { - var transformations = sequenceTransformations + resultTransformation + return buildPresentation(sequenceTransformations + resultTransformation, null) + } + + private fun buildPresentation(transformations: List, prevPresentation: String?): String { val MAX = 3 - var result: String? = null if (transformations.size > MAX) { - transformations = transformations.drop(transformations.size - MAX) - result = ".." + if (transformations[0] is AsSequenceTransformation) { + return buildPresentation(transformations.drop(1), transformations[0].presentation) + } + + return buildPresentation(transformations.drop(transformations.size - MAX), prevPresentation?.let { it + ".." } ?: "..") } + + var result: String? = prevPresentation for (transformation in transformations) { result = transformation.buildPresentation(result) } @@ -54,7 +67,7 @@ class LoopToCallChainIntention : SelfTargetingRangeIntention( } override fun applyTo(element: KtForExpression, editor: Editor?) { - val match = match(element)!! + val match = match(element, lazy)!! val result = convertLoop(element, match) val offset = when (result) { @@ -65,4 +78,4 @@ class LoopToCallChainIntention : SelfTargetingRangeIntention( editor?.moveCaret(offset) } -} \ No newline at end of file +} diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/loopToCallChain/baseTransformations.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/loopToCallChain/baseTransformations.kt index 96ba9e8511b..589c3e8bf95 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/loopToCallChain/baseTransformations.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/loopToCallChain/baseTransformations.kt @@ -89,6 +89,9 @@ abstract class AssignToVariableResultTransformation( override fun generateCode(chainedCallGenerator: ChainedCallGenerator): KtExpression { return delegate.generateCode(chainedCallGenerator) } + + override val lazyMakesSense: Boolean + get() = delegate.lazyMakesSense } } } diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/loopToCallChain/interfaces.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/loopToCallChain/interfaces.kt index 4fd80ff574f..07acb4abed3 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/loopToCallChain/interfaces.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/loopToCallChain/interfaces.kt @@ -89,6 +89,9 @@ interface ResultTransformation : Transformation { * except for the loop itself and the result element returned from this method */ fun convertLoop(resultCallChain: KtExpression, commentSavingRangeHolder: CommentSavingRangeHolder): KtExpression + + val lazyMakesSense: Boolean + get() = false } /** @@ -103,6 +106,7 @@ data class MatchingState( * Matchers can assume that indexVariable is null if it's not used in the rest of the loop */ val indexVariable: KtCallableDeclaration?, + val lazySequence: Boolean, val pseudocodeProvider: () -> Pseudocode, val initializationStatementsToDelete: Collection = emptyList(), val previousTransformations: MutableList = arrayListOf(), @@ -210,3 +214,15 @@ class CommentSavingRangeHolder(range: PsiChildRange) { private fun PsiElement.siblingsBefore() = if (prevSibling != null) PsiChildRange(parent.firstChild, prevSibling) else PsiChildRange.EMPTY } + +class AsSequenceTransformation(override val loop: KtForExpression) : SequenceTransformation { + override val presentation: String + get() = "asSequence()" + + override val affectsIndex: Boolean + get() = false + + override fun generateCode(chainedCallGenerator: ChainedCallGenerator): KtExpression { + return chainedCallGenerator.generate("asSequence()") + } +} diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/loopToCallChain/matchAndConvert.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/loopToCallChain/matchAndConvert.kt index 537cb6af8d8..172a9f77124 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/loopToCallChain/matchAndConvert.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/loopToCallChain/matchAndConvert.kt @@ -25,10 +25,7 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.idea.analysis.analyzeInContext import org.jetbrains.kotlin.idea.caches.resolve.analyze import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade -import org.jetbrains.kotlin.idea.intentions.loopToCallChain.result.AddToCollectionTransformation -import org.jetbrains.kotlin.idea.intentions.loopToCallChain.result.CountTransformation -import org.jetbrains.kotlin.idea.intentions.loopToCallChain.result.FindTransformationMatcher -import org.jetbrains.kotlin.idea.intentions.loopToCallChain.result.ForEachTransformation +import org.jetbrains.kotlin.idea.intentions.loopToCallChain.result.* import org.jetbrains.kotlin.idea.intentions.loopToCallChain.sequence.FilterTransformation import org.jetbrains.kotlin.idea.intentions.loopToCallChain.sequence.FlatMapTransformation import org.jetbrains.kotlin.idea.intentions.loopToCallChain.sequence.IntroduceIndexMatcher @@ -66,10 +63,11 @@ data class MatchResult( val initializationStatementsToDelete: Collection ) -fun match(loop: KtForExpression): MatchResult? { +//TODO: loop which is already over Sequence +fun match(loop: KtForExpression, useLazySequence: Boolean): MatchResult? { val (inputVariable, indexVariable, sequenceExpression) = extractLoopData(loop) ?: return null - var state = createInitialMatchingState(loop, inputVariable, indexVariable) ?: return null + var state = createInitialMatchingState(loop, inputVariable, indexVariable, useLazySequence) ?: return null // used just as optimization to avoid unnecessary checks val loopContainsEmbeddedBreakOrContinue = loop.containsEmbeddedBreakOrContinue() @@ -122,9 +120,22 @@ fun match(loop: KtForExpression): MatchResult? { is TransformationMatch.Result -> { if (restContainsEmbeddedBreakOrContinue && !matcher.embeddedBreakOrContinuePossible) continue@MatchersLoop - return TransformationMatch.Result(match.resultTransformation, state.previousTransformations) - .let { mergeTransformations(it) } - .let { MatchResult(sequenceExpression, it, state.initializationStatementsToDelete) } + var result = TransformationMatch.Result(match.resultTransformation, state.previousTransformations) + result = mergeTransformations(result) + + if (useLazySequence) { + val sequenceTransformations = result.sequenceTransformations + val resultTransformation = result.resultTransformation + if (sequenceTransformations.isEmpty() && !resultTransformation.lazyMakesSense + || sequenceTransformations.size == 1 && resultTransformation is AssignToListTransformation) { + return null // it makes no sense to use lazy sequence if no intermediate sequences produced + } + val asSequence = AsSequenceTransformation(loop) + result = TransformationMatch.Result(resultTransformation, listOf(asSequence) + sequenceTransformations) + } + + + return MatchResult(sequenceExpression, result, state.initializationStatementsToDelete) .check { checkSmartCastsPreserved(loop, it) } } } @@ -135,7 +146,6 @@ fun match(loop: KtForExpression): MatchResult? { } } -//TODO: offer to use of .asSequence() as an option fun convertLoop(loop: KtForExpression, matchResult: MatchResult): KtExpression { val resultTransformation = matchResult.transformationMatch.resultTransformation @@ -191,7 +201,8 @@ private fun extractLoopData(loop: KtForExpression): LoopData? { private fun createInitialMatchingState( loop: KtForExpression, inputVariable: KtCallableDeclaration, - indexVariable: KtCallableDeclaration? + indexVariable: KtCallableDeclaration?, + useLazySequence: Boolean ): MatchingState? { val pseudocodeProvider: () -> Pseudocode = object : () -> Pseudocode { @@ -210,6 +221,7 @@ private fun createInitialMatchingState( statements = listOf(loop.body ?: return null), inputVariable = inputVariable, indexVariable = indexVariable, + lazySequence = useLazySequence, pseudocodeProvider = pseudocodeProvider ) } @@ -363,7 +375,7 @@ fun matchIndexToIntroduce(loop: KtForExpression): IntroduceIndexData? { val (inputVariable, indexVariable) = extractLoopData(loop) ?: return null if (indexVariable != null) return null // loop is already with "withIndex" - val state = createInitialMatchingState(loop, inputVariable, indexVariable)?.unwrapBlock() ?: return null + val state = createInitialMatchingState(loop, inputVariable, indexVariable, useLazySequence = false)?.unwrapBlock() ?: return null val match = IntroduceIndexMatcher.match(state) ?: return null assert(match.sequenceTransformations.isEmpty()) diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/loopToCallChain/result/AddToCollectionTransformation.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/loopToCallChain/result/AddToCollectionTransformation.kt index 1b62b09a80d..135de745bb8 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/loopToCallChain/result/AddToCollectionTransformation.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/loopToCallChain/result/AddToCollectionTransformation.kt @@ -129,14 +129,21 @@ class AddToCollectionTransformation( CollectionKind.LIST -> { when { canChangeInitializerType(collectionInitialization, KotlinBuiltIns.FQ_NAMES.list, state.outerLoop) -> { - val transformation = if (argumentIsInputVariable) { - AssignToListTransformation(state.outerLoop, collectionInitialization) + if (argumentIsInputVariable) { + val assignToList = AssignToListTransformation(state.outerLoop, collectionInitialization, state.lazySequence) + return TransformationMatch.Result(assignToList) } else { val mapTransformation = MapTransformation(state.outerLoop, state.inputVariable, null, addOperationArgument, mapNotNull = false) - AssignSequenceResultTransformation(mapTransformation, collectionInitialization) + if (state.lazySequence) { + val assignToList = AssignToListTransformation(state.outerLoop, collectionInitialization, lazySequence = true) + return TransformationMatch.Result(assignToList, mapTransformation) + } + else { + val assignSequence = AssignSequenceResultTransformation(mapTransformation, collectionInitialization) + return TransformationMatch.Result(assignSequence) + } } - return TransformationMatch.Result(transformation) } canChangeInitializerType(collectionInitialization, KotlinBuiltIns.FQ_NAMES.mutableList, state.outerLoop) -> { @@ -325,6 +332,11 @@ class FlatMapToTransformation private constructor( return chainedCallGenerator.generate("flatMapTo($0) $1:'{}'", targetCollection, lambda) } + // asSequence().flatMapTo(){} makes real difference (because expression inside lambda is evaluated lazily) + //TODO: return false if expression is input variable + override val lazyMakesSense: Boolean + get() = true + companion object { fun create( loop: KtForExpression, @@ -346,14 +358,16 @@ class FlatMapToTransformation private constructor( class AssignToListTransformation( loop: KtForExpression, - initialization: VariableInitialization + initialization: VariableInitialization, + private val lazySequence: Boolean ) : AssignToVariableResultTransformation(loop, initialization) { override val presentation: String get() = "toList()" override fun mergeWithPrevious(previousTransformation: SequenceTransformation): ResultTransformation? { - //TODO: can be any SequenceTransformation's that return not List? Also this code needs to be changed when .asSequence() used + if (lazySequence) return null // toList() is necessary if the result is Sequence + //TODO: can be any SequenceTransformation's that return not List? return AssignSequenceResultTransformation(previousTransformation, initialization) } diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/loopToCallChain/sequence/FlatMapTransformation.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/loopToCallChain/sequence/FlatMapTransformation.kt index c8e1b8f24bd..f637a75793f 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/loopToCallChain/sequence/FlatMapTransformation.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/loopToCallChain/sequence/FlatMapTransformation.kt @@ -70,7 +70,8 @@ class FlatMapTransformation( // if nested loop range uses index, convert to "mapIndexed {...}.flatMap { it }" val mapIndexedTransformation = MapTransformation(state.outerLoop, state.inputVariable, state.indexVariable, transform, mapNotNull = false) val inputVarExpression = KtPsiFactory(nestedLoop).createExpressionByPattern("$0", state.inputVariable.nameAsSafeName) - val flatMapTransformation = FlatMapTransformation(state.outerLoop, state.inputVariable, inputVarExpression) + val transformToUse = if (state.lazySequence) inputVarExpression.asSequence() else inputVarExpression + val flatMapTransformation = FlatMapTransformation(state.outerLoop, state.inputVariable, transformToUse) val newState = state.copy( innerLoop = nestedLoop, statements = listOf(nestedLoopBody), @@ -79,7 +80,8 @@ class FlatMapTransformation( return TransformationMatch.Sequence(listOf(mapIndexedTransformation, flatMapTransformation), newState) } - val transformation = FlatMapTransformation(state.outerLoop, state.inputVariable, transform) + val transformToUse = if (state.lazySequence) transform.asSequence() else transform + val transformation = FlatMapTransformation(state.outerLoop, state.inputVariable, transformToUse) val newState = state.copy( innerLoop = nestedLoop, statements = listOf(nestedLoopBody), @@ -87,5 +89,9 @@ class FlatMapTransformation( ) return TransformationMatch.Sequence(transformation, newState) } + + private fun KtExpression.asSequence(): KtExpression { + return KtPsiFactory(this).createExpressionByPattern("$0.asSequence()", this) + } } } \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/.intention2 b/idea/testData/intentions/loopToCallChain/.intention2 new file mode 100644 index 00000000000..5619a06f8da --- /dev/null +++ b/idea/testData/intentions/loopToCallChain/.intention2 @@ -0,0 +1 @@ +org.jetbrains.kotlin.idea.intentions.loopToCallChain.LoopToLazyCallChainIntention \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/addToCollection.kt b/idea/testData/intentions/loopToCallChain/addToCollection.kt index a3f3d38b1cf..2271cd0fec9 100644 --- a/idea/testData/intentions/loopToCallChain/addToCollection.kt +++ b/idea/testData/intentions/loopToCallChain/addToCollection.kt @@ -1,7 +1,8 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with '+='" +// IS_APPLICABLE_2: false fun foo(list: List, target: MutableList) { for (s in list) { target.add(s) } -} \ No newline at end of file +} diff --git a/idea/testData/intentions/loopToCallChain/addToCollection.kt.after b/idea/testData/intentions/loopToCallChain/addToCollection.kt.after index fb662a13435..f2213239a51 100644 --- a/idea/testData/intentions/loopToCallChain/addToCollection.kt.after +++ b/idea/testData/intentions/loopToCallChain/addToCollection.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with '+='" +// IS_APPLICABLE_2: false fun foo(list: List, target: MutableList) { target += list -} \ No newline at end of file +} diff --git a/idea/testData/intentions/loopToCallChain/addToCollection_addAfterLoop.kt b/idea/testData/intentions/loopToCallChain/addToCollection_addAfterLoop.kt index 7931528654f..00fe4da81f2 100644 --- a/idea/testData/intentions/loopToCallChain/addToCollection_addAfterLoop.kt +++ b/idea/testData/intentions/loopToCallChain/addToCollection_addAfterLoop.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'toMutableList()'" +// IS_APPLICABLE_2: false import java.util.ArrayList fun foo(map: Map): List { diff --git a/idea/testData/intentions/loopToCallChain/addToCollection_addAfterLoop.kt.after b/idea/testData/intentions/loopToCallChain/addToCollection_addAfterLoop.kt.after index 1c73a60021e..9da61bd02b5 100644 --- a/idea/testData/intentions/loopToCallChain/addToCollection_addAfterLoop.kt.after +++ b/idea/testData/intentions/loopToCallChain/addToCollection_addAfterLoop.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'toMutableList()'" +// IS_APPLICABLE_2: false import java.util.ArrayList fun foo(map: Map): List { diff --git a/idea/testData/intentions/loopToCallChain/addToCollection_badReceiver1.kt b/idea/testData/intentions/loopToCallChain/addToCollection_badReceiver1.kt index 782a7f33822..2d051ed7712 100644 --- a/idea/testData/intentions/loopToCallChain/addToCollection_badReceiver1.kt +++ b/idea/testData/intentions/loopToCallChain/addToCollection_badReceiver1.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // IS_APPLICABLE: false +// IS_APPLICABLE_2: false fun foo(list: List>) { for (collection in list) { collection.add(collection.size) diff --git a/idea/testData/intentions/loopToCallChain/addToCollection_badReceiver2.kt b/idea/testData/intentions/loopToCallChain/addToCollection_badReceiver2.kt index cda76bca6d2..11eecb7356d 100644 --- a/idea/testData/intentions/loopToCallChain/addToCollection_badReceiver2.kt +++ b/idea/testData/intentions/loopToCallChain/addToCollection_badReceiver2.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // IS_APPLICABLE: false +// IS_APPLICABLE_2: false import java.util.ArrayList var globalCollection = ArrayList() diff --git a/idea/testData/intentions/loopToCallChain/addToCollection_goodReceiver.kt b/idea/testData/intentions/loopToCallChain/addToCollection_goodReceiver.kt index a247578c6dc..89db28da1b8 100644 --- a/idea/testData/intentions/loopToCallChain/addToCollection_goodReceiver.kt +++ b/idea/testData/intentions/loopToCallChain/addToCollection_goodReceiver.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'mapTo(){}'" +// IS_APPLICABLE_2: false import java.util.ArrayList fun foo(list: List>) { diff --git a/idea/testData/intentions/loopToCallChain/addToCollection_goodReceiver.kt.after b/idea/testData/intentions/loopToCallChain/addToCollection_goodReceiver.kt.after index 098edcd0e77..17b0a98b55c 100644 --- a/idea/testData/intentions/loopToCallChain/addToCollection_goodReceiver.kt.after +++ b/idea/testData/intentions/loopToCallChain/addToCollection_goodReceiver.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'mapTo(){}'" +// IS_APPLICABLE_2: false import java.util.ArrayList fun foo(list: List>) { diff --git a/idea/testData/intentions/loopToCallChain/any_ifAssign.kt b/idea/testData/intentions/loopToCallChain/any_ifAssign.kt index dc823a0245b..076702c66b0 100644 --- a/idea/testData/intentions/loopToCallChain/any_ifAssign.kt +++ b/idea/testData/intentions/loopToCallChain/any_ifAssign.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'any{}'" +// IS_APPLICABLE_2: false fun foo(list: List) { var found = false for (s in list) { diff --git a/idea/testData/intentions/loopToCallChain/any_ifAssign.kt.after b/idea/testData/intentions/loopToCallChain/any_ifAssign.kt.after index d79e4bf9210..d37ef8ea335 100644 --- a/idea/testData/intentions/loopToCallChain/any_ifAssign.kt.after +++ b/idea/testData/intentions/loopToCallChain/any_ifAssign.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'any{}'" +// IS_APPLICABLE_2: false fun foo(list: List) { val found = list.any { it.length > 0 } } \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/any_ifAssign_moveDeclaration.kt b/idea/testData/intentions/loopToCallChain/any_ifAssign_moveDeclaration.kt index cda382103cd..652b6cb12d3 100644 --- a/idea/testData/intentions/loopToCallChain/any_ifAssign_moveDeclaration.kt +++ b/idea/testData/intentions/loopToCallChain/any_ifAssign_moveDeclaration.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'any{}'" +// IS_APPLICABLE_2: false fun foo(list: List) { var found = false println("Starting the search") diff --git a/idea/testData/intentions/loopToCallChain/any_ifAssign_moveDeclaration.kt.after b/idea/testData/intentions/loopToCallChain/any_ifAssign_moveDeclaration.kt.after index 78503c57cdf..8b6e9a2046b 100644 --- a/idea/testData/intentions/loopToCallChain/any_ifAssign_moveDeclaration.kt.after +++ b/idea/testData/intentions/loopToCallChain/any_ifAssign_moveDeclaration.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'any{}'" +// IS_APPLICABLE_2: false fun foo(list: List) { println("Starting the search") val found = list.any { it.length > 0 } diff --git a/idea/testData/intentions/loopToCallChain/any_ifAssign_moveInitialization.kt b/idea/testData/intentions/loopToCallChain/any_ifAssign_moveInitialization.kt index 2ebf9c61bab..ba8aae4995b 100644 --- a/idea/testData/intentions/loopToCallChain/any_ifAssign_moveInitialization.kt +++ b/idea/testData/intentions/loopToCallChain/any_ifAssign_moveInitialization.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'any{}'" +// IS_APPLICABLE_2: false fun foo(list: List, p: Int) { var found: Boolean if (p > 0) { diff --git a/idea/testData/intentions/loopToCallChain/any_ifAssign_moveInitialization.kt.after b/idea/testData/intentions/loopToCallChain/any_ifAssign_moveInitialization.kt.after index 708c28d66bd..b614d9faf61 100644 --- a/idea/testData/intentions/loopToCallChain/any_ifAssign_moveInitialization.kt.after +++ b/idea/testData/intentions/loopToCallChain/any_ifAssign_moveInitialization.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'any{}'" +// IS_APPLICABLE_2: false fun foo(list: List, p: Int) { var found: Boolean if (p > 0) { diff --git a/idea/testData/intentions/loopToCallChain/any_ifAssign_noBreak.kt b/idea/testData/intentions/loopToCallChain/any_ifAssign_noBreak.kt index 15106c2af9c..36a2c43d4b9 100644 --- a/idea/testData/intentions/loopToCallChain/any_ifAssign_noBreak.kt +++ b/idea/testData/intentions/loopToCallChain/any_ifAssign_noBreak.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'any{}'" +// IS_APPLICABLE_2: false fun foo(list: List) { var found = false for (s in list) { diff --git a/idea/testData/intentions/loopToCallChain/any_ifAssign_noBreak.kt.after b/idea/testData/intentions/loopToCallChain/any_ifAssign_noBreak.kt.after index d79e4bf9210..d37ef8ea335 100644 --- a/idea/testData/intentions/loopToCallChain/any_ifAssign_noBreak.kt.after +++ b/idea/testData/intentions/loopToCallChain/any_ifAssign_noBreak.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'any{}'" +// IS_APPLICABLE_2: false fun foo(list: List) { val found = list.any { it.length > 0 } } \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/any_ifAssign_nonBooleanResult.kt b/idea/testData/intentions/loopToCallChain/any_ifAssign_nonBooleanResult.kt index 2e73f7036f3..0a59dee7e27 100644 --- a/idea/testData/intentions/loopToCallChain/any_ifAssign_nonBooleanResult.kt +++ b/idea/testData/intentions/loopToCallChain/any_ifAssign_nonBooleanResult.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'any{}'" +// IS_APPLICABLE_2: false fun foo(list: List) { var result = 0 for (s in list) { diff --git a/idea/testData/intentions/loopToCallChain/any_ifAssign_nonBooleanResult.kt.after b/idea/testData/intentions/loopToCallChain/any_ifAssign_nonBooleanResult.kt.after index 54fdfb6517e..be33a96073d 100644 --- a/idea/testData/intentions/loopToCallChain/any_ifAssign_nonBooleanResult.kt.after +++ b/idea/testData/intentions/loopToCallChain/any_ifAssign_nonBooleanResult.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'any{}'" +// IS_APPLICABLE_2: false fun foo(list: List) { val result = if (list.any { it.length > 0 }) 1 else 0 } \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/any_ifAssign_nonBooleanResult2.kt b/idea/testData/intentions/loopToCallChain/any_ifAssign_nonBooleanResult2.kt index a72376cae9a..23940e23184 100644 --- a/idea/testData/intentions/loopToCallChain/any_ifAssign_nonBooleanResult2.kt +++ b/idea/testData/intentions/loopToCallChain/any_ifAssign_nonBooleanResult2.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // IS_APPLICABLE: false +// IS_APPLICABLE_2: false fun foo(list: List) { var result = takeInt() for (s in list) { diff --git a/idea/testData/intentions/loopToCallChain/any_ifReturn.kt b/idea/testData/intentions/loopToCallChain/any_ifReturn.kt index 0dd4ff1e3bc..4c0372149b9 100644 --- a/idea/testData/intentions/loopToCallChain/any_ifReturn.kt +++ b/idea/testData/intentions/loopToCallChain/any_ifReturn.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'any{}'" +// IS_APPLICABLE_2: false fun foo(list: List): Boolean { for (s in list) { if (s.length > 0) { diff --git a/idea/testData/intentions/loopToCallChain/any_ifReturn.kt.after b/idea/testData/intentions/loopToCallChain/any_ifReturn.kt.after index fad34492c7a..28f66c790ca 100644 --- a/idea/testData/intentions/loopToCallChain/any_ifReturn.kt.after +++ b/idea/testData/intentions/loopToCallChain/any_ifReturn.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'any{}'" +// IS_APPLICABLE_2: false fun foo(list: List): Boolean { return list.any { it.length > 0 } } \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/any_ifReturn_nonBooleanResult.kt b/idea/testData/intentions/loopToCallChain/any_ifReturn_nonBooleanResult.kt index 9b37cedb621..365b95dd90a 100644 --- a/idea/testData/intentions/loopToCallChain/any_ifReturn_nonBooleanResult.kt +++ b/idea/testData/intentions/loopToCallChain/any_ifReturn_nonBooleanResult.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'any{}'" +// IS_APPLICABLE_2: false fun foo(list: List): Int { for (s in list) { if (s.length > 0) { diff --git a/idea/testData/intentions/loopToCallChain/any_ifReturn_nonBooleanResult.kt.after b/idea/testData/intentions/loopToCallChain/any_ifReturn_nonBooleanResult.kt.after index 546c3c2ec78..c3e0a944f58 100644 --- a/idea/testData/intentions/loopToCallChain/any_ifReturn_nonBooleanResult.kt.after +++ b/idea/testData/intentions/loopToCallChain/any_ifReturn_nonBooleanResult.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'any{}'" +// IS_APPLICABLE_2: false fun foo(list: List): Int { return if (list.any { it.length > 0 }) -1 else takeInt() } diff --git a/idea/testData/intentions/loopToCallChain/any_indexNeeded.kt b/idea/testData/intentions/loopToCallChain/any_indexNeeded.kt index 97c2d6660f4..034e443b5b1 100644 --- a/idea/testData/intentions/loopToCallChain/any_indexNeeded.kt +++ b/idea/testData/intentions/loopToCallChain/any_indexNeeded.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filterIndexed{}.any()'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.any()'" fun foo(list: List) { var found = false for ((index, s) in list.withIndex()) { diff --git a/idea/testData/intentions/loopToCallChain/any_indexNeeded.kt.after b/idea/testData/intentions/loopToCallChain/any_indexNeeded.kt.after index 651df60094f..1180d8e93e8 100644 --- a/idea/testData/intentions/loopToCallChain/any_indexNeeded.kt.after +++ b/idea/testData/intentions/loopToCallChain/any_indexNeeded.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filterIndexed{}.any()'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.any()'" fun foo(list: List) { val found = list .filterIndexed { index, s -> s.length > index } diff --git a/idea/testData/intentions/loopToCallChain/any_indexNeeded.kt.after2 b/idea/testData/intentions/loopToCallChain/any_indexNeeded.kt.after2 new file mode 100644 index 00000000000..6b9401a511d --- /dev/null +++ b/idea/testData/intentions/loopToCallChain/any_indexNeeded.kt.after2 @@ -0,0 +1,9 @@ +// WITH_RUNTIME +// INTENTION_TEXT: "Replace with 'filterIndexed{}.any()'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.any()'" +fun foo(list: List) { + val found = list + .asSequence() + .filterIndexed { index, s -> s.length > index } + .any() +} \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/any_return.kt b/idea/testData/intentions/loopToCallChain/any_return.kt index 923129475f7..e7f435947e3 100644 --- a/idea/testData/intentions/loopToCallChain/any_return.kt +++ b/idea/testData/intentions/loopToCallChain/any_return.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'any()'" +// IS_APPLICABLE_2: false fun foo(list: List): Boolean { for (s in list) { return true diff --git a/idea/testData/intentions/loopToCallChain/any_return.kt.after b/idea/testData/intentions/loopToCallChain/any_return.kt.after index db6dcf84008..ede5a8749fd 100644 --- a/idea/testData/intentions/loopToCallChain/any_return.kt.after +++ b/idea/testData/intentions/loopToCallChain/any_return.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'any()'" +// IS_APPLICABLE_2: false fun foo(list: List): Boolean { return list.any() } \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/array.kt b/idea/testData/intentions/loopToCallChain/array.kt index c09b8777d0c..5da72d08903 100644 --- a/idea/testData/intentions/loopToCallChain/array.kt +++ b/idea/testData/intentions/loopToCallChain/array.kt @@ -1,4 +1,6 @@ // WITH_RUNTIME +// INTENTION_TEXT: "Replace with 'firstOrNull{}'" +// IS_APPLICABLE_2: false fun foo(array: Array): String? { for (s in array) { if (s.isNotBlank()) { diff --git a/idea/testData/intentions/loopToCallChain/array.kt.after b/idea/testData/intentions/loopToCallChain/array.kt.after index 6ec56d095fd..6697879eb69 100644 --- a/idea/testData/intentions/loopToCallChain/array.kt.after +++ b/idea/testData/intentions/loopToCallChain/array.kt.after @@ -1,4 +1,6 @@ // WITH_RUNTIME +// INTENTION_TEXT: "Replace with 'firstOrNull{}'" +// IS_APPLICABLE_2: false fun foo(array: Array): String? { return array.firstOrNull { it.isNotBlank() } } diff --git a/idea/testData/intentions/loopToCallChain/assignFilter.kt b/idea/testData/intentions/loopToCallChain/assignFilter.kt index 6279c957b15..573eeab12bf 100644 --- a/idea/testData/intentions/loopToCallChain/assignFilter.kt +++ b/idea/testData/intentions/loopToCallChain/assignFilter.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filter{}'" +// IS_APPLICABLE_2: false import java.util.ArrayList fun foo(list: List): List { diff --git a/idea/testData/intentions/loopToCallChain/assignFilter.kt.after b/idea/testData/intentions/loopToCallChain/assignFilter.kt.after index aac1e353ee0..87bb47fb7b9 100644 --- a/idea/testData/intentions/loopToCallChain/assignFilter.kt.after +++ b/idea/testData/intentions/loopToCallChain/assignFilter.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filter{}'" +// IS_APPLICABLE_2: false import java.util.ArrayList fun foo(list: List): List { diff --git a/idea/testData/intentions/loopToCallChain/assignFilter2.kt b/idea/testData/intentions/loopToCallChain/assignFilter2.kt index b326df270c6..f00998a9c37 100644 --- a/idea/testData/intentions/loopToCallChain/assignFilter2.kt +++ b/idea/testData/intentions/loopToCallChain/assignFilter2.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filter{}'" +// IS_APPLICABLE_2: false import java.util.ArrayList fun foo(list: List, p: Int): List { diff --git a/idea/testData/intentions/loopToCallChain/assignFilter2.kt.after b/idea/testData/intentions/loopToCallChain/assignFilter2.kt.after index 11828dc76ee..6d8855feafb 100644 --- a/idea/testData/intentions/loopToCallChain/assignFilter2.kt.after +++ b/idea/testData/intentions/loopToCallChain/assignFilter2.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filter{}'" +// IS_APPLICABLE_2: false import java.util.ArrayList fun foo(list: List, p: Int): List { diff --git a/idea/testData/intentions/loopToCallChain/assignFilterIndexed.kt b/idea/testData/intentions/loopToCallChain/assignFilterIndexed.kt index 76cce2dce41..be29ca805c8 100644 --- a/idea/testData/intentions/loopToCallChain/assignFilterIndexed.kt +++ b/idea/testData/intentions/loopToCallChain/assignFilterIndexed.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filterIndexed{}'" +// IS_APPLICABLE_2: false import java.util.* fun foo(list: List): List { diff --git a/idea/testData/intentions/loopToCallChain/assignFilterIndexed.kt.after b/idea/testData/intentions/loopToCallChain/assignFilterIndexed.kt.after index dd48aea7ed4..744d83168b5 100644 --- a/idea/testData/intentions/loopToCallChain/assignFilterIndexed.kt.after +++ b/idea/testData/intentions/loopToCallChain/assignFilterIndexed.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filterIndexed{}'" +// IS_APPLICABLE_2: false import java.util.* fun foo(list: List): List { diff --git a/idea/testData/intentions/loopToCallChain/assignFilterNotNull.kt b/idea/testData/intentions/loopToCallChain/assignFilterNotNull.kt index d91c9a99081..dd1ce8c1390 100644 --- a/idea/testData/intentions/loopToCallChain/assignFilterNotNull.kt +++ b/idea/testData/intentions/loopToCallChain/assignFilterNotNull.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filterNotNull()'" +// IS_APPLICABLE_2: false import java.util.ArrayList fun foo(list: List): List { diff --git a/idea/testData/intentions/loopToCallChain/assignFilterNotNull.kt.after b/idea/testData/intentions/loopToCallChain/assignFilterNotNull.kt.after index 109da40f98c..ec16759b255 100644 --- a/idea/testData/intentions/loopToCallChain/assignFilterNotNull.kt.after +++ b/idea/testData/intentions/loopToCallChain/assignFilterNotNull.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filterNotNull()'" +// IS_APPLICABLE_2: false import java.util.ArrayList fun foo(list: List): List { diff --git a/idea/testData/intentions/loopToCallChain/assignFilter_ArrayListRequired.kt b/idea/testData/intentions/loopToCallChain/assignFilter_ArrayListRequired.kt index 250501a5984..be8a4fd7d42 100644 --- a/idea/testData/intentions/loopToCallChain/assignFilter_ArrayListRequired.kt +++ b/idea/testData/intentions/loopToCallChain/assignFilter_ArrayListRequired.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filterTo(){}'" +// IS_APPLICABLE_2: false import java.util.ArrayList fun foo(list: List): ArrayList { diff --git a/idea/testData/intentions/loopToCallChain/assignFilter_ArrayListRequired.kt.after b/idea/testData/intentions/loopToCallChain/assignFilter_ArrayListRequired.kt.after index f09b76bc5a1..252eb9bd441 100644 --- a/idea/testData/intentions/loopToCallChain/assignFilter_ArrayListRequired.kt.after +++ b/idea/testData/intentions/loopToCallChain/assignFilter_ArrayListRequired.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filterTo(){}'" +// IS_APPLICABLE_2: false import java.util.ArrayList fun foo(list: List): ArrayList { diff --git a/idea/testData/intentions/loopToCallChain/assignFilter_ArrayListRequired2.kt b/idea/testData/intentions/loopToCallChain/assignFilter_ArrayListRequired2.kt index 37258137dab..f5df472770f 100644 --- a/idea/testData/intentions/loopToCallChain/assignFilter_ArrayListRequired2.kt +++ b/idea/testData/intentions/loopToCallChain/assignFilter_ArrayListRequired2.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filterTo(){}'" +// IS_APPLICABLE_2: false import java.util.ArrayList fun foo(list: List, p: Int): ArrayList { diff --git a/idea/testData/intentions/loopToCallChain/assignFilter_ArrayListRequired2.kt.after b/idea/testData/intentions/loopToCallChain/assignFilter_ArrayListRequired2.kt.after index 7d17bd20e6e..ddd986c0769 100644 --- a/idea/testData/intentions/loopToCallChain/assignFilter_ArrayListRequired2.kt.after +++ b/idea/testData/intentions/loopToCallChain/assignFilter_ArrayListRequired2.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filterTo(){}'" +// IS_APPLICABLE_2: false import java.util.ArrayList fun foo(list: List, p: Int): ArrayList { diff --git a/idea/testData/intentions/loopToCallChain/assignFilter_ArrayListRequired3.kt b/idea/testData/intentions/loopToCallChain/assignFilter_ArrayListRequired3.kt index d72439126b3..4d37dbe99eb 100644 --- a/idea/testData/intentions/loopToCallChain/assignFilter_ArrayListRequired3.kt +++ b/idea/testData/intentions/loopToCallChain/assignFilter_ArrayListRequired3.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filterTo(){}'" +// IS_APPLICABLE_2: false import java.util.* fun foo(list: List): ArrayList { diff --git a/idea/testData/intentions/loopToCallChain/assignFilter_ArrayListRequired3.kt.after b/idea/testData/intentions/loopToCallChain/assignFilter_ArrayListRequired3.kt.after index 5dd7e61894f..88b59cb3a23 100644 --- a/idea/testData/intentions/loopToCallChain/assignFilter_ArrayListRequired3.kt.after +++ b/idea/testData/intentions/loopToCallChain/assignFilter_ArrayListRequired3.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filterTo(){}'" +// IS_APPLICABLE_2: false import java.util.* fun foo(list: List): ArrayList { diff --git a/idea/testData/intentions/loopToCallChain/assignFilter_MutableListRequired.kt b/idea/testData/intentions/loopToCallChain/assignFilter_MutableListRequired.kt index 42288ec8d7b..6d9aea86058 100644 --- a/idea/testData/intentions/loopToCallChain/assignFilter_MutableListRequired.kt +++ b/idea/testData/intentions/loopToCallChain/assignFilter_MutableListRequired.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filter{}.toMutableList()'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.toMutableList()'" import java.util.ArrayList fun foo(list: List): MutableList { diff --git a/idea/testData/intentions/loopToCallChain/assignFilter_MutableListRequired.kt.after b/idea/testData/intentions/loopToCallChain/assignFilter_MutableListRequired.kt.after index ae5e82c4296..adb1104bfcf 100644 --- a/idea/testData/intentions/loopToCallChain/assignFilter_MutableListRequired.kt.after +++ b/idea/testData/intentions/loopToCallChain/assignFilter_MutableListRequired.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filter{}.toMutableList()'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.toMutableList()'" import java.util.ArrayList fun foo(list: List): MutableList { diff --git a/idea/testData/intentions/loopToCallChain/assignFilter_MutableListRequired.kt.after2 b/idea/testData/intentions/loopToCallChain/assignFilter_MutableListRequired.kt.after2 new file mode 100644 index 00000000000..2d32fbe2898 --- /dev/null +++ b/idea/testData/intentions/loopToCallChain/assignFilter_MutableListRequired.kt.after2 @@ -0,0 +1,12 @@ +// WITH_RUNTIME +// INTENTION_TEXT: "Replace with 'filter{}.toMutableList()'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.toMutableList()'" +import java.util.ArrayList + +fun foo(list: List): MutableList { + val result = list + .asSequence() + .filter { it.length > 0 } + .toMutableList() + return result +} \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/assignFilter_breakAndContinue.kt b/idea/testData/intentions/loopToCallChain/assignFilter_breakAndContinue.kt index ad76817eeb6..331bb3f4907 100644 --- a/idea/testData/intentions/loopToCallChain/assignFilter_breakAndContinue.kt +++ b/idea/testData/intentions/loopToCallChain/assignFilter_breakAndContinue.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filter{}'" +// IS_APPLICABLE_2: false import java.util.ArrayList fun foo(): List { diff --git a/idea/testData/intentions/loopToCallChain/assignFilter_breakAndContinue.kt.after b/idea/testData/intentions/loopToCallChain/assignFilter_breakAndContinue.kt.after index 05efff63889..52aacf9ffe9 100644 --- a/idea/testData/intentions/loopToCallChain/assignFilter_breakAndContinue.kt.after +++ b/idea/testData/intentions/loopToCallChain/assignFilter_breakAndContinue.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filter{}'" +// IS_APPLICABLE_2: false import java.util.ArrayList fun foo(): List { diff --git a/idea/testData/intentions/loopToCallChain/assignMap.kt b/idea/testData/intentions/loopToCallChain/assignMap.kt index f2f97c28baa..46d5fc0b0c5 100644 --- a/idea/testData/intentions/loopToCallChain/assignMap.kt +++ b/idea/testData/intentions/loopToCallChain/assignMap.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filter{}.map{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.map{}.toList()'" import java.util.ArrayList fun foo(list: List): List { diff --git a/idea/testData/intentions/loopToCallChain/assignMap.kt.after b/idea/testData/intentions/loopToCallChain/assignMap.kt.after index d9f65c3fd7b..05821dfce21 100644 --- a/idea/testData/intentions/loopToCallChain/assignMap.kt.after +++ b/idea/testData/intentions/loopToCallChain/assignMap.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filter{}.map{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.map{}.toList()'" import java.util.ArrayList fun foo(list: List): List { diff --git a/idea/testData/intentions/loopToCallChain/assignMap.kt.after2 b/idea/testData/intentions/loopToCallChain/assignMap.kt.after2 new file mode 100644 index 00000000000..23b4af882f1 --- /dev/null +++ b/idea/testData/intentions/loopToCallChain/assignMap.kt.after2 @@ -0,0 +1,13 @@ +// WITH_RUNTIME +// INTENTION_TEXT: "Replace with 'filter{}.map{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.map{}.toList()'" +import java.util.ArrayList + +fun foo(list: List): List { + val result = list + .asSequence() + .filter { it.length > 0 } + .map { it.hashCode() } + .toList() + return result +} \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/assignMap2.kt b/idea/testData/intentions/loopToCallChain/assignMap2.kt index 742c1638eab..9a93c387180 100644 --- a/idea/testData/intentions/loopToCallChain/assignMap2.kt +++ b/idea/testData/intentions/loopToCallChain/assignMap2.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filter{}.map{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.map{}.toList()'" import java.util.ArrayList fun foo(list: List): List { diff --git a/idea/testData/intentions/loopToCallChain/assignMap2.kt.after b/idea/testData/intentions/loopToCallChain/assignMap2.kt.after index 6caa3c1905a..c3db82ff5be 100644 --- a/idea/testData/intentions/loopToCallChain/assignMap2.kt.after +++ b/idea/testData/intentions/loopToCallChain/assignMap2.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filter{}.map{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.map{}.toList()'" import java.util.ArrayList fun foo(list: List): List { diff --git a/idea/testData/intentions/loopToCallChain/assignMap2.kt.after2 b/idea/testData/intentions/loopToCallChain/assignMap2.kt.after2 new file mode 100644 index 00000000000..e0f5ac22a09 --- /dev/null +++ b/idea/testData/intentions/loopToCallChain/assignMap2.kt.after2 @@ -0,0 +1,13 @@ +// WITH_RUNTIME +// INTENTION_TEXT: "Replace with 'filter{}.map{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.map{}.toList()'" +import java.util.ArrayList + +fun foo(list: List): List { + val result = list + .asSequence() + .filter { it.length > 0 } + .map { it.hashCode() } + .toList() + return result +} \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/contains.kt b/idea/testData/intentions/loopToCallChain/contains.kt index 37b0af5fbfc..5ac52c19d81 100644 --- a/idea/testData/intentions/loopToCallChain/contains.kt +++ b/idea/testData/intentions/loopToCallChain/contains.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'contains()'" +// IS_APPLICABLE_2: false fun foo(list: List): Boolean { for (s in list) { if (s == "a") { diff --git a/idea/testData/intentions/loopToCallChain/contains.kt.after b/idea/testData/intentions/loopToCallChain/contains.kt.after index 94cf93a1eca..416433381ba 100644 --- a/idea/testData/intentions/loopToCallChain/contains.kt.after +++ b/idea/testData/intentions/loopToCallChain/contains.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'contains()'" +// IS_APPLICABLE_2: false fun foo(list: List): Boolean { return list.contains("a") } \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/contains2.kt b/idea/testData/intentions/loopToCallChain/contains2.kt index bed3e2c7d08..6be84362781 100644 --- a/idea/testData/intentions/loopToCallChain/contains2.kt +++ b/idea/testData/intentions/loopToCallChain/contains2.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'contains()'" +// IS_APPLICABLE_2: false fun foo(list: List) { var v = true for (s in list) { diff --git a/idea/testData/intentions/loopToCallChain/contains2.kt.after b/idea/testData/intentions/loopToCallChain/contains2.kt.after index 0f4611dd6c4..7279e8233fe 100644 --- a/idea/testData/intentions/loopToCallChain/contains2.kt.after +++ b/idea/testData/intentions/loopToCallChain/contains2.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'contains()'" +// IS_APPLICABLE_2: false fun foo(list: List) { val v = !list.contains("a") } \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/contains3.kt b/idea/testData/intentions/loopToCallChain/contains3.kt index babb299c143..776f7c87c45 100644 --- a/idea/testData/intentions/loopToCallChain/contains3.kt +++ b/idea/testData/intentions/loopToCallChain/contains3.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'contains()'" +// IS_APPLICABLE_2: false fun foo(list: List) { var v = false for (s in list) { diff --git a/idea/testData/intentions/loopToCallChain/contains3.kt.after b/idea/testData/intentions/loopToCallChain/contains3.kt.after index c9b4777ee52..f30e130ff2d 100644 --- a/idea/testData/intentions/loopToCallChain/contains3.kt.after +++ b/idea/testData/intentions/loopToCallChain/contains3.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'contains()'" +// IS_APPLICABLE_2: false fun foo(list: List) { val v = list.contains("a") } \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/contains4.kt b/idea/testData/intentions/loopToCallChain/contains4.kt index 1f3d2c6dc58..8b277c95015 100644 --- a/idea/testData/intentions/loopToCallChain/contains4.kt +++ b/idea/testData/intentions/loopToCallChain/contains4.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'contains()'" +// IS_APPLICABLE_2: false fun foo(list: List): Int { for (s in list) { if (s == "a") { diff --git a/idea/testData/intentions/loopToCallChain/contains4.kt.after b/idea/testData/intentions/loopToCallChain/contains4.kt.after index e2017a7bed1..22bd7a087bf 100644 --- a/idea/testData/intentions/loopToCallChain/contains4.kt.after +++ b/idea/testData/intentions/loopToCallChain/contains4.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'contains()'" +// IS_APPLICABLE_2: false fun foo(list: List): Int { return if (list.contains("a")) 1 else 0 } \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/count1.kt b/idea/testData/intentions/loopToCallChain/count1.kt index 0807bf1d14a..760fd3116d9 100644 --- a/idea/testData/intentions/loopToCallChain/count1.kt +++ b/idea/testData/intentions/loopToCallChain/count1.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'count{}'" +// IS_APPLICABLE_2: false fun foo(list: List): Int { var count = 0 for (s in list) { diff --git a/idea/testData/intentions/loopToCallChain/count1.kt.after b/idea/testData/intentions/loopToCallChain/count1.kt.after index 31d8c2c1d99..56ce0706476 100644 --- a/idea/testData/intentions/loopToCallChain/count1.kt.after +++ b/idea/testData/intentions/loopToCallChain/count1.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'count{}'" +// IS_APPLICABLE_2: false fun foo(list: List): Int { val count = list.count { it.isNotBlank() } return count diff --git a/idea/testData/intentions/loopToCallChain/count2.kt b/idea/testData/intentions/loopToCallChain/count2.kt index 25629baf997..318d1ce617c 100644 --- a/idea/testData/intentions/loopToCallChain/count2.kt +++ b/idea/testData/intentions/loopToCallChain/count2.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'count()'" +// IS_APPLICABLE_2: false fun foo(list: Iterable): Int { var count = 0 for (s in list) { diff --git a/idea/testData/intentions/loopToCallChain/count2.kt.after b/idea/testData/intentions/loopToCallChain/count2.kt.after index 4913e945652..b96f6d55d38 100644 --- a/idea/testData/intentions/loopToCallChain/count2.kt.after +++ b/idea/testData/intentions/loopToCallChain/count2.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'count()'" +// IS_APPLICABLE_2: false fun foo(list: Iterable): Int { val count = list.count() return count diff --git a/idea/testData/intentions/loopToCallChain/count_Long.kt b/idea/testData/intentions/loopToCallChain/count_Long.kt index a8575b565ff..39257ca84c8 100644 --- a/idea/testData/intentions/loopToCallChain/count_Long.kt +++ b/idea/testData/intentions/loopToCallChain/count_Long.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // IS_APPLICABLE: false +// IS_APPLICABLE_2: false fun foo(list: List): Long { var count = 0L for (s in list) { diff --git a/idea/testData/intentions/loopToCallChain/count_nonConstantInitial.kt b/idea/testData/intentions/loopToCallChain/count_nonConstantInitial.kt index a42ea1e237f..e40db4a6ed6 100644 --- a/idea/testData/intentions/loopToCallChain/count_nonConstantInitial.kt +++ b/idea/testData/intentions/loopToCallChain/count_nonConstantInitial.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'count{}'" +// IS_APPLICABLE_2: false fun foo(list: List): Int { var count = bar() for (s in list) { diff --git a/idea/testData/intentions/loopToCallChain/count_nonConstantInitial.kt.after b/idea/testData/intentions/loopToCallChain/count_nonConstantInitial.kt.after index 436f7f02e1a..6608508b9d6 100644 --- a/idea/testData/intentions/loopToCallChain/count_nonConstantInitial.kt.after +++ b/idea/testData/intentions/loopToCallChain/count_nonConstantInitial.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'count{}'" +// IS_APPLICABLE_2: false fun foo(list: List): Int { val count = bar() + list.count { it.isNotBlank() } return count diff --git a/idea/testData/intentions/loopToCallChain/count_nonZeroInitial.kt b/idea/testData/intentions/loopToCallChain/count_nonZeroInitial.kt index 488b69d0b5b..d85df7d25e5 100644 --- a/idea/testData/intentions/loopToCallChain/count_nonZeroInitial.kt +++ b/idea/testData/intentions/loopToCallChain/count_nonZeroInitial.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'count{}'" +// IS_APPLICABLE_2: false fun foo(list: List): Int { var count = 1 for (s in list) { diff --git a/idea/testData/intentions/loopToCallChain/count_nonZeroInitial.kt.after b/idea/testData/intentions/loopToCallChain/count_nonZeroInitial.kt.after index 50a5d562195..41e751584fb 100644 --- a/idea/testData/intentions/loopToCallChain/count_nonZeroInitial.kt.after +++ b/idea/testData/intentions/loopToCallChain/count_nonZeroInitial.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'count{}'" +// IS_APPLICABLE_2: false fun foo(list: List): Int { val count = 1 + list.count { it.isNotBlank() } return count diff --git a/idea/testData/intentions/loopToCallChain/count_prefix.kt b/idea/testData/intentions/loopToCallChain/count_prefix.kt index e9fd0601de9..614e6263a83 100644 --- a/idea/testData/intentions/loopToCallChain/count_prefix.kt +++ b/idea/testData/intentions/loopToCallChain/count_prefix.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'count{}'" +// IS_APPLICABLE_2: false fun foo(list: List): Int { var count = 0 for (s in list) { diff --git a/idea/testData/intentions/loopToCallChain/count_prefix.kt.after b/idea/testData/intentions/loopToCallChain/count_prefix.kt.after index 31d8c2c1d99..56ce0706476 100644 --- a/idea/testData/intentions/loopToCallChain/count_prefix.kt.after +++ b/idea/testData/intentions/loopToCallChain/count_prefix.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'count{}'" +// IS_APPLICABLE_2: false fun foo(list: List): Int { val count = list.count { it.isNotBlank() } return count diff --git a/idea/testData/intentions/loopToCallChain/count_variableUsedBefore.kt b/idea/testData/intentions/loopToCallChain/count_variableUsedBefore.kt index fd786da2407..bbeafe77d30 100644 --- a/idea/testData/intentions/loopToCallChain/count_variableUsedBefore.kt +++ b/idea/testData/intentions/loopToCallChain/count_variableUsedBefore.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // IS_APPLICABLE: false +// IS_APPLICABLE_2: false fun foo(list: List): Int { var count = 0 for (s in list) { diff --git a/idea/testData/intentions/loopToCallChain/customTypeWithIterator.kt b/idea/testData/intentions/loopToCallChain/customTypeWithIterator.kt index 61f733da609..f1d42f5a4e9 100644 --- a/idea/testData/intentions/loopToCallChain/customTypeWithIterator.kt +++ b/idea/testData/intentions/loopToCallChain/customTypeWithIterator.kt @@ -1,5 +1,6 @@ -// IS_APPLICABLE: false // WITH_RUNTIME +// IS_APPLICABLE: false +// IS_APPLICABLE_2: false class X { operator fun iterator(): Iterator{ return emptyList().iterator() diff --git a/idea/testData/intentions/loopToCallChain/embeddedBreak1.kt b/idea/testData/intentions/loopToCallChain/embeddedBreak1.kt index 28d09aae8cc..dcd6f9bba7c 100644 --- a/idea/testData/intentions/loopToCallChain/embeddedBreak1.kt +++ b/idea/testData/intentions/loopToCallChain/embeddedBreak1.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // IS_APPLICABLE: false +// IS_APPLICABLE_2: false fun foo(list: List, target: MutableList) { for (s in list) { val length = s?.length ?: break diff --git a/idea/testData/intentions/loopToCallChain/embeddedBreak2.kt b/idea/testData/intentions/loopToCallChain/embeddedBreak2.kt index 6d77729d536..f062860a3bc 100644 --- a/idea/testData/intentions/loopToCallChain/embeddedBreak2.kt +++ b/idea/testData/intentions/loopToCallChain/embeddedBreak2.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // IS_APPLICABLE: false +// IS_APPLICABLE_2: false fun foo(list: List, target: MutableList) { for (s in list) { val length = if (s.isNotEmpty()) s.length else break diff --git a/idea/testData/intentions/loopToCallChain/embeddedContinue.kt b/idea/testData/intentions/loopToCallChain/embeddedContinue.kt index aecfd7fb845..b31106c5557 100644 --- a/idea/testData/intentions/loopToCallChain/embeddedContinue.kt +++ b/idea/testData/intentions/loopToCallChain/embeddedContinue.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // IS_APPLICABLE: false +// IS_APPLICABLE_2: false fun foo(list: List, target: MutableList) { for (s in list) { val length = if (s.isNotEmpty()) s.length else continue diff --git a/idea/testData/intentions/loopToCallChain/filterIndexed.kt b/idea/testData/intentions/loopToCallChain/filterIndexed.kt index c9a14c17a1d..d75dc118a1b 100644 --- a/idea/testData/intentions/loopToCallChain/filterIndexed.kt +++ b/idea/testData/intentions/loopToCallChain/filterIndexed.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filterIndexed{}.firstOrNull()'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.firstOrNull()'" fun foo(list: List): String? { for ((index, s) in list.withIndex()) { if (s.length > index) { diff --git a/idea/testData/intentions/loopToCallChain/filterIndexed.kt.after b/idea/testData/intentions/loopToCallChain/filterIndexed.kt.after index 3b48882aa53..c2472f0b8dd 100644 --- a/idea/testData/intentions/loopToCallChain/filterIndexed.kt.after +++ b/idea/testData/intentions/loopToCallChain/filterIndexed.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filterIndexed{}.firstOrNull()'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.firstOrNull()'" fun foo(list: List): String? { return list .filterIndexed { index, s -> s.length > index } diff --git a/idea/testData/intentions/loopToCallChain/filterIndexed.kt.after2 b/idea/testData/intentions/loopToCallChain/filterIndexed.kt.after2 new file mode 100644 index 00000000000..ed0fdb27141 --- /dev/null +++ b/idea/testData/intentions/loopToCallChain/filterIndexed.kt.after2 @@ -0,0 +1,9 @@ +// WITH_RUNTIME +// INTENTION_TEXT: "Replace with 'filterIndexed{}.firstOrNull()'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.firstOrNull()'" +fun foo(list: List): String? { + return list + .asSequence() + .filterIndexed { index, s -> s.length > index } + .firstOrNull() +} \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/filterIndexed2.kt b/idea/testData/intentions/loopToCallChain/filterIndexed2.kt index 54d352283a4..6d5a4805e8d 100644 --- a/idea/testData/intentions/loopToCallChain/filterIndexed2.kt +++ b/idea/testData/intentions/loopToCallChain/filterIndexed2.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filterIndexed{}.firstOrNull()'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.firstOrNull()'" fun foo(list: List): String? { var i = 0 for (s in list) { diff --git a/idea/testData/intentions/loopToCallChain/filterIndexed2.kt.after b/idea/testData/intentions/loopToCallChain/filterIndexed2.kt.after index c20fa3f53bf..c9681aa6f0f 100644 --- a/idea/testData/intentions/loopToCallChain/filterIndexed2.kt.after +++ b/idea/testData/intentions/loopToCallChain/filterIndexed2.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filterIndexed{}.firstOrNull()'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.firstOrNull()'" fun foo(list: List): String? { return list .filterIndexed { i, s -> s.length > i } diff --git a/idea/testData/intentions/loopToCallChain/filterIndexed2.kt.after2 b/idea/testData/intentions/loopToCallChain/filterIndexed2.kt.after2 new file mode 100644 index 00000000000..830c8d0148c --- /dev/null +++ b/idea/testData/intentions/loopToCallChain/filterIndexed2.kt.after2 @@ -0,0 +1,9 @@ +// WITH_RUNTIME +// INTENTION_TEXT: "Replace with 'filterIndexed{}.firstOrNull()'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.firstOrNull()'" +fun foo(list: List): String? { + return list + .asSequence() + .filterIndexed { i, s -> s.length > i } + .firstOrNull() +} \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/filterIndexedAndFlatMapWithContinue.kt b/idea/testData/intentions/loopToCallChain/filterIndexedAndFlatMapWithContinue.kt index 1786271d5e7..bc6201f1e65 100644 --- a/idea/testData/intentions/loopToCallChain/filterIndexedAndFlatMapWithContinue.kt +++ b/idea/testData/intentions/loopToCallChain/filterIndexedAndFlatMapWithContinue.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with '...flatMap{}.filterNot{}.mapTo(){}'" +// INTENTION_TEXT_2: "Replace with 'asSequence()...flatMap{}.filterNot{}.mapTo(){}'" fun foo(list: List, target: MutableCollection) { var i = 0 for (s in list) { diff --git a/idea/testData/intentions/loopToCallChain/filterIndexedAndFlatMapWithContinue.kt.after b/idea/testData/intentions/loopToCallChain/filterIndexedAndFlatMapWithContinue.kt.after index c2105ffdc42..241ac49f320 100644 --- a/idea/testData/intentions/loopToCallChain/filterIndexedAndFlatMapWithContinue.kt.after +++ b/idea/testData/intentions/loopToCallChain/filterIndexedAndFlatMapWithContinue.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with '...flatMap{}.filterNot{}.mapTo(){}'" +// INTENTION_TEXT_2: "Replace with 'asSequence()...flatMap{}.filterNot{}.mapTo(){}'" fun foo(list: List, target: MutableCollection) { list .filterIndexed { i, s -> i % 10 != 0 } diff --git a/idea/testData/intentions/loopToCallChain/filterIndexedAndFlatMapWithContinue.kt.after2 b/idea/testData/intentions/loopToCallChain/filterIndexedAndFlatMapWithContinue.kt.after2 new file mode 100644 index 00000000000..3be1aec7ecc --- /dev/null +++ b/idea/testData/intentions/loopToCallChain/filterIndexedAndFlatMapWithContinue.kt.after2 @@ -0,0 +1,11 @@ +// WITH_RUNTIME +// INTENTION_TEXT: "Replace with '...flatMap{}.filterNot{}.mapTo(){}'" +// INTENTION_TEXT_2: "Replace with 'asSequence()...flatMap{}.filterNot{}.mapTo(){}'" +fun foo(list: List, target: MutableCollection) { + list + .asSequence() + .filterIndexed { i, s -> i % 10 != 0 } + .flatMap { it.indices.asSequence() } + .filterNot { it == 10 } + .mapTo(target) { it.toString() } +} \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/filterIndexedTo.kt b/idea/testData/intentions/loopToCallChain/filterIndexedTo.kt index 535454390df..1fec930f357 100644 --- a/idea/testData/intentions/loopToCallChain/filterIndexedTo.kt +++ b/idea/testData/intentions/loopToCallChain/filterIndexedTo.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filterIndexedTo(){}'" +// IS_APPLICABLE_2: false fun foo(list: List, target: MutableList) { for ((index, s) in list.withIndex()) { if (s.length > index) diff --git a/idea/testData/intentions/loopToCallChain/filterIndexedTo.kt.after b/idea/testData/intentions/loopToCallChain/filterIndexedTo.kt.after index c7067763d94..96b2702058f 100644 --- a/idea/testData/intentions/loopToCallChain/filterIndexedTo.kt.after +++ b/idea/testData/intentions/loopToCallChain/filterIndexedTo.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filterIndexedTo(){}'" +// IS_APPLICABLE_2: false fun foo(list: List, target: MutableList) { list.filterIndexedTo(target) { index, s -> s.length > index } } \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/filterIndexedTo2.kt b/idea/testData/intentions/loopToCallChain/filterIndexedTo2.kt index 53d564f76d5..2137e935cae 100644 --- a/idea/testData/intentions/loopToCallChain/filterIndexedTo2.kt +++ b/idea/testData/intentions/loopToCallChain/filterIndexedTo2.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filterIndexedTo(){}'" +// IS_APPLICABLE_2: false import java.util.ArrayList fun foo(list: List): List { diff --git a/idea/testData/intentions/loopToCallChain/filterIndexedTo2.kt.after b/idea/testData/intentions/loopToCallChain/filterIndexedTo2.kt.after index bc1b0316ea0..09c8342897e 100644 --- a/idea/testData/intentions/loopToCallChain/filterIndexedTo2.kt.after +++ b/idea/testData/intentions/loopToCallChain/filterIndexedTo2.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filterIndexedTo(){}'" +// IS_APPLICABLE_2: false import java.util.ArrayList fun foo(list: List): List { diff --git a/idea/testData/intentions/loopToCallChain/filterIndexed_indexChangedTwice.kt b/idea/testData/intentions/loopToCallChain/filterIndexed_indexChangedTwice.kt index 586e369d527..50268f90a5e 100644 --- a/idea/testData/intentions/loopToCallChain/filterIndexed_indexChangedTwice.kt +++ b/idea/testData/intentions/loopToCallChain/filterIndexed_indexChangedTwice.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // IS_APPLICABLE: false +// IS_APPLICABLE_2: false fun foo(list: List, target: MutableCollection): String? { var i = 0 for (s in list) { diff --git a/idea/testData/intentions/loopToCallChain/filterIndexed_indexStartNotZero.kt b/idea/testData/intentions/loopToCallChain/filterIndexed_indexStartNotZero.kt index d761bb2bc46..50d24ffb750 100644 --- a/idea/testData/intentions/loopToCallChain/filterIndexed_indexStartNotZero.kt +++ b/idea/testData/intentions/loopToCallChain/filterIndexed_indexStartNotZero.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // IS_APPLICABLE: false +// IS_APPLICABLE_2: false fun foo(list: List): String? { var i = 1 for (s in list) { diff --git a/idea/testData/intentions/loopToCallChain/filterIndexed_indexUsedAfter.kt b/idea/testData/intentions/loopToCallChain/filterIndexed_indexUsedAfter.kt index 4c4ea02e7fb..daa16795da4 100644 --- a/idea/testData/intentions/loopToCallChain/filterIndexed_indexUsedAfter.kt +++ b/idea/testData/intentions/loopToCallChain/filterIndexed_indexUsedAfter.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // IS_APPLICABLE: false +// IS_APPLICABLE_2: false fun foo(list: List, target: MutableCollection): String? { var i = 0 for (s in list) { diff --git a/idea/testData/intentions/loopToCallChain/filterIndexed_indexUsedEarlierInLoop.kt b/idea/testData/intentions/loopToCallChain/filterIndexed_indexUsedEarlierInLoop.kt index 54cb7888260..28df43ad579 100644 --- a/idea/testData/intentions/loopToCallChain/filterIndexed_indexUsedEarlierInLoop.kt +++ b/idea/testData/intentions/loopToCallChain/filterIndexed_indexUsedEarlierInLoop.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // IS_APPLICABLE: false +// IS_APPLICABLE_2: false fun foo(list: List, target: MutableCollection): String? { var i = 0 for (s in list) { diff --git a/idea/testData/intentions/loopToCallChain/filterIndexed_merge1.kt b/idea/testData/intentions/loopToCallChain/filterIndexed_merge1.kt index 3ba6a90278a..416c13527f8 100644 --- a/idea/testData/intentions/loopToCallChain/filterIndexed_merge1.kt +++ b/idea/testData/intentions/loopToCallChain/filterIndexed_merge1.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filterIndexed{}.firstOrNull()'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.firstOrNull()'" fun foo(list: List): String? { for ((index, s) in list.withIndex()) { if (s.length > index * 10) continue diff --git a/idea/testData/intentions/loopToCallChain/filterIndexed_merge1.kt.after b/idea/testData/intentions/loopToCallChain/filterIndexed_merge1.kt.after index d1a28dbe654..1203ddea360 100644 --- a/idea/testData/intentions/loopToCallChain/filterIndexed_merge1.kt.after +++ b/idea/testData/intentions/loopToCallChain/filterIndexed_merge1.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filterIndexed{}.firstOrNull()'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.firstOrNull()'" fun foo(list: List): String? { return list .filterIndexed { index, s -> s.length <= index * 10 && s.length > index } diff --git a/idea/testData/intentions/loopToCallChain/filterIndexed_merge1.kt.after2 b/idea/testData/intentions/loopToCallChain/filterIndexed_merge1.kt.after2 new file mode 100644 index 00000000000..96b28dd21a9 --- /dev/null +++ b/idea/testData/intentions/loopToCallChain/filterIndexed_merge1.kt.after2 @@ -0,0 +1,9 @@ +// WITH_RUNTIME +// INTENTION_TEXT: "Replace with 'filterIndexed{}.firstOrNull()'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.firstOrNull()'" +fun foo(list: List): String? { + return list + .asSequence() + .filterIndexed { index, s -> s.length <= index * 10 && s.length > index } + .firstOrNull() +} \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/filterIndexed_merge2.kt b/idea/testData/intentions/loopToCallChain/filterIndexed_merge2.kt index 5774814e3e9..ac588e89209 100644 --- a/idea/testData/intentions/loopToCallChain/filterIndexed_merge2.kt +++ b/idea/testData/intentions/loopToCallChain/filterIndexed_merge2.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filterIndexed{}.firstOrNull()'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.firstOrNull()'" fun foo(list: List): String? { for ((index, s) in list.withIndex()) { if (s.isBlank()) continue diff --git a/idea/testData/intentions/loopToCallChain/filterIndexed_merge2.kt.after b/idea/testData/intentions/loopToCallChain/filterIndexed_merge2.kt.after index 48ad88a2b4d..6fdaa80c271 100644 --- a/idea/testData/intentions/loopToCallChain/filterIndexed_merge2.kt.after +++ b/idea/testData/intentions/loopToCallChain/filterIndexed_merge2.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filterIndexed{}.firstOrNull()'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.firstOrNull()'" fun foo(list: List): String? { return list .filterIndexed { index, s -> !s.isBlank() && s.length > index } diff --git a/idea/testData/intentions/loopToCallChain/filterIndexed_merge2.kt.after2 b/idea/testData/intentions/loopToCallChain/filterIndexed_merge2.kt.after2 new file mode 100644 index 00000000000..aa40e164b08 --- /dev/null +++ b/idea/testData/intentions/loopToCallChain/filterIndexed_merge2.kt.after2 @@ -0,0 +1,9 @@ +// WITH_RUNTIME +// INTENTION_TEXT: "Replace with 'filterIndexed{}.firstOrNull()'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.firstOrNull()'" +fun foo(list: List): String? { + return list + .asSequence() + .filterIndexed { index, s -> !s.isBlank() && s.length > index } + .firstOrNull() +} \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/filterIndexed_merge3.kt b/idea/testData/intentions/loopToCallChain/filterIndexed_merge3.kt index 0dfa3dbaaa3..48d82e09802 100644 --- a/idea/testData/intentions/loopToCallChain/filterIndexed_merge3.kt +++ b/idea/testData/intentions/loopToCallChain/filterIndexed_merge3.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filterIndexed{}.firstOrNull()'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.firstOrNull()'" fun foo(list: List): String? { for ((index, s) in list.withIndex()) { if (s.length > index) continue diff --git a/idea/testData/intentions/loopToCallChain/filterIndexed_merge3.kt.after b/idea/testData/intentions/loopToCallChain/filterIndexed_merge3.kt.after index f1490d63d39..b1342807c07 100644 --- a/idea/testData/intentions/loopToCallChain/filterIndexed_merge3.kt.after +++ b/idea/testData/intentions/loopToCallChain/filterIndexed_merge3.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filterIndexed{}.firstOrNull()'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.firstOrNull()'" fun foo(list: List): String? { return list .filterIndexed { index, s -> s.length <= index && s.isNotBlank() } diff --git a/idea/testData/intentions/loopToCallChain/filterIndexed_merge3.kt.after2 b/idea/testData/intentions/loopToCallChain/filterIndexed_merge3.kt.after2 new file mode 100644 index 00000000000..e8d26f594bd --- /dev/null +++ b/idea/testData/intentions/loopToCallChain/filterIndexed_merge3.kt.after2 @@ -0,0 +1,9 @@ +// WITH_RUNTIME +// INTENTION_TEXT: "Replace with 'filterIndexed{}.firstOrNull()'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.firstOrNull()'" +fun foo(list: List): String? { + return list + .asSequence() + .filterIndexed { index, s -> s.length <= index && s.isNotBlank() } + .firstOrNull() +} \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/filterIndexed_merge4.kt b/idea/testData/intentions/loopToCallChain/filterIndexed_merge4.kt index f0ab475a083..de4a7669513 100644 --- a/idea/testData/intentions/loopToCallChain/filterIndexed_merge4.kt +++ b/idea/testData/intentions/loopToCallChain/filterIndexed_merge4.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filterIndexed{}.firstOrNull()'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.firstOrNull()'" fun foo(list: List): String? { var index2 = 0 for ((index1, s) in list.withIndex()) { diff --git a/idea/testData/intentions/loopToCallChain/filterIndexed_merge4.kt.after b/idea/testData/intentions/loopToCallChain/filterIndexed_merge4.kt.after index b9beb42ba86..5393146e1a5 100644 --- a/idea/testData/intentions/loopToCallChain/filterIndexed_merge4.kt.after +++ b/idea/testData/intentions/loopToCallChain/filterIndexed_merge4.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filterIndexed{}.firstOrNull()'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.firstOrNull()'" fun foo(list: List): String? { var index2 = 0 return list diff --git a/idea/testData/intentions/loopToCallChain/filterIndexed_merge4.kt.after2 b/idea/testData/intentions/loopToCallChain/filterIndexed_merge4.kt.after2 new file mode 100644 index 00000000000..6bdbbe1db78 --- /dev/null +++ b/idea/testData/intentions/loopToCallChain/filterIndexed_merge4.kt.after2 @@ -0,0 +1,10 @@ +// WITH_RUNTIME +// INTENTION_TEXT: "Replace with 'filterIndexed{}.firstOrNull()'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.firstOrNull()'" +fun foo(list: List): String? { + var index2 = 0 + return list + .asSequence() + .filterIndexed { index1, s -> s.length <= index1 && s.length >= index2++ } + .firstOrNull() +} \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/filterIndexed_twoIndices.kt b/idea/testData/intentions/loopToCallChain/filterIndexed_twoIndices.kt index a80445b5519..2ed028524ed 100644 --- a/idea/testData/intentions/loopToCallChain/filterIndexed_twoIndices.kt +++ b/idea/testData/intentions/loopToCallChain/filterIndexed_twoIndices.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filterIndexed{}.filterIndexedTo(){}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.filterIndexedTo(){}'" fun foo(list: List, target: MutableCollection) { var j = 0 for ((i, s) in list.withIndex()) { diff --git a/idea/testData/intentions/loopToCallChain/filterIndexed_twoIndices.kt.after b/idea/testData/intentions/loopToCallChain/filterIndexed_twoIndices.kt.after index ed251f71beb..88355ecf23a 100644 --- a/idea/testData/intentions/loopToCallChain/filterIndexed_twoIndices.kt.after +++ b/idea/testData/intentions/loopToCallChain/filterIndexed_twoIndices.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filterIndexed{}.filterIndexedTo(){}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.filterIndexedTo(){}'" fun foo(list: List, target: MutableCollection) { list .filterIndexed { i, s -> s.length <= i } diff --git a/idea/testData/intentions/loopToCallChain/filterIndexed_twoIndices.kt.after2 b/idea/testData/intentions/loopToCallChain/filterIndexed_twoIndices.kt.after2 new file mode 100644 index 00000000000..33585c6432c --- /dev/null +++ b/idea/testData/intentions/loopToCallChain/filterIndexed_twoIndices.kt.after2 @@ -0,0 +1,9 @@ +// WITH_RUNTIME +// INTENTION_TEXT: "Replace with 'filterIndexed{}.filterIndexedTo(){}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.filterIndexedTo(){}'" +fun foo(list: List, target: MutableCollection) { + list + .asSequence() + .filterIndexed { i, s -> s.length <= i } + .filterIndexedTo(target) { j, s -> s.length % j == 0 } +} \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/filterIndexed_twoIndicesUsed.kt b/idea/testData/intentions/loopToCallChain/filterIndexed_twoIndicesUsed.kt index c16379fede4..b68788fa8cf 100644 --- a/idea/testData/intentions/loopToCallChain/filterIndexed_twoIndicesUsed.kt +++ b/idea/testData/intentions/loopToCallChain/filterIndexed_twoIndicesUsed.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // IS_APPLICABLE: false +// IS_APPLICABLE_2: false fun foo(list: List, target: MutableCollection) { var j = 0 for ((i, s) in list.withIndex()) { diff --git a/idea/testData/intentions/loopToCallChain/filterIsInstance.kt b/idea/testData/intentions/loopToCallChain/filterIsInstance.kt index 5cc56d506a9..6b13850375a 100644 --- a/idea/testData/intentions/loopToCallChain/filterIsInstance.kt +++ b/idea/testData/intentions/loopToCallChain/filterIsInstance.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filterIsInstance<>().map{}.firstOrNull()'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filterIsInstance<>().map{}.firstOrNull()'" fun foo(list: List): Int? { for (o in list) { if (o is String) { diff --git a/idea/testData/intentions/loopToCallChain/filterIsInstance.kt.after b/idea/testData/intentions/loopToCallChain/filterIsInstance.kt.after index ea7ba4023ec..5110045d434 100644 --- a/idea/testData/intentions/loopToCallChain/filterIsInstance.kt.after +++ b/idea/testData/intentions/loopToCallChain/filterIsInstance.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filterIsInstance<>().map{}.firstOrNull()'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filterIsInstance<>().map{}.firstOrNull()'" fun foo(list: List): Int? { return list .filterIsInstance() diff --git a/idea/testData/intentions/loopToCallChain/filterIsInstance.kt.after2 b/idea/testData/intentions/loopToCallChain/filterIsInstance.kt.after2 new file mode 100644 index 00000000000..8fd72f3b20e --- /dev/null +++ b/idea/testData/intentions/loopToCallChain/filterIsInstance.kt.after2 @@ -0,0 +1,10 @@ +// WITH_RUNTIME +// INTENTION_TEXT: "Replace with 'filterIsInstance<>().map{}.firstOrNull()'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filterIsInstance<>().map{}.firstOrNull()'" +fun foo(list: List): Int? { + return list + .asSequence() + .filterIsInstance() + .map { it.length } + .firstOrNull() +} \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/filterIsInstanceTo.kt b/idea/testData/intentions/loopToCallChain/filterIsInstanceTo.kt index 92e20d58550..ad6a7857cbf 100644 --- a/idea/testData/intentions/loopToCallChain/filterIsInstanceTo.kt +++ b/idea/testData/intentions/loopToCallChain/filterIsInstanceTo.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with '+= filterIsInstance<>()'" +// INTENTION_TEXT_2: "Replace with '+= asSequence().filterIsInstance<>()'" // decided to not generate "filterIsInstanceTo" because it either requires 2 type arguments (looks awful) or no type arguments at all (looks confusing) diff --git a/idea/testData/intentions/loopToCallChain/filterIsInstanceTo.kt.after b/idea/testData/intentions/loopToCallChain/filterIsInstanceTo.kt.after index 683f488ae11..148c60f60ff 100644 --- a/idea/testData/intentions/loopToCallChain/filterIsInstanceTo.kt.after +++ b/idea/testData/intentions/loopToCallChain/filterIsInstanceTo.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with '+= filterIsInstance<>()'" +// INTENTION_TEXT_2: "Replace with '+= asSequence().filterIsInstance<>()'" // decided to not generate "filterIsInstanceTo" because it either requires 2 type arguments (looks awful) or no type arguments at all (looks confusing) diff --git a/idea/testData/intentions/loopToCallChain/filterIsInstanceTo.kt.after2 b/idea/testData/intentions/loopToCallChain/filterIsInstanceTo.kt.after2 new file mode 100644 index 00000000000..72f76c67cf7 --- /dev/null +++ b/idea/testData/intentions/loopToCallChain/filterIsInstanceTo.kt.after2 @@ -0,0 +1,11 @@ +// WITH_RUNTIME +// INTENTION_TEXT: "Replace with '+= filterIsInstance<>()'" +// INTENTION_TEXT_2: "Replace with '+= asSequence().filterIsInstance<>()'" + +// decided to not generate "filterIsInstanceTo" because it either requires 2 type arguments (looks awful) or no type arguments at all (looks confusing) + +fun foo(list: List, target: MutableCollection) { + target += list + .asSequence() + .filterIsInstance() +} \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/filterIsInstance_ifContinue.kt b/idea/testData/intentions/loopToCallChain/filterIsInstance_ifContinue.kt index 341badbcf83..128a8b82643 100644 --- a/idea/testData/intentions/loopToCallChain/filterIsInstance_ifContinue.kt +++ b/idea/testData/intentions/loopToCallChain/filterIsInstance_ifContinue.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filterIsInstance<>().map{}.firstOrNull()'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filterIsInstance<>().map{}.firstOrNull()'" fun foo(list: List): Int? { for (o in list) { if (o !is String) continue diff --git a/idea/testData/intentions/loopToCallChain/filterIsInstance_ifContinue.kt.after b/idea/testData/intentions/loopToCallChain/filterIsInstance_ifContinue.kt.after index ea7ba4023ec..5110045d434 100644 --- a/idea/testData/intentions/loopToCallChain/filterIsInstance_ifContinue.kt.after +++ b/idea/testData/intentions/loopToCallChain/filterIsInstance_ifContinue.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filterIsInstance<>().map{}.firstOrNull()'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filterIsInstance<>().map{}.firstOrNull()'" fun foo(list: List): Int? { return list .filterIsInstance() diff --git a/idea/testData/intentions/loopToCallChain/filterIsInstance_ifContinue.kt.after2 b/idea/testData/intentions/loopToCallChain/filterIsInstance_ifContinue.kt.after2 new file mode 100644 index 00000000000..8fd72f3b20e --- /dev/null +++ b/idea/testData/intentions/loopToCallChain/filterIsInstance_ifContinue.kt.after2 @@ -0,0 +1,10 @@ +// WITH_RUNTIME +// INTENTION_TEXT: "Replace with 'filterIsInstance<>().map{}.firstOrNull()'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filterIsInstance<>().map{}.firstOrNull()'" +fun foo(list: List): Int? { + return list + .asSequence() + .filterIsInstance() + .map { it.length } + .firstOrNull() +} \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/filterNotNull.kt b/idea/testData/intentions/loopToCallChain/filterNotNull.kt index 1568629e637..76b9b6a18ad 100644 --- a/idea/testData/intentions/loopToCallChain/filterNotNull.kt +++ b/idea/testData/intentions/loopToCallChain/filterNotNull.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filterNotNull().map{}.firstOrNull()'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filterNotNull().map{}.firstOrNull()'" fun foo(list: List): Int? { for (s in list) { if (s != null) { diff --git a/idea/testData/intentions/loopToCallChain/filterNotNull.kt.after b/idea/testData/intentions/loopToCallChain/filterNotNull.kt.after index dcf15bb6767..9c66d536cb3 100644 --- a/idea/testData/intentions/loopToCallChain/filterNotNull.kt.after +++ b/idea/testData/intentions/loopToCallChain/filterNotNull.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filterNotNull().map{}.firstOrNull()'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filterNotNull().map{}.firstOrNull()'" fun foo(list: List): Int? { return list .filterNotNull() diff --git a/idea/testData/intentions/loopToCallChain/filterNotNull.kt.after2 b/idea/testData/intentions/loopToCallChain/filterNotNull.kt.after2 new file mode 100644 index 00000000000..c0e85ab584e --- /dev/null +++ b/idea/testData/intentions/loopToCallChain/filterNotNull.kt.after2 @@ -0,0 +1,10 @@ +// WITH_RUNTIME +// INTENTION_TEXT: "Replace with 'filterNotNull().map{}.firstOrNull()'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filterNotNull().map{}.firstOrNull()'" +fun foo(list: List): Int? { + return list + .asSequence() + .filterNotNull() + .map { it.length } + .firstOrNull() +} \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/filterNotNullTo.kt b/idea/testData/intentions/loopToCallChain/filterNotNullTo.kt index 14d45edf855..8e6b0bb82ef 100644 --- a/idea/testData/intentions/loopToCallChain/filterNotNullTo.kt +++ b/idea/testData/intentions/loopToCallChain/filterNotNullTo.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filterNotNullTo()'" +// IS_APPLICABLE_2: false fun foo(list: List, target: MutableCollection) { for (s in list) { if (s != null) { diff --git a/idea/testData/intentions/loopToCallChain/filterNotNullTo.kt.after b/idea/testData/intentions/loopToCallChain/filterNotNullTo.kt.after index aac8cc4789d..b931aa6d868 100644 --- a/idea/testData/intentions/loopToCallChain/filterNotNullTo.kt.after +++ b/idea/testData/intentions/loopToCallChain/filterNotNullTo.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filterNotNullTo()'" +// IS_APPLICABLE_2: false fun foo(list: List, target: MutableCollection) { list.filterNotNullTo(target) } \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/filterNotNullTo2.kt b/idea/testData/intentions/loopToCallChain/filterNotNullTo2.kt index 2a78a848cef..80c5805f191 100644 --- a/idea/testData/intentions/loopToCallChain/filterNotNullTo2.kt +++ b/idea/testData/intentions/loopToCallChain/filterNotNullTo2.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filterNotNullTo()'" +// IS_APPLICABLE_2: false import java.util.ArrayList fun foo(list: List) { diff --git a/idea/testData/intentions/loopToCallChain/filterNotNullTo2.kt.after b/idea/testData/intentions/loopToCallChain/filterNotNullTo2.kt.after index 644d020ed11..ed49b9b6dce 100644 --- a/idea/testData/intentions/loopToCallChain/filterNotNullTo2.kt.after +++ b/idea/testData/intentions/loopToCallChain/filterNotNullTo2.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filterNotNullTo()'" +// IS_APPLICABLE_2: false import java.util.ArrayList fun foo(list: List) { diff --git a/idea/testData/intentions/loopToCallChain/filterNotNull_ifContinue.kt b/idea/testData/intentions/loopToCallChain/filterNotNull_ifContinue.kt index fed19dc9b94..b4a63922017 100644 --- a/idea/testData/intentions/loopToCallChain/filterNotNull_ifContinue.kt +++ b/idea/testData/intentions/loopToCallChain/filterNotNull_ifContinue.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filterNotNull().map{}.firstOrNull()'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filterNotNull().map{}.firstOrNull()'" fun foo(list: List): Int? { for (o in list) { if (o == null) continue diff --git a/idea/testData/intentions/loopToCallChain/filterNotNull_ifContinue.kt.after b/idea/testData/intentions/loopToCallChain/filterNotNull_ifContinue.kt.after index 85d51b00bba..4050363ae19 100644 --- a/idea/testData/intentions/loopToCallChain/filterNotNull_ifContinue.kt.after +++ b/idea/testData/intentions/loopToCallChain/filterNotNull_ifContinue.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filterNotNull().map{}.firstOrNull()'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filterNotNull().map{}.firstOrNull()'" fun foo(list: List): Int? { return list .filterNotNull() diff --git a/idea/testData/intentions/loopToCallChain/filterNotNull_ifContinue.kt.after2 b/idea/testData/intentions/loopToCallChain/filterNotNull_ifContinue.kt.after2 new file mode 100644 index 00000000000..523c3b43562 --- /dev/null +++ b/idea/testData/intentions/loopToCallChain/filterNotNull_ifContinue.kt.after2 @@ -0,0 +1,10 @@ +// WITH_RUNTIME +// INTENTION_TEXT: "Replace with 'filterNotNull().map{}.firstOrNull()'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filterNotNull().map{}.firstOrNull()'" +fun foo(list: List): Int? { + return list + .asSequence() + .filterNotNull() + .map { it.hashCode() } + .firstOrNull() +} \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/filterNotTo.kt b/idea/testData/intentions/loopToCallChain/filterNotTo.kt index 92dac16733c..2c7991dd994 100644 --- a/idea/testData/intentions/loopToCallChain/filterNotTo.kt +++ b/idea/testData/intentions/loopToCallChain/filterNotTo.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filterNotTo(){}'" +// IS_APPLICABLE_2: false fun foo(list: List, target: MutableList) { for (s in list) { if (s.length == 0) continue diff --git a/idea/testData/intentions/loopToCallChain/filterNotTo.kt.after b/idea/testData/intentions/loopToCallChain/filterNotTo.kt.after index 3a99dd02197..8d8dec42f72 100644 --- a/idea/testData/intentions/loopToCallChain/filterNotTo.kt.after +++ b/idea/testData/intentions/loopToCallChain/filterNotTo.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filterNotTo(){}'" +// IS_APPLICABLE_2: false fun foo(list: List, target: MutableList) { list.filterNotTo(target) { it.length == 0 } } \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/filterNot_ifContinue.kt b/idea/testData/intentions/loopToCallChain/filterNot_ifContinue.kt index d1e74c23d8a..e30d3e7fe46 100644 --- a/idea/testData/intentions/loopToCallChain/filterNot_ifContinue.kt +++ b/idea/testData/intentions/loopToCallChain/filterNot_ifContinue.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filterNot{}.map{}.firstOrNull()'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filterNot{}.map{}.firstOrNull()'" fun foo(list: List): Int? { for (s in list) { if (s.isEmpty()) continue diff --git a/idea/testData/intentions/loopToCallChain/filterNot_ifContinue.kt.after b/idea/testData/intentions/loopToCallChain/filterNot_ifContinue.kt.after index 34ac70fb56a..f766b4a4271 100644 --- a/idea/testData/intentions/loopToCallChain/filterNot_ifContinue.kt.after +++ b/idea/testData/intentions/loopToCallChain/filterNot_ifContinue.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filterNot{}.map{}.firstOrNull()'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filterNot{}.map{}.firstOrNull()'" fun foo(list: List): Int? { return list .filterNot { it.isEmpty() } diff --git a/idea/testData/intentions/loopToCallChain/filterNot_ifContinue.kt.after2 b/idea/testData/intentions/loopToCallChain/filterNot_ifContinue.kt.after2 new file mode 100644 index 00000000000..607356a51ce --- /dev/null +++ b/idea/testData/intentions/loopToCallChain/filterNot_ifContinue.kt.after2 @@ -0,0 +1,10 @@ +// WITH_RUNTIME +// INTENTION_TEXT: "Replace with 'filterNot{}.map{}.firstOrNull()'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filterNot{}.map{}.firstOrNull()'" +fun foo(list: List): Int? { + return list + .asSequence() + .filterNot { it.isEmpty() } + .map { it.length } + .firstOrNull() +} \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/filterTo.kt b/idea/testData/intentions/loopToCallChain/filterTo.kt index 24a3c70e5ee..08d6c6de73e 100644 --- a/idea/testData/intentions/loopToCallChain/filterTo.kt +++ b/idea/testData/intentions/loopToCallChain/filterTo.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filterTo(){}'" +// IS_APPLICABLE_2: false fun foo(list: List, target: MutableList) { for (s in list) { if (s.length > 0) diff --git a/idea/testData/intentions/loopToCallChain/filterTo.kt.after b/idea/testData/intentions/loopToCallChain/filterTo.kt.after index 40c646820fc..3c6ba89a8ca 100644 --- a/idea/testData/intentions/loopToCallChain/filterTo.kt.after +++ b/idea/testData/intentions/loopToCallChain/filterTo.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filterTo(){}'" +// IS_APPLICABLE_2: false fun foo(list: List, target: MutableList) { list.filterTo(target) { it.length > 0 } } \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/filterTo2.kt b/idea/testData/intentions/loopToCallChain/filterTo2.kt index d9b8845d6a1..c52093ee998 100644 --- a/idea/testData/intentions/loopToCallChain/filterTo2.kt +++ b/idea/testData/intentions/loopToCallChain/filterTo2.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filterTo(){}'" +// IS_APPLICABLE_2: false fun foo(list: List) { val target = createCollection() for (s in list) { diff --git a/idea/testData/intentions/loopToCallChain/filterTo2.kt.after b/idea/testData/intentions/loopToCallChain/filterTo2.kt.after index 641d0ff05eb..0c699aefdff 100644 --- a/idea/testData/intentions/loopToCallChain/filterTo2.kt.after +++ b/idea/testData/intentions/loopToCallChain/filterTo2.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filterTo(){}'" +// IS_APPLICABLE_2: false fun foo(list: List) { val target = createCollection() list.filterTo(target) { it.length > 0 } diff --git a/idea/testData/intentions/loopToCallChain/filter_ifContinue.kt b/idea/testData/intentions/loopToCallChain/filter_ifContinue.kt index 25c19e283b1..a145c540ade 100644 --- a/idea/testData/intentions/loopToCallChain/filter_ifContinue.kt +++ b/idea/testData/intentions/loopToCallChain/filter_ifContinue.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'firstOrNull{}'" +// IS_APPLICABLE_2: false fun foo(list: List): String? { for (s in list) { if (s.isEmpty()) continue diff --git a/idea/testData/intentions/loopToCallChain/filter_ifContinue.kt.after b/idea/testData/intentions/loopToCallChain/filter_ifContinue.kt.after index 7478c511744..8f33180b3eb 100644 --- a/idea/testData/intentions/loopToCallChain/filter_ifContinue.kt.after +++ b/idea/testData/intentions/loopToCallChain/filter_ifContinue.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'firstOrNull{}'" +// IS_APPLICABLE_2: false fun foo(list: List): String? { return list.firstOrNull { !it.isEmpty() } } \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/filter_ifContinue2.kt b/idea/testData/intentions/loopToCallChain/filter_ifContinue2.kt index f69e1faeae6..8362f3b6794 100644 --- a/idea/testData/intentions/loopToCallChain/filter_ifContinue2.kt +++ b/idea/testData/intentions/loopToCallChain/filter_ifContinue2.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'firstOrNull{}'" +// IS_APPLICABLE_2: false fun foo(list: List): String? { for (s in list) { if (!s.isEmpty()) continue diff --git a/idea/testData/intentions/loopToCallChain/filter_ifContinue2.kt.after b/idea/testData/intentions/loopToCallChain/filter_ifContinue2.kt.after index e1bcb0743d1..e009fe59671 100644 --- a/idea/testData/intentions/loopToCallChain/filter_ifContinue2.kt.after +++ b/idea/testData/intentions/loopToCallChain/filter_ifContinue2.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'firstOrNull{}'" +// IS_APPLICABLE_2: false fun foo(list: List): String? { return list.firstOrNull { it.isEmpty() } } \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/filter_ifContinueInBlock.kt b/idea/testData/intentions/loopToCallChain/filter_ifContinueInBlock.kt index 323626a1c30..424a0920727 100644 --- a/idea/testData/intentions/loopToCallChain/filter_ifContinueInBlock.kt +++ b/idea/testData/intentions/loopToCallChain/filter_ifContinueInBlock.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'firstOrNull{}'" +// IS_APPLICABLE_2: false fun foo(list: List): String? { for (s in list) { if (s.isEmpty()) { diff --git a/idea/testData/intentions/loopToCallChain/filter_ifContinueInBlock.kt.after b/idea/testData/intentions/loopToCallChain/filter_ifContinueInBlock.kt.after index 7478c511744..8f33180b3eb 100644 --- a/idea/testData/intentions/loopToCallChain/filter_ifContinueInBlock.kt.after +++ b/idea/testData/intentions/loopToCallChain/filter_ifContinueInBlock.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'firstOrNull{}'" +// IS_APPLICABLE_2: false fun foo(list: List): String? { return list.firstOrNull { !it.isEmpty() } } \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/filter_ifContinueWithLabel.kt b/idea/testData/intentions/loopToCallChain/filter_ifContinueWithLabel.kt index b81b4c6ff44..dfe387a98cf 100644 --- a/idea/testData/intentions/loopToCallChain/filter_ifContinueWithLabel.kt +++ b/idea/testData/intentions/loopToCallChain/filter_ifContinueWithLabel.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // IS_APPLICABLE: false +// IS_APPLICABLE_2: false fun foo(): String? { Loop@ while (x()) { diff --git a/idea/testData/intentions/loopToCallChain/filter_inputVarNotUsed.kt b/idea/testData/intentions/loopToCallChain/filter_inputVarNotUsed.kt index 58c0773c7f5..1eb9055d8a9 100644 --- a/idea/testData/intentions/loopToCallChain/filter_inputVarNotUsed.kt +++ b/idea/testData/intentions/loopToCallChain/filter_inputVarNotUsed.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // IS_APPLICABLE: false +// IS_APPLICABLE_2: false import java.util.* fun foo(list: List): String? { diff --git a/idea/testData/intentions/loopToCallChain/filter_mergeMultiple.kt b/idea/testData/intentions/loopToCallChain/filter_mergeMultiple.kt index 97cac304f92..779381f9853 100644 --- a/idea/testData/intentions/loopToCallChain/filter_mergeMultiple.kt +++ b/idea/testData/intentions/loopToCallChain/filter_mergeMultiple.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filter{}.map{}.firstOrNull()'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.map{}.firstOrNull()'" fun foo(list: List): String? { for (s in list) { if (s.isEmpty()) continue diff --git a/idea/testData/intentions/loopToCallChain/filter_mergeMultiple.kt.after b/idea/testData/intentions/loopToCallChain/filter_mergeMultiple.kt.after index 8e5695a2d46..7d869d3a664 100644 --- a/idea/testData/intentions/loopToCallChain/filter_mergeMultiple.kt.after +++ b/idea/testData/intentions/loopToCallChain/filter_mergeMultiple.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filter{}.map{}.firstOrNull()'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.map{}.firstOrNull()'" fun foo(list: List): String? { return list .filter { !it.isEmpty() && it.length < 10 && it != "abc" && it != "def" } diff --git a/idea/testData/intentions/loopToCallChain/filter_mergeMultiple.kt.after2 b/idea/testData/intentions/loopToCallChain/filter_mergeMultiple.kt.after2 new file mode 100644 index 00000000000..d39dd67a87c --- /dev/null +++ b/idea/testData/intentions/loopToCallChain/filter_mergeMultiple.kt.after2 @@ -0,0 +1,10 @@ +// WITH_RUNTIME +// INTENTION_TEXT: "Replace with 'filter{}.map{}.firstOrNull()'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.map{}.firstOrNull()'" +fun foo(list: List): String? { + return list + .asSequence() + .filter { !it.isEmpty() && it.length < 10 && it != "abc" && it != "def" } + .map { it + "x" } + .firstOrNull() +} \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/firstOrNull_assignmentInitialization.kt b/idea/testData/intentions/loopToCallChain/firstOrNull_assignmentInitialization.kt index 70c4de29415..0cde23068fd 100644 --- a/idea/testData/intentions/loopToCallChain/firstOrNull_assignmentInitialization.kt +++ b/idea/testData/intentions/loopToCallChain/firstOrNull_assignmentInitialization.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'firstOrNull{}'" +// IS_APPLICABLE_2: false fun foo(list: List) { var result: String? = "" diff --git a/idea/testData/intentions/loopToCallChain/firstOrNull_assignmentInitialization.kt.after b/idea/testData/intentions/loopToCallChain/firstOrNull_assignmentInitialization.kt.after index 4921bac310d..fcf0efbdf53 100644 --- a/idea/testData/intentions/loopToCallChain/firstOrNull_assignmentInitialization.kt.after +++ b/idea/testData/intentions/loopToCallChain/firstOrNull_assignmentInitialization.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'firstOrNull{}'" +// IS_APPLICABLE_2: false fun foo(list: List) { var result: String? = "" diff --git a/idea/testData/intentions/loopToCallChain/firstOrNull_cannotUseLet.kt b/idea/testData/intentions/loopToCallChain/firstOrNull_cannotUseLet.kt index 8cc66ab7cdf..2f25b8995d1 100644 --- a/idea/testData/intentions/loopToCallChain/firstOrNull_cannotUseLet.kt +++ b/idea/testData/intentions/loopToCallChain/firstOrNull_cannotUseLet.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // IS_APPLICABLE: false +// IS_APPLICABLE_2: false fun foo(list: List) { var result: String? = null for (s in list) { diff --git a/idea/testData/intentions/loopToCallChain/firstOrNull_ifAssign.kt b/idea/testData/intentions/loopToCallChain/firstOrNull_ifAssign.kt index b3d721456d0..c487d6278a9 100644 --- a/idea/testData/intentions/loopToCallChain/firstOrNull_ifAssign.kt +++ b/idea/testData/intentions/loopToCallChain/firstOrNull_ifAssign.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'firstOrNull{}'" +// IS_APPLICABLE_2: false fun foo(list: List) { var result: String? = null for (s in list) { diff --git a/idea/testData/intentions/loopToCallChain/firstOrNull_ifAssign.kt.after b/idea/testData/intentions/loopToCallChain/firstOrNull_ifAssign.kt.after index 3bbef95ae6f..8bb15cb7ddb 100644 --- a/idea/testData/intentions/loopToCallChain/firstOrNull_ifAssign.kt.after +++ b/idea/testData/intentions/loopToCallChain/firstOrNull_ifAssign.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'firstOrNull{}'" +// IS_APPLICABLE_2: false fun foo(list: List) { val result: String? = list.firstOrNull { it.length > 0 } } \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/firstOrNull_ifAssign_breakWithLabel.kt b/idea/testData/intentions/loopToCallChain/firstOrNull_ifAssign_breakWithLabel.kt index da5f9e0d895..259f134c79d 100644 --- a/idea/testData/intentions/loopToCallChain/firstOrNull_ifAssign_breakWithLabel.kt +++ b/idea/testData/intentions/loopToCallChain/firstOrNull_ifAssign_breakWithLabel.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // IS_APPLICABLE: false +// IS_APPLICABLE_2: false fun foo() { MainLoop@ for (i in 1..10) { diff --git a/idea/testData/intentions/loopToCallChain/firstOrNull_ifAssign_cannotBeVal.kt b/idea/testData/intentions/loopToCallChain/firstOrNull_ifAssign_cannotBeVal.kt index 22158797cb3..a3788aac23d 100644 --- a/idea/testData/intentions/loopToCallChain/firstOrNull_ifAssign_cannotBeVal.kt +++ b/idea/testData/intentions/loopToCallChain/firstOrNull_ifAssign_cannotBeVal.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'firstOrNull{}'" +// IS_APPLICABLE_2: false fun foo(list: List) { var result: String? = null for (s in list) { diff --git a/idea/testData/intentions/loopToCallChain/firstOrNull_ifAssign_cannotBeVal.kt.after b/idea/testData/intentions/loopToCallChain/firstOrNull_ifAssign_cannotBeVal.kt.after index e2eceaed0f7..c8edd2af8b1 100644 --- a/idea/testData/intentions/loopToCallChain/firstOrNull_ifAssign_cannotBeVal.kt.after +++ b/idea/testData/intentions/loopToCallChain/firstOrNull_ifAssign_cannotBeVal.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'firstOrNull{}'" +// IS_APPLICABLE_2: false fun foo(list: List) { var result: String? = list.firstOrNull { it.length > 0 } diff --git a/idea/testData/intentions/loopToCallChain/firstOrNull_ifAssign_preserveComments.kt b/idea/testData/intentions/loopToCallChain/firstOrNull_ifAssign_preserveComments.kt index 58108c325f7..3426f00d84f 100644 --- a/idea/testData/intentions/loopToCallChain/firstOrNull_ifAssign_preserveComments.kt +++ b/idea/testData/intentions/loopToCallChain/firstOrNull_ifAssign_preserveComments.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'firstOrNull{}'" +// IS_APPLICABLE_2: false fun foo(list: List) { var result: String? = null for (s in list) { // search for first non-empty string in the list diff --git a/idea/testData/intentions/loopToCallChain/firstOrNull_ifAssign_preserveComments.kt.after b/idea/testData/intentions/loopToCallChain/firstOrNull_ifAssign_preserveComments.kt.after index 17e2570e368..742de73db6d 100644 --- a/idea/testData/intentions/loopToCallChain/firstOrNull_ifAssign_preserveComments.kt.after +++ b/idea/testData/intentions/loopToCallChain/firstOrNull_ifAssign_preserveComments.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'firstOrNull{}'" +// IS_APPLICABLE_2: false fun foo(list: List) { // string should be non-empty // save it into result diff --git a/idea/testData/intentions/loopToCallChain/firstOrNull_ifAssign_variableUsedBefore.kt b/idea/testData/intentions/loopToCallChain/firstOrNull_ifAssign_variableUsedBefore.kt index 16769bfd896..f60b086e7af 100644 --- a/idea/testData/intentions/loopToCallChain/firstOrNull_ifAssign_variableUsedBefore.kt +++ b/idea/testData/intentions/loopToCallChain/firstOrNull_ifAssign_variableUsedBefore.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // IS_APPLICABLE: false +// IS_APPLICABLE_2: false fun foo(list: List) { var result: String? = null for (s in list) { diff --git a/idea/testData/intentions/loopToCallChain/firstOrNull_ifReturn.kt b/idea/testData/intentions/loopToCallChain/firstOrNull_ifReturn.kt index 2702f03b0ba..8d129e54477 100644 --- a/idea/testData/intentions/loopToCallChain/firstOrNull_ifReturn.kt +++ b/idea/testData/intentions/loopToCallChain/firstOrNull_ifReturn.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'firstOrNull{}'" +// IS_APPLICABLE_2: false fun foo(list: List): String? { for (s in list) { if (s.length > 0) { diff --git a/idea/testData/intentions/loopToCallChain/firstOrNull_ifReturn.kt.after b/idea/testData/intentions/loopToCallChain/firstOrNull_ifReturn.kt.after index 074857a8c28..aefa3269ea6 100644 --- a/idea/testData/intentions/loopToCallChain/firstOrNull_ifReturn.kt.after +++ b/idea/testData/intentions/loopToCallChain/firstOrNull_ifReturn.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'firstOrNull{}'" +// IS_APPLICABLE_2: false fun foo(list: List): String? { return list.firstOrNull { it.length > 0 } } \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/firstOrNull_let.kt b/idea/testData/intentions/loopToCallChain/firstOrNull_let.kt index 91201450805..57c83585f15 100644 --- a/idea/testData/intentions/loopToCallChain/firstOrNull_let.kt +++ b/idea/testData/intentions/loopToCallChain/firstOrNull_let.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'firstOrNull{}'" +// IS_APPLICABLE_2: false fun foo(list: List) { var result: String? = null for (s in list) { diff --git a/idea/testData/intentions/loopToCallChain/firstOrNull_let.kt.after b/idea/testData/intentions/loopToCallChain/firstOrNull_let.kt.after index 74fb23090ae..9d408c8e3f0 100644 --- a/idea/testData/intentions/loopToCallChain/firstOrNull_let.kt.after +++ b/idea/testData/intentions/loopToCallChain/firstOrNull_let.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'firstOrNull{}'" +// IS_APPLICABLE_2: false fun foo(list: List) { val result: String? = list .firstOrNull { it.length > 0 } diff --git a/idea/testData/intentions/loopToCallChain/firstOrNull_let2.kt b/idea/testData/intentions/loopToCallChain/firstOrNull_let2.kt index dabcc9ae4c7..1e32a132d78 100644 --- a/idea/testData/intentions/loopToCallChain/firstOrNull_let2.kt +++ b/idea/testData/intentions/loopToCallChain/firstOrNull_let2.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'firstOrNull{}'" +// IS_APPLICABLE_2: false fun foo(list: List) { var result: String? = null for (s in list) { diff --git a/idea/testData/intentions/loopToCallChain/firstOrNull_let2.kt.after b/idea/testData/intentions/loopToCallChain/firstOrNull_let2.kt.after index 0db7d52a1f2..b4c6da35ca5 100644 --- a/idea/testData/intentions/loopToCallChain/firstOrNull_let2.kt.after +++ b/idea/testData/intentions/loopToCallChain/firstOrNull_let2.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'firstOrNull{}'" +// IS_APPLICABLE_2: false fun foo(list: List) { val result: String? = list .firstOrNull { it.length > 0 } diff --git a/idea/testData/intentions/loopToCallChain/firstOrNull_letOrNotNull.kt b/idea/testData/intentions/loopToCallChain/firstOrNull_letOrNotNull.kt index e1e0d65e9f8..16b4b70522f 100644 --- a/idea/testData/intentions/loopToCallChain/firstOrNull_letOrNotNull.kt +++ b/idea/testData/intentions/loopToCallChain/firstOrNull_letOrNotNull.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'firstOrNull{}'" +// IS_APPLICABLE_2: false fun foo(list: List) { var result = "" for (s in list) { diff --git a/idea/testData/intentions/loopToCallChain/firstOrNull_letOrNotNull.kt.after b/idea/testData/intentions/loopToCallChain/firstOrNull_letOrNotNull.kt.after index 922b0538b99..e5db524aadf 100644 --- a/idea/testData/intentions/loopToCallChain/firstOrNull_letOrNotNull.kt.after +++ b/idea/testData/intentions/loopToCallChain/firstOrNull_letOrNotNull.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'firstOrNull{}'" +// IS_APPLICABLE_2: false fun foo(list: List) { val result = list .firstOrNull { it.length > 0 } diff --git a/idea/testData/intentions/loopToCallChain/firstOrNull_return.kt b/idea/testData/intentions/loopToCallChain/firstOrNull_return.kt index 6e881270ce4..27338835608 100644 --- a/idea/testData/intentions/loopToCallChain/firstOrNull_return.kt +++ b/idea/testData/intentions/loopToCallChain/firstOrNull_return.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'firstOrNull()'" +// IS_APPLICABLE_2: false fun foo(list: List): String? { for (s in list) { return s diff --git a/idea/testData/intentions/loopToCallChain/firstOrNull_return.kt.after b/idea/testData/intentions/loopToCallChain/firstOrNull_return.kt.after index 26d37bfb2fe..a3a245a3f5e 100644 --- a/idea/testData/intentions/loopToCallChain/firstOrNull_return.kt.after +++ b/idea/testData/intentions/loopToCallChain/firstOrNull_return.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'firstOrNull()'" +// IS_APPLICABLE_2: false fun foo(list: List): String? { return list.firstOrNull() } \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/firstOrNull_returnExpression.kt b/idea/testData/intentions/loopToCallChain/firstOrNull_returnExpression.kt index 872e6287d91..19f77db7957 100644 --- a/idea/testData/intentions/loopToCallChain/firstOrNull_returnExpression.kt +++ b/idea/testData/intentions/loopToCallChain/firstOrNull_returnExpression.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'firstOrNull{}'" +// IS_APPLICABLE_2: false fun foo(list: List): Int? { for (s in list) { if (s.isNotEmpty()) { diff --git a/idea/testData/intentions/loopToCallChain/firstOrNull_returnExpression.kt.after b/idea/testData/intentions/loopToCallChain/firstOrNull_returnExpression.kt.after index 26ed81335e7..c4141f48083 100644 --- a/idea/testData/intentions/loopToCallChain/firstOrNull_returnExpression.kt.after +++ b/idea/testData/intentions/loopToCallChain/firstOrNull_returnExpression.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'firstOrNull{}'" +// IS_APPLICABLE_2: false fun foo(list: List): Int? { return list .firstOrNull { it.isNotEmpty() } diff --git a/idea/testData/intentions/loopToCallChain/firstOrNull_returnExpressionOrNotNull.kt b/idea/testData/intentions/loopToCallChain/firstOrNull_returnExpressionOrNotNull.kt index f911b1b73b1..7f57906aec2 100644 --- a/idea/testData/intentions/loopToCallChain/firstOrNull_returnExpressionOrNotNull.kt +++ b/idea/testData/intentions/loopToCallChain/firstOrNull_returnExpressionOrNotNull.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'firstOrNull{}'" +// IS_APPLICABLE_2: false fun foo(list: List): Int { for (s in list) { if (s.isNotEmpty()) { diff --git a/idea/testData/intentions/loopToCallChain/firstOrNull_returnExpressionOrNotNull.kt.after b/idea/testData/intentions/loopToCallChain/firstOrNull_returnExpressionOrNotNull.kt.after index 2a2a6190456..dcffddc025b 100644 --- a/idea/testData/intentions/loopToCallChain/firstOrNull_returnExpressionOrNotNull.kt.after +++ b/idea/testData/intentions/loopToCallChain/firstOrNull_returnExpressionOrNotNull.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'firstOrNull{}'" +// IS_APPLICABLE_2: false fun foo(list: List): Int { return list .firstOrNull { it.isNotEmpty() } diff --git a/idea/testData/intentions/loopToCallChain/firstOrNull_returnNotNullIfNone.kt b/idea/testData/intentions/loopToCallChain/firstOrNull_returnNotNullIfNone.kt index 6af1ddb9cfb..362e7d8f4b2 100644 --- a/idea/testData/intentions/loopToCallChain/firstOrNull_returnNotNullIfNone.kt +++ b/idea/testData/intentions/loopToCallChain/firstOrNull_returnNotNullIfNone.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'firstOrNull{}'" +// IS_APPLICABLE_2: false fun foo(list: List): String { for (s in list) { if (s.isNotEmpty()) { diff --git a/idea/testData/intentions/loopToCallChain/firstOrNull_returnNotNullIfNone.kt.after b/idea/testData/intentions/loopToCallChain/firstOrNull_returnNotNullIfNone.kt.after index b5bc722fcd2..e672166bf20 100644 --- a/idea/testData/intentions/loopToCallChain/firstOrNull_returnNotNullIfNone.kt.after +++ b/idea/testData/intentions/loopToCallChain/firstOrNull_returnNotNullIfNone.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'firstOrNull{}'" +// IS_APPLICABLE_2: false fun foo(list: List): String { return list.firstOrNull { it.isNotEmpty() } ?: "" diff --git a/idea/testData/intentions/loopToCallChain/firstOrNull_returnNotNullIfNone2.kt b/idea/testData/intentions/loopToCallChain/firstOrNull_returnNotNullIfNone2.kt index cf8b5ee6360..87036eecfc8 100644 --- a/idea/testData/intentions/loopToCallChain/firstOrNull_returnNotNullIfNone2.kt +++ b/idea/testData/intentions/loopToCallChain/firstOrNull_returnNotNullIfNone2.kt @@ -1,4 +1,6 @@ // WITH_RUNTIME +// INTENTION_TEXT: "Replace with 'filter{}.forEach{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.forEach{}'" fun foo(list: List): String? { for (s in list) { if (s == null || s.isNotEmpty()) { diff --git a/idea/testData/intentions/loopToCallChain/firstOrNull_returnNotNullIfNone2.kt.after b/idea/testData/intentions/loopToCallChain/firstOrNull_returnNotNullIfNone2.kt.after index 70c33a66a30..d1728e669af 100644 --- a/idea/testData/intentions/loopToCallChain/firstOrNull_returnNotNullIfNone2.kt.after +++ b/idea/testData/intentions/loopToCallChain/firstOrNull_returnNotNullIfNone2.kt.after @@ -1,4 +1,6 @@ // WITH_RUNTIME +// INTENTION_TEXT: "Replace with 'filter{}.forEach{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.forEach{}'" fun foo(list: List): String? { list .filter { it == null || it.isNotEmpty() } diff --git a/idea/testData/intentions/loopToCallChain/firstOrNull_returnNotNullIfNone2.kt.after2 b/idea/testData/intentions/loopToCallChain/firstOrNull_returnNotNullIfNone2.kt.after2 new file mode 100644 index 00000000000..ee9a8ecf074 --- /dev/null +++ b/idea/testData/intentions/loopToCallChain/firstOrNull_returnNotNullIfNone2.kt.after2 @@ -0,0 +1,10 @@ +// WITH_RUNTIME +// INTENTION_TEXT: "Replace with 'filter{}.forEach{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.forEach{}'" +fun foo(list: List): String? { + list + .asSequence() + .filter { it == null || it.isNotEmpty() } + .forEach { return it } + return "" +} \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/firstOrNull_return_comment.kt b/idea/testData/intentions/loopToCallChain/firstOrNull_return_comment.kt index d6397e54ef7..2ffbd0e5d2a 100644 --- a/idea/testData/intentions/loopToCallChain/firstOrNull_return_comment.kt +++ b/idea/testData/intentions/loopToCallChain/firstOrNull_return_comment.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'firstOrNull()'" +// IS_APPLICABLE_2: false fun foo(list: List): String? { for (s in list) { return s diff --git a/idea/testData/intentions/loopToCallChain/firstOrNull_return_comment.kt.after b/idea/testData/intentions/loopToCallChain/firstOrNull_return_comment.kt.after index 52dbc147c9a..526d79d156b 100644 --- a/idea/testData/intentions/loopToCallChain/firstOrNull_return_comment.kt.after +++ b/idea/testData/intentions/loopToCallChain/firstOrNull_return_comment.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'firstOrNull()'" +// IS_APPLICABLE_2: false fun foo(list: List): String? { // return null if not found return list.firstOrNull() diff --git a/idea/testData/intentions/loopToCallChain/firstOrNull_safeDotExpression.kt b/idea/testData/intentions/loopToCallChain/firstOrNull_safeDotExpression.kt index f34bb7d5038..03523647933 100644 --- a/idea/testData/intentions/loopToCallChain/firstOrNull_safeDotExpression.kt +++ b/idea/testData/intentions/loopToCallChain/firstOrNull_safeDotExpression.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'firstOrNull{}'" +// IS_APPLICABLE_2: false fun foo(list: List) { var result: String? = null for (s in list) { diff --git a/idea/testData/intentions/loopToCallChain/firstOrNull_safeDotExpression.kt.after b/idea/testData/intentions/loopToCallChain/firstOrNull_safeDotExpression.kt.after index cc52207d140..b1d1eabb51f 100644 --- a/idea/testData/intentions/loopToCallChain/firstOrNull_safeDotExpression.kt.after +++ b/idea/testData/intentions/loopToCallChain/firstOrNull_safeDotExpression.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'firstOrNull{}'" +// IS_APPLICABLE_2: false fun foo(list: List) { val result: String? = list .firstOrNull { it != "" } diff --git a/idea/testData/intentions/loopToCallChain/firstOrNull_withMergedFilter.kt b/idea/testData/intentions/loopToCallChain/firstOrNull_withMergedFilter.kt index e5ba339ec3d..bfb69532ed4 100644 --- a/idea/testData/intentions/loopToCallChain/firstOrNull_withMergedFilter.kt +++ b/idea/testData/intentions/loopToCallChain/firstOrNull_withMergedFilter.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'firstOrNull{}'" +// IS_APPLICABLE_2: false fun foo(list: List): String? { for (s in list) { if (s.isEmpty()) continue diff --git a/idea/testData/intentions/loopToCallChain/firstOrNull_withMergedFilter.kt.after b/idea/testData/intentions/loopToCallChain/firstOrNull_withMergedFilter.kt.after index 427f43b6e0c..865f2d68c00 100644 --- a/idea/testData/intentions/loopToCallChain/firstOrNull_withMergedFilter.kt.after +++ b/idea/testData/intentions/loopToCallChain/firstOrNull_withMergedFilter.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'firstOrNull{}'" +// IS_APPLICABLE_2: false fun foo(list: List): String? { return list.firstOrNull { !it.isEmpty() && it.length < 10 && it != "abc" && it != "def" } } \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/flatMap.kt b/idea/testData/intentions/loopToCallChain/flatMap.kt index 57caae2c70c..0f4595f9e4e 100644 --- a/idea/testData/intentions/loopToCallChain/flatMap.kt +++ b/idea/testData/intentions/loopToCallChain/flatMap.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'flatMap{}.firstOrNull{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().flatMap{}.firstOrNull{}'" fun foo(list: List): String? { for (s in list) { for (line in s.lines()) { diff --git a/idea/testData/intentions/loopToCallChain/flatMap.kt.after b/idea/testData/intentions/loopToCallChain/flatMap.kt.after index 04e54759526..1c66c342193 100644 --- a/idea/testData/intentions/loopToCallChain/flatMap.kt.after +++ b/idea/testData/intentions/loopToCallChain/flatMap.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'flatMap{}.firstOrNull{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().flatMap{}.firstOrNull{}'" fun foo(list: List): String? { return list .flatMap { it.lines() } diff --git a/idea/testData/intentions/loopToCallChain/flatMap.kt.after2 b/idea/testData/intentions/loopToCallChain/flatMap.kt.after2 new file mode 100644 index 00000000000..ec05bfe20f6 --- /dev/null +++ b/idea/testData/intentions/loopToCallChain/flatMap.kt.after2 @@ -0,0 +1,9 @@ +// WITH_RUNTIME +// INTENTION_TEXT: "Replace with 'flatMap{}.firstOrNull{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().flatMap{}.firstOrNull{}'" +fun foo(list: List): String? { + return list + .asSequence() + .flatMap { it.lines().asSequence() } + .firstOrNull { it.isNotBlank() } +} \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/flatMapTo.kt b/idea/testData/intentions/loopToCallChain/flatMapTo.kt index 17bc715c2c3..b2930d8dbb7 100644 --- a/idea/testData/intentions/loopToCallChain/flatMapTo.kt +++ b/idea/testData/intentions/loopToCallChain/flatMapTo.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'flatMapTo(){}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().flatMapTo(){}'" fun foo(list: List, target: MutableList) { for (s in list) { for (line in s.lines()) { diff --git a/idea/testData/intentions/loopToCallChain/flatMapTo.kt.after b/idea/testData/intentions/loopToCallChain/flatMapTo.kt.after index 78f3c136715..939b0c6fb59 100644 --- a/idea/testData/intentions/loopToCallChain/flatMapTo.kt.after +++ b/idea/testData/intentions/loopToCallChain/flatMapTo.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'flatMapTo(){}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().flatMapTo(){}'" fun foo(list: List, target: MutableList) { list.flatMapTo(target) { it.lines() } } \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/flatMapTo.kt.after2 b/idea/testData/intentions/loopToCallChain/flatMapTo.kt.after2 new file mode 100644 index 00000000000..0d35ff01a93 --- /dev/null +++ b/idea/testData/intentions/loopToCallChain/flatMapTo.kt.after2 @@ -0,0 +1,8 @@ +// WITH_RUNTIME +// INTENTION_TEXT: "Replace with 'flatMapTo(){}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().flatMapTo(){}'" +fun foo(list: List, target: MutableList) { + list + .asSequence() + .flatMapTo(target) { it.lines().asSequence() } +} \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/flatMapTo2.kt b/idea/testData/intentions/loopToCallChain/flatMapTo2.kt index f03cf24ab83..c3f4e0ff170 100644 --- a/idea/testData/intentions/loopToCallChain/flatMapTo2.kt +++ b/idea/testData/intentions/loopToCallChain/flatMapTo2.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'flatMapTo(){}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().flatMapTo(){}'" import java.util.ArrayList fun foo(list: List): List { diff --git a/idea/testData/intentions/loopToCallChain/flatMapTo2.kt.after b/idea/testData/intentions/loopToCallChain/flatMapTo2.kt.after index ba07af17cb6..33a4f34533b 100644 --- a/idea/testData/intentions/loopToCallChain/flatMapTo2.kt.after +++ b/idea/testData/intentions/loopToCallChain/flatMapTo2.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'flatMapTo(){}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().flatMapTo(){}'" import java.util.ArrayList fun foo(list: List): List { diff --git a/idea/testData/intentions/loopToCallChain/flatMapTo2.kt.after2 b/idea/testData/intentions/loopToCallChain/flatMapTo2.kt.after2 new file mode 100644 index 00000000000..74e0dce77c6 --- /dev/null +++ b/idea/testData/intentions/loopToCallChain/flatMapTo2.kt.after2 @@ -0,0 +1,11 @@ +// WITH_RUNTIME +// INTENTION_TEXT: "Replace with 'flatMapTo(){}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().flatMapTo(){}'" +import java.util.ArrayList + +fun foo(list: List): List { + val target = list + .asSequence() + .flatMapTo(ArrayList(100)) { it.lines().asSequence() } + return target +} \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/flatMapTo3.kt b/idea/testData/intentions/loopToCallChain/flatMapTo3.kt index c27591e2b01..04068c70e83 100644 --- a/idea/testData/intentions/loopToCallChain/flatMapTo3.kt +++ b/idea/testData/intentions/loopToCallChain/flatMapTo3.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'flatMapTo(){}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().flatMapTo(){}'" fun foo(list: List): List { val target = createCollection() for (s in list) { diff --git a/idea/testData/intentions/loopToCallChain/flatMapTo3.kt.after b/idea/testData/intentions/loopToCallChain/flatMapTo3.kt.after index 1cf490c63fb..bbcf02a6467 100644 --- a/idea/testData/intentions/loopToCallChain/flatMapTo3.kt.after +++ b/idea/testData/intentions/loopToCallChain/flatMapTo3.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'flatMapTo(){}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().flatMapTo(){}'" fun foo(list: List): List { val target = createCollection() list.flatMapTo(target) { it.lines() } diff --git a/idea/testData/intentions/loopToCallChain/flatMapTo3.kt.after2 b/idea/testData/intentions/loopToCallChain/flatMapTo3.kt.after2 new file mode 100644 index 00000000000..215c601a26f --- /dev/null +++ b/idea/testData/intentions/loopToCallChain/flatMapTo3.kt.after2 @@ -0,0 +1,12 @@ +// WITH_RUNTIME +// INTENTION_TEXT: "Replace with 'flatMapTo(){}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().flatMapTo(){}'" +fun foo(list: List): List { + val target = createCollection() + list + .asSequence() + .flatMapTo(target) { it.lines().asSequence() } + return target +} + +fun createCollection() = java.util.ArrayList() \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/flatMapWithBreak.kt b/idea/testData/intentions/loopToCallChain/flatMapWithBreak.kt index 7884d5d7956..91c659bc64c 100644 --- a/idea/testData/intentions/loopToCallChain/flatMapWithBreak.kt +++ b/idea/testData/intentions/loopToCallChain/flatMapWithBreak.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'flatMap{}.firstOrNull{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().flatMap{}.firstOrNull{}'" fun foo(list: List): String? { var result: String? = null MainLoop@ diff --git a/idea/testData/intentions/loopToCallChain/flatMapWithBreak.kt.after b/idea/testData/intentions/loopToCallChain/flatMapWithBreak.kt.after index 16c926e5dcc..0b364a2fbf8 100644 --- a/idea/testData/intentions/loopToCallChain/flatMapWithBreak.kt.after +++ b/idea/testData/intentions/loopToCallChain/flatMapWithBreak.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'flatMap{}.firstOrNull{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().flatMap{}.firstOrNull{}'" fun foo(list: List): String? { val result: String? = list .flatMap { it.lines() } diff --git a/idea/testData/intentions/loopToCallChain/flatMapWithBreak.kt.after2 b/idea/testData/intentions/loopToCallChain/flatMapWithBreak.kt.after2 new file mode 100644 index 00000000000..3e5fbb122fa --- /dev/null +++ b/idea/testData/intentions/loopToCallChain/flatMapWithBreak.kt.after2 @@ -0,0 +1,10 @@ +// WITH_RUNTIME +// INTENTION_TEXT: "Replace with 'flatMap{}.firstOrNull{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().flatMap{}.firstOrNull{}'" +fun foo(list: List): String? { + val result: String? = list + .asSequence() + .flatMap { it.lines().asSequence() } + .firstOrNull { it.isNotBlank() } + return result +} \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/flatMapWithContinue.kt b/idea/testData/intentions/loopToCallChain/flatMapWithContinue.kt index 7b8004e1845..f74c874cb63 100644 --- a/idea/testData/intentions/loopToCallChain/flatMapWithContinue.kt +++ b/idea/testData/intentions/loopToCallChain/flatMapWithContinue.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'flatMap{}.firstOrNull{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().flatMap{}.firstOrNull{}'" fun foo(list: List): String? { for (s in list) { for (line in s.lines()) { diff --git a/idea/testData/intentions/loopToCallChain/flatMapWithContinue.kt.after b/idea/testData/intentions/loopToCallChain/flatMapWithContinue.kt.after index a72f85c246e..8730a928a67 100644 --- a/idea/testData/intentions/loopToCallChain/flatMapWithContinue.kt.after +++ b/idea/testData/intentions/loopToCallChain/flatMapWithContinue.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'flatMap{}.firstOrNull{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().flatMap{}.firstOrNull{}'" fun foo(list: List): String? { return list .flatMap { it.lines() } diff --git a/idea/testData/intentions/loopToCallChain/flatMapWithContinue.kt.after2 b/idea/testData/intentions/loopToCallChain/flatMapWithContinue.kt.after2 new file mode 100644 index 00000000000..987487a901d --- /dev/null +++ b/idea/testData/intentions/loopToCallChain/flatMapWithContinue.kt.after2 @@ -0,0 +1,9 @@ +// WITH_RUNTIME +// INTENTION_TEXT: "Replace with 'flatMap{}.firstOrNull{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().flatMap{}.firstOrNull{}'" +fun foo(list: List): String? { + return list + .asSequence() + .flatMap { it.lines().asSequence() } + .firstOrNull { !it.isBlank() } +} \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/flatMapWithWrongBreak.kt b/idea/testData/intentions/loopToCallChain/flatMapWithWrongBreak.kt index bc287cf6c91..ddf4cbddbe3 100644 --- a/idea/testData/intentions/loopToCallChain/flatMapWithWrongBreak.kt +++ b/idea/testData/intentions/loopToCallChain/flatMapWithWrongBreak.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // IS_APPLICABLE: false +// IS_APPLICABLE_2: false fun foo(list: List): String? { var result: String? = null for (s in list) { diff --git a/idea/testData/intentions/loopToCallChain/flatMap_indexUsed.kt b/idea/testData/intentions/loopToCallChain/flatMap_indexUsed.kt index a36d6c19b08..d51b929ca34 100644 --- a/idea/testData/intentions/loopToCallChain/flatMap_indexUsed.kt +++ b/idea/testData/intentions/loopToCallChain/flatMap_indexUsed.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'mapIndexed{}.flatMap{}.firstOrNull{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().mapIndexed{}.flatMap{}.firstOrNull{}'" fun foo(list: List): String? { for ((index, s) in list.withIndex()) { for (line in s.lines().take(index)) { diff --git a/idea/testData/intentions/loopToCallChain/flatMap_indexUsed.kt.after b/idea/testData/intentions/loopToCallChain/flatMap_indexUsed.kt.after index fe00ed08f1f..143816de9e1 100644 --- a/idea/testData/intentions/loopToCallChain/flatMap_indexUsed.kt.after +++ b/idea/testData/intentions/loopToCallChain/flatMap_indexUsed.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'mapIndexed{}.flatMap{}.firstOrNull{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().mapIndexed{}.flatMap{}.firstOrNull{}'" fun foo(list: List): String? { return list .mapIndexed { index, s -> s.lines().take(index) } diff --git a/idea/testData/intentions/loopToCallChain/flatMap_indexUsed.kt.after2 b/idea/testData/intentions/loopToCallChain/flatMap_indexUsed.kt.after2 new file mode 100644 index 00000000000..7be6eb75095 --- /dev/null +++ b/idea/testData/intentions/loopToCallChain/flatMap_indexUsed.kt.after2 @@ -0,0 +1,10 @@ +// WITH_RUNTIME +// INTENTION_TEXT: "Replace with 'mapIndexed{}.flatMap{}.firstOrNull{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().mapIndexed{}.flatMap{}.firstOrNull{}'" +fun foo(list: List): String? { + return list + .asSequence() + .mapIndexed { index, s -> s.lines().take(index) } + .flatMap { it.asSequence() } + .firstOrNull { it.isNotBlank() } +} \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/flatMap_notIterable.kt b/idea/testData/intentions/loopToCallChain/flatMap_notIterable.kt index d785cf65247..51cc9b33552 100644 --- a/idea/testData/intentions/loopToCallChain/flatMap_notIterable.kt +++ b/idea/testData/intentions/loopToCallChain/flatMap_notIterable.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // IS_APPLICABLE: false +// IS_APPLICABLE_2: false fun foo(list: List): Char? { for (s in list) { for (c in s) { diff --git a/idea/testData/intentions/loopToCallChain/flatMap_workingVarStillNeeded.kt b/idea/testData/intentions/loopToCallChain/flatMap_workingVarStillNeeded.kt index 0b878edc866..f68ec731237 100644 --- a/idea/testData/intentions/loopToCallChain/flatMap_workingVarStillNeeded.kt +++ b/idea/testData/intentions/loopToCallChain/flatMap_workingVarStillNeeded.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // IS_APPLICABLE: false +// IS_APPLICABLE_2: false fun foo(list: List): String? { for (s in list) { for (line in s.lines()) { diff --git a/idea/testData/intentions/loopToCallChain/flatMap_wrongContinue.kt b/idea/testData/intentions/loopToCallChain/flatMap_wrongContinue.kt index ce181631d50..fcc893c3856 100644 --- a/idea/testData/intentions/loopToCallChain/flatMap_wrongContinue.kt +++ b/idea/testData/intentions/loopToCallChain/flatMap_wrongContinue.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // IS_APPLICABLE: false +// IS_APPLICABLE_2: false fun foo(list: List): String? { OuterLoop@ for (s in list) { diff --git a/idea/testData/intentions/loopToCallChain/forEach.kt b/idea/testData/intentions/loopToCallChain/forEach.kt index fe6c1a9e956..49be13b4145 100644 --- a/idea/testData/intentions/loopToCallChain/forEach.kt +++ b/idea/testData/intentions/loopToCallChain/forEach.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filter{}.forEach{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.forEach{}'" fun foo(list: List) { for (s in list) { if (s.isNotBlank()) { diff --git a/idea/testData/intentions/loopToCallChain/forEach.kt.after b/idea/testData/intentions/loopToCallChain/forEach.kt.after index be03fa3a074..1443c5f941c 100644 --- a/idea/testData/intentions/loopToCallChain/forEach.kt.after +++ b/idea/testData/intentions/loopToCallChain/forEach.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filter{}.forEach{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.forEach{}'" fun foo(list: List) { list .filter { it.isNotBlank() } diff --git a/idea/testData/intentions/loopToCallChain/forEach.kt.after2 b/idea/testData/intentions/loopToCallChain/forEach.kt.after2 new file mode 100644 index 00000000000..549fdd70011 --- /dev/null +++ b/idea/testData/intentions/loopToCallChain/forEach.kt.after2 @@ -0,0 +1,9 @@ +// WITH_RUNTIME +// INTENTION_TEXT: "Replace with 'filter{}.forEach{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.forEach{}'" +fun foo(list: List) { + list + .asSequence() + .filter { it.isNotBlank() } + .forEach { println(it) } +} \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/forEachIndexed.kt b/idea/testData/intentions/loopToCallChain/forEachIndexed.kt index a5b20ba620e..7ec4b330680 100644 --- a/idea/testData/intentions/loopToCallChain/forEachIndexed.kt +++ b/idea/testData/intentions/loopToCallChain/forEachIndexed.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'map{}.forEachIndexed{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().map{}.forEachIndexed{}'" fun foo(list: List) { for ((index, s) in list.withIndex()) { val s1 = s.substring(1) diff --git a/idea/testData/intentions/loopToCallChain/forEachIndexed.kt.after b/idea/testData/intentions/loopToCallChain/forEachIndexed.kt.after index 2a9320a2ff2..0d4506e88f8 100644 --- a/idea/testData/intentions/loopToCallChain/forEachIndexed.kt.after +++ b/idea/testData/intentions/loopToCallChain/forEachIndexed.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'map{}.forEachIndexed{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().map{}.forEachIndexed{}'" fun foo(list: List) { list .map { it.substring(1) } diff --git a/idea/testData/intentions/loopToCallChain/forEachIndexed.kt.after2 b/idea/testData/intentions/loopToCallChain/forEachIndexed.kt.after2 new file mode 100644 index 00000000000..1cd5747b841 --- /dev/null +++ b/idea/testData/intentions/loopToCallChain/forEachIndexed.kt.after2 @@ -0,0 +1,9 @@ +// WITH_RUNTIME +// INTENTION_TEXT: "Replace with 'map{}.forEachIndexed{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().map{}.forEachIndexed{}'" +fun foo(list: List) { + list + .asSequence() + .map { it.substring(1) } + .forEachIndexed { index, s1 -> println(s1.hashCode() * index) } +} \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/forEachIndexed_nothingElse.kt b/idea/testData/intentions/loopToCallChain/forEachIndexed_nothingElse.kt index 7d9c70e2ec5..59db6f726d5 100644 --- a/idea/testData/intentions/loopToCallChain/forEachIndexed_nothingElse.kt +++ b/idea/testData/intentions/loopToCallChain/forEachIndexed_nothingElse.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // IS_APPLICABLE: false +// IS_APPLICABLE_2: false fun foo(list: List) { for ((index, s) in list.withIndex()) { println(s.hashCode() * index) diff --git a/idea/testData/intentions/loopToCallChain/forEach_notAvailable.kt b/idea/testData/intentions/loopToCallChain/forEach_notAvailable.kt index 750a6ea3291..7b669e292ff 100644 --- a/idea/testData/intentions/loopToCallChain/forEach_notAvailable.kt +++ b/idea/testData/intentions/loopToCallChain/forEach_notAvailable.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // IS_APPLICABLE: false +// IS_APPLICABLE_2: false fun foo(list: List) { for (s in list) { println(s) diff --git a/idea/testData/intentions/loopToCallChain/forEach_notIndexed.kt b/idea/testData/intentions/loopToCallChain/forEach_notIndexed.kt index 9c569378d4d..e16c2d2cb5a 100644 --- a/idea/testData/intentions/loopToCallChain/forEach_notIndexed.kt +++ b/idea/testData/intentions/loopToCallChain/forEach_notIndexed.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'mapIndexed{}.forEach{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().mapIndexed{}.forEach{}'" fun foo(list: List) { for ((index, s) in list.withIndex()) { val x = s.length * index diff --git a/idea/testData/intentions/loopToCallChain/forEach_notIndexed.kt.after b/idea/testData/intentions/loopToCallChain/forEach_notIndexed.kt.after index 37fef4d3e70..2d26b6a0d58 100644 --- a/idea/testData/intentions/loopToCallChain/forEach_notIndexed.kt.after +++ b/idea/testData/intentions/loopToCallChain/forEach_notIndexed.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'mapIndexed{}.forEach{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().mapIndexed{}.forEach{}'" fun foo(list: List) { list .mapIndexed { index, s -> s.length * index } diff --git a/idea/testData/intentions/loopToCallChain/forEach_notIndexed.kt.after2 b/idea/testData/intentions/loopToCallChain/forEach_notIndexed.kt.after2 new file mode 100644 index 00000000000..85a46bfd6b2 --- /dev/null +++ b/idea/testData/intentions/loopToCallChain/forEach_notIndexed.kt.after2 @@ -0,0 +1,9 @@ +// WITH_RUNTIME +// INTENTION_TEXT: "Replace with 'mapIndexed{}.forEach{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().mapIndexed{}.forEach{}'" +fun foo(list: List) { + list + .asSequence() + .mapIndexed { index, s -> s.length * index } + .forEach { println(it) } +} \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/indexOf.kt b/idea/testData/intentions/loopToCallChain/indexOf.kt index 3572beb82a3..6cb8a98d549 100644 --- a/idea/testData/intentions/loopToCallChain/indexOf.kt +++ b/idea/testData/intentions/loopToCallChain/indexOf.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'indexOf()'" +// IS_APPLICABLE_2: false fun foo(list: List): Int { for ((index, s) in list.withIndex()) { if (s == "a") { diff --git a/idea/testData/intentions/loopToCallChain/indexOf.kt.after b/idea/testData/intentions/loopToCallChain/indexOf.kt.after index b9e552099e2..ff878a1eec7 100644 --- a/idea/testData/intentions/loopToCallChain/indexOf.kt.after +++ b/idea/testData/intentions/loopToCallChain/indexOf.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'indexOf()'" +// IS_APPLICABLE_2: false fun foo(list: List): Int { return list.indexOf("a") } \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/indexOfFirst_ifAssign.kt b/idea/testData/intentions/loopToCallChain/indexOfFirst_ifAssign.kt index e7a7c44139f..6dee7dbf7d4 100644 --- a/idea/testData/intentions/loopToCallChain/indexOfFirst_ifAssign.kt +++ b/idea/testData/intentions/loopToCallChain/indexOfFirst_ifAssign.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'indexOfFirst{}'" +// IS_APPLICABLE_2: false fun foo(list: List) { var result = -1 for ((index, s) in list.withIndex()) { diff --git a/idea/testData/intentions/loopToCallChain/indexOfFirst_ifAssign.kt.after b/idea/testData/intentions/loopToCallChain/indexOfFirst_ifAssign.kt.after index 75d317bd303..2dfc7dd9b11 100644 --- a/idea/testData/intentions/loopToCallChain/indexOfFirst_ifAssign.kt.after +++ b/idea/testData/intentions/loopToCallChain/indexOfFirst_ifAssign.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'indexOfFirst{}'" +// IS_APPLICABLE_2: false fun foo(list: List) { val result = list.indexOfFirst { it.length > 0 } } \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/indexOfFirst_ifReturn.kt b/idea/testData/intentions/loopToCallChain/indexOfFirst_ifReturn.kt index 0b0e8488f4e..dde7e958588 100644 --- a/idea/testData/intentions/loopToCallChain/indexOfFirst_ifReturn.kt +++ b/idea/testData/intentions/loopToCallChain/indexOfFirst_ifReturn.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'indexOfFirst{}'" +// IS_APPLICABLE_2: false fun foo(list: List): Int { for ((index, s) in list.withIndex()) { if (s.length > 0) { diff --git a/idea/testData/intentions/loopToCallChain/indexOfFirst_ifReturn.kt.after b/idea/testData/intentions/loopToCallChain/indexOfFirst_ifReturn.kt.after index 1270aeb1630..f40f3884917 100644 --- a/idea/testData/intentions/loopToCallChain/indexOfFirst_ifReturn.kt.after +++ b/idea/testData/intentions/loopToCallChain/indexOfFirst_ifReturn.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'indexOfFirst{}'" +// IS_APPLICABLE_2: false fun foo(list: List): Int { return list.indexOfFirst { it.length > 0 } } \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/indexOfFirst_mustBeNoIndexInCondition.kt b/idea/testData/intentions/loopToCallChain/indexOfFirst_mustBeNoIndexInCondition.kt index ebd06773402..f838f6a4a43 100644 --- a/idea/testData/intentions/loopToCallChain/indexOfFirst_mustBeNoIndexInCondition.kt +++ b/idea/testData/intentions/loopToCallChain/indexOfFirst_mustBeNoIndexInCondition.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // IS_APPLICABLE: false +// IS_APPLICABLE_2: false fun foo(list: List) { var result = -1 for ((index, s) in list.withIndex()) { diff --git a/idea/testData/intentions/loopToCallChain/indexOfLast_ifAssign.kt b/idea/testData/intentions/loopToCallChain/indexOfLast_ifAssign.kt index 1a6f9bdda90..4afdafb873f 100644 --- a/idea/testData/intentions/loopToCallChain/indexOfLast_ifAssign.kt +++ b/idea/testData/intentions/loopToCallChain/indexOfLast_ifAssign.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'indexOfLast{}'" +// IS_APPLICABLE_2: false fun foo(list: List) { var result = -1 for ((index, s) in list.withIndex()) { diff --git a/idea/testData/intentions/loopToCallChain/indexOfLast_ifAssign.kt.after b/idea/testData/intentions/loopToCallChain/indexOfLast_ifAssign.kt.after index 59b12551752..5dd057ff4b2 100644 --- a/idea/testData/intentions/loopToCallChain/indexOfLast_ifAssign.kt.after +++ b/idea/testData/intentions/loopToCallChain/indexOfLast_ifAssign.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'indexOfLast{}'" +// IS_APPLICABLE_2: false fun foo(list: List) { val result = list.indexOfLast { it.length > 0 } } \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/indexPlusPlusInsideExpression.kt b/idea/testData/intentions/loopToCallChain/indexPlusPlusInsideExpression.kt index 26854070c55..b24d810b3a0 100644 --- a/idea/testData/intentions/loopToCallChain/indexPlusPlusInsideExpression.kt +++ b/idea/testData/intentions/loopToCallChain/indexPlusPlusInsideExpression.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filterNot{}.mapIndexed{}.firstOrNull{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filterNot{}.mapIndexed{}.firstOrNull{}'" fun foo(list: List): Int? { var index = 0 for (s in list) { diff --git a/idea/testData/intentions/loopToCallChain/indexPlusPlusInsideExpression.kt.after b/idea/testData/intentions/loopToCallChain/indexPlusPlusInsideExpression.kt.after index 000cbbd54ed..29afe43e596 100644 --- a/idea/testData/intentions/loopToCallChain/indexPlusPlusInsideExpression.kt.after +++ b/idea/testData/intentions/loopToCallChain/indexPlusPlusInsideExpression.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filterNot{}.mapIndexed{}.firstOrNull{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filterNot{}.mapIndexed{}.firstOrNull{}'" fun foo(list: List): Int? { return list .filterNot { it.isBlank() } diff --git a/idea/testData/intentions/loopToCallChain/indexPlusPlusInsideExpression.kt.after2 b/idea/testData/intentions/loopToCallChain/indexPlusPlusInsideExpression.kt.after2 new file mode 100644 index 00000000000..4eeae1e3ccb --- /dev/null +++ b/idea/testData/intentions/loopToCallChain/indexPlusPlusInsideExpression.kt.after2 @@ -0,0 +1,10 @@ +// WITH_RUNTIME +// INTENTION_TEXT: "Replace with 'filterNot{}.mapIndexed{}.firstOrNull{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filterNot{}.mapIndexed{}.firstOrNull{}'" +fun foo(list: List): Int? { + return list + .asSequence() + .filterNot { it.isBlank() } + .mapIndexed { index, s -> s.length * index } + .firstOrNull { it > 0 } +} \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/indexPlusPlusInsideExpression_indexUsedAfterIncrement.kt b/idea/testData/intentions/loopToCallChain/indexPlusPlusInsideExpression_indexUsedAfterIncrement.kt index c812da36d2b..588ccbcf2b9 100644 --- a/idea/testData/intentions/loopToCallChain/indexPlusPlusInsideExpression_indexUsedAfterIncrement.kt +++ b/idea/testData/intentions/loopToCallChain/indexPlusPlusInsideExpression_indexUsedAfterIncrement.kt @@ -1,5 +1,7 @@ // WITH_RUNTIME //TODO: should not be available without "asSequence()"! +// INTENTION_TEXT: "Replace with 'filterNot{}.map{}.firstOrNull{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filterNot{}.map{}.firstOrNull{}'" fun foo(list: List): Int? { var index = 0 for (s in list) { diff --git a/idea/testData/intentions/loopToCallChain/indexPlusPlusInsideExpression_indexUsedAfterIncrement.kt.after b/idea/testData/intentions/loopToCallChain/indexPlusPlusInsideExpression_indexUsedAfterIncrement.kt.after index c01b9e545fc..723ec3b88b0 100644 --- a/idea/testData/intentions/loopToCallChain/indexPlusPlusInsideExpression_indexUsedAfterIncrement.kt.after +++ b/idea/testData/intentions/loopToCallChain/indexPlusPlusInsideExpression_indexUsedAfterIncrement.kt.after @@ -1,5 +1,7 @@ // WITH_RUNTIME //TODO: should not be available without "asSequence()"! +// INTENTION_TEXT: "Replace with 'filterNot{}.map{}.firstOrNull{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filterNot{}.map{}.firstOrNull{}'" fun foo(list: List): Int? { var index = 0 return list diff --git a/idea/testData/intentions/loopToCallChain/indexPlusPlusInsideExpression_indexUsedAfterIncrement.kt.after2 b/idea/testData/intentions/loopToCallChain/indexPlusPlusInsideExpression_indexUsedAfterIncrement.kt.after2 new file mode 100644 index 00000000000..590cadbaca8 --- /dev/null +++ b/idea/testData/intentions/loopToCallChain/indexPlusPlusInsideExpression_indexUsedAfterIncrement.kt.after2 @@ -0,0 +1,12 @@ +// WITH_RUNTIME +//TODO: should not be available without "asSequence()"! +// INTENTION_TEXT: "Replace with 'filterNot{}.map{}.firstOrNull{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filterNot{}.map{}.firstOrNull{}'" +fun foo(list: List): Int? { + var index = 0 + return list + .asSequence() + .filterNot { it.isBlank() } + .map { it.length * index++ } + .firstOrNull { it * 100 > index * index } +} \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/indexPlusPlusInsideExpression_indexUsedBeforeIncrement.kt b/idea/testData/intentions/loopToCallChain/indexPlusPlusInsideExpression_indexUsedBeforeIncrement.kt index 6cd03c0188f..5b4e01e2130 100644 --- a/idea/testData/intentions/loopToCallChain/indexPlusPlusInsideExpression_indexUsedBeforeIncrement.kt +++ b/idea/testData/intentions/loopToCallChain/indexPlusPlusInsideExpression_indexUsedBeforeIncrement.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with '...mapIndexed{}.mapIndexed{}.firstOrNull{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence()...mapIndexed{}.mapIndexed{}.firstOrNull{}'" fun foo(list: List): Int? { var index = 0 for (s in list) { diff --git a/idea/testData/intentions/loopToCallChain/indexPlusPlusInsideExpression_indexUsedBeforeIncrement.kt.after b/idea/testData/intentions/loopToCallChain/indexPlusPlusInsideExpression_indexUsedBeforeIncrement.kt.after index b175d3d21f6..456013faced 100644 --- a/idea/testData/intentions/loopToCallChain/indexPlusPlusInsideExpression_indexUsedBeforeIncrement.kt.after +++ b/idea/testData/intentions/loopToCallChain/indexPlusPlusInsideExpression_indexUsedBeforeIncrement.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with '...mapIndexed{}.mapIndexed{}.firstOrNull{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence()...mapIndexed{}.mapIndexed{}.firstOrNull{}'" fun foo(list: List): Int? { return list .filterNot { it.isBlank() } diff --git a/idea/testData/intentions/loopToCallChain/indexPlusPlusInsideExpression_indexUsedBeforeIncrement.kt.after2 b/idea/testData/intentions/loopToCallChain/indexPlusPlusInsideExpression_indexUsedBeforeIncrement.kt.after2 new file mode 100644 index 00000000000..d94f859da9d --- /dev/null +++ b/idea/testData/intentions/loopToCallChain/indexPlusPlusInsideExpression_indexUsedBeforeIncrement.kt.after2 @@ -0,0 +1,11 @@ +// WITH_RUNTIME +// INTENTION_TEXT: "Replace with '...mapIndexed{}.mapIndexed{}.firstOrNull{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence()...mapIndexed{}.mapIndexed{}.firstOrNull{}'" +fun foo(list: List): Int? { + return list + .asSequence() + .filterNot { it.isBlank() } + .mapIndexed { index, s -> s.length * index } + .mapIndexed { index, x -> x * index } + .firstOrNull { it > 1000 } +} \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/indexPlusPlusInsideExpression_indexUsedBeforeIncrement2.kt b/idea/testData/intentions/loopToCallChain/indexPlusPlusInsideExpression_indexUsedBeforeIncrement2.kt index e9edce2b13a..2af28a15b08 100644 --- a/idea/testData/intentions/loopToCallChain/indexPlusPlusInsideExpression_indexUsedBeforeIncrement2.kt +++ b/idea/testData/intentions/loopToCallChain/indexPlusPlusInsideExpression_indexUsedBeforeIncrement2.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'mapIndexed{}.mapIndexed{}.firstOrNull{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().mapIndexed{}.mapIndexed{}.firstOrNull{}'" fun foo(list: List): Int? { var index = 0 for (s in list) { diff --git a/idea/testData/intentions/loopToCallChain/indexPlusPlusInsideExpression_indexUsedBeforeIncrement2.kt.after b/idea/testData/intentions/loopToCallChain/indexPlusPlusInsideExpression_indexUsedBeforeIncrement2.kt.after index c64bb0aba28..ebdca2bbd22 100644 --- a/idea/testData/intentions/loopToCallChain/indexPlusPlusInsideExpression_indexUsedBeforeIncrement2.kt.after +++ b/idea/testData/intentions/loopToCallChain/indexPlusPlusInsideExpression_indexUsedBeforeIncrement2.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'mapIndexed{}.mapIndexed{}.firstOrNull{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().mapIndexed{}.mapIndexed{}.firstOrNull{}'" fun foo(list: List): Int? { return list .mapIndexed { index, s -> s.length * index } diff --git a/idea/testData/intentions/loopToCallChain/indexPlusPlusInsideExpression_indexUsedBeforeIncrement2.kt.after2 b/idea/testData/intentions/loopToCallChain/indexPlusPlusInsideExpression_indexUsedBeforeIncrement2.kt.after2 new file mode 100644 index 00000000000..a6446cb17b1 --- /dev/null +++ b/idea/testData/intentions/loopToCallChain/indexPlusPlusInsideExpression_indexUsedBeforeIncrement2.kt.after2 @@ -0,0 +1,10 @@ +// WITH_RUNTIME +// INTENTION_TEXT: "Replace with 'mapIndexed{}.mapIndexed{}.firstOrNull{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().mapIndexed{}.mapIndexed{}.firstOrNull{}'" +fun foo(list: List): Int? { + return list + .asSequence() + .mapIndexed { index, s -> s.length * index } + .mapIndexed { index, x -> x * index } + .firstOrNull { it <= 1000 } +} \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/indexPlusPlusIsNotLastStatement.kt b/idea/testData/intentions/loopToCallChain/indexPlusPlusIsNotLastStatement.kt index cf0a606f8d6..511f2bdc801 100644 --- a/idea/testData/intentions/loopToCallChain/indexPlusPlusIsNotLastStatement.kt +++ b/idea/testData/intentions/loopToCallChain/indexPlusPlusIsNotLastStatement.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filterNot{}.mapIndexed{}.firstOrNull{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filterNot{}.mapIndexed{}.firstOrNull{}'" fun foo(list: List): Int? { var index = 0 for (s in list) { diff --git a/idea/testData/intentions/loopToCallChain/indexPlusPlusIsNotLastStatement.kt.after b/idea/testData/intentions/loopToCallChain/indexPlusPlusIsNotLastStatement.kt.after index 000cbbd54ed..29afe43e596 100644 --- a/idea/testData/intentions/loopToCallChain/indexPlusPlusIsNotLastStatement.kt.after +++ b/idea/testData/intentions/loopToCallChain/indexPlusPlusIsNotLastStatement.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filterNot{}.mapIndexed{}.firstOrNull{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filterNot{}.mapIndexed{}.firstOrNull{}'" fun foo(list: List): Int? { return list .filterNot { it.isBlank() } diff --git a/idea/testData/intentions/loopToCallChain/indexPlusPlusIsNotLastStatement.kt.after2 b/idea/testData/intentions/loopToCallChain/indexPlusPlusIsNotLastStatement.kt.after2 new file mode 100644 index 00000000000..4eeae1e3ccb --- /dev/null +++ b/idea/testData/intentions/loopToCallChain/indexPlusPlusIsNotLastStatement.kt.after2 @@ -0,0 +1,10 @@ +// WITH_RUNTIME +// INTENTION_TEXT: "Replace with 'filterNot{}.mapIndexed{}.firstOrNull{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filterNot{}.mapIndexed{}.firstOrNull{}'" +fun foo(list: List): Int? { + return list + .asSequence() + .filterNot { it.isBlank() } + .mapIndexed { index, s -> s.length * index } + .firstOrNull { it > 0 } +} \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/indexPlusPlusIsNotLastStatement_indexUsedAfterIncrement.kt b/idea/testData/intentions/loopToCallChain/indexPlusPlusIsNotLastStatement_indexUsedAfterIncrement.kt index a2a242deb4e..d8bd66fc6c8 100644 --- a/idea/testData/intentions/loopToCallChain/indexPlusPlusIsNotLastStatement_indexUsedAfterIncrement.kt +++ b/idea/testData/intentions/loopToCallChain/indexPlusPlusIsNotLastStatement_indexUsedAfterIncrement.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // IS_APPLICABLE: false +// IS_APPLICABLE_2: false fun foo(list: List): Int? { var index = 0 for (s in list) { diff --git a/idea/testData/intentions/loopToCallChain/indexWithNestedLoop.kt b/idea/testData/intentions/loopToCallChain/indexWithNestedLoop.kt index 9e2b60d1ba2..45cc13b7072 100644 --- a/idea/testData/intentions/loopToCallChain/indexWithNestedLoop.kt +++ b/idea/testData/intentions/loopToCallChain/indexWithNestedLoop.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'flatMap{}.filterNot{}.mapIndexedTo(){}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().flatMap{}.filterNot{}.mapIndexedTo(){}'" fun foo(list: List, target: MutableCollection) { var i = 0 for (s in list) { diff --git a/idea/testData/intentions/loopToCallChain/indexWithNestedLoop.kt.after b/idea/testData/intentions/loopToCallChain/indexWithNestedLoop.kt.after index dd5158f4346..315c2150f5c 100644 --- a/idea/testData/intentions/loopToCallChain/indexWithNestedLoop.kt.after +++ b/idea/testData/intentions/loopToCallChain/indexWithNestedLoop.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'flatMap{}.filterNot{}.mapIndexedTo(){}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().flatMap{}.filterNot{}.mapIndexedTo(){}'" fun foo(list: List, target: MutableCollection) { list .flatMap { it.indices } diff --git a/idea/testData/intentions/loopToCallChain/indexWithNestedLoop.kt.after2 b/idea/testData/intentions/loopToCallChain/indexWithNestedLoop.kt.after2 new file mode 100644 index 00000000000..8453c184f6e --- /dev/null +++ b/idea/testData/intentions/loopToCallChain/indexWithNestedLoop.kt.after2 @@ -0,0 +1,10 @@ +// WITH_RUNTIME +// INTENTION_TEXT: "Replace with 'flatMap{}.filterNot{}.mapIndexedTo(){}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().flatMap{}.filterNot{}.mapIndexedTo(){}'" +fun foo(list: List, target: MutableCollection) { + list + .asSequence() + .flatMap { it.indices.asSequence() } + .filterNot { it == 10 } + .mapIndexedTo(target) { i, j -> i + j } +} \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/intArray.kt b/idea/testData/intentions/loopToCallChain/intArray.kt index 01c6ca99af3..254451cb217 100644 --- a/idea/testData/intentions/loopToCallChain/intArray.kt +++ b/idea/testData/intentions/loopToCallChain/intArray.kt @@ -1,4 +1,6 @@ // WITH_RUNTIME +// INTENTION_TEXT: "Replace with 'filter{}'" +// IS_APPLICABLE_2: false import java.util.ArrayList fun foo(array: IntArray): List { diff --git a/idea/testData/intentions/loopToCallChain/intArray.kt.after b/idea/testData/intentions/loopToCallChain/intArray.kt.after index 059579a8e3d..1a980ba751c 100644 --- a/idea/testData/intentions/loopToCallChain/intArray.kt.after +++ b/idea/testData/intentions/loopToCallChain/intArray.kt.after @@ -1,4 +1,6 @@ // WITH_RUNTIME +// INTENTION_TEXT: "Replace with 'filter{}'" +// IS_APPLICABLE_2: false import java.util.ArrayList fun foo(array: IntArray): List { diff --git a/idea/testData/intentions/loopToCallChain/itAlreadyUsed.kt b/idea/testData/intentions/loopToCallChain/itAlreadyUsed.kt index 55d326766de..8956a99e015 100644 --- a/idea/testData/intentions/loopToCallChain/itAlreadyUsed.kt +++ b/idea/testData/intentions/loopToCallChain/itAlreadyUsed.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'any{}'" +// IS_APPLICABLE_2: false fun foo(list: List, it: Int) { var found = false for (s in list) { diff --git a/idea/testData/intentions/loopToCallChain/itAlreadyUsed.kt.after b/idea/testData/intentions/loopToCallChain/itAlreadyUsed.kt.after index 75d1551f836..24ffdf109b1 100644 --- a/idea/testData/intentions/loopToCallChain/itAlreadyUsed.kt.after +++ b/idea/testData/intentions/loopToCallChain/itAlreadyUsed.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'any{}'" +// IS_APPLICABLE_2: false fun foo(list: List, it: Int) { val found = list.any { s -> s.length > it } } \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/lastIndexOf.kt b/idea/testData/intentions/loopToCallChain/lastIndexOf.kt index 4c8c42e36e6..af2af33cfa4 100644 --- a/idea/testData/intentions/loopToCallChain/lastIndexOf.kt +++ b/idea/testData/intentions/loopToCallChain/lastIndexOf.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'lastIndexOf()'" +// IS_APPLICABLE_2: false fun foo(list: List) { var result = -1 for ((index, s) in list.withIndex()) { diff --git a/idea/testData/intentions/loopToCallChain/lastIndexOf.kt.after b/idea/testData/intentions/loopToCallChain/lastIndexOf.kt.after index f6885843a8a..c41309fba3c 100644 --- a/idea/testData/intentions/loopToCallChain/lastIndexOf.kt.after +++ b/idea/testData/intentions/loopToCallChain/lastIndexOf.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'lastIndexOf()'" +// IS_APPLICABLE_2: false fun foo(list: List) { val result = list.lastIndexOf("a") } \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/lastOrNull_ifAssign.kt b/idea/testData/intentions/loopToCallChain/lastOrNull_ifAssign.kt index 08c46eb0202..d55e3e0ab55 100644 --- a/idea/testData/intentions/loopToCallChain/lastOrNull_ifAssign.kt +++ b/idea/testData/intentions/loopToCallChain/lastOrNull_ifAssign.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'lastOrNull{}'" +// IS_APPLICABLE_2: false fun foo(list: List) { var result: String? = null for (s in list) { diff --git a/idea/testData/intentions/loopToCallChain/lastOrNull_ifAssign.kt.after b/idea/testData/intentions/loopToCallChain/lastOrNull_ifAssign.kt.after index 55558033370..4f83ce39e0e 100644 --- a/idea/testData/intentions/loopToCallChain/lastOrNull_ifAssign.kt.after +++ b/idea/testData/intentions/loopToCallChain/lastOrNull_ifAssign.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'lastOrNull{}'" +// IS_APPLICABLE_2: false fun foo(list: List) { val result: String? = list.lastOrNull { it.length > 0 } } \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/map.kt b/idea/testData/intentions/loopToCallChain/map.kt index fdff9eab6d4..9c048c417a0 100644 --- a/idea/testData/intentions/loopToCallChain/map.kt +++ b/idea/testData/intentions/loopToCallChain/map.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'map{}.firstOrNull{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().map{}.firstOrNull{}'" fun foo(list: List): Int? { for (s in list) { val length = s.length diff --git a/idea/testData/intentions/loopToCallChain/map.kt.after b/idea/testData/intentions/loopToCallChain/map.kt.after index 66e475bfdfe..850c6d9f602 100644 --- a/idea/testData/intentions/loopToCallChain/map.kt.after +++ b/idea/testData/intentions/loopToCallChain/map.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'map{}.firstOrNull{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().map{}.firstOrNull{}'" fun foo(list: List): Int? { return list .map { it.length } diff --git a/idea/testData/intentions/loopToCallChain/map.kt.after2 b/idea/testData/intentions/loopToCallChain/map.kt.after2 new file mode 100644 index 00000000000..67600762ba4 --- /dev/null +++ b/idea/testData/intentions/loopToCallChain/map.kt.after2 @@ -0,0 +1,9 @@ +// WITH_RUNTIME +// INTENTION_TEXT: "Replace with 'map{}.firstOrNull{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().map{}.firstOrNull{}'" +fun foo(list: List): Int? { + return list + .asSequence() + .map { it.length } + .firstOrNull { it > 0 } +} \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/mapAndFilterIndexed.kt b/idea/testData/intentions/loopToCallChain/mapAndFilterIndexed.kt index 2e98613ef63..7be807c7f53 100644 --- a/idea/testData/intentions/loopToCallChain/mapAndFilterIndexed.kt +++ b/idea/testData/intentions/loopToCallChain/mapAndFilterIndexed.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'map{}.filterIndexed{}.firstOrNull()'" +// INTENTION_TEXT_2: "Replace with 'asSequence().map{}.filterIndexed{}.firstOrNull()'" fun foo(list: List): Int? { for ((index, s) in list.withIndex()) { val l = s.length diff --git a/idea/testData/intentions/loopToCallChain/mapAndFilterIndexed.kt.after b/idea/testData/intentions/loopToCallChain/mapAndFilterIndexed.kt.after index e8a46c55572..ef4cee53532 100644 --- a/idea/testData/intentions/loopToCallChain/mapAndFilterIndexed.kt.after +++ b/idea/testData/intentions/loopToCallChain/mapAndFilterIndexed.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'map{}.filterIndexed{}.firstOrNull()'" +// INTENTION_TEXT_2: "Replace with 'asSequence().map{}.filterIndexed{}.firstOrNull()'" fun foo(list: List): Int? { return list .map { it.length } diff --git a/idea/testData/intentions/loopToCallChain/mapAndFilterIndexed.kt.after2 b/idea/testData/intentions/loopToCallChain/mapAndFilterIndexed.kt.after2 new file mode 100644 index 00000000000..b2b94e60e1e --- /dev/null +++ b/idea/testData/intentions/loopToCallChain/mapAndFilterIndexed.kt.after2 @@ -0,0 +1,10 @@ +// WITH_RUNTIME +// INTENTION_TEXT: "Replace with 'map{}.filterIndexed{}.firstOrNull()'" +// INTENTION_TEXT_2: "Replace with 'asSequence().map{}.filterIndexed{}.firstOrNull()'" +fun foo(list: List): Int? { + return list + .asSequence() + .map { it.length } + .filterIndexed { index, l -> l > index } + .firstOrNull() +} \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/mapIndexed.kt b/idea/testData/intentions/loopToCallChain/mapIndexed.kt index 114e772d81c..dee2835d67d 100644 --- a/idea/testData/intentions/loopToCallChain/mapIndexed.kt +++ b/idea/testData/intentions/loopToCallChain/mapIndexed.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'mapIndexed{}.firstOrNull{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().mapIndexed{}.firstOrNull{}'" fun foo(list: List): Int? { for ((index, s) in list.withIndex()) { val x = s.length * index diff --git a/idea/testData/intentions/loopToCallChain/mapIndexed.kt.after b/idea/testData/intentions/loopToCallChain/mapIndexed.kt.after index ff38c362f28..2aba8f742e4 100644 --- a/idea/testData/intentions/loopToCallChain/mapIndexed.kt.after +++ b/idea/testData/intentions/loopToCallChain/mapIndexed.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'mapIndexed{}.firstOrNull{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().mapIndexed{}.firstOrNull{}'" fun foo(list: List): Int? { return list .mapIndexed { index, s -> s.length * index } diff --git a/idea/testData/intentions/loopToCallChain/mapIndexed.kt.after2 b/idea/testData/intentions/loopToCallChain/mapIndexed.kt.after2 new file mode 100644 index 00000000000..d0a8ce46781 --- /dev/null +++ b/idea/testData/intentions/loopToCallChain/mapIndexed.kt.after2 @@ -0,0 +1,9 @@ +// WITH_RUNTIME +// INTENTION_TEXT: "Replace with 'mapIndexed{}.firstOrNull{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().mapIndexed{}.firstOrNull{}'" +fun foo(list: List): Int? { + return list + .asSequence() + .mapIndexed { index, s -> s.length * index } + .firstOrNull { it > 0 } +} \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/mapIndexedNotNull.kt b/idea/testData/intentions/loopToCallChain/mapIndexedNotNull.kt index 57380912bd9..0e91ba1c793 100644 --- a/idea/testData/intentions/loopToCallChain/mapIndexedNotNull.kt +++ b/idea/testData/intentions/loopToCallChain/mapIndexedNotNull.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'mapIndexedNotNull{}.mapTo(){}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().mapIndexedNotNull{}.mapTo(){}'" fun foo(list: List, target: MutableList) { for ((index, s) in list.withIndex()) { val length = s?.substring(index)?.length diff --git a/idea/testData/intentions/loopToCallChain/mapIndexedNotNull.kt.after b/idea/testData/intentions/loopToCallChain/mapIndexedNotNull.kt.after index 1f5245bb3eb..5454bb15f5e 100644 --- a/idea/testData/intentions/loopToCallChain/mapIndexedNotNull.kt.after +++ b/idea/testData/intentions/loopToCallChain/mapIndexedNotNull.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'mapIndexedNotNull{}.mapTo(){}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().mapIndexedNotNull{}.mapTo(){}'" fun foo(list: List, target: MutableList) { list .mapIndexedNotNull { index, s -> s?.substring(index)?.length } diff --git a/idea/testData/intentions/loopToCallChain/mapIndexedNotNull.kt.after2 b/idea/testData/intentions/loopToCallChain/mapIndexedNotNull.kt.after2 new file mode 100644 index 00000000000..ba598210979 --- /dev/null +++ b/idea/testData/intentions/loopToCallChain/mapIndexedNotNull.kt.after2 @@ -0,0 +1,9 @@ +// WITH_RUNTIME +// INTENTION_TEXT: "Replace with 'mapIndexedNotNull{}.mapTo(){}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().mapIndexedNotNull{}.mapTo(){}'" +fun foo(list: List, target: MutableList) { + list + .asSequence() + .mapIndexedNotNull { index, s -> s?.substring(index)?.length } + .mapTo(target) { it.toString() } +} \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/mapIndexedNotNullTo.kt b/idea/testData/intentions/loopToCallChain/mapIndexedNotNullTo.kt index f2da84b4806..0b1bb33746e 100644 --- a/idea/testData/intentions/loopToCallChain/mapIndexedNotNullTo.kt +++ b/idea/testData/intentions/loopToCallChain/mapIndexedNotNullTo.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'mapIndexedNotNullTo(){}'" +// IS_APPLICABLE_2: false fun foo(list: List, target: MutableList) { for ((index, s) in list.withIndex()) { val length = s?.substring(index)?.length diff --git a/idea/testData/intentions/loopToCallChain/mapIndexedNotNullTo.kt.after b/idea/testData/intentions/loopToCallChain/mapIndexedNotNullTo.kt.after index 489199c5f76..22ac267b9d8 100644 --- a/idea/testData/intentions/loopToCallChain/mapIndexedNotNullTo.kt.after +++ b/idea/testData/intentions/loopToCallChain/mapIndexedNotNullTo.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'mapIndexedNotNullTo(){}'" +// IS_APPLICABLE_2: false fun foo(list: List, target: MutableList) { list.mapIndexedNotNullTo(target) { index, s -> s?.substring(index)?.length } } \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/mapIndexedNotNullTo_elvisContinue.kt b/idea/testData/intentions/loopToCallChain/mapIndexedNotNullTo_elvisContinue.kt index 8e0006a4cab..094ebc74f0a 100644 --- a/idea/testData/intentions/loopToCallChain/mapIndexedNotNullTo_elvisContinue.kt +++ b/idea/testData/intentions/loopToCallChain/mapIndexedNotNullTo_elvisContinue.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'mapIndexedNotNullTo(){}'" +// IS_APPLICABLE_2: false fun foo(list: List, target: MutableList) { for ((index, s) in list.withIndex()) { val length = s?.substring(index)?.length ?: continue diff --git a/idea/testData/intentions/loopToCallChain/mapIndexedNotNullTo_elvisContinue.kt.after b/idea/testData/intentions/loopToCallChain/mapIndexedNotNullTo_elvisContinue.kt.after index 489199c5f76..22ac267b9d8 100644 --- a/idea/testData/intentions/loopToCallChain/mapIndexedNotNullTo_elvisContinue.kt.after +++ b/idea/testData/intentions/loopToCallChain/mapIndexedNotNullTo_elvisContinue.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'mapIndexedNotNullTo(){}'" +// IS_APPLICABLE_2: false fun foo(list: List, target: MutableList) { list.mapIndexedNotNullTo(target) { index, s -> s?.substring(index)?.length } } \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/mapIndexedNotNull_elvisContinue.kt b/idea/testData/intentions/loopToCallChain/mapIndexedNotNull_elvisContinue.kt index 9fc0ec93437..7a7b9f3f181 100644 --- a/idea/testData/intentions/loopToCallChain/mapIndexedNotNull_elvisContinue.kt +++ b/idea/testData/intentions/loopToCallChain/mapIndexedNotNull_elvisContinue.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'mapIndexedNotNull{}.mapTo(){}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().mapIndexedNotNull{}.mapTo(){}'" fun foo(list: List, target: MutableList) { for ((index, s) in list.withIndex()) { val length = s?.substring(index)?.length ?: continue diff --git a/idea/testData/intentions/loopToCallChain/mapIndexedNotNull_elvisContinue.kt.after b/idea/testData/intentions/loopToCallChain/mapIndexedNotNull_elvisContinue.kt.after index 1f5245bb3eb..5454bb15f5e 100644 --- a/idea/testData/intentions/loopToCallChain/mapIndexedNotNull_elvisContinue.kt.after +++ b/idea/testData/intentions/loopToCallChain/mapIndexedNotNull_elvisContinue.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'mapIndexedNotNull{}.mapTo(){}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().mapIndexedNotNull{}.mapTo(){}'" fun foo(list: List, target: MutableList) { list .mapIndexedNotNull { index, s -> s?.substring(index)?.length } diff --git a/idea/testData/intentions/loopToCallChain/mapIndexedNotNull_elvisContinue.kt.after2 b/idea/testData/intentions/loopToCallChain/mapIndexedNotNull_elvisContinue.kt.after2 new file mode 100644 index 00000000000..ba598210979 --- /dev/null +++ b/idea/testData/intentions/loopToCallChain/mapIndexedNotNull_elvisContinue.kt.after2 @@ -0,0 +1,9 @@ +// WITH_RUNTIME +// INTENTION_TEXT: "Replace with 'mapIndexedNotNull{}.mapTo(){}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().mapIndexedNotNull{}.mapTo(){}'" +fun foo(list: List, target: MutableList) { + list + .asSequence() + .mapIndexedNotNull { index, s -> s?.substring(index)?.length } + .mapTo(target) { it.toString() } +} \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/mapIndexedTo.kt b/idea/testData/intentions/loopToCallChain/mapIndexedTo.kt index ce7a4faa755..e45443c89b5 100644 --- a/idea/testData/intentions/loopToCallChain/mapIndexedTo.kt +++ b/idea/testData/intentions/loopToCallChain/mapIndexedTo.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'mapIndexedTo(){}'" +// IS_APPLICABLE_2: false fun foo(list: List, target: MutableList) { for ((index, s) in list.withIndex()) { target.add(s.hashCode() * index) diff --git a/idea/testData/intentions/loopToCallChain/mapIndexedTo.kt.after b/idea/testData/intentions/loopToCallChain/mapIndexedTo.kt.after index 6c96861dcf2..3b7db7dd35c 100644 --- a/idea/testData/intentions/loopToCallChain/mapIndexedTo.kt.after +++ b/idea/testData/intentions/loopToCallChain/mapIndexedTo.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'mapIndexedTo(){}'" +// IS_APPLICABLE_2: false fun foo(list: List, target: MutableList) { list.mapIndexedTo(target) { index, s -> s.hashCode() * index } } \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/mapIndexed_afterFilter.kt b/idea/testData/intentions/loopToCallChain/mapIndexed_afterFilter.kt index cf0a606f8d6..511f2bdc801 100644 --- a/idea/testData/intentions/loopToCallChain/mapIndexed_afterFilter.kt +++ b/idea/testData/intentions/loopToCallChain/mapIndexed_afterFilter.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filterNot{}.mapIndexed{}.firstOrNull{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filterNot{}.mapIndexed{}.firstOrNull{}'" fun foo(list: List): Int? { var index = 0 for (s in list) { diff --git a/idea/testData/intentions/loopToCallChain/mapIndexed_afterFilter.kt.after b/idea/testData/intentions/loopToCallChain/mapIndexed_afterFilter.kt.after index f05675ef88d..a5badd2c248 100644 --- a/idea/testData/intentions/loopToCallChain/mapIndexed_afterFilter.kt.after +++ b/idea/testData/intentions/loopToCallChain/mapIndexed_afterFilter.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filterNot{}.mapIndexed{}.firstOrNull{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filterNot{}.mapIndexed{}.firstOrNull{}'" fun foo(list: List): Int? { return list .filterNot { it.isBlank() } diff --git a/idea/testData/intentions/loopToCallChain/mapIndexed_afterFilter.kt.after2 b/idea/testData/intentions/loopToCallChain/mapIndexed_afterFilter.kt.after2 new file mode 100644 index 00000000000..341dcdafa77 --- /dev/null +++ b/idea/testData/intentions/loopToCallChain/mapIndexed_afterFilter.kt.after2 @@ -0,0 +1,10 @@ +// WITH_RUNTIME +// INTENTION_TEXT: "Replace with 'filterNot{}.mapIndexed{}.firstOrNull{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filterNot{}.mapIndexed{}.firstOrNull{}'" +fun foo(list: List): Int? { + return list + .asSequence() + .filterNot { it.isBlank() } + .mapIndexed { index, s -> s.length * index } + .firstOrNull { it > 0 } +} \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/mapIndexed_twice.kt b/idea/testData/intentions/loopToCallChain/mapIndexed_twice.kt index 4fe5ca4ac52..e7607b78906 100644 --- a/idea/testData/intentions/loopToCallChain/mapIndexed_twice.kt +++ b/idea/testData/intentions/loopToCallChain/mapIndexed_twice.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'mapIndexed{}.mapIndexed{}.firstOrNull{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().mapIndexed{}.mapIndexed{}.firstOrNull{}'" fun foo(list: List): Int? { for ((index, s) in list.withIndex()) { val x = s.length * index diff --git a/idea/testData/intentions/loopToCallChain/mapIndexed_twice.kt.after b/idea/testData/intentions/loopToCallChain/mapIndexed_twice.kt.after index f506e4ba2cd..8ea4f69ddb1 100644 --- a/idea/testData/intentions/loopToCallChain/mapIndexed_twice.kt.after +++ b/idea/testData/intentions/loopToCallChain/mapIndexed_twice.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'mapIndexed{}.mapIndexed{}.firstOrNull{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().mapIndexed{}.mapIndexed{}.firstOrNull{}'" fun foo(list: List): Int? { return list .mapIndexed { index, s -> s.length * index } diff --git a/idea/testData/intentions/loopToCallChain/mapIndexed_twice.kt.after2 b/idea/testData/intentions/loopToCallChain/mapIndexed_twice.kt.after2 new file mode 100644 index 00000000000..6d9194606f9 --- /dev/null +++ b/idea/testData/intentions/loopToCallChain/mapIndexed_twice.kt.after2 @@ -0,0 +1,10 @@ +// WITH_RUNTIME +// INTENTION_TEXT: "Replace with 'mapIndexed{}.mapIndexed{}.firstOrNull{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().mapIndexed{}.mapIndexed{}.firstOrNull{}'" +fun foo(list: List): Int? { + return list + .asSequence() + .mapIndexed { index, s -> s.length * index } + .mapIndexed { index, x -> x + index } + .firstOrNull { it > 0 } +} \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/mapNotNull.kt b/idea/testData/intentions/loopToCallChain/mapNotNull.kt index 652693bc8df..2b83903eaab 100644 --- a/idea/testData/intentions/loopToCallChain/mapNotNull.kt +++ b/idea/testData/intentions/loopToCallChain/mapNotNull.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'mapNotNull{}.mapTo(){}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().mapNotNull{}.mapTo(){}'" fun foo(list: List, target: MutableList) { for (s in list) { val length = s?.length diff --git a/idea/testData/intentions/loopToCallChain/mapNotNull.kt.after b/idea/testData/intentions/loopToCallChain/mapNotNull.kt.after index b9a82c98c29..831860de7ff 100644 --- a/idea/testData/intentions/loopToCallChain/mapNotNull.kt.after +++ b/idea/testData/intentions/loopToCallChain/mapNotNull.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'mapNotNull{}.mapTo(){}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().mapNotNull{}.mapTo(){}'" fun foo(list: List, target: MutableList) { list .mapNotNull { it?.length } diff --git a/idea/testData/intentions/loopToCallChain/mapNotNull.kt.after2 b/idea/testData/intentions/loopToCallChain/mapNotNull.kt.after2 new file mode 100644 index 00000000000..574a2fe7671 --- /dev/null +++ b/idea/testData/intentions/loopToCallChain/mapNotNull.kt.after2 @@ -0,0 +1,9 @@ +// WITH_RUNTIME +// INTENTION_TEXT: "Replace with 'mapNotNull{}.mapTo(){}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().mapNotNull{}.mapTo(){}'" +fun foo(list: List, target: MutableList) { + list + .asSequence() + .mapNotNull { it?.length } + .mapTo(target) { it.toString() } +} \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/mapNotNullTo.kt b/idea/testData/intentions/loopToCallChain/mapNotNullTo.kt index 817042c1f0e..80fe8fc557c 100644 --- a/idea/testData/intentions/loopToCallChain/mapNotNullTo.kt +++ b/idea/testData/intentions/loopToCallChain/mapNotNullTo.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'mapNotNullTo(){}'" +// IS_APPLICABLE_2: false fun foo(list: List, target: MutableList) { for (s in list) { val length = s?.length diff --git a/idea/testData/intentions/loopToCallChain/mapNotNullTo.kt.after b/idea/testData/intentions/loopToCallChain/mapNotNullTo.kt.after index cc1630fffef..fba2a8060a0 100644 --- a/idea/testData/intentions/loopToCallChain/mapNotNullTo.kt.after +++ b/idea/testData/intentions/loopToCallChain/mapNotNullTo.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'mapNotNullTo(){}'" +// IS_APPLICABLE_2: false fun foo(list: List, target: MutableList) { list.mapNotNullTo(target) { it?.length } } \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/mapNotNullTo_elvisContinue.kt b/idea/testData/intentions/loopToCallChain/mapNotNullTo_elvisContinue.kt index ad7d20cfdec..0dc8b6c25f9 100644 --- a/idea/testData/intentions/loopToCallChain/mapNotNullTo_elvisContinue.kt +++ b/idea/testData/intentions/loopToCallChain/mapNotNullTo_elvisContinue.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'mapNotNullTo(){}'" +// IS_APPLICABLE_2: false fun foo(list: List, target: MutableList) { for (s in list) { val length = s?.length ?: continue diff --git a/idea/testData/intentions/loopToCallChain/mapNotNullTo_elvisContinue.kt.after b/idea/testData/intentions/loopToCallChain/mapNotNullTo_elvisContinue.kt.after index cc1630fffef..fba2a8060a0 100644 --- a/idea/testData/intentions/loopToCallChain/mapNotNullTo_elvisContinue.kt.after +++ b/idea/testData/intentions/loopToCallChain/mapNotNullTo_elvisContinue.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'mapNotNullTo(){}'" +// IS_APPLICABLE_2: false fun foo(list: List, target: MutableList) { list.mapNotNullTo(target) { it?.length } } \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/mapNotNull_elvisContinue.kt b/idea/testData/intentions/loopToCallChain/mapNotNull_elvisContinue.kt index f7dcf57747d..f258c86090a 100644 --- a/idea/testData/intentions/loopToCallChain/mapNotNull_elvisContinue.kt +++ b/idea/testData/intentions/loopToCallChain/mapNotNull_elvisContinue.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'mapNotNull{}.mapTo(){}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().mapNotNull{}.mapTo(){}'" fun foo(list: List, target: MutableList) { for (s in list) { val length = s?.length ?: continue diff --git a/idea/testData/intentions/loopToCallChain/mapNotNull_elvisContinue.kt.after b/idea/testData/intentions/loopToCallChain/mapNotNull_elvisContinue.kt.after index b9a82c98c29..831860de7ff 100644 --- a/idea/testData/intentions/loopToCallChain/mapNotNull_elvisContinue.kt.after +++ b/idea/testData/intentions/loopToCallChain/mapNotNull_elvisContinue.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'mapNotNull{}.mapTo(){}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().mapNotNull{}.mapTo(){}'" fun foo(list: List, target: MutableList) { list .mapNotNull { it?.length } diff --git a/idea/testData/intentions/loopToCallChain/mapNotNull_elvisContinue.kt.after2 b/idea/testData/intentions/loopToCallChain/mapNotNull_elvisContinue.kt.after2 new file mode 100644 index 00000000000..574a2fe7671 --- /dev/null +++ b/idea/testData/intentions/loopToCallChain/mapNotNull_elvisContinue.kt.after2 @@ -0,0 +1,9 @@ +// WITH_RUNTIME +// INTENTION_TEXT: "Replace with 'mapNotNull{}.mapTo(){}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().mapNotNull{}.mapTo(){}'" +fun foo(list: List, target: MutableList) { + list + .asSequence() + .mapNotNull { it?.length } + .mapTo(target) { it.toString() } +} \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/mapNotNull_nestedLoopElvisContinue.kt b/idea/testData/intentions/loopToCallChain/mapNotNull_nestedLoopElvisContinue.kt index 174b37f87c7..7d1ae4e3e88 100644 --- a/idea/testData/intentions/loopToCallChain/mapNotNull_nestedLoopElvisContinue.kt +++ b/idea/testData/intentions/loopToCallChain/mapNotNull_nestedLoopElvisContinue.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'flatMap{}.mapNotNull{}.mapTo(){}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().flatMap{}.mapNotNull{}.mapTo(){}'" fun foo(list: List, target: MutableList) { for (s in list) { for (i in s.indices) { diff --git a/idea/testData/intentions/loopToCallChain/mapNotNull_nestedLoopElvisContinue.kt.after b/idea/testData/intentions/loopToCallChain/mapNotNull_nestedLoopElvisContinue.kt.after index bf6eaa76fc4..ef5502e2439 100644 --- a/idea/testData/intentions/loopToCallChain/mapNotNull_nestedLoopElvisContinue.kt.after +++ b/idea/testData/intentions/loopToCallChain/mapNotNull_nestedLoopElvisContinue.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'flatMap{}.mapNotNull{}.mapTo(){}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().flatMap{}.mapNotNull{}.mapTo(){}'" fun foo(list: List, target: MutableList) { list .flatMap { it.indices } diff --git a/idea/testData/intentions/loopToCallChain/mapNotNull_nestedLoopElvisContinue.kt.after2 b/idea/testData/intentions/loopToCallChain/mapNotNull_nestedLoopElvisContinue.kt.after2 new file mode 100644 index 00000000000..c2fb0f0008e --- /dev/null +++ b/idea/testData/intentions/loopToCallChain/mapNotNull_nestedLoopElvisContinue.kt.after2 @@ -0,0 +1,12 @@ +// WITH_RUNTIME +// INTENTION_TEXT: "Replace with 'flatMap{}.mapNotNull{}.mapTo(){}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().flatMap{}.mapNotNull{}.mapTo(){}'" +fun foo(list: List, target: MutableList) { + list + .asSequence() + .flatMap { it.indices.asSequence() } + .mapNotNull { bar(it) } + .mapTo(target) { it.substring(1) } +} + +fun bar(p: Int): String? = null \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/mapNotNull_wrongElvisContinue.kt b/idea/testData/intentions/loopToCallChain/mapNotNull_wrongElvisContinue.kt index 3968ce9be2e..24eca8f25c9 100644 --- a/idea/testData/intentions/loopToCallChain/mapNotNull_wrongElvisContinue.kt +++ b/idea/testData/intentions/loopToCallChain/mapNotNull_wrongElvisContinue.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // IS_APPLICABLE: false +// IS_APPLICABLE_2: false fun foo(list: List, target: MutableList) { Loop@ for (s in list) { diff --git a/idea/testData/intentions/loopToCallChain/mapTo.kt b/idea/testData/intentions/loopToCallChain/mapTo.kt index 8fe2d47fb78..f2a5869b4de 100644 --- a/idea/testData/intentions/loopToCallChain/mapTo.kt +++ b/idea/testData/intentions/loopToCallChain/mapTo.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filter{}.mapTo(){}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.mapTo(){}'" fun foo(list: List, target: MutableList) { for (s in list) { if (s.length > 0) diff --git a/idea/testData/intentions/loopToCallChain/mapTo.kt.after b/idea/testData/intentions/loopToCallChain/mapTo.kt.after index 19fdb4b8503..87c469b2ca3 100644 --- a/idea/testData/intentions/loopToCallChain/mapTo.kt.after +++ b/idea/testData/intentions/loopToCallChain/mapTo.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filter{}.mapTo(){}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.mapTo(){}'" fun foo(list: List, target: MutableList) { list .filter { it.length > 0 } diff --git a/idea/testData/intentions/loopToCallChain/mapTo.kt.after2 b/idea/testData/intentions/loopToCallChain/mapTo.kt.after2 new file mode 100644 index 00000000000..d327711d3a5 --- /dev/null +++ b/idea/testData/intentions/loopToCallChain/mapTo.kt.after2 @@ -0,0 +1,9 @@ +// WITH_RUNTIME +// INTENTION_TEXT: "Replace with 'filter{}.mapTo(){}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.mapTo(){}'" +fun foo(list: List, target: MutableList) { + list + .asSequence() + .filter { it.length > 0 } + .mapTo(target) { it.hashCode() } +} \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/mapTo2.kt b/idea/testData/intentions/loopToCallChain/mapTo2.kt index 24690627026..a352b01a4aa 100644 --- a/idea/testData/intentions/loopToCallChain/mapTo2.kt +++ b/idea/testData/intentions/loopToCallChain/mapTo2.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'mapTo(){}'" +// IS_APPLICABLE_2: false fun foo(list: List, target: MutableList) { for (s in list) { val l = s.length diff --git a/idea/testData/intentions/loopToCallChain/mapTo2.kt.after b/idea/testData/intentions/loopToCallChain/mapTo2.kt.after index 1192bd5a3f8..0d1379f84a6 100644 --- a/idea/testData/intentions/loopToCallChain/mapTo2.kt.after +++ b/idea/testData/intentions/loopToCallChain/mapTo2.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'mapTo(){}'" +// IS_APPLICABLE_2: false fun foo(list: List, target: MutableList) { list.mapTo(target) { it.length } } \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/mapTo3.kt b/idea/testData/intentions/loopToCallChain/mapTo3.kt index 82f1fd99ad3..6b452ba10f3 100644 --- a/idea/testData/intentions/loopToCallChain/mapTo3.kt +++ b/idea/testData/intentions/loopToCallChain/mapTo3.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filter{}.mapTo(){}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.mapTo(){}'" import java.util.ArrayList fun foo(list: List): List { diff --git a/idea/testData/intentions/loopToCallChain/mapTo3.kt.after b/idea/testData/intentions/loopToCallChain/mapTo3.kt.after index c1edb598710..5b7091e3ee9 100644 --- a/idea/testData/intentions/loopToCallChain/mapTo3.kt.after +++ b/idea/testData/intentions/loopToCallChain/mapTo3.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filter{}.mapTo(){}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.mapTo(){}'" import java.util.ArrayList fun foo(list: List): List { diff --git a/idea/testData/intentions/loopToCallChain/mapTo3.kt.after2 b/idea/testData/intentions/loopToCallChain/mapTo3.kt.after2 new file mode 100644 index 00000000000..41c4ff94f08 --- /dev/null +++ b/idea/testData/intentions/loopToCallChain/mapTo3.kt.after2 @@ -0,0 +1,12 @@ +// WITH_RUNTIME +// INTENTION_TEXT: "Replace with 'filter{}.mapTo(){}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.mapTo(){}'" +import java.util.ArrayList + +fun foo(list: List): List { + val target = list + .asSequence() + .filter { it.length > 0 } + .mapTo(ArrayList(100)) { it.hashCode() } + return target +} diff --git a/idea/testData/intentions/loopToCallChain/mapTo4.kt b/idea/testData/intentions/loopToCallChain/mapTo4.kt index f8dc988896c..6b7908b2b7b 100644 --- a/idea/testData/intentions/loopToCallChain/mapTo4.kt +++ b/idea/testData/intentions/loopToCallChain/mapTo4.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filter{}.mapTo(){}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.mapTo(){}'" fun foo(list: List): List { val target = createCollection() for (s in list) { diff --git a/idea/testData/intentions/loopToCallChain/mapTo4.kt.after b/idea/testData/intentions/loopToCallChain/mapTo4.kt.after index 50d13a5c8df..fb969828375 100644 --- a/idea/testData/intentions/loopToCallChain/mapTo4.kt.after +++ b/idea/testData/intentions/loopToCallChain/mapTo4.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filter{}.mapTo(){}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.mapTo(){}'" fun foo(list: List): List { val target = createCollection() list diff --git a/idea/testData/intentions/loopToCallChain/mapTo4.kt.after2 b/idea/testData/intentions/loopToCallChain/mapTo4.kt.after2 new file mode 100644 index 00000000000..b4230db74d6 --- /dev/null +++ b/idea/testData/intentions/loopToCallChain/mapTo4.kt.after2 @@ -0,0 +1,13 @@ +// WITH_RUNTIME +// INTENTION_TEXT: "Replace with 'filter{}.mapTo(){}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.mapTo(){}'" +fun foo(list: List): List { + val target = createCollection() + list + .asSequence() + .filter { it.length > 0 } + .mapTo(target) { it.hashCode() } + return target +} + +fun createCollection(): MutableList = java.util.ArrayList() \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/mapTo_inputVarNotUsed.kt b/idea/testData/intentions/loopToCallChain/mapTo_inputVarNotUsed.kt index c84b3d481a4..58ad9c221d1 100644 --- a/idea/testData/intentions/loopToCallChain/mapTo_inputVarNotUsed.kt +++ b/idea/testData/intentions/loopToCallChain/mapTo_inputVarNotUsed.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // IS_APPLICABLE: false +// IS_APPLICABLE_2: false fun foo(list: List, target: MutableList) { for (s in list) { if (s.length > 0) diff --git a/idea/testData/intentions/loopToCallChain/mapUsesOldIndexAfterFilter.kt b/idea/testData/intentions/loopToCallChain/mapUsesOldIndexAfterFilter.kt index 6f993868fd6..5ccd020ef3d 100644 --- a/idea/testData/intentions/loopToCallChain/mapUsesOldIndexAfterFilter.kt +++ b/idea/testData/intentions/loopToCallChain/mapUsesOldIndexAfterFilter.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // IS_APPLICABLE: false +// IS_APPLICABLE_2: false fun foo(list: List): Int? { for ((index, s) in list.withIndex()) { if (s.isBlank()) continue diff --git a/idea/testData/intentions/loopToCallChain/mapVar.kt b/idea/testData/intentions/loopToCallChain/mapVar.kt index 21cdabbd835..dd6565ac415 100644 --- a/idea/testData/intentions/loopToCallChain/mapVar.kt +++ b/idea/testData/intentions/loopToCallChain/mapVar.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'map{}.firstOrNull{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().map{}.firstOrNull{}'" fun foo(list: List): Int? { for (s in list) { var length = s.length diff --git a/idea/testData/intentions/loopToCallChain/mapVar.kt.after b/idea/testData/intentions/loopToCallChain/mapVar.kt.after index 66e475bfdfe..850c6d9f602 100644 --- a/idea/testData/intentions/loopToCallChain/mapVar.kt.after +++ b/idea/testData/intentions/loopToCallChain/mapVar.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'map{}.firstOrNull{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().map{}.firstOrNull{}'" fun foo(list: List): Int? { return list .map { it.length } diff --git a/idea/testData/intentions/loopToCallChain/mapVar.kt.after2 b/idea/testData/intentions/loopToCallChain/mapVar.kt.after2 new file mode 100644 index 00000000000..67600762ba4 --- /dev/null +++ b/idea/testData/intentions/loopToCallChain/mapVar.kt.after2 @@ -0,0 +1,9 @@ +// WITH_RUNTIME +// INTENTION_TEXT: "Replace with 'map{}.firstOrNull{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().map{}.firstOrNull{}'" +fun foo(list: List): Int? { + return list + .asSequence() + .map { it.length } + .firstOrNull { it > 0 } +} \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/map_var.kt b/idea/testData/intentions/loopToCallChain/map_var.kt index f3b31c57f11..28fa5cff415 100644 --- a/idea/testData/intentions/loopToCallChain/map_var.kt +++ b/idea/testData/intentions/loopToCallChain/map_var.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // IS_APPLICABLE: false +// IS_APPLICABLE_2: false fun foo(list: List): Int? { for (s in list) { var length = s.length diff --git a/idea/testData/intentions/loopToCallChain/map_variableStillNeeded.kt b/idea/testData/intentions/loopToCallChain/map_variableStillNeeded.kt index 45118e9ca89..1fc7931be02 100644 --- a/idea/testData/intentions/loopToCallChain/map_variableStillNeeded.kt +++ b/idea/testData/intentions/loopToCallChain/map_variableStillNeeded.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // IS_APPLICABLE: false +// IS_APPLICABLE_2: false fun foo(list: List): String? { for (s in list) { val length = s.length diff --git a/idea/testData/intentions/loopToCallChain/moveInitializationsCloserToLoop.kt b/idea/testData/intentions/loopToCallChain/moveInitializationsCloserToLoop.kt index edb0b23bd41..e7a78222dd3 100644 --- a/idea/testData/intentions/loopToCallChain/moveInitializationsCloserToLoop.kt +++ b/idea/testData/intentions/loopToCallChain/moveInitializationsCloserToLoop.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'map{}'" +// IS_APPLICABLE_2: false import java.util.* fun foo(list: List) { diff --git a/idea/testData/intentions/loopToCallChain/moveInitializationsCloserToLoop.kt.after b/idea/testData/intentions/loopToCallChain/moveInitializationsCloserToLoop.kt.after index 671ed988343..bd7fe977f8a 100644 --- a/idea/testData/intentions/loopToCallChain/moveInitializationsCloserToLoop.kt.after +++ b/idea/testData/intentions/loopToCallChain/moveInitializationsCloserToLoop.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'map{}'" +// IS_APPLICABLE_2: false import java.util.* fun foo(list: List) { diff --git a/idea/testData/intentions/loopToCallChain/none_ifReturn.kt b/idea/testData/intentions/loopToCallChain/none_ifReturn.kt index f41bee0f240..cb2bb57fc54 100644 --- a/idea/testData/intentions/loopToCallChain/none_ifReturn.kt +++ b/idea/testData/intentions/loopToCallChain/none_ifReturn.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'none{}'" +// IS_APPLICABLE_2: false fun foo(list: List): Boolean { for (s in list) { if (s.length > 0) { diff --git a/idea/testData/intentions/loopToCallChain/none_ifReturn.kt.after b/idea/testData/intentions/loopToCallChain/none_ifReturn.kt.after index 06100d88495..a4076af88f2 100644 --- a/idea/testData/intentions/loopToCallChain/none_ifReturn.kt.after +++ b/idea/testData/intentions/loopToCallChain/none_ifReturn.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'none{}'" +// IS_APPLICABLE_2: false fun foo(list: List): Boolean { return list.none { it.length > 0 } } \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/prefixIndexPlusPlusInsideExpression.kt b/idea/testData/intentions/loopToCallChain/prefixIndexPlusPlusInsideExpression.kt index 012a540de95..bb0b03975e2 100644 --- a/idea/testData/intentions/loopToCallChain/prefixIndexPlusPlusInsideExpression.kt +++ b/idea/testData/intentions/loopToCallChain/prefixIndexPlusPlusInsideExpression.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filterNot{}.mapIndexed{}.firstOrNull{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filterNot{}.mapIndexed{}.firstOrNull{}'" fun foo(list: List): Int? { var index = 0 for (s in list) { diff --git a/idea/testData/intentions/loopToCallChain/prefixIndexPlusPlusInsideExpression.kt.after b/idea/testData/intentions/loopToCallChain/prefixIndexPlusPlusInsideExpression.kt.after index b56d24f81f8..cf8b3c0e2ee 100644 --- a/idea/testData/intentions/loopToCallChain/prefixIndexPlusPlusInsideExpression.kt.after +++ b/idea/testData/intentions/loopToCallChain/prefixIndexPlusPlusInsideExpression.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filterNot{}.mapIndexed{}.firstOrNull{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filterNot{}.mapIndexed{}.firstOrNull{}'" fun foo(list: List): Int? { return list .filterNot { it.isBlank() } diff --git a/idea/testData/intentions/loopToCallChain/prefixIndexPlusPlusInsideExpression.kt.after2 b/idea/testData/intentions/loopToCallChain/prefixIndexPlusPlusInsideExpression.kt.after2 new file mode 100644 index 00000000000..851616d0c11 --- /dev/null +++ b/idea/testData/intentions/loopToCallChain/prefixIndexPlusPlusInsideExpression.kt.after2 @@ -0,0 +1,10 @@ +// WITH_RUNTIME +// INTENTION_TEXT: "Replace with 'filterNot{}.mapIndexed{}.firstOrNull{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filterNot{}.mapIndexed{}.firstOrNull{}'" +fun foo(list: List): Int? { + return list + .asSequence() + .filterNot { it.isBlank() } + .mapIndexed { index, s -> s.length * (index + 1) } + .firstOrNull { it > 0 } +} \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/range.kt b/idea/testData/intentions/loopToCallChain/range.kt index d4765d06d81..9da786ec5ab 100644 --- a/idea/testData/intentions/loopToCallChain/range.kt +++ b/idea/testData/intentions/loopToCallChain/range.kt @@ -1,4 +1,6 @@ // WITH_RUNTIME +// INTENTION_TEXT: "Replace with 'filter{}'" +// IS_APPLICABLE_2: false import java.util.* fun foo(): List { diff --git a/idea/testData/intentions/loopToCallChain/range.kt.after b/idea/testData/intentions/loopToCallChain/range.kt.after index 34fcb781587..2feb9f0c27a 100644 --- a/idea/testData/intentions/loopToCallChain/range.kt.after +++ b/idea/testData/intentions/loopToCallChain/range.kt.after @@ -1,4 +1,6 @@ // WITH_RUNTIME +// INTENTION_TEXT: "Replace with 'filter{}'" +// IS_APPLICABLE_2: false import java.util.* fun foo(): List { diff --git a/idea/testData/intentions/loopToCallChain/resultCollectionUsedInsideLoop.kt b/idea/testData/intentions/loopToCallChain/resultCollectionUsedInsideLoop.kt index 2545bbb4723..3275ab43a80 100644 --- a/idea/testData/intentions/loopToCallChain/resultCollectionUsedInsideLoop.kt +++ b/idea/testData/intentions/loopToCallChain/resultCollectionUsedInsideLoop.kt @@ -1,4 +1,6 @@ // WITH_RUNTIME +// INTENTION_TEXT: "Replace with 'filter{}.forEach{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.forEach{}'" import java.util.ArrayList fun foo(list: List): List { diff --git a/idea/testData/intentions/loopToCallChain/resultCollectionUsedInsideLoop.kt.after b/idea/testData/intentions/loopToCallChain/resultCollectionUsedInsideLoop.kt.after index 8b23f09062c..69eefe2d673 100644 --- a/idea/testData/intentions/loopToCallChain/resultCollectionUsedInsideLoop.kt.after +++ b/idea/testData/intentions/loopToCallChain/resultCollectionUsedInsideLoop.kt.after @@ -1,4 +1,6 @@ // WITH_RUNTIME +// INTENTION_TEXT: "Replace with 'filter{}.forEach{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.forEach{}'" import java.util.ArrayList fun foo(list: List): List { diff --git a/idea/testData/intentions/loopToCallChain/resultCollectionUsedInsideLoop.kt.after2 b/idea/testData/intentions/loopToCallChain/resultCollectionUsedInsideLoop.kt.after2 new file mode 100644 index 00000000000..9e849ec29ba --- /dev/null +++ b/idea/testData/intentions/loopToCallChain/resultCollectionUsedInsideLoop.kt.after2 @@ -0,0 +1,13 @@ +// WITH_RUNTIME +// INTENTION_TEXT: "Replace with 'filter{}.forEach{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.forEach{}'" +import java.util.ArrayList + +fun foo(list: List): List { + val result = ArrayList() + list + .asSequence() + .filter { it.length > result.size } + .forEach { result.add(it.hashCode()) } + return result +} \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/smartCastNotBroken.kt b/idea/testData/intentions/loopToCallChain/smartCastNotBroken.kt index a794cfd1575..291dcc00c5c 100644 --- a/idea/testData/intentions/loopToCallChain/smartCastNotBroken.kt +++ b/idea/testData/intentions/loopToCallChain/smartCastNotBroken.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with '...filter{}.map{}.firstOrNull()'" +// INTENTION_TEXT_2: "Replace with 'asSequence()...filter{}.map{}.firstOrNull()'" fun foo(list: List, o: Any): Int? { if (o is Int) { for (s in list) { diff --git a/idea/testData/intentions/loopToCallChain/smartCastNotBroken.kt.after b/idea/testData/intentions/loopToCallChain/smartCastNotBroken.kt.after index 11391fe2604..06cdd4d5112 100644 --- a/idea/testData/intentions/loopToCallChain/smartCastNotBroken.kt.after +++ b/idea/testData/intentions/loopToCallChain/smartCastNotBroken.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with '...filter{}.map{}.firstOrNull()'" +// INTENTION_TEXT_2: "Replace with 'asSequence()...filter{}.map{}.firstOrNull()'" fun foo(list: List, o: Any): Int? { if (o is Int) { return list diff --git a/idea/testData/intentions/loopToCallChain/smartCastNotBroken.kt.after2 b/idea/testData/intentions/loopToCallChain/smartCastNotBroken.kt.after2 new file mode 100644 index 00000000000..d9d557107ba --- /dev/null +++ b/idea/testData/intentions/loopToCallChain/smartCastNotBroken.kt.after2 @@ -0,0 +1,14 @@ +// WITH_RUNTIME +// INTENTION_TEXT: "Replace with '...filter{}.map{}.firstOrNull()'" +// INTENTION_TEXT_2: "Replace with 'asSequence()...filter{}.map{}.firstOrNull()'" +fun foo(list: List, o: Any): Int? { + if (o is Int) { + return list + .asSequence() + .map { it.length + o } + .filter { it > 0 } + .map { it * o.hashCode() } + .firstOrNull() + } + return 0 +} \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/smartCastNotBroken2.kt.after b/idea/testData/intentions/loopToCallChain/smartCastNotBroken2.kt.after index 717bce458dc..9a4784652d4 100644 --- a/idea/testData/intentions/loopToCallChain/smartCastNotBroken2.kt.after +++ b/idea/testData/intentions/loopToCallChain/smartCastNotBroken2.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'map{}.map{}.firstOrNull{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().map{}.map{}.firstOrNull{}'" fun foo(list: List, o: Any): Int? { if (o is CharSequence) { return list diff --git a/idea/testData/intentions/loopToCallChain/smartCastNotBroken2.kt.todo b/idea/testData/intentions/loopToCallChain/smartCastNotBroken2.kt.todo index 31ddc1fd671..e046a3b6035 100644 --- a/idea/testData/intentions/loopToCallChain/smartCastNotBroken2.kt.todo +++ b/idea/testData/intentions/loopToCallChain/smartCastNotBroken2.kt.todo @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'map{}.map{}.firstOrNull{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().map{}.map{}.firstOrNull{}'" fun foo(list: List, o: Any): Int? { if (o is CharSequence) { for (s in list) { diff --git a/idea/testData/intentions/loopToCallChain/smartCastNotNullRequired.kt b/idea/testData/intentions/loopToCallChain/smartCastNotNullRequired.kt index 9de5f591d3d..2ca0c8ff12b 100644 --- a/idea/testData/intentions/loopToCallChain/smartCastNotNullRequired.kt +++ b/idea/testData/intentions/loopToCallChain/smartCastNotNullRequired.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // IS_APPLICABLE: false +// IS_APPLICABLE_2: false fun foo(list: List, o: Int?): Int? { for (s in list) { val length = s.length + o!! diff --git a/idea/testData/intentions/loopToCallChain/smartCastNotRequired.kt b/idea/testData/intentions/loopToCallChain/smartCastNotRequired.kt index 6d16b22cb96..a90559a535d 100644 --- a/idea/testData/intentions/loopToCallChain/smartCastNotRequired.kt +++ b/idea/testData/intentions/loopToCallChain/smartCastNotRequired.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with '...filter{}.map{}.firstOrNull()'" +// INTENTION_TEXT_2: "Replace with 'asSequence()...filter{}.map{}.firstOrNull()'" fun foo(list: List, o: Any): Int? { for (s in list) { val length = s.length + (o as Int) diff --git a/idea/testData/intentions/loopToCallChain/smartCastNotRequired.kt.after b/idea/testData/intentions/loopToCallChain/smartCastNotRequired.kt.after index b60878628e2..9a5f2a9d3fe 100644 --- a/idea/testData/intentions/loopToCallChain/smartCastNotRequired.kt.after +++ b/idea/testData/intentions/loopToCallChain/smartCastNotRequired.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with '...filter{}.map{}.firstOrNull()'" +// INTENTION_TEXT_2: "Replace with 'asSequence()...filter{}.map{}.firstOrNull()'" fun foo(list: List, o: Any): Int? { return list .map { it.length + (o as Int) } diff --git a/idea/testData/intentions/loopToCallChain/smartCastNotRequired.kt.after2 b/idea/testData/intentions/loopToCallChain/smartCastNotRequired.kt.after2 new file mode 100644 index 00000000000..9785114da04 --- /dev/null +++ b/idea/testData/intentions/loopToCallChain/smartCastNotRequired.kt.after2 @@ -0,0 +1,11 @@ +// WITH_RUNTIME +// INTENTION_TEXT: "Replace with '...filter{}.map{}.firstOrNull()'" +// INTENTION_TEXT_2: "Replace with 'asSequence()...filter{}.map{}.firstOrNull()'" +fun foo(list: List, o: Any): Int? { + return list + .asSequence() + .map { it.length + (o as Int) } + .filter { it > 0 } + .map { it * o.hashCode() } + .firstOrNull() +} \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/smartCastRequired.kt b/idea/testData/intentions/loopToCallChain/smartCastRequired.kt index 9e62ef09670..a8d5de80c9a 100644 --- a/idea/testData/intentions/loopToCallChain/smartCastRequired.kt +++ b/idea/testData/intentions/loopToCallChain/smartCastRequired.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // IS_APPLICABLE: false +// IS_APPLICABLE_2: false fun foo(list: List, o: Any): Int? { for (s in list) { val length = s.length + (o as Int) diff --git a/idea/testData/intentions/loopToCallChain/smartCastRequired2.kt b/idea/testData/intentions/loopToCallChain/smartCastRequired2.kt index 7879fe2c9f1..6ffa86e9218 100644 --- a/idea/testData/intentions/loopToCallChain/smartCastRequired2.kt +++ b/idea/testData/intentions/loopToCallChain/smartCastRequired2.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // IS_APPLICABLE: false +// IS_APPLICABLE_2: false fun foo(list: List, o: Any): Int? { for (s in list) { if (s is String && s.length > 0) { diff --git a/idea/testData/intentions/loopToCallChain/smartCastRequired3.kt b/idea/testData/intentions/loopToCallChain/smartCastRequired3.kt index 09f013dd05a..bb78c253522 100644 --- a/idea/testData/intentions/loopToCallChain/smartCastRequired3.kt +++ b/idea/testData/intentions/loopToCallChain/smartCastRequired3.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // IS_APPLICABLE: false +// IS_APPLICABLE_2: false fun foo(list: List): String? { for (o in list) { if (bar(o as String)) { diff --git a/idea/testData/intentions/loopToCallChain/smartCastRequired4.kt b/idea/testData/intentions/loopToCallChain/smartCastRequired4.kt index 673110b53c6..bb648eefc9c 100644 --- a/idea/testData/intentions/loopToCallChain/smartCastRequired4.kt +++ b/idea/testData/intentions/loopToCallChain/smartCastRequired4.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // IS_APPLICABLE: false +// IS_APPLICABLE_2: false fun foo(list: List): String? { var v: String? = null for (o in list) { diff --git a/idea/testData/intentions/loopToCallChain/smartCastRequired5.kt b/idea/testData/intentions/loopToCallChain/smartCastRequired5.kt index b4c4c895484..e09d2d589e3 100644 --- a/idea/testData/intentions/loopToCallChain/smartCastRequired5.kt +++ b/idea/testData/intentions/loopToCallChain/smartCastRequired5.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // IS_APPLICABLE: false +// IS_APPLICABLE_2: false fun foo(list: List, target: MutableCollection) { for (o in list) { if (bar(o as String)) { diff --git a/idea/testData/intentions/loopToCallChain/smartCastThisRequired.kt b/idea/testData/intentions/loopToCallChain/smartCastThisRequired.kt index 03755d6169a..205dd23813d 100644 --- a/idea/testData/intentions/loopToCallChain/smartCastThisRequired.kt +++ b/idea/testData/intentions/loopToCallChain/smartCastThisRequired.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // IS_APPLICABLE: false +// IS_APPLICABLE_2: false fun Any.foo(list: List): Int? { for (s in list) { if (s.length > 0 && this is String) { diff --git a/idea/testData/intentions/loopToCallChain/takeWhile.kt b/idea/testData/intentions/loopToCallChain/takeWhile.kt index 91d7368f45b..0ccb95891ab 100644 --- a/idea/testData/intentions/loopToCallChain/takeWhile.kt +++ b/idea/testData/intentions/loopToCallChain/takeWhile.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with '+= takeWhile{}'" +// INTENTION_TEXT_2: "Replace with '+= asSequence().takeWhile{}'" fun foo(list: List, target: MutableCollection) { for (s in list) { if (s.isEmpty()) break diff --git a/idea/testData/intentions/loopToCallChain/takeWhile.kt.after b/idea/testData/intentions/loopToCallChain/takeWhile.kt.after index f2d1c963b8a..cdefe2ba358 100644 --- a/idea/testData/intentions/loopToCallChain/takeWhile.kt.after +++ b/idea/testData/intentions/loopToCallChain/takeWhile.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with '+= takeWhile{}'" +// INTENTION_TEXT_2: "Replace with '+= asSequence().takeWhile{}'" fun foo(list: List, target: MutableCollection) { target += list.takeWhile { !it.isEmpty() } } \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/takeWhile.kt.after2 b/idea/testData/intentions/loopToCallChain/takeWhile.kt.after2 new file mode 100644 index 00000000000..0f70a2a9ce6 --- /dev/null +++ b/idea/testData/intentions/loopToCallChain/takeWhile.kt.after2 @@ -0,0 +1,8 @@ +// WITH_RUNTIME +// INTENTION_TEXT: "Replace with '+= takeWhile{}'" +// INTENTION_TEXT_2: "Replace with '+= asSequence().takeWhile{}'" +fun foo(list: List, target: MutableCollection) { + target += list + .asSequence() + .takeWhile { !it.isEmpty() } +} \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/takeWhile_nestedLoop.kt b/idea/testData/intentions/loopToCallChain/takeWhile_nestedLoop.kt index a7922bcb5cb..b8d212016c5 100644 --- a/idea/testData/intentions/loopToCallChain/takeWhile_nestedLoop.kt +++ b/idea/testData/intentions/loopToCallChain/takeWhile_nestedLoop.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with '+= flatMap{}.takeWhile{}'" +// INTENTION_TEXT_2: "Replace with '+= asSequence().flatMap{}.takeWhile{}'" fun foo(list: List, target: MutableCollection) { Outer@ for (s in list) { diff --git a/idea/testData/intentions/loopToCallChain/takeWhile_nestedLoop.kt.after b/idea/testData/intentions/loopToCallChain/takeWhile_nestedLoop.kt.after index 5121e06e5ff..46de422a7e6 100644 --- a/idea/testData/intentions/loopToCallChain/takeWhile_nestedLoop.kt.after +++ b/idea/testData/intentions/loopToCallChain/takeWhile_nestedLoop.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with '+= flatMap{}.takeWhile{}'" +// INTENTION_TEXT_2: "Replace with '+= asSequence().flatMap{}.takeWhile{}'" fun foo(list: List, target: MutableCollection) { target += list .flatMap { it.indices } diff --git a/idea/testData/intentions/loopToCallChain/takeWhile_nestedLoop.kt.after2 b/idea/testData/intentions/loopToCallChain/takeWhile_nestedLoop.kt.after2 new file mode 100644 index 00000000000..7444e01897b --- /dev/null +++ b/idea/testData/intentions/loopToCallChain/takeWhile_nestedLoop.kt.after2 @@ -0,0 +1,9 @@ +// WITH_RUNTIME +// INTENTION_TEXT: "Replace with '+= flatMap{}.takeWhile{}'" +// INTENTION_TEXT_2: "Replace with '+= asSequence().flatMap{}.takeWhile{}'" +fun foo(list: List, target: MutableCollection) { + target += list + .asSequence() + .flatMap { it.indices.asSequence() } + .takeWhile { it <= 1000 } +} \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/takeWhile_wrongBreak.kt b/idea/testData/intentions/loopToCallChain/takeWhile_wrongBreak.kt index 4f45bbe5f96..1de8339c66d 100644 --- a/idea/testData/intentions/loopToCallChain/takeWhile_wrongBreak.kt +++ b/idea/testData/intentions/loopToCallChain/takeWhile_wrongBreak.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // IS_APPLICABLE: false +// IS_APPLICABLE_2: false fun foo(list: List, target: MutableCollection) { for (s in list) { for (i in s.indices) { diff --git a/idea/testData/intentions/loopToCallChain/toList.kt b/idea/testData/intentions/loopToCallChain/toList.kt index 737eb48f9c7..47c997a3fcc 100644 --- a/idea/testData/intentions/loopToCallChain/toList.kt +++ b/idea/testData/intentions/loopToCallChain/toList.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'toList()'" +// IS_APPLICABLE_2: false import java.util.ArrayList fun foo(map: Map): List { diff --git a/idea/testData/intentions/loopToCallChain/toList.kt.after b/idea/testData/intentions/loopToCallChain/toList.kt.after index 1bcee259ffd..968bd958141 100644 --- a/idea/testData/intentions/loopToCallChain/toList.kt.after +++ b/idea/testData/intentions/loopToCallChain/toList.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'toList()'" +// IS_APPLICABLE_2: false import java.util.ArrayList fun foo(map: Map): List { diff --git a/idea/testData/intentions/loopToCallChain/toMutableSet.kt b/idea/testData/intentions/loopToCallChain/toMutableSet.kt index 45ed829385e..07090ae19b5 100644 --- a/idea/testData/intentions/loopToCallChain/toMutableSet.kt +++ b/idea/testData/intentions/loopToCallChain/toMutableSet.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'toMutableSet()'" +// IS_APPLICABLE_2: false import java.util.HashSet fun foo(map: Map): MutableCollection { diff --git a/idea/testData/intentions/loopToCallChain/toMutableSet.kt.after b/idea/testData/intentions/loopToCallChain/toMutableSet.kt.after index 06dccfbcb6a..f89dfb12670 100644 --- a/idea/testData/intentions/loopToCallChain/toMutableSet.kt.after +++ b/idea/testData/intentions/loopToCallChain/toMutableSet.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'toMutableSet()'" +// IS_APPLICABLE_2: false import java.util.HashSet fun foo(map: Map): MutableCollection { diff --git a/idea/testData/intentions/loopToCallChain/toSet.kt b/idea/testData/intentions/loopToCallChain/toSet.kt index b91a2fede16..01c1cc6f333 100644 --- a/idea/testData/intentions/loopToCallChain/toSet.kt +++ b/idea/testData/intentions/loopToCallChain/toSet.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'toSet()'" +// IS_APPLICABLE_2: false import java.util.HashSet fun foo(map: Map): Collection { diff --git a/idea/testData/intentions/loopToCallChain/toSet.kt.after b/idea/testData/intentions/loopToCallChain/toSet.kt.after index be8d562e51f..b70b77a0596 100644 --- a/idea/testData/intentions/loopToCallChain/toSet.kt.after +++ b/idea/testData/intentions/loopToCallChain/toSet.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'toSet()'" +// IS_APPLICABLE_2: false import java.util.HashSet fun foo(map: Map): Collection { diff --git a/idea/testData/intentions/loopToCallChain/toSetWithMap.kt b/idea/testData/intentions/loopToCallChain/toSetWithMap.kt index 7aacd903d39..22ce78d7c56 100644 --- a/idea/testData/intentions/loopToCallChain/toSetWithMap.kt +++ b/idea/testData/intentions/loopToCallChain/toSetWithMap.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'map{}.toSet()'" +// INTENTION_TEXT_2: "Replace with 'asSequence().map{}.toSet()'" import java.util.HashSet fun foo(map: Map): Collection { diff --git a/idea/testData/intentions/loopToCallChain/toSetWithMap.kt.after b/idea/testData/intentions/loopToCallChain/toSetWithMap.kt.after index c9e57dd3332..763755501b9 100644 --- a/idea/testData/intentions/loopToCallChain/toSetWithMap.kt.after +++ b/idea/testData/intentions/loopToCallChain/toSetWithMap.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'map{}.toSet()'" +// INTENTION_TEXT_2: "Replace with 'asSequence().map{}.toSet()'" import java.util.HashSet fun foo(map: Map): Collection { diff --git a/idea/testData/intentions/loopToCallChain/toSetWithMap.kt.after2 b/idea/testData/intentions/loopToCallChain/toSetWithMap.kt.after2 new file mode 100644 index 00000000000..2e687e91477 --- /dev/null +++ b/idea/testData/intentions/loopToCallChain/toSetWithMap.kt.after2 @@ -0,0 +1,12 @@ +// WITH_RUNTIME +// INTENTION_TEXT: "Replace with 'map{}.toSet()'" +// INTENTION_TEXT_2: "Replace with 'asSequence().map{}.toSet()'" +import java.util.HashSet + +fun foo(map: Map): Collection { + val result = map.values + .asSequence() + .map { it.length } + .toSet() + return result +} \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/twoInitializationsBeforeLoop.kt b/idea/testData/intentions/loopToCallChain/twoInitializationsBeforeLoop.kt index 90f9f04d067..b8c407c5425 100644 --- a/idea/testData/intentions/loopToCallChain/twoInitializationsBeforeLoop.kt +++ b/idea/testData/intentions/loopToCallChain/twoInitializationsBeforeLoop.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filterIndexed{}.map{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.map{}.toList()'" import java.util.* fun foo(list: List): List { diff --git a/idea/testData/intentions/loopToCallChain/twoInitializationsBeforeLoop.kt.after b/idea/testData/intentions/loopToCallChain/twoInitializationsBeforeLoop.kt.after index b3484cae220..241e4620abd 100644 --- a/idea/testData/intentions/loopToCallChain/twoInitializationsBeforeLoop.kt.after +++ b/idea/testData/intentions/loopToCallChain/twoInitializationsBeforeLoop.kt.after @@ -1,5 +1,6 @@ // WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filterIndexed{}.map{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.map{}.toList()'" import java.util.* fun foo(list: List): List { diff --git a/idea/testData/intentions/loopToCallChain/twoInitializationsBeforeLoop.kt.after2 b/idea/testData/intentions/loopToCallChain/twoInitializationsBeforeLoop.kt.after2 new file mode 100644 index 00000000000..d3852e8753c --- /dev/null +++ b/idea/testData/intentions/loopToCallChain/twoInitializationsBeforeLoop.kt.after2 @@ -0,0 +1,13 @@ +// WITH_RUNTIME +// INTENTION_TEXT: "Replace with 'filterIndexed{}.map{}'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.map{}.toList()'" +import java.util.* + +fun foo(list: List): List { + val result = list + .asSequence() + .filterIndexed { i, s -> s.length > i } + .map { it.length } + .toList() + return result +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/intentions/AbstractIntentionTest.java b/idea/tests/org/jetbrains/kotlin/idea/intentions/AbstractIntentionTest.java index e32ea57d036..88d89ae0ab9 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/intentions/AbstractIntentionTest.java +++ b/idea/tests/org/jetbrains/kotlin/idea/intentions/AbstractIntentionTest.java @@ -50,12 +50,32 @@ import java.util.List; import java.util.Map; public abstract class AbstractIntentionTest extends KotlinCodeInsightTestCase { - private static IntentionAction createIntention(File testDataFile) throws Exception { + @NotNull + protected String intentionFileName() { + return ".intention"; + } + + @NotNull + protected String afterFileNameSuffix() { + return ".after"; + } + + @NotNull + protected String isApplicableDirectiveName() { + return "IS_APPLICABLE"; + } + + @NotNull + protected String intentionTextDirectiveName() { + return "INTENTION_TEXT"; + } + + private IntentionAction createIntention(File testDataFile) throws Exception { List candidateFiles = Lists.newArrayList(); File current = testDataFile.getParentFile(); while (current != null) { - File candidate = new File(current, ".intention"); + File candidate = new File(current, intentionFileName()); if (candidate.exists()) { candidateFiles.add(candidate); } @@ -143,7 +163,7 @@ public abstract class AbstractIntentionTest extends KotlinCodeInsightTestCase { } private void doTestFor(String mainFilePath, Map pathToFiles, final IntentionAction intentionAction, String fileText) throws Exception { - String isApplicableString = InTextDirectivesUtils.findStringWithPrefixes(fileText, "// IS_APPLICABLE: "); + String isApplicableString = InTextDirectivesUtils.findStringWithPrefixes(fileText, "// " + isApplicableDirectiveName() + ": "); boolean isApplicableExpected = isApplicableString == null || isApplicableString.equals("true"); boolean isApplicableOnPooled = ApplicationManager.getApplication().executeOnPooledThread(new java.util.concurrent.Callable() { @@ -166,7 +186,7 @@ public abstract class AbstractIntentionTest extends KotlinCodeInsightTestCase { "isAvailable() for " + intentionAction.getClass() + " should return " + isApplicableExpected, isApplicableExpected == isApplicableOnEdt); - String intentionTextString = InTextDirectivesUtils.findStringWithPrefixes(fileText, "// INTENTION_TEXT: "); + String intentionTextString = InTextDirectivesUtils.findStringWithPrefixes(fileText, "// " + intentionTextDirectiveName() + ": "); if (intentionTextString != null) { assertEquals("Intention text mismatch.", intentionTextString, intentionAction.getText()); @@ -192,7 +212,7 @@ public abstract class AbstractIntentionTest extends KotlinCodeInsightTestCase { if (shouldFailString.isEmpty()) { for (Map.Entry entry: pathToFiles.entrySet()) { String filePath = entry.getKey(); - String canonicalPathToExpectedFile = PathUtil.getCanonicalPath(filePath + ".after"); + String canonicalPathToExpectedFile = PathUtil.getCanonicalPath(filePath + afterFileNameSuffix()); if (filePath.equals(mainFilePath)) { try { checkResultByFile(canonicalPathToExpectedFile); @@ -230,3 +250,4 @@ public abstract class AbstractIntentionTest extends KotlinCodeInsightTestCase { return ""; } } + diff --git a/idea/tests/org/jetbrains/kotlin/idea/intentions/AbstractIntentionTest2.kt b/idea/tests/org/jetbrains/kotlin/idea/intentions/AbstractIntentionTest2.kt new file mode 100644 index 00000000000..232a2fcc96e --- /dev/null +++ b/idea/tests/org/jetbrains/kotlin/idea/intentions/AbstractIntentionTest2.kt @@ -0,0 +1,24 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.idea.intentions + +abstract class AbstractIntentionTest2 : AbstractIntentionTest() { + override fun intentionFileName() = ".intention2" + override fun afterFileNameSuffix() = ".after2" + override fun intentionTextDirectiveName() = "INTENTION_TEXT_2" + override fun isApplicableDirectiveName() = "IS_APPLICABLE_2" +} diff --git a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTest2Generated.java b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTest2Generated.java new file mode 100644 index 00000000000..9efb7d685c7 --- /dev/null +++ b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTest2Generated.java @@ -0,0 +1,1069 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.idea.intentions; + +import com.intellij.testFramework.TestDataPath; +import org.jetbrains.kotlin.test.JUnit3RunnerWithInners; +import org.jetbrains.kotlin.test.KotlinTestUtils; +import org.jetbrains.kotlin.test.TestMetadata; +import org.junit.runner.RunWith; + +import java.io.File; +import java.util.regex.Pattern; + +/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */ +@SuppressWarnings("all") +@TestMetadata("idea/testData/intentions/loopToCallChain") +@TestDataPath("$PROJECT_ROOT") +@RunWith(JUnit3RunnerWithInners.class) +public class IntentionTest2Generated extends AbstractIntentionTest2 { + @TestMetadata("addToCollection.kt") + public void testAddToCollection() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/addToCollection.kt"); + doTest(fileName); + } + + @TestMetadata("addToCollection_addAfterLoop.kt") + public void testAddToCollection_addAfterLoop() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/addToCollection_addAfterLoop.kt"); + doTest(fileName); + } + + @TestMetadata("addToCollection_badReceiver1.kt") + public void testAddToCollection_badReceiver1() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/addToCollection_badReceiver1.kt"); + doTest(fileName); + } + + @TestMetadata("addToCollection_badReceiver2.kt") + public void testAddToCollection_badReceiver2() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/addToCollection_badReceiver2.kt"); + doTest(fileName); + } + + @TestMetadata("addToCollection_goodReceiver.kt") + public void testAddToCollection_goodReceiver() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/addToCollection_goodReceiver.kt"); + doTest(fileName); + } + + public void testAllFilesPresentInLoopToCallChain() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/intentions/loopToCallChain"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), true); + } + + @TestMetadata("any_ifAssign.kt") + public void testAny_ifAssign() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/any_ifAssign.kt"); + doTest(fileName); + } + + @TestMetadata("any_ifAssign_moveDeclaration.kt") + public void testAny_ifAssign_moveDeclaration() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/any_ifAssign_moveDeclaration.kt"); + doTest(fileName); + } + + @TestMetadata("any_ifAssign_moveInitialization.kt") + public void testAny_ifAssign_moveInitialization() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/any_ifAssign_moveInitialization.kt"); + doTest(fileName); + } + + @TestMetadata("any_ifAssign_noBreak.kt") + public void testAny_ifAssign_noBreak() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/any_ifAssign_noBreak.kt"); + doTest(fileName); + } + + @TestMetadata("any_ifAssign_nonBooleanResult.kt") + public void testAny_ifAssign_nonBooleanResult() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/any_ifAssign_nonBooleanResult.kt"); + doTest(fileName); + } + + @TestMetadata("any_ifAssign_nonBooleanResult2.kt") + public void testAny_ifAssign_nonBooleanResult2() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/any_ifAssign_nonBooleanResult2.kt"); + doTest(fileName); + } + + @TestMetadata("any_ifReturn.kt") + public void testAny_ifReturn() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/any_ifReturn.kt"); + doTest(fileName); + } + + @TestMetadata("any_ifReturn_nonBooleanResult.kt") + public void testAny_ifReturn_nonBooleanResult() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/any_ifReturn_nonBooleanResult.kt"); + doTest(fileName); + } + + @TestMetadata("any_indexNeeded.kt") + public void testAny_indexNeeded() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/any_indexNeeded.kt"); + doTest(fileName); + } + + @TestMetadata("any_return.kt") + public void testAny_return() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/any_return.kt"); + doTest(fileName); + } + + @TestMetadata("array.kt") + public void testArray() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/array.kt"); + doTest(fileName); + } + + @TestMetadata("assignFilter.kt") + public void testAssignFilter() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/assignFilter.kt"); + doTest(fileName); + } + + @TestMetadata("assignFilter2.kt") + public void testAssignFilter2() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/assignFilter2.kt"); + doTest(fileName); + } + + @TestMetadata("assignFilterIndexed.kt") + public void testAssignFilterIndexed() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/assignFilterIndexed.kt"); + doTest(fileName); + } + + @TestMetadata("assignFilterNotNull.kt") + public void testAssignFilterNotNull() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/assignFilterNotNull.kt"); + doTest(fileName); + } + + @TestMetadata("assignFilter_ArrayListRequired.kt") + public void testAssignFilter_ArrayListRequired() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/assignFilter_ArrayListRequired.kt"); + doTest(fileName); + } + + @TestMetadata("assignFilter_ArrayListRequired2.kt") + public void testAssignFilter_ArrayListRequired2() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/assignFilter_ArrayListRequired2.kt"); + doTest(fileName); + } + + @TestMetadata("assignFilter_ArrayListRequired3.kt") + public void testAssignFilter_ArrayListRequired3() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/assignFilter_ArrayListRequired3.kt"); + doTest(fileName); + } + + @TestMetadata("assignFilter_MutableListRequired.kt") + public void testAssignFilter_MutableListRequired() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/assignFilter_MutableListRequired.kt"); + doTest(fileName); + } + + @TestMetadata("assignFilter_breakAndContinue.kt") + public void testAssignFilter_breakAndContinue() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/assignFilter_breakAndContinue.kt"); + doTest(fileName); + } + + @TestMetadata("assignMap.kt") + public void testAssignMap() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/assignMap.kt"); + doTest(fileName); + } + + @TestMetadata("assignMap2.kt") + public void testAssignMap2() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/assignMap2.kt"); + doTest(fileName); + } + + @TestMetadata("contains.kt") + public void testContains() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/contains.kt"); + doTest(fileName); + } + + @TestMetadata("contains2.kt") + public void testContains2() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/contains2.kt"); + doTest(fileName); + } + + @TestMetadata("contains3.kt") + public void testContains3() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/contains3.kt"); + doTest(fileName); + } + + @TestMetadata("contains4.kt") + public void testContains4() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/contains4.kt"); + doTest(fileName); + } + + @TestMetadata("count1.kt") + public void testCount1() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/count1.kt"); + doTest(fileName); + } + + @TestMetadata("count2.kt") + public void testCount2() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/count2.kt"); + doTest(fileName); + } + + @TestMetadata("count_Long.kt") + public void testCount_Long() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/count_Long.kt"); + doTest(fileName); + } + + @TestMetadata("count_nonConstantInitial.kt") + public void testCount_nonConstantInitial() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/count_nonConstantInitial.kt"); + doTest(fileName); + } + + @TestMetadata("count_nonZeroInitial.kt") + public void testCount_nonZeroInitial() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/count_nonZeroInitial.kt"); + doTest(fileName); + } + + @TestMetadata("count_prefix.kt") + public void testCount_prefix() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/count_prefix.kt"); + doTest(fileName); + } + + @TestMetadata("count_variableUsedBefore.kt") + public void testCount_variableUsedBefore() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/count_variableUsedBefore.kt"); + doTest(fileName); + } + + @TestMetadata("customTypeWithIterator.kt") + public void testCustomTypeWithIterator() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/customTypeWithIterator.kt"); + doTest(fileName); + } + + @TestMetadata("embeddedBreak1.kt") + public void testEmbeddedBreak1() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/embeddedBreak1.kt"); + doTest(fileName); + } + + @TestMetadata("embeddedBreak2.kt") + public void testEmbeddedBreak2() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/embeddedBreak2.kt"); + doTest(fileName); + } + + @TestMetadata("embeddedContinue.kt") + public void testEmbeddedContinue() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/embeddedContinue.kt"); + doTest(fileName); + } + + @TestMetadata("filterIndexed.kt") + public void testFilterIndexed() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/filterIndexed.kt"); + doTest(fileName); + } + + @TestMetadata("filterIndexed2.kt") + public void testFilterIndexed2() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/filterIndexed2.kt"); + doTest(fileName); + } + + @TestMetadata("filterIndexedAndFlatMapWithContinue.kt") + public void testFilterIndexedAndFlatMapWithContinue() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/filterIndexedAndFlatMapWithContinue.kt"); + doTest(fileName); + } + + @TestMetadata("filterIndexedTo.kt") + public void testFilterIndexedTo() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/filterIndexedTo.kt"); + doTest(fileName); + } + + @TestMetadata("filterIndexedTo2.kt") + public void testFilterIndexedTo2() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/filterIndexedTo2.kt"); + doTest(fileName); + } + + @TestMetadata("filterIndexed_indexChangedTwice.kt") + public void testFilterIndexed_indexChangedTwice() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/filterIndexed_indexChangedTwice.kt"); + doTest(fileName); + } + + @TestMetadata("filterIndexed_indexStartNotZero.kt") + public void testFilterIndexed_indexStartNotZero() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/filterIndexed_indexStartNotZero.kt"); + doTest(fileName); + } + + @TestMetadata("filterIndexed_indexUsedAfter.kt") + public void testFilterIndexed_indexUsedAfter() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/filterIndexed_indexUsedAfter.kt"); + doTest(fileName); + } + + @TestMetadata("filterIndexed_indexUsedEarlierInLoop.kt") + public void testFilterIndexed_indexUsedEarlierInLoop() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/filterIndexed_indexUsedEarlierInLoop.kt"); + doTest(fileName); + } + + @TestMetadata("filterIndexed_merge1.kt") + public void testFilterIndexed_merge1() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/filterIndexed_merge1.kt"); + doTest(fileName); + } + + @TestMetadata("filterIndexed_merge2.kt") + public void testFilterIndexed_merge2() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/filterIndexed_merge2.kt"); + doTest(fileName); + } + + @TestMetadata("filterIndexed_merge3.kt") + public void testFilterIndexed_merge3() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/filterIndexed_merge3.kt"); + doTest(fileName); + } + + @TestMetadata("filterIndexed_merge4.kt") + public void testFilterIndexed_merge4() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/filterIndexed_merge4.kt"); + doTest(fileName); + } + + @TestMetadata("filterIndexed_twoIndices.kt") + public void testFilterIndexed_twoIndices() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/filterIndexed_twoIndices.kt"); + doTest(fileName); + } + + @TestMetadata("filterIndexed_twoIndicesUsed.kt") + public void testFilterIndexed_twoIndicesUsed() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/filterIndexed_twoIndicesUsed.kt"); + doTest(fileName); + } + + @TestMetadata("filterIsInstance.kt") + public void testFilterIsInstance() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/filterIsInstance.kt"); + doTest(fileName); + } + + @TestMetadata("filterIsInstanceTo.kt") + public void testFilterIsInstanceTo() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/filterIsInstanceTo.kt"); + doTest(fileName); + } + + @TestMetadata("filterIsInstance_ifContinue.kt") + public void testFilterIsInstance_ifContinue() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/filterIsInstance_ifContinue.kt"); + doTest(fileName); + } + + @TestMetadata("filterNotNull.kt") + public void testFilterNotNull() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/filterNotNull.kt"); + doTest(fileName); + } + + @TestMetadata("filterNotNullTo.kt") + public void testFilterNotNullTo() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/filterNotNullTo.kt"); + doTest(fileName); + } + + @TestMetadata("filterNotNullTo2.kt") + public void testFilterNotNullTo2() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/filterNotNullTo2.kt"); + doTest(fileName); + } + + @TestMetadata("filterNotNull_ifContinue.kt") + public void testFilterNotNull_ifContinue() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/filterNotNull_ifContinue.kt"); + doTest(fileName); + } + + @TestMetadata("filterNotTo.kt") + public void testFilterNotTo() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/filterNotTo.kt"); + doTest(fileName); + } + + @TestMetadata("filterNot_ifContinue.kt") + public void testFilterNot_ifContinue() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/filterNot_ifContinue.kt"); + doTest(fileName); + } + + @TestMetadata("filterTo.kt") + public void testFilterTo() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/filterTo.kt"); + doTest(fileName); + } + + @TestMetadata("filterTo2.kt") + public void testFilterTo2() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/filterTo2.kt"); + doTest(fileName); + } + + @TestMetadata("filter_ifContinue.kt") + public void testFilter_ifContinue() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/filter_ifContinue.kt"); + doTest(fileName); + } + + @TestMetadata("filter_ifContinue2.kt") + public void testFilter_ifContinue2() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/filter_ifContinue2.kt"); + doTest(fileName); + } + + @TestMetadata("filter_ifContinueInBlock.kt") + public void testFilter_ifContinueInBlock() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/filter_ifContinueInBlock.kt"); + doTest(fileName); + } + + @TestMetadata("filter_ifContinueWithLabel.kt") + public void testFilter_ifContinueWithLabel() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/filter_ifContinueWithLabel.kt"); + doTest(fileName); + } + + @TestMetadata("filter_inputVarNotUsed.kt") + public void testFilter_inputVarNotUsed() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/filter_inputVarNotUsed.kt"); + doTest(fileName); + } + + @TestMetadata("filter_mergeMultiple.kt") + public void testFilter_mergeMultiple() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/filter_mergeMultiple.kt"); + doTest(fileName); + } + + @TestMetadata("firstOrNull_assignmentInitialization.kt") + public void testFirstOrNull_assignmentInitialization() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/firstOrNull_assignmentInitialization.kt"); + doTest(fileName); + } + + @TestMetadata("firstOrNull_cannotUseLet.kt") + public void testFirstOrNull_cannotUseLet() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/firstOrNull_cannotUseLet.kt"); + doTest(fileName); + } + + @TestMetadata("firstOrNull_ifAssign.kt") + public void testFirstOrNull_ifAssign() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/firstOrNull_ifAssign.kt"); + doTest(fileName); + } + + @TestMetadata("firstOrNull_ifAssign_breakWithLabel.kt") + public void testFirstOrNull_ifAssign_breakWithLabel() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/firstOrNull_ifAssign_breakWithLabel.kt"); + doTest(fileName); + } + + @TestMetadata("firstOrNull_ifAssign_cannotBeVal.kt") + public void testFirstOrNull_ifAssign_cannotBeVal() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/firstOrNull_ifAssign_cannotBeVal.kt"); + doTest(fileName); + } + + @TestMetadata("firstOrNull_ifAssign_preserveComments.kt") + public void testFirstOrNull_ifAssign_preserveComments() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/firstOrNull_ifAssign_preserveComments.kt"); + doTest(fileName); + } + + @TestMetadata("firstOrNull_ifAssign_variableUsedBefore.kt") + public void testFirstOrNull_ifAssign_variableUsedBefore() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/firstOrNull_ifAssign_variableUsedBefore.kt"); + doTest(fileName); + } + + @TestMetadata("firstOrNull_ifReturn.kt") + public void testFirstOrNull_ifReturn() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/firstOrNull_ifReturn.kt"); + doTest(fileName); + } + + @TestMetadata("firstOrNull_let.kt") + public void testFirstOrNull_let() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/firstOrNull_let.kt"); + doTest(fileName); + } + + @TestMetadata("firstOrNull_let2.kt") + public void testFirstOrNull_let2() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/firstOrNull_let2.kt"); + doTest(fileName); + } + + @TestMetadata("firstOrNull_letOrNotNull.kt") + public void testFirstOrNull_letOrNotNull() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/firstOrNull_letOrNotNull.kt"); + doTest(fileName); + } + + @TestMetadata("firstOrNull_return.kt") + public void testFirstOrNull_return() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/firstOrNull_return.kt"); + doTest(fileName); + } + + @TestMetadata("firstOrNull_returnExpression.kt") + public void testFirstOrNull_returnExpression() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/firstOrNull_returnExpression.kt"); + doTest(fileName); + } + + @TestMetadata("firstOrNull_returnExpressionOrNotNull.kt") + public void testFirstOrNull_returnExpressionOrNotNull() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/firstOrNull_returnExpressionOrNotNull.kt"); + doTest(fileName); + } + + @TestMetadata("firstOrNull_returnNotNullIfNone.kt") + public void testFirstOrNull_returnNotNullIfNone() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/firstOrNull_returnNotNullIfNone.kt"); + doTest(fileName); + } + + @TestMetadata("firstOrNull_returnNotNullIfNone2.kt") + public void testFirstOrNull_returnNotNullIfNone2() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/firstOrNull_returnNotNullIfNone2.kt"); + doTest(fileName); + } + + @TestMetadata("firstOrNull_return_comment.kt") + public void testFirstOrNull_return_comment() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/firstOrNull_return_comment.kt"); + doTest(fileName); + } + + @TestMetadata("firstOrNull_safeDotExpression.kt") + public void testFirstOrNull_safeDotExpression() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/firstOrNull_safeDotExpression.kt"); + doTest(fileName); + } + + @TestMetadata("firstOrNull_withMergedFilter.kt") + public void testFirstOrNull_withMergedFilter() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/firstOrNull_withMergedFilter.kt"); + doTest(fileName); + } + + @TestMetadata("flatMap.kt") + public void testFlatMap() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/flatMap.kt"); + doTest(fileName); + } + + @TestMetadata("flatMapTo.kt") + public void testFlatMapTo() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/flatMapTo.kt"); + doTest(fileName); + } + + @TestMetadata("flatMapTo2.kt") + public void testFlatMapTo2() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/flatMapTo2.kt"); + doTest(fileName); + } + + @TestMetadata("flatMapTo3.kt") + public void testFlatMapTo3() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/flatMapTo3.kt"); + doTest(fileName); + } + + @TestMetadata("flatMapWithBreak.kt") + public void testFlatMapWithBreak() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/flatMapWithBreak.kt"); + doTest(fileName); + } + + @TestMetadata("flatMapWithContinue.kt") + public void testFlatMapWithContinue() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/flatMapWithContinue.kt"); + doTest(fileName); + } + + @TestMetadata("flatMapWithWrongBreak.kt") + public void testFlatMapWithWrongBreak() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/flatMapWithWrongBreak.kt"); + doTest(fileName); + } + + @TestMetadata("flatMap_indexUsed.kt") + public void testFlatMap_indexUsed() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/flatMap_indexUsed.kt"); + doTest(fileName); + } + + @TestMetadata("flatMap_notIterable.kt") + public void testFlatMap_notIterable() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/flatMap_notIterable.kt"); + doTest(fileName); + } + + @TestMetadata("flatMap_workingVarStillNeeded.kt") + public void testFlatMap_workingVarStillNeeded() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/flatMap_workingVarStillNeeded.kt"); + doTest(fileName); + } + + @TestMetadata("flatMap_wrongContinue.kt") + public void testFlatMap_wrongContinue() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/flatMap_wrongContinue.kt"); + doTest(fileName); + } + + @TestMetadata("forEach.kt") + public void testForEach() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/forEach.kt"); + doTest(fileName); + } + + @TestMetadata("forEachIndexed.kt") + public void testForEachIndexed() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/forEachIndexed.kt"); + doTest(fileName); + } + + @TestMetadata("forEachIndexed_nothingElse.kt") + public void testForEachIndexed_nothingElse() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/forEachIndexed_nothingElse.kt"); + doTest(fileName); + } + + @TestMetadata("forEach_notAvailable.kt") + public void testForEach_notAvailable() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/forEach_notAvailable.kt"); + doTest(fileName); + } + + @TestMetadata("forEach_notIndexed.kt") + public void testForEach_notIndexed() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/forEach_notIndexed.kt"); + doTest(fileName); + } + + @TestMetadata("indexOf.kt") + public void testIndexOf() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/indexOf.kt"); + doTest(fileName); + } + + @TestMetadata("indexOfFirst_ifAssign.kt") + public void testIndexOfFirst_ifAssign() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/indexOfFirst_ifAssign.kt"); + doTest(fileName); + } + + @TestMetadata("indexOfFirst_ifReturn.kt") + public void testIndexOfFirst_ifReturn() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/indexOfFirst_ifReturn.kt"); + doTest(fileName); + } + + @TestMetadata("indexOfFirst_mustBeNoIndexInCondition.kt") + public void testIndexOfFirst_mustBeNoIndexInCondition() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/indexOfFirst_mustBeNoIndexInCondition.kt"); + doTest(fileName); + } + + @TestMetadata("indexOfLast_ifAssign.kt") + public void testIndexOfLast_ifAssign() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/indexOfLast_ifAssign.kt"); + doTest(fileName); + } + + @TestMetadata("indexPlusPlusInsideExpression.kt") + public void testIndexPlusPlusInsideExpression() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/indexPlusPlusInsideExpression.kt"); + doTest(fileName); + } + + @TestMetadata("indexPlusPlusInsideExpression_indexUsedAfterIncrement.kt") + public void testIndexPlusPlusInsideExpression_indexUsedAfterIncrement() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/indexPlusPlusInsideExpression_indexUsedAfterIncrement.kt"); + doTest(fileName); + } + + @TestMetadata("indexPlusPlusInsideExpression_indexUsedBeforeIncrement.kt") + public void testIndexPlusPlusInsideExpression_indexUsedBeforeIncrement() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/indexPlusPlusInsideExpression_indexUsedBeforeIncrement.kt"); + doTest(fileName); + } + + @TestMetadata("indexPlusPlusInsideExpression_indexUsedBeforeIncrement2.kt") + public void testIndexPlusPlusInsideExpression_indexUsedBeforeIncrement2() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/indexPlusPlusInsideExpression_indexUsedBeforeIncrement2.kt"); + doTest(fileName); + } + + @TestMetadata("indexPlusPlusIsNotLastStatement.kt") + public void testIndexPlusPlusIsNotLastStatement() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/indexPlusPlusIsNotLastStatement.kt"); + doTest(fileName); + } + + @TestMetadata("indexPlusPlusIsNotLastStatement_indexUsedAfterIncrement.kt") + public void testIndexPlusPlusIsNotLastStatement_indexUsedAfterIncrement() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/indexPlusPlusIsNotLastStatement_indexUsedAfterIncrement.kt"); + doTest(fileName); + } + + @TestMetadata("indexWithNestedLoop.kt") + public void testIndexWithNestedLoop() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/indexWithNestedLoop.kt"); + doTest(fileName); + } + + @TestMetadata("intArray.kt") + public void testIntArray() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/intArray.kt"); + doTest(fileName); + } + + @TestMetadata("itAlreadyUsed.kt") + public void testItAlreadyUsed() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/itAlreadyUsed.kt"); + doTest(fileName); + } + + @TestMetadata("lastIndexOf.kt") + public void testLastIndexOf() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/lastIndexOf.kt"); + doTest(fileName); + } + + @TestMetadata("lastOrNull_ifAssign.kt") + public void testLastOrNull_ifAssign() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/lastOrNull_ifAssign.kt"); + doTest(fileName); + } + + @TestMetadata("map.kt") + public void testMap() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/map.kt"); + doTest(fileName); + } + + @TestMetadata("mapAndFilterIndexed.kt") + public void testMapAndFilterIndexed() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/mapAndFilterIndexed.kt"); + doTest(fileName); + } + + @TestMetadata("mapIndexed.kt") + public void testMapIndexed() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/mapIndexed.kt"); + doTest(fileName); + } + + @TestMetadata("mapIndexedNotNull.kt") + public void testMapIndexedNotNull() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/mapIndexedNotNull.kt"); + doTest(fileName); + } + + @TestMetadata("mapIndexedNotNullTo.kt") + public void testMapIndexedNotNullTo() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/mapIndexedNotNullTo.kt"); + doTest(fileName); + } + + @TestMetadata("mapIndexedNotNullTo_elvisContinue.kt") + public void testMapIndexedNotNullTo_elvisContinue() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/mapIndexedNotNullTo_elvisContinue.kt"); + doTest(fileName); + } + + @TestMetadata("mapIndexedNotNull_elvisContinue.kt") + public void testMapIndexedNotNull_elvisContinue() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/mapIndexedNotNull_elvisContinue.kt"); + doTest(fileName); + } + + @TestMetadata("mapIndexedTo.kt") + public void testMapIndexedTo() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/mapIndexedTo.kt"); + doTest(fileName); + } + + @TestMetadata("mapIndexed_afterFilter.kt") + public void testMapIndexed_afterFilter() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/mapIndexed_afterFilter.kt"); + doTest(fileName); + } + + @TestMetadata("mapIndexed_twice.kt") + public void testMapIndexed_twice() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/mapIndexed_twice.kt"); + doTest(fileName); + } + + @TestMetadata("mapNotNull.kt") + public void testMapNotNull() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/mapNotNull.kt"); + doTest(fileName); + } + + @TestMetadata("mapNotNullTo.kt") + public void testMapNotNullTo() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/mapNotNullTo.kt"); + doTest(fileName); + } + + @TestMetadata("mapNotNullTo_elvisContinue.kt") + public void testMapNotNullTo_elvisContinue() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/mapNotNullTo_elvisContinue.kt"); + doTest(fileName); + } + + @TestMetadata("mapNotNull_elvisContinue.kt") + public void testMapNotNull_elvisContinue() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/mapNotNull_elvisContinue.kt"); + doTest(fileName); + } + + @TestMetadata("mapNotNull_nestedLoopElvisContinue.kt") + public void testMapNotNull_nestedLoopElvisContinue() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/mapNotNull_nestedLoopElvisContinue.kt"); + doTest(fileName); + } + + @TestMetadata("mapNotNull_wrongElvisContinue.kt") + public void testMapNotNull_wrongElvisContinue() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/mapNotNull_wrongElvisContinue.kt"); + doTest(fileName); + } + + @TestMetadata("mapTo.kt") + public void testMapTo() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/mapTo.kt"); + doTest(fileName); + } + + @TestMetadata("mapTo2.kt") + public void testMapTo2() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/mapTo2.kt"); + doTest(fileName); + } + + @TestMetadata("mapTo3.kt") + public void testMapTo3() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/mapTo3.kt"); + doTest(fileName); + } + + @TestMetadata("mapTo4.kt") + public void testMapTo4() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/mapTo4.kt"); + doTest(fileName); + } + + @TestMetadata("mapTo_inputVarNotUsed.kt") + public void testMapTo_inputVarNotUsed() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/mapTo_inputVarNotUsed.kt"); + doTest(fileName); + } + + @TestMetadata("mapUsesOldIndexAfterFilter.kt") + public void testMapUsesOldIndexAfterFilter() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/mapUsesOldIndexAfterFilter.kt"); + doTest(fileName); + } + + @TestMetadata("mapVar.kt") + public void testMapVar() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/mapVar.kt"); + doTest(fileName); + } + + @TestMetadata("map_var.kt") + public void testMap_var() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/map_var.kt"); + doTest(fileName); + } + + @TestMetadata("map_variableStillNeeded.kt") + public void testMap_variableStillNeeded() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/map_variableStillNeeded.kt"); + doTest(fileName); + } + + @TestMetadata("moveInitializationsCloserToLoop.kt") + public void testMoveInitializationsCloserToLoop() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/moveInitializationsCloserToLoop.kt"); + doTest(fileName); + } + + @TestMetadata("none_ifReturn.kt") + public void testNone_ifReturn() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/none_ifReturn.kt"); + doTest(fileName); + } + + @TestMetadata("prefixIndexPlusPlusInsideExpression.kt") + public void testPrefixIndexPlusPlusInsideExpression() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/prefixIndexPlusPlusInsideExpression.kt"); + doTest(fileName); + } + + @TestMetadata("range.kt") + public void testRange() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/range.kt"); + doTest(fileName); + } + + @TestMetadata("resultCollectionUsedInsideLoop.kt") + public void testResultCollectionUsedInsideLoop() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/resultCollectionUsedInsideLoop.kt"); + doTest(fileName); + } + + @TestMetadata("smartCastNotBroken.kt") + public void testSmartCastNotBroken() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/smartCastNotBroken.kt"); + doTest(fileName); + } + + @TestMetadata("smartCastNotNullRequired.kt") + public void testSmartCastNotNullRequired() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/smartCastNotNullRequired.kt"); + doTest(fileName); + } + + @TestMetadata("smartCastNotRequired.kt") + public void testSmartCastNotRequired() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/smartCastNotRequired.kt"); + doTest(fileName); + } + + @TestMetadata("smartCastRequired.kt") + public void testSmartCastRequired() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/smartCastRequired.kt"); + doTest(fileName); + } + + @TestMetadata("smartCastRequired2.kt") + public void testSmartCastRequired2() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/smartCastRequired2.kt"); + doTest(fileName); + } + + @TestMetadata("smartCastRequired3.kt") + public void testSmartCastRequired3() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/smartCastRequired3.kt"); + doTest(fileName); + } + + @TestMetadata("smartCastRequired4.kt") + public void testSmartCastRequired4() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/smartCastRequired4.kt"); + doTest(fileName); + } + + @TestMetadata("smartCastRequired5.kt") + public void testSmartCastRequired5() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/smartCastRequired5.kt"); + doTest(fileName); + } + + @TestMetadata("smartCastThisRequired.kt") + public void testSmartCastThisRequired() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/smartCastThisRequired.kt"); + doTest(fileName); + } + + @TestMetadata("takeWhile.kt") + public void testTakeWhile() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/takeWhile.kt"); + doTest(fileName); + } + + @TestMetadata("takeWhile_nestedLoop.kt") + public void testTakeWhile_nestedLoop() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/takeWhile_nestedLoop.kt"); + doTest(fileName); + } + + @TestMetadata("takeWhile_wrongBreak.kt") + public void testTakeWhile_wrongBreak() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/takeWhile_wrongBreak.kt"); + doTest(fileName); + } + + @TestMetadata("toList.kt") + public void testToList() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/toList.kt"); + doTest(fileName); + } + + @TestMetadata("toMutableSet.kt") + public void testToMutableSet() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/toMutableSet.kt"); + doTest(fileName); + } + + @TestMetadata("toSet.kt") + public void testToSet() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/toSet.kt"); + doTest(fileName); + } + + @TestMetadata("toSetWithMap.kt") + public void testToSetWithMap() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/toSetWithMap.kt"); + doTest(fileName); + } + + @TestMetadata("twoInitializationsBeforeLoop.kt") + public void testTwoInitializationsBeforeLoop() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/twoInitializationsBeforeLoop.kt"); + doTest(fileName); + } +}