KT-14191 FormattingModelInconsistencyException Exception on applying intention Replace with count()
#KT-14191 Fixed
This commit is contained in:
@@ -285,6 +285,7 @@ class CommentSaver(originalElements: PsiChildRange, private val saveLineBreaks:
|
|||||||
val document = psiDocumentManager.getDocument(file)
|
val document = psiDocumentManager.getDocument(file)
|
||||||
if (document != null) {
|
if (document != null) {
|
||||||
psiDocumentManager.doPostponedOperationsAndUnblockDocument(document)
|
psiDocumentManager.doPostponedOperationsAndUnblockDocument(document)
|
||||||
|
psiDocumentManager.commitDocument(document)
|
||||||
}
|
}
|
||||||
CodeStyleManager.getInstance(project).adjustLineIndent(file, resultElements.textRange)
|
CodeStyleManager.getInstance(project).adjustLineIndent(file, resultElements.textRange)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
// WITH_RUNTIME
|
||||||
|
// INTENTION_TEXT: "Replace with 'filterNotNull().count()'"
|
||||||
|
// INTENTION_TEXT_2: "Replace with 'asSequence().filterNotNull().count()'"
|
||||||
|
fun f11(list: List<Any?>): Int{
|
||||||
|
var objs = 0
|
||||||
|
<caret>for (d in list) {
|
||||||
|
if (d != null) {
|
||||||
|
objs++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return objs
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
// WITH_RUNTIME
|
||||||
|
// INTENTION_TEXT: "Replace with 'filterNotNull().count()'"
|
||||||
|
// INTENTION_TEXT_2: "Replace with 'asSequence().filterNotNull().count()'"
|
||||||
|
fun f11(list: List<Any?>): Int{
|
||||||
|
val <caret>objs = list
|
||||||
|
.filterNotNull()
|
||||||
|
.count()
|
||||||
|
return objs
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
// WITH_RUNTIME
|
||||||
|
// INTENTION_TEXT: "Replace with 'filterNotNull().count()'"
|
||||||
|
// INTENTION_TEXT_2: "Replace with 'asSequence().filterNotNull().count()'"
|
||||||
|
fun f11(list: List<Any?>): Int{
|
||||||
|
val <caret>objs = list
|
||||||
|
.asSequence()
|
||||||
|
.filterNotNull()
|
||||||
|
.count()
|
||||||
|
return objs
|
||||||
|
}
|
||||||
@@ -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);
|
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")
|
@TestMetadata("long.kt")
|
||||||
public void testLong() throws Exception {
|
public void testLong() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/count/long.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/count/long.kt");
|
||||||
|
|||||||
@@ -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);
|
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")
|
@TestMetadata("long.kt")
|
||||||
public void testLong() throws Exception {
|
public void testLong() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/count/long.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/loopToCallChain/count/long.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user