diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/util/CommentSaver.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/util/CommentSaver.kt index 890311d3a61..89f270dae14 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/util/CommentSaver.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/util/CommentSaver.kt @@ -285,6 +285,7 @@ class CommentSaver(originalElements: PsiChildRange, private val saveLineBreaks: val document = psiDocumentManager.getDocument(file) if (document != null) { psiDocumentManager.doPostponedOperationsAndUnblockDocument(document) + psiDocumentManager.commitDocument(document) } CodeStyleManager.getInstance(project).adjustLineIndent(file, resultElements.textRange) } diff --git a/idea/testData/intentions/loopToCallChain/count/KT14191.kt b/idea/testData/intentions/loopToCallChain/count/KT14191.kt new file mode 100644 index 00000000000..28a2990a62a --- /dev/null +++ b/idea/testData/intentions/loopToCallChain/count/KT14191.kt @@ -0,0 +1,12 @@ +// WITH_RUNTIME +// INTENTION_TEXT: "Replace with 'filterNotNull().count()'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filterNotNull().count()'" +fun f11(list: List): Int{ + var objs = 0 + for (d in list) { + if (d != null) { + objs++ + } + } + return objs +} \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/count/KT14191.kt.after b/idea/testData/intentions/loopToCallChain/count/KT14191.kt.after new file mode 100644 index 00000000000..e03c7254fcd --- /dev/null +++ b/idea/testData/intentions/loopToCallChain/count/KT14191.kt.after @@ -0,0 +1,9 @@ +// WITH_RUNTIME +// INTENTION_TEXT: "Replace with 'filterNotNull().count()'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filterNotNull().count()'" +fun f11(list: List): Int{ + val objs = list + .filterNotNull() + .count() + return objs +} \ No newline at end of file diff --git a/idea/testData/intentions/loopToCallChain/count/KT14191.kt.after2 b/idea/testData/intentions/loopToCallChain/count/KT14191.kt.after2 new file mode 100644 index 00000000000..d8b3cb28f9c --- /dev/null +++ b/idea/testData/intentions/loopToCallChain/count/KT14191.kt.after2 @@ -0,0 +1,10 @@ +// WITH_RUNTIME +// INTENTION_TEXT: "Replace with 'filterNotNull().count()'" +// INTENTION_TEXT_2: "Replace with 'asSequence().filterNotNull().count()'" +fun f11(list: List): Int{ + val objs = list + .asSequence() + .filterNotNull() + .count() + return objs +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTest2Generated.java b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTest2Generated.java index 81061060e74..5828d27d074 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTest2Generated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTest2Generated.java @@ -235,6 +235,12 @@ public class IntentionTest2Generated extends AbstractIntentionTest2 { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/intentions/loopToCallChain/count"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), true); } + @TestMetadata("KT14191.kt") + public void testKT14191() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/count/KT14191.kt"); + doTest(fileName); + } + @TestMetadata("long.kt") public void testLong() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/count/long.kt"); diff --git a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java index 9a6d91c93de..76cb248fe59 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java @@ -8143,6 +8143,12 @@ public class IntentionTestGenerated extends AbstractIntentionTest { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/intentions/loopToCallChain/count"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), true); } + @TestMetadata("KT14191.kt") + public void testKT14191() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/count/KT14191.kt"); + doTest(fileName); + } + @TestMetadata("long.kt") public void testLong() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/count/long.kt");