mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[kotlin] Fix rendering of missing branches in AddRemainingWhenBranches
KTIJ-30496 GitOrigin-RevId: 4e33efd8dc48ca0f51fddd95d3b70d7df4a82a60
This commit is contained in:
committed by
intellij-monorepo-bot
parent
28eaf8206e
commit
63191ad02b
+10
@@ -3514,6 +3514,16 @@ public abstract class HighLevelQuickFixTestGenerated extends AbstractHighLevelQu
|
||||
runTest("../../../idea/tests/testData/quickfix/when/addRemainingBranchesEnumStatement.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("addRemainingBranchesGeneric.kt")
|
||||
public void testAddRemainingBranchesGeneric() throws Exception {
|
||||
runTest("../../../idea/tests/testData/quickfix/when/addRemainingBranchesGeneric.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("addRemainingBranchesGeneric2.kt")
|
||||
public void testAddRemainingBranchesGeneric2() throws Exception {
|
||||
runTest("../../../idea/tests/testData/quickfix/when/addRemainingBranchesGeneric2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("addRemainingBranchesInNonDefaultPackage.kt")
|
||||
public void testAddRemainingBranchesInNonDefaultPackage() throws Exception {
|
||||
runTest("../../../idea/tests/testData/quickfix/when/addRemainingBranchesInNonDefaultPackage.kt");
|
||||
|
||||
+1
-13
@@ -58,19 +58,7 @@ object AddRemainingWhenBranchesUtils {
|
||||
val elseBranch = element.entries.find { it.isElse }
|
||||
(whenCloseBrace.prevSibling as? PsiWhiteSpace)?.replace(psiFactory.createNewLine())
|
||||
for (case in missingCases) {
|
||||
val branchConditionText = when (case) {
|
||||
WhenMissingCase.Unknown,
|
||||
WhenMissingCase.NullIsMissing,
|
||||
is WhenMissingCase.BooleanIsMissing,
|
||||
is WhenMissingCase.ConditionTypeIsExpect -> case.branchConditionText
|
||||
is WhenMissingCase.IsTypeCheckIsMissing ->
|
||||
if (case.isSingleton) {
|
||||
""
|
||||
} else {
|
||||
"is "
|
||||
} + case.classId.asSingleFqName().render()
|
||||
is WhenMissingCase.EnumCheckIsMissing -> case.callableId.asSingleFqName().render()
|
||||
}
|
||||
val branchConditionText = case.branchConditionText
|
||||
val entry = psiFactory.createWhenEntry("$branchConditionText -> TODO()")
|
||||
if (elseBranch != null) {
|
||||
element.addBefore(entry, elseBranch)
|
||||
|
||||
+10
@@ -19780,6 +19780,16 @@ public abstract class K1QuickFixTestGenerated extends AbstractK1QuickFixTest {
|
||||
runTest("testData/quickfix/when/addRemainingBranchesEnumStatement.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("addRemainingBranchesGeneric.kt")
|
||||
public void testAddRemainingBranchesGeneric() throws Exception {
|
||||
runTest("testData/quickfix/when/addRemainingBranchesGeneric.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("addRemainingBranchesGeneric2.kt")
|
||||
public void testAddRemainingBranchesGeneric2() throws Exception {
|
||||
runTest("testData/quickfix/when/addRemainingBranchesGeneric2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("addRemainingBranchesInNonDefaultPackage.kt")
|
||||
public void testAddRemainingBranchesInNonDefaultPackage() throws Exception {
|
||||
runTest("testData/quickfix/when/addRemainingBranchesInNonDefaultPackage.kt");
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
// "Add remaining branches" "true"
|
||||
// ERROR: Unresolved reference: TODO
|
||||
// ERROR: Unresolved reference: TODO
|
||||
|
||||
sealed class Base<U, V, W> {
|
||||
fun foo(it: Base<U, V, W>) {
|
||||
<caret>when (it) {
|
||||
is Derived -> TODO()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Derived<U, V>: Base<U, V, Int>()
|
||||
class Generic<V, T>: Base<Int, V, String>()
|
||||
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddWhenRemainingBranchesFix
|
||||
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.k2.codeinsight.fixes.AddWhenRemainingBranchFixFactories$AddRemainingWhenBranchesQuickFix
|
||||
@@ -0,0 +1,18 @@
|
||||
// "Add remaining branches" "true"
|
||||
// ERROR: Unresolved reference: TODO
|
||||
// ERROR: Unresolved reference: TODO
|
||||
|
||||
sealed class Base<U, V, W> {
|
||||
fun foo(it: Base<U, V, W>) {
|
||||
when (it) {
|
||||
is Derived -> TODO()
|
||||
is Generic<*, *> -> TODO()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Derived<U, V>: Base<U, V, Int>()
|
||||
class Generic<V, T>: Base<Int, V, String>()
|
||||
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddWhenRemainingBranchesFix
|
||||
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.k2.codeinsight.fixes.AddWhenRemainingBranchFixFactories$AddRemainingWhenBranchesQuickFix
|
||||
@@ -0,0 +1,18 @@
|
||||
// "Add remaining branches" "true"
|
||||
// ERROR: Unresolved reference: TODO
|
||||
// ERROR: Unresolved reference: TODO
|
||||
|
||||
sealed class Base<U, V, W> {
|
||||
fun bar(it: TA) {
|
||||
<caret>when (it) {
|
||||
is Derived -> TODO()
|
||||
}
|
||||
}
|
||||
}
|
||||
class Derived<U, V>: Base<U, V, Int>()
|
||||
class Generic<V, T>: Base<Int, V, String>()
|
||||
|
||||
typealias TA = Base<Double, Int, String>
|
||||
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddWhenRemainingBranchesFix
|
||||
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.k2.codeinsight.fixes.AddWhenRemainingBranchFixFactories$AddRemainingWhenBranchesQuickFix
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// "Add remaining branches" "true"
|
||||
// ERROR: Unresolved reference: TODO
|
||||
// ERROR: Unresolved reference: TODO
|
||||
|
||||
sealed class Base<U, V, W> {
|
||||
fun bar(it: TA) {
|
||||
when (it) {
|
||||
is Derived -> TODO()
|
||||
is Generic<*, *> -> TODO()
|
||||
}
|
||||
}
|
||||
}
|
||||
class Derived<U, V>: Base<U, V, Int>()
|
||||
class Generic<V, T>: Base<Int, V, String>()
|
||||
|
||||
typealias TA = Base<Double, Int, String>
|
||||
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddWhenRemainingBranchesFix
|
||||
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.k2.codeinsight.fixes.AddWhenRemainingBranchFixFactories$AddRemainingWhenBranchesQuickFix
|
||||
Reference in New Issue
Block a user