diff --git a/generators/org/jetbrains/jet/generators/tests/GenerateTests.java b/generators/org/jetbrains/jet/generators/tests/GenerateTests.java index ebfd4695151..8049091a2a3 100644 --- a/generators/org/jetbrains/jet/generators/tests/GenerateTests.java +++ b/generators/org/jetbrains/jet/generators/tests/GenerateTests.java @@ -306,8 +306,7 @@ public class GenerateTests { "CodeTransformationsTestGenerated", AbstractCodeTransformationTest.class, testModel("idea/testData/codeInsight/codeTransformations/ifStatementWithAssignmentsToExpression", "doTestIfStatementWithAssignmentsToExpression"), - testModel("idea/testData/codeInsight/codeTransformations/assignmentWithIfExpressionToStatement", "doTestAssignmentWithIfExpressionToStatement"), - testModel("idea/testData/codeInsight/codeTransformations/removeUnnecessaryParentheses", "doTestRemoveUnnecessaryParentheses") + testModel("idea/testData/codeInsight/codeTransformations/assignmentWithIfExpressionToStatement", "doTestAssignmentWithIfExpressionToStatement") ); generateTest( diff --git a/idea/testData/codeInsight/codeTransformations/ifStatementWithAssignmentsToExpression/innerIfTransformed.kt b/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/innerIfTransformed.kt similarity index 100% rename from idea/testData/codeInsight/codeTransformations/ifStatementWithAssignmentsToExpression/innerIfTransformed.kt rename to idea/testData/codeInsight/codeTransformations/branched/folding/assignment/innerIfTransformed.kt diff --git a/idea/testData/codeInsight/codeTransformations/ifStatementWithAssignmentsToExpression/innerIfTransformed.kt.after b/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/innerIfTransformed.kt.after similarity index 100% rename from idea/testData/codeInsight/codeTransformations/ifStatementWithAssignmentsToExpression/innerIfTransformed.kt.after rename to idea/testData/codeInsight/codeTransformations/branched/folding/assignment/innerIfTransformed.kt.after diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/innerWhenTransformed.kt b/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/innerWhenTransformed.kt new file mode 100644 index 00000000000..c1784696fd1 --- /dev/null +++ b/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/innerWhenTransformed.kt @@ -0,0 +1,21 @@ +fun test(n: Int): String { + var res: String + + if (3 > 2) { + when(n) { + 1 -> { + println("***") + res = "one" + } + else -> { + println("***") + res = "two" + } + } + } else { + println("***") + res = "???" + } + + return res +} \ No newline at end of file diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/innerWhenTransformed.kt.after b/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/innerWhenTransformed.kt.after new file mode 100644 index 00000000000..d3f6b00fa62 --- /dev/null +++ b/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/innerWhenTransformed.kt.after @@ -0,0 +1,21 @@ +fun test(n: Int): String { + var res: String + + if (3 > 2) { + res = when(n) { + 1 -> { + println("***") + "one" + } + else -> { + println("***") + "two" + } + } + } else { + println("***") + res = "???" + } + + return res +} \ No newline at end of file diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleIf.kt b/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleIf.kt new file mode 100644 index 00000000000..b35ea7a79dc --- /dev/null +++ b/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleIf.kt @@ -0,0 +1,7 @@ +fun test(n: Int): String { + var res: String + + if (n == 1) res = "one" else res = "two" + + return res +} \ No newline at end of file diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleIf.kt.after b/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleIf.kt.after new file mode 100644 index 00000000000..2270e195d3e --- /dev/null +++ b/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleIf.kt.after @@ -0,0 +1,7 @@ +fun test(n: Int): String { + var res: String + + res = if (n == 1) "one" else "two" + + return res +} \ No newline at end of file diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleIfWithAugmentedAssignment.kt b/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleIfWithAugmentedAssignment.kt new file mode 100644 index 00000000000..ccd31de0a4b --- /dev/null +++ b/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleIfWithAugmentedAssignment.kt @@ -0,0 +1,7 @@ +fun test(n: Int): String { + var res: String = "!" + + if (n == 1) res += "one" else res += "two" + + return res +} \ No newline at end of file diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleIfWithAugmentedAssignment.kt.after b/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleIfWithAugmentedAssignment.kt.after new file mode 100644 index 00000000000..bdd35f4f302 --- /dev/null +++ b/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleIfWithAugmentedAssignment.kt.after @@ -0,0 +1,7 @@ +fun test(n: Int): String { + var res: String = "!" + + res += if (n == 1) "one" else "two" + + return res +} \ No newline at end of file diff --git a/idea/testData/codeInsight/codeTransformations/assignmentWithIfExpressionToStatement/simpleIf.kt.after b/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleIfWithBlocks.kt similarity index 100% rename from idea/testData/codeInsight/codeTransformations/assignmentWithIfExpressionToStatement/simpleIf.kt.after rename to idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleIfWithBlocks.kt diff --git a/idea/testData/codeInsight/codeTransformations/assignmentWithIfExpressionToStatement/simpleIf.kt b/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleIfWithBlocks.kt.after similarity index 100% rename from idea/testData/codeInsight/codeTransformations/assignmentWithIfExpressionToStatement/simpleIf.kt rename to idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleIfWithBlocks.kt.after diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleIfWithShadowedVar.kt b/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleIfWithShadowedVar.kt new file mode 100644 index 00000000000..a234873b8d9 --- /dev/null +++ b/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleIfWithShadowedVar.kt @@ -0,0 +1,16 @@ +// IS_APPLICABLE: false +fun test(n: Int): String { + var res: String = "" + + if (n == 1) { + println("***") + res = "one" + } else { + var res: String + + println("***") + res = "two" + } + + return res +} \ No newline at end of file diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleIfWithUnmatchedAssignmentOps.kt b/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleIfWithUnmatchedAssignmentOps.kt new file mode 100644 index 00000000000..e7a6033e708 --- /dev/null +++ b/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleIfWithUnmatchedAssignmentOps.kt @@ -0,0 +1,12 @@ +// IS_APPLICABLE: false +fun test(s: String): Int { + var n: Int = 1; + + if (s.equals("add")) { + n += 1 + } else { + n -= 1 + } + + return n +} \ No newline at end of file diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleIfWithUnmatchedAssignments.kt b/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleIfWithUnmatchedAssignments.kt new file mode 100644 index 00000000000..38c0aeabbec --- /dev/null +++ b/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleIfWithUnmatchedAssignments.kt @@ -0,0 +1,13 @@ +// IS_APPLICABLE: false +fun test(n: Int): String { + var res: String = "" + var res2: String = "" + + if (n == 1) { + res = "one" + } else { + res2 = "two" + } + + return res + res2 +} \ No newline at end of file diff --git a/idea/testData/codeInsight/codeTransformations/ifStatementWithAssignmentsToExpression/simpleIfWithoutElse.kt b/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleIfWithoutElse.kt similarity index 100% rename from idea/testData/codeInsight/codeTransformations/ifStatementWithAssignmentsToExpression/simpleIfWithoutElse.kt rename to idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleIfWithoutElse.kt diff --git a/idea/testData/codeInsight/codeTransformations/ifStatementWithAssignmentsToExpression/simpleIfWithoutTerminatingAssignment.kt b/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleIfWithoutTerminatingAssignment.kt similarity index 100% rename from idea/testData/codeInsight/codeTransformations/ifStatementWithAssignmentsToExpression/simpleIfWithoutTerminatingAssignment.kt rename to idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleIfWithoutTerminatingAssignment.kt diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleWhen.kt b/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleWhen.kt new file mode 100644 index 00000000000..bf7f1257945 --- /dev/null +++ b/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleWhen.kt @@ -0,0 +1,10 @@ +fun test(n: Int): String { + var res: String + + when(n) { + 1 -> res = "one" + else -> res = "two" + } + + return res +} \ No newline at end of file diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleWhen.kt.after b/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleWhen.kt.after new file mode 100644 index 00000000000..c961e534ccc --- /dev/null +++ b/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleWhen.kt.after @@ -0,0 +1,10 @@ +fun test(n: Int): String { + var res: String + + res = when(n) { + 1 -> "one" + else -> "two" + } + + return res +} \ No newline at end of file diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleWhenWithBlocks.kt b/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleWhenWithBlocks.kt new file mode 100644 index 00000000000..d3e4325d5de --- /dev/null +++ b/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleWhenWithBlocks.kt @@ -0,0 +1,16 @@ +fun test(n: Int): String { + var res: String + + when (n) { + 1 -> { + println("***") + res = "one" + } + else -> { + println("***") + res = "two" + } + } + + return res +} \ No newline at end of file diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleWhenWithBlocks.kt.after b/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleWhenWithBlocks.kt.after new file mode 100644 index 00000000000..237433b09f3 --- /dev/null +++ b/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleWhenWithBlocks.kt.after @@ -0,0 +1,16 @@ +fun test(n: Int): String { + var res: String + + res = when (n) { + 1 -> { + println("***") + "one" + } + else -> { + println("***") + "two" + } + } + + return res +} \ No newline at end of file diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleWhenWithShadowedVar.kt b/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleWhenWithShadowedVar.kt new file mode 100644 index 00000000000..e258e21ffe4 --- /dev/null +++ b/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleWhenWithShadowedVar.kt @@ -0,0 +1,19 @@ +// IS_APPLICABLE: false +fun test(n: Int): String { + var res: String = "" + + when (n) { + 1 -> { + println("***") + res = "one" + } + else -> { + var res: String + + res = "two" + println("***") + } + } + + return res +} \ No newline at end of file diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleWhenWithUnmatchedAssignments.kt b/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleWhenWithUnmatchedAssignments.kt new file mode 100644 index 00000000000..dc577d43980 --- /dev/null +++ b/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleWhenWithUnmatchedAssignments.kt @@ -0,0 +1,18 @@ +// IS_APPLICABLE: false +fun test(n: Int): String { + var res: String = "" + var res2: String = "" + + when (n) { + 1 -> { + println("***") + res = "one" + } + else -> { + println("***") + res2 = "two" + } + } + + return res + res2 +} \ No newline at end of file diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleWhenWithoutTerminatingAssignment.kt b/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleWhenWithoutTerminatingAssignment.kt new file mode 100644 index 00000000000..6b2f07c7e4a --- /dev/null +++ b/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleWhenWithoutTerminatingAssignment.kt @@ -0,0 +1,17 @@ +// IS_APPLICABLE: false +fun test(n: Int): String { + var res: String + + when (n) { + 1 -> { + println("***") + res = "one" + } + else -> { + res = "two" + println("***") + } + } + + return res +} \ No newline at end of file diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/asymmetricReturn/simpleIf.kt b/idea/testData/codeInsight/codeTransformations/branched/folding/asymmetricReturn/simpleIf.kt new file mode 100644 index 00000000000..1760f3812e5 --- /dev/null +++ b/idea/testData/codeInsight/codeTransformations/branched/folding/asymmetricReturn/simpleIf.kt @@ -0,0 +1,4 @@ +fun test(n: Int): String { + if (n == 1) return "one" + return "two" +} \ No newline at end of file diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/asymmetricReturn/simpleIf.kt.after b/idea/testData/codeInsight/codeTransformations/branched/folding/asymmetricReturn/simpleIf.kt.after new file mode 100644 index 00000000000..741973c35c6 --- /dev/null +++ b/idea/testData/codeInsight/codeTransformations/branched/folding/asymmetricReturn/simpleIf.kt.after @@ -0,0 +1,3 @@ +fun test(n: Int): String { + return if (n == 1) "one" else "two" +} \ No newline at end of file diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/asymmetricReturn/simpleIfWithBlocks.kt b/idea/testData/codeInsight/codeTransformations/branched/folding/asymmetricReturn/simpleIfWithBlocks.kt new file mode 100644 index 00000000000..ccdf2e9f3e6 --- /dev/null +++ b/idea/testData/codeInsight/codeTransformations/branched/folding/asymmetricReturn/simpleIfWithBlocks.kt @@ -0,0 +1,7 @@ +fun test(n: Int): String { + if (n == 1) { + println("***") + return "one" + } + return "two" +} \ No newline at end of file diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/asymmetricReturn/simpleIfWithBlocks.kt.after b/idea/testData/codeInsight/codeTransformations/branched/folding/asymmetricReturn/simpleIfWithBlocks.kt.after new file mode 100644 index 00000000000..5777e6c7ac1 --- /dev/null +++ b/idea/testData/codeInsight/codeTransformations/branched/folding/asymmetricReturn/simpleIfWithBlocks.kt.after @@ -0,0 +1,6 @@ +fun test(n: Int): String { + return if (n == 1) { + println("***") + "one" + } else "two" +} \ No newline at end of file diff --git a/idea/testData/codeInsight/codeTransformations/assignmentWithIfExpressionToStatement/nestedIfs.kt.after b/idea/testData/codeInsight/codeTransformations/branched/folding/return/innerIfTransformed.kt similarity index 53% rename from idea/testData/codeInsight/codeTransformations/assignmentWithIfExpressionToStatement/nestedIfs.kt.after rename to idea/testData/codeInsight/codeTransformations/branched/folding/return/innerIfTransformed.kt index f7be6ee23aa..b402a1c2f2d 100644 --- a/idea/testData/codeInsight/codeTransformations/assignmentWithIfExpressionToStatement/nestedIfs.kt.after +++ b/idea/testData/codeInsight/codeTransformations/branched/folding/return/innerIfTransformed.kt @@ -1,21 +1,17 @@ fun test(n: Int): String { - var res: String - - if (n == 1) { - if (3 > 2) { + if (n == 1) { + if (3 > 2) { println("***") - res = "one" + return "one" } else { println("***") - res = "???" + return "???" } } else if (n == 2) { println("***") - res = "two" + return "two" } else { println("***") - res = "too many" + return "too many" } - - return res } \ No newline at end of file diff --git a/idea/testData/codeInsight/codeTransformations/ifStatementWithAssignmentsToExpression/nestedIfs.kt b/idea/testData/codeInsight/codeTransformations/branched/folding/return/innerIfTransformed.kt.after similarity index 53% rename from idea/testData/codeInsight/codeTransformations/ifStatementWithAssignmentsToExpression/nestedIfs.kt rename to idea/testData/codeInsight/codeTransformations/branched/folding/return/innerIfTransformed.kt.after index f7be6ee23aa..bf97963e5f0 100644 --- a/idea/testData/codeInsight/codeTransformations/ifStatementWithAssignmentsToExpression/nestedIfs.kt +++ b/idea/testData/codeInsight/codeTransformations/branched/folding/return/innerIfTransformed.kt.after @@ -1,21 +1,17 @@ fun test(n: Int): String { - var res: String - - if (n == 1) { - if (3 > 2) { + if (n == 1) { + return if (3 > 2) { println("***") - res = "one" + "one" } else { println("***") - res = "???" + "???" } } else if (n == 2) { println("***") - res = "two" + return "two" } else { println("***") - res = "too many" + return "too many" } - - return res } \ No newline at end of file diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/return/innerWhenTransformed.kt b/idea/testData/codeInsight/codeTransformations/branched/folding/return/innerWhenTransformed.kt new file mode 100644 index 00000000000..0a5a8764560 --- /dev/null +++ b/idea/testData/codeInsight/codeTransformations/branched/folding/return/innerWhenTransformed.kt @@ -0,0 +1,11 @@ +fun test(n: Int): String { + if (3 > 2) { + when (n) { + 1 -> return "one" + else -> return "two" + } + } else { + println("***") + return "???" + } +} \ No newline at end of file diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/return/innerWhenTransformed.kt.after b/idea/testData/codeInsight/codeTransformations/branched/folding/return/innerWhenTransformed.kt.after new file mode 100644 index 00000000000..cec7664dbfa --- /dev/null +++ b/idea/testData/codeInsight/codeTransformations/branched/folding/return/innerWhenTransformed.kt.after @@ -0,0 +1,11 @@ +fun test(n: Int): String { + if (3 > 2) { + return when (n) { + 1 -> "one" + else -> "two" + } + } else { + println("***") + return "???" + } +} \ No newline at end of file diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/return/simpleIf.kt b/idea/testData/codeInsight/codeTransformations/branched/folding/return/simpleIf.kt new file mode 100644 index 00000000000..a37ae9c22d3 --- /dev/null +++ b/idea/testData/codeInsight/codeTransformations/branched/folding/return/simpleIf.kt @@ -0,0 +1,6 @@ +fun test(n: Int): String { + if (n == 1) + return "one" + else + return "two" +} \ No newline at end of file diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/return/simpleIf.kt.after b/idea/testData/codeInsight/codeTransformations/branched/folding/return/simpleIf.kt.after new file mode 100644 index 00000000000..d7158b67554 --- /dev/null +++ b/idea/testData/codeInsight/codeTransformations/branched/folding/return/simpleIf.kt.after @@ -0,0 +1,6 @@ +fun test(n: Int): String { + return if (n == 1) + "one" + else + "two" +} \ No newline at end of file diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/return/simpleIfWithBlocks.kt b/idea/testData/codeInsight/codeTransformations/branched/folding/return/simpleIfWithBlocks.kt new file mode 100644 index 00000000000..4a306f5f17d --- /dev/null +++ b/idea/testData/codeInsight/codeTransformations/branched/folding/return/simpleIfWithBlocks.kt @@ -0,0 +1,9 @@ +fun test(n: Int): String { + if (n == 1) { + println("***") + return "one" + } else { + println("***") + return "two" + } +} \ No newline at end of file diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/return/simpleIfWithBlocks.kt.after b/idea/testData/codeInsight/codeTransformations/branched/folding/return/simpleIfWithBlocks.kt.after new file mode 100644 index 00000000000..a88492572b5 --- /dev/null +++ b/idea/testData/codeInsight/codeTransformations/branched/folding/return/simpleIfWithBlocks.kt.after @@ -0,0 +1,9 @@ +fun test(n: Int): String { + return if (n == 1) { + println("***") + "one" + } else { + println("***") + "two" + } +} \ No newline at end of file diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/return/simpleWhen.kt b/idea/testData/codeInsight/codeTransformations/branched/folding/return/simpleWhen.kt new file mode 100644 index 00000000000..09add4b1e81 --- /dev/null +++ b/idea/testData/codeInsight/codeTransformations/branched/folding/return/simpleWhen.kt @@ -0,0 +1,6 @@ +fun test(n: Int): String { + when (n) { + 1 -> return "one" + else -> return "two" + } +} \ No newline at end of file diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/return/simpleWhen.kt.after b/idea/testData/codeInsight/codeTransformations/branched/folding/return/simpleWhen.kt.after new file mode 100644 index 00000000000..83a1dee18ec --- /dev/null +++ b/idea/testData/codeInsight/codeTransformations/branched/folding/return/simpleWhen.kt.after @@ -0,0 +1,6 @@ +fun test(n: Int): String { + return when (n) { + 1 -> "one" + else -> "two" + } +} \ No newline at end of file diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/return/simpleWhenWithBlocks.kt b/idea/testData/codeInsight/codeTransformations/branched/folding/return/simpleWhenWithBlocks.kt new file mode 100644 index 00000000000..1c9b980257f --- /dev/null +++ b/idea/testData/codeInsight/codeTransformations/branched/folding/return/simpleWhenWithBlocks.kt @@ -0,0 +1,11 @@ +fun test(n: Int): String { + when(n) { + 1 -> { + println("***") + return "one" + } + else -> { + println("***") + return "two" + } +} \ No newline at end of file diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/return/simpleWhenWithBlocks.kt.after b/idea/testData/codeInsight/codeTransformations/branched/folding/return/simpleWhenWithBlocks.kt.after new file mode 100644 index 00000000000..5565cdc2ecd --- /dev/null +++ b/idea/testData/codeInsight/codeTransformations/branched/folding/return/simpleWhenWithBlocks.kt.after @@ -0,0 +1,11 @@ +fun test(n: Int): String { + return when(n) { + 1 -> { + println("***") + "one" + } + else -> { + println("***") + "two" + } +} \ No newline at end of file diff --git a/idea/testData/codeInsight/codeTransformations/assignmentWithIfExpressionToStatement/innerIfTransformed.kt b/idea/testData/codeInsight/codeTransformations/branched/unfolding/assignment/innerIfTransformed.kt similarity index 100% rename from idea/testData/codeInsight/codeTransformations/assignmentWithIfExpressionToStatement/innerIfTransformed.kt rename to idea/testData/codeInsight/codeTransformations/branched/unfolding/assignment/innerIfTransformed.kt diff --git a/idea/testData/codeInsight/codeTransformations/assignmentWithIfExpressionToStatement/innerIfTransformed.kt.after b/idea/testData/codeInsight/codeTransformations/branched/unfolding/assignment/innerIfTransformed.kt.after similarity index 100% rename from idea/testData/codeInsight/codeTransformations/assignmentWithIfExpressionToStatement/innerIfTransformed.kt.after rename to idea/testData/codeInsight/codeTransformations/branched/unfolding/assignment/innerIfTransformed.kt.after diff --git a/idea/testData/codeInsight/codeTransformations/assignmentWithIfExpressionToStatement/nestedIfs.kt b/idea/testData/codeInsight/codeTransformations/branched/unfolding/assignment/nestedIfs.kt similarity index 100% rename from idea/testData/codeInsight/codeTransformations/assignmentWithIfExpressionToStatement/nestedIfs.kt rename to idea/testData/codeInsight/codeTransformations/branched/unfolding/assignment/nestedIfs.kt diff --git a/idea/testData/codeInsight/codeTransformations/ifStatementWithAssignmentsToExpression/nestedIfs.kt.after b/idea/testData/codeInsight/codeTransformations/branched/unfolding/assignment/nestedIfs.kt.after similarity index 77% rename from idea/testData/codeInsight/codeTransformations/ifStatementWithAssignmentsToExpression/nestedIfs.kt.after rename to idea/testData/codeInsight/codeTransformations/branched/unfolding/assignment/nestedIfs.kt.after index d5ae1e4a2b0..a4f680c426d 100644 --- a/idea/testData/codeInsight/codeTransformations/ifStatementWithAssignmentsToExpression/nestedIfs.kt.after +++ b/idea/testData/codeInsight/codeTransformations/branched/unfolding/assignment/nestedIfs.kt.after @@ -1,15 +1,15 @@ fun test(n: Int): String { var res: String - res = if (n == 1) { - if (3 > 2) { + if (n == 1) { + res = if (3 > 2) { println("***") "one" } else { println("***") "???" } - } else if (n == 2) { + } else res = if (n == 2) { println("***") "two" } else { diff --git a/idea/testData/codeInsight/codeTransformations/branched/unfolding/assignment/simpleIf.kt b/idea/testData/codeInsight/codeTransformations/branched/unfolding/assignment/simpleIf.kt new file mode 100644 index 00000000000..2270e195d3e --- /dev/null +++ b/idea/testData/codeInsight/codeTransformations/branched/unfolding/assignment/simpleIf.kt @@ -0,0 +1,7 @@ +fun test(n: Int): String { + var res: String + + res = if (n == 1) "one" else "two" + + return res +} \ No newline at end of file diff --git a/idea/testData/codeInsight/codeTransformations/branched/unfolding/assignment/simpleIf.kt.after b/idea/testData/codeInsight/codeTransformations/branched/unfolding/assignment/simpleIf.kt.after new file mode 100644 index 00000000000..b35ea7a79dc --- /dev/null +++ b/idea/testData/codeInsight/codeTransformations/branched/unfolding/assignment/simpleIf.kt.after @@ -0,0 +1,7 @@ +fun test(n: Int): String { + var res: String + + if (n == 1) res = "one" else res = "two" + + return res +} \ No newline at end of file diff --git a/idea/testData/codeInsight/codeTransformations/branched/unfolding/assignment/simpleIfWithAugmentedAssignment.kt b/idea/testData/codeInsight/codeTransformations/branched/unfolding/assignment/simpleIfWithAugmentedAssignment.kt new file mode 100644 index 00000000000..bdd35f4f302 --- /dev/null +++ b/idea/testData/codeInsight/codeTransformations/branched/unfolding/assignment/simpleIfWithAugmentedAssignment.kt @@ -0,0 +1,7 @@ +fun test(n: Int): String { + var res: String = "!" + + res += if (n == 1) "one" else "two" + + return res +} \ No newline at end of file diff --git a/idea/testData/codeInsight/codeTransformations/branched/unfolding/assignment/simpleIfWithAugmentedAssignment.kt.after b/idea/testData/codeInsight/codeTransformations/branched/unfolding/assignment/simpleIfWithAugmentedAssignment.kt.after new file mode 100644 index 00000000000..ccd31de0a4b --- /dev/null +++ b/idea/testData/codeInsight/codeTransformations/branched/unfolding/assignment/simpleIfWithAugmentedAssignment.kt.after @@ -0,0 +1,7 @@ +fun test(n: Int): String { + var res: String = "!" + + if (n == 1) res += "one" else res += "two" + + return res +} \ No newline at end of file diff --git a/idea/testData/codeInsight/codeTransformations/ifStatementWithAssignmentsToExpression/simpleIf.kt.after b/idea/testData/codeInsight/codeTransformations/branched/unfolding/assignment/simpleIfWithBlocks.kt similarity index 100% rename from idea/testData/codeInsight/codeTransformations/ifStatementWithAssignmentsToExpression/simpleIf.kt.after rename to idea/testData/codeInsight/codeTransformations/branched/unfolding/assignment/simpleIfWithBlocks.kt diff --git a/idea/testData/codeInsight/codeTransformations/ifStatementWithAssignmentsToExpression/simpleIf.kt b/idea/testData/codeInsight/codeTransformations/branched/unfolding/assignment/simpleIfWithBlocks.kt.after similarity index 100% rename from idea/testData/codeInsight/codeTransformations/ifStatementWithAssignmentsToExpression/simpleIf.kt rename to idea/testData/codeInsight/codeTransformations/branched/unfolding/assignment/simpleIfWithBlocks.kt.after diff --git a/idea/testData/codeInsight/codeTransformations/assignmentWithIfExpressionToStatement/simpleIfWithoutAssignment.kt b/idea/testData/codeInsight/codeTransformations/branched/unfolding/assignment/simpleIfWithoutAssignment.kt similarity index 100% rename from idea/testData/codeInsight/codeTransformations/assignmentWithIfExpressionToStatement/simpleIfWithoutAssignment.kt rename to idea/testData/codeInsight/codeTransformations/branched/unfolding/assignment/simpleIfWithoutAssignment.kt diff --git a/idea/testData/codeInsight/codeTransformations/branched/unfolding/asymmetricReturn/simpleIf.kt b/idea/testData/codeInsight/codeTransformations/branched/unfolding/asymmetricReturn/simpleIf.kt new file mode 100644 index 00000000000..741973c35c6 --- /dev/null +++ b/idea/testData/codeInsight/codeTransformations/branched/unfolding/asymmetricReturn/simpleIf.kt @@ -0,0 +1,3 @@ +fun test(n: Int): String { + return if (n == 1) "one" else "two" +} \ No newline at end of file diff --git a/idea/testData/codeInsight/codeTransformations/branched/unfolding/asymmetricReturn/simpleIf.kt.after b/idea/testData/codeInsight/codeTransformations/branched/unfolding/asymmetricReturn/simpleIf.kt.after new file mode 100644 index 00000000000..28edafffc4f --- /dev/null +++ b/idea/testData/codeInsight/codeTransformations/branched/unfolding/asymmetricReturn/simpleIf.kt.after @@ -0,0 +1,3 @@ +fun test(n: Int): String { + if (n == 1) return "one" else return "two" +} \ No newline at end of file diff --git a/idea/testData/codeInsight/codeTransformations/branched/unfolding/asymmetricReturn/simpleIfWithBlocks.kt b/idea/testData/codeInsight/codeTransformations/branched/unfolding/asymmetricReturn/simpleIfWithBlocks.kt new file mode 100644 index 00000000000..5777e6c7ac1 --- /dev/null +++ b/idea/testData/codeInsight/codeTransformations/branched/unfolding/asymmetricReturn/simpleIfWithBlocks.kt @@ -0,0 +1,6 @@ +fun test(n: Int): String { + return if (n == 1) { + println("***") + "one" + } else "two" +} \ No newline at end of file diff --git a/idea/testData/codeInsight/codeTransformations/branched/unfolding/asymmetricReturn/simpleIfWithBlocks.kt.after b/idea/testData/codeInsight/codeTransformations/branched/unfolding/asymmetricReturn/simpleIfWithBlocks.kt.after new file mode 100644 index 00000000000..d750043923c --- /dev/null +++ b/idea/testData/codeInsight/codeTransformations/branched/unfolding/asymmetricReturn/simpleIfWithBlocks.kt.after @@ -0,0 +1,6 @@ +fun test(n: Int): String { + if (n == 1) { + println("***") + return "one" + } else return "two" +} \ No newline at end of file diff --git a/idea/testData/codeInsight/codeTransformations/branched/unfolding/return/innerIfTransformed.kt b/idea/testData/codeInsight/codeTransformations/branched/unfolding/return/innerIfTransformed.kt new file mode 100644 index 00000000000..bf97963e5f0 --- /dev/null +++ b/idea/testData/codeInsight/codeTransformations/branched/unfolding/return/innerIfTransformed.kt @@ -0,0 +1,17 @@ +fun test(n: Int): String { + if (n == 1) { + return if (3 > 2) { + println("***") + "one" + } else { + println("***") + "???" + } + } else if (n == 2) { + println("***") + return "two" + } else { + println("***") + return "too many" + } +} \ No newline at end of file diff --git a/idea/testData/codeInsight/codeTransformations/branched/unfolding/return/innerIfTransformed.kt.after b/idea/testData/codeInsight/codeTransformations/branched/unfolding/return/innerIfTransformed.kt.after new file mode 100644 index 00000000000..b402a1c2f2d --- /dev/null +++ b/idea/testData/codeInsight/codeTransformations/branched/unfolding/return/innerIfTransformed.kt.after @@ -0,0 +1,17 @@ +fun test(n: Int): String { + if (n == 1) { + if (3 > 2) { + println("***") + return "one" + } else { + println("***") + return "???" + } + } else if (n == 2) { + println("***") + return "two" + } else { + println("***") + return "too many" + } +} \ No newline at end of file diff --git a/idea/testData/codeInsight/codeTransformations/branched/unfolding/return/simpleIf.kt b/idea/testData/codeInsight/codeTransformations/branched/unfolding/return/simpleIf.kt new file mode 100644 index 00000000000..ab784e48446 --- /dev/null +++ b/idea/testData/codeInsight/codeTransformations/branched/unfolding/return/simpleIf.kt @@ -0,0 +1,6 @@ +fun test(n: Int): String { + return if (n == 1) + "one" + else + "two" +} \ No newline at end of file diff --git a/idea/testData/codeInsight/codeTransformations/branched/unfolding/return/simpleIf.kt.after b/idea/testData/codeInsight/codeTransformations/branched/unfolding/return/simpleIf.kt.after new file mode 100644 index 00000000000..588394bf7fd --- /dev/null +++ b/idea/testData/codeInsight/codeTransformations/branched/unfolding/return/simpleIf.kt.after @@ -0,0 +1,6 @@ +fun test(n: Int): String { + if (n == 1) + return "one" + else + return "two" +} \ No newline at end of file diff --git a/idea/testData/codeInsight/codeTransformations/branched/unfolding/return/simpleIfWithBlocks.kt b/idea/testData/codeInsight/codeTransformations/branched/unfolding/return/simpleIfWithBlocks.kt new file mode 100644 index 00000000000..a88492572b5 --- /dev/null +++ b/idea/testData/codeInsight/codeTransformations/branched/unfolding/return/simpleIfWithBlocks.kt @@ -0,0 +1,9 @@ +fun test(n: Int): String { + return if (n == 1) { + println("***") + "one" + } else { + println("***") + "two" + } +} \ No newline at end of file diff --git a/idea/testData/codeInsight/codeTransformations/branched/unfolding/return/simpleIfWithBlocks.kt.after b/idea/testData/codeInsight/codeTransformations/branched/unfolding/return/simpleIfWithBlocks.kt.after new file mode 100644 index 00000000000..4a306f5f17d --- /dev/null +++ b/idea/testData/codeInsight/codeTransformations/branched/unfolding/return/simpleIfWithBlocks.kt.after @@ -0,0 +1,9 @@ +fun test(n: Int): String { + if (n == 1) { + println("***") + return "one" + } else { + println("***") + return "two" + } +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/jet/plugin/codeInsight/codeTransformations/CodeTransformationsTestGenerated.java b/idea/tests/org/jetbrains/jet/plugin/codeInsight/codeTransformations/CodeTransformationsTestGenerated.java index 5241ce2fe83..fb13ee13277 100644 --- a/idea/tests/org/jetbrains/jet/plugin/codeInsight/codeTransformations/CodeTransformationsTestGenerated.java +++ b/idea/tests/org/jetbrains/jet/plugin/codeInsight/codeTransformations/CodeTransformationsTestGenerated.java @@ -30,7 +30,7 @@ import org.jetbrains.jet.plugin.codeInsight.codeTransformations.AbstractCodeTran /** This class is generated by {@link org.jetbrains.jet.generators.tests.GenerateTests}. DO NOT MODIFY MANUALLY */ @SuppressWarnings("all") -@InnerTestClasses({CodeTransformationsTestGenerated.IfStatementWithAssignmentsToExpression.class, CodeTransformationsTestGenerated.AssignmentWithIfExpressionToStatement.class, CodeTransformationsTestGenerated.RemoveUnnecessaryParentheses.class}) +@InnerTestClasses({CodeTransformationsTestGenerated.IfStatementWithAssignmentsToExpression.class, CodeTransformationsTestGenerated.AssignmentWithIfExpressionToStatement.class}) public class CodeTransformationsTestGenerated extends AbstractCodeTransformationTest { @TestMetadata("idea/testData/codeInsight/codeTransformations/ifStatementWithAssignmentsToExpression") public static class IfStatementWithAssignmentsToExpression extends AbstractCodeTransformationTest {