KT-13884 Exception "Invalid root block PSI element" on replacing trivial when-expression to if
#KT-13884 Fixed
This commit is contained in:
+1
@@ -33,6 +33,7 @@ class WhenToIfIntention : SelfTargetingRangeIntention<KtWhenExpression>(KtWhenEx
|
||||
if (entries.isEmpty()) return null
|
||||
val lastEntry = entries.last()
|
||||
if (entries.any { it != lastEntry && it.isElse }) return null
|
||||
if (entries.all { it.isElse }) return null // 'when' with only 'else' branch is not supported
|
||||
return element.whenKeyword.textRange
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
//IS_APPLICABLE: false
|
||||
fun foo() {
|
||||
<caret>when {
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
@@ -1771,6 +1771,12 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt13884.kt")
|
||||
public void testKt13884() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/branched/ifWhen/whenToIf/kt13884.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("whenWithDotQualifiedExpression.kt")
|
||||
public void testWhenWithDotQualifiedExpression() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/branched/ifWhen/whenToIf/whenWithDotQualifiedExpression.kt");
|
||||
|
||||
Reference in New Issue
Block a user