diff --git a/generators/org/jetbrains/jet/generators/tests/GenerateTests.java b/generators/org/jetbrains/jet/generators/tests/GenerateTests.java
index 8049091a2a3..25e534362f2 100644
--- a/generators/org/jetbrains/jet/generators/tests/GenerateTests.java
+++ b/generators/org/jetbrains/jet/generators/tests/GenerateTests.java
@@ -305,8 +305,15 @@ public class GenerateTests {
"idea/tests/",
"CodeTransformationsTestGenerated",
AbstractCodeTransformationTest.class,
- testModel("idea/testData/codeInsight/codeTransformations/ifStatementWithAssignmentsToExpression", "doTestIfStatementWithAssignmentsToExpression"),
- testModel("idea/testData/codeInsight/codeTransformations/assignmentWithIfExpressionToStatement", "doTestAssignmentWithIfExpressionToStatement")
+ testModel("idea/testData/codeInsight/codeTransformations/branched/folding/ifToAssignment", "doTestFoldIfToAssignment"),
+ testModel("idea/testData/codeInsight/codeTransformations/branched/folding/ifToReturn", "doTestFoldIfToReturn"),
+ testModel("idea/testData/codeInsight/codeTransformations/branched/folding/ifToReturnAsymmetrically", "doTestFoldIfToReturnAsymmetrically"),
+ testModel("idea/testData/codeInsight/codeTransformations/branched/folding/whenToAssignment", "doTestFoldWhenToAssignment"),
+ testModel("idea/testData/codeInsight/codeTransformations/branched/folding/whenToReturn", "doTestFoldWhenToReturn"),
+ testModel("idea/testData/codeInsight/codeTransformations/branched/unfolding/assignmentToIf", "doTestUnfoldAssignmentToIf"),
+ testModel("idea/testData/codeInsight/codeTransformations/branched/unfolding/assignmentToWhen", "doTestUnfoldAssignmentToWhen"),
+ testModel("idea/testData/codeInsight/codeTransformations/branched/unfolding/returnToIf", "doTestUnfoldReturnToIf"),
+ testModel("idea/testData/codeInsight/codeTransformations/branched/unfolding/returnToWhen", "doTestUnfoldReturnToWhen")
);
generateTest(
diff --git a/idea/resources/intentionDescriptions/FoldBranchedExpressionIntention/after.kt.template b/idea/resources/intentionDescriptions/FoldBranchedExpressionIntention/after.kt.template
deleted file mode 100644
index 2a07dd895ee..00000000000
--- a/idea/resources/intentionDescriptions/FoldBranchedExpressionIntention/after.kt.template
+++ /dev/null
@@ -1,7 +0,0 @@
-res = if (n == 1) {
- println("***")
- "one"
-} else {
- println("***")
- "two"
-}
\ No newline at end of file
diff --git a/idea/resources/intentionDescriptions/FoldBranchedExpressionIntention/before.kt.template b/idea/resources/intentionDescriptions/FoldBranchedExpressionIntention/before.kt.template
deleted file mode 100644
index e61b2e5599b..00000000000
--- a/idea/resources/intentionDescriptions/FoldBranchedExpressionIntention/before.kt.template
+++ /dev/null
@@ -1,7 +0,0 @@
-if (n == 1) {
- println("***")
- res = "one"
-} else {
- println("***")
- res = "two"
-}
\ No newline at end of file
diff --git a/idea/resources/intentionDescriptions/FoldBranchedExpressionIntention/description.html b/idea/resources/intentionDescriptions/FoldBranchedExpressionIntention/description.html
deleted file mode 100644
index 256249f1e15..00000000000
--- a/idea/resources/intentionDescriptions/FoldBranchedExpressionIntention/description.html
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-This intention converts branched (if/when) expression where each branch is terminated with assignment/return/method call into single
-assignment/return/method call with branched expression as argument
-
-
\ No newline at end of file
diff --git a/idea/resources/intentionDescriptions/FoldIfToAssignmentIntention/after.kt.template b/idea/resources/intentionDescriptions/FoldIfToAssignmentIntention/after.kt.template
new file mode 100644
index 00000000000..81e1d86690b
--- /dev/null
+++ b/idea/resources/intentionDescriptions/FoldIfToAssignmentIntention/after.kt.template
@@ -0,0 +1,5 @@
+res = if (ok) {
+ "ok"
+} else {
+ "failed"
+}
\ No newline at end of file
diff --git a/idea/resources/intentionDescriptions/FoldIfToAssignmentIntention/before.kt.template b/idea/resources/intentionDescriptions/FoldIfToAssignmentIntention/before.kt.template
new file mode 100644
index 00000000000..03c87bc1010
--- /dev/null
+++ b/idea/resources/intentionDescriptions/FoldIfToAssignmentIntention/before.kt.template
@@ -0,0 +1,5 @@
+if (ok) {
+ res = "ok"
+} else {
+ res = "failed"
+}
\ No newline at end of file
diff --git a/idea/resources/intentionDescriptions/FoldIfToAssignmentIntention/description.html b/idea/resources/intentionDescriptions/FoldIfToAssignmentIntention/description.html
new file mode 100644
index 00000000000..9a581e4ade0
--- /dev/null
+++ b/idea/resources/intentionDescriptions/FoldIfToAssignmentIntention/description.html
@@ -0,0 +1,5 @@
+
+
+This intention converts 'if' expression where each branch is terminated with assignment into a single assignment with 'if' expression as a right-hand side
+
+
\ No newline at end of file
diff --git a/idea/resources/intentionDescriptions/FoldIfToReturnAsymmetricallyIntention/after.kt.template b/idea/resources/intentionDescriptions/FoldIfToReturnAsymmetricallyIntention/after.kt.template
new file mode 100644
index 00000000000..20fcc992c5d
--- /dev/null
+++ b/idea/resources/intentionDescriptions/FoldIfToReturnAsymmetricallyIntention/after.kt.template
@@ -0,0 +1,3 @@
+return if (ok) {
+ "ok"
+} else "failed"
\ No newline at end of file
diff --git a/idea/resources/intentionDescriptions/FoldIfToReturnAsymmetricallyIntention/before.kt.template b/idea/resources/intentionDescriptions/FoldIfToReturnAsymmetricallyIntention/before.kt.template
new file mode 100644
index 00000000000..ef72374d66c
--- /dev/null
+++ b/idea/resources/intentionDescriptions/FoldIfToReturnAsymmetricallyIntention/before.kt.template
@@ -0,0 +1,4 @@
+if (ok) {
+ return "ok"
+}
+return "failed"
\ No newline at end of file
diff --git a/idea/resources/intentionDescriptions/FoldIfToReturnAsymmetricallyIntention/description.html b/idea/resources/intentionDescriptions/FoldIfToReturnAsymmetricallyIntention/description.html
new file mode 100644
index 00000000000..d1df2972fb1
--- /dev/null
+++ b/idea/resources/intentionDescriptions/FoldIfToReturnAsymmetricallyIntention/description.html
@@ -0,0 +1,5 @@
+
+
+This intention converts single-branch 'if' expression immediately followed by 'return' into a single 'return' with 'if' expression as an argument
+
+
\ No newline at end of file
diff --git a/idea/resources/intentionDescriptions/FoldIfToReturnIntention/after.kt.template b/idea/resources/intentionDescriptions/FoldIfToReturnIntention/after.kt.template
new file mode 100644
index 00000000000..0394cfc84c6
--- /dev/null
+++ b/idea/resources/intentionDescriptions/FoldIfToReturnIntention/after.kt.template
@@ -0,0 +1,5 @@
+return if (ok) {
+ "ok"
+} else {
+ "failed"
+}
\ No newline at end of file
diff --git a/idea/resources/intentionDescriptions/FoldIfToReturnIntention/before.kt.template b/idea/resources/intentionDescriptions/FoldIfToReturnIntention/before.kt.template
new file mode 100644
index 00000000000..2cdc1aaaa9f
--- /dev/null
+++ b/idea/resources/intentionDescriptions/FoldIfToReturnIntention/before.kt.template
@@ -0,0 +1,5 @@
+if (ok) {
+ return "ok"
+} else {
+ return "failed"
+}
\ No newline at end of file
diff --git a/idea/resources/intentionDescriptions/FoldIfToReturnIntention/description.html b/idea/resources/intentionDescriptions/FoldIfToReturnIntention/description.html
new file mode 100644
index 00000000000..e700394d8ff
--- /dev/null
+++ b/idea/resources/intentionDescriptions/FoldIfToReturnIntention/description.html
@@ -0,0 +1,5 @@
+
+
+This intention converts 'if' expression where each branch is terminated with 'return' into a single 'return' with 'if' expression as a right-hand side
+
+
\ No newline at end of file
diff --git a/idea/resources/intentionDescriptions/FoldWhenToAssignmentIntention/after.kt.template b/idea/resources/intentionDescriptions/FoldWhenToAssignmentIntention/after.kt.template
new file mode 100644
index 00000000000..12ecbd93619
--- /dev/null
+++ b/idea/resources/intentionDescriptions/FoldWhenToAssignmentIntention/after.kt.template
@@ -0,0 +1,5 @@
+res = when (n) {
+ 1 -> "one"
+ 2 -> "two"
+ else -> "many"
+}
\ No newline at end of file
diff --git a/idea/resources/intentionDescriptions/FoldWhenToAssignmentIntention/before.kt.template b/idea/resources/intentionDescriptions/FoldWhenToAssignmentIntention/before.kt.template
new file mode 100644
index 00000000000..a059e3024f7
--- /dev/null
+++ b/idea/resources/intentionDescriptions/FoldWhenToAssignmentIntention/before.kt.template
@@ -0,0 +1,5 @@
+when (n) {
+ 1 -> res = "one"
+ 2 -> res = "two"
+ else -> res = "many"
+}
\ No newline at end of file
diff --git a/idea/resources/intentionDescriptions/FoldWhenToAssignmentIntention/description.html b/idea/resources/intentionDescriptions/FoldWhenToAssignmentIntention/description.html
new file mode 100644
index 00000000000..d90211f6b50
--- /dev/null
+++ b/idea/resources/intentionDescriptions/FoldWhenToAssignmentIntention/description.html
@@ -0,0 +1,5 @@
+
+
+This intention converts 'when' expression where each branch is terminated with assignment into a single assignment with 'when' expression as right-hand side
+
+
\ No newline at end of file
diff --git a/idea/resources/intentionDescriptions/FoldWhenToReturnIntention/after.kt.template b/idea/resources/intentionDescriptions/FoldWhenToReturnIntention/after.kt.template
new file mode 100644
index 00000000000..ec9b48b8a9b
--- /dev/null
+++ b/idea/resources/intentionDescriptions/FoldWhenToReturnIntention/after.kt.template
@@ -0,0 +1,5 @@
+return when (n) {
+ 1 -> "one"
+ 2 -> "two"
+ else -> "many"
+}
\ No newline at end of file
diff --git a/idea/resources/intentionDescriptions/FoldWhenToReturnIntention/before.kt.template b/idea/resources/intentionDescriptions/FoldWhenToReturnIntention/before.kt.template
new file mode 100644
index 00000000000..9ea6721ea13
--- /dev/null
+++ b/idea/resources/intentionDescriptions/FoldWhenToReturnIntention/before.kt.template
@@ -0,0 +1,5 @@
+when (n) {
+ 1 -> return "one"
+ 2 -> return "two"
+ else -> return "many"
+}
\ No newline at end of file
diff --git a/idea/resources/intentionDescriptions/FoldWhenToReturnIntention/description.html b/idea/resources/intentionDescriptions/FoldWhenToReturnIntention/description.html
new file mode 100644
index 00000000000..1101f0ea527
--- /dev/null
+++ b/idea/resources/intentionDescriptions/FoldWhenToReturnIntention/description.html
@@ -0,0 +1,5 @@
+
+
+This intention converts 'when' expression where each branch is terminated with 'return' into a single 'return' with 'when' expression as a right-hand side
+
+
\ No newline at end of file
diff --git a/idea/resources/intentionDescriptions/UnfoldAssignmentToIfIntention/after.kt.template b/idea/resources/intentionDescriptions/UnfoldAssignmentToIfIntention/after.kt.template
new file mode 100644
index 00000000000..03c87bc1010
--- /dev/null
+++ b/idea/resources/intentionDescriptions/UnfoldAssignmentToIfIntention/after.kt.template
@@ -0,0 +1,5 @@
+if (ok) {
+ res = "ok"
+} else {
+ res = "failed"
+}
\ No newline at end of file
diff --git a/idea/resources/intentionDescriptions/UnfoldAssignmentToIfIntention/before.kt.template b/idea/resources/intentionDescriptions/UnfoldAssignmentToIfIntention/before.kt.template
new file mode 100644
index 00000000000..81e1d86690b
--- /dev/null
+++ b/idea/resources/intentionDescriptions/UnfoldAssignmentToIfIntention/before.kt.template
@@ -0,0 +1,5 @@
+res = if (ok) {
+ "ok"
+} else {
+ "failed"
+}
\ No newline at end of file
diff --git a/idea/resources/intentionDescriptions/UnfoldAssignmentToIfIntention/description.html b/idea/resources/intentionDescriptions/UnfoldAssignmentToIfIntention/description.html
new file mode 100644
index 00000000000..0491b178023
--- /dev/null
+++ b/idea/resources/intentionDescriptions/UnfoldAssignmentToIfIntention/description.html
@@ -0,0 +1,5 @@
+
+
+This intention converts assignment with 'if' right-hand side to 'if' expression where each branch is terminated with assignment
+
+
\ No newline at end of file
diff --git a/idea/resources/intentionDescriptions/UnfoldAssignmentToWhenIntention/after.kt.template b/idea/resources/intentionDescriptions/UnfoldAssignmentToWhenIntention/after.kt.template
new file mode 100644
index 00000000000..a059e3024f7
--- /dev/null
+++ b/idea/resources/intentionDescriptions/UnfoldAssignmentToWhenIntention/after.kt.template
@@ -0,0 +1,5 @@
+when (n) {
+ 1 -> res = "one"
+ 2 -> res = "two"
+ else -> res = "many"
+}
\ No newline at end of file
diff --git a/idea/resources/intentionDescriptions/UnfoldAssignmentToWhenIntention/before.kt.template b/idea/resources/intentionDescriptions/UnfoldAssignmentToWhenIntention/before.kt.template
new file mode 100644
index 00000000000..12ecbd93619
--- /dev/null
+++ b/idea/resources/intentionDescriptions/UnfoldAssignmentToWhenIntention/before.kt.template
@@ -0,0 +1,5 @@
+res = when (n) {
+ 1 -> "one"
+ 2 -> "two"
+ else -> "many"
+}
\ No newline at end of file
diff --git a/idea/resources/intentionDescriptions/UnfoldAssignmentToWhenIntention/description.html b/idea/resources/intentionDescriptions/UnfoldAssignmentToWhenIntention/description.html
new file mode 100644
index 00000000000..5c034ae4b11
--- /dev/null
+++ b/idea/resources/intentionDescriptions/UnfoldAssignmentToWhenIntention/description.html
@@ -0,0 +1,5 @@
+
+
+This intention converts assignment with 'when' right-hand side to 'when' expression where each branch is terminated with assignment
+
+
\ No newline at end of file
diff --git a/idea/resources/intentionDescriptions/UnfoldBranchedExpressionIntention/after.kt.template b/idea/resources/intentionDescriptions/UnfoldBranchedExpressionIntention/after.kt.template
deleted file mode 100644
index e61b2e5599b..00000000000
--- a/idea/resources/intentionDescriptions/UnfoldBranchedExpressionIntention/after.kt.template
+++ /dev/null
@@ -1,7 +0,0 @@
-if (n == 1) {
- println("***")
- res = "one"
-} else {
- println("***")
- res = "two"
-}
\ No newline at end of file
diff --git a/idea/resources/intentionDescriptions/UnfoldBranchedExpressionIntention/before.kt.template b/idea/resources/intentionDescriptions/UnfoldBranchedExpressionIntention/before.kt.template
deleted file mode 100644
index 2a07dd895ee..00000000000
--- a/idea/resources/intentionDescriptions/UnfoldBranchedExpressionIntention/before.kt.template
+++ /dev/null
@@ -1,7 +0,0 @@
-res = if (n == 1) {
- println("***")
- "one"
-} else {
- println("***")
- "two"
-}
\ No newline at end of file
diff --git a/idea/resources/intentionDescriptions/UnfoldBranchedExpressionIntention/description.html b/idea/resources/intentionDescriptions/UnfoldBranchedExpressionIntention/description.html
deleted file mode 100644
index e130de78a1b..00000000000
--- a/idea/resources/intentionDescriptions/UnfoldBranchedExpressionIntention/description.html
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-This intention converts assignment/return/method call with branched (if/when) expression as argument
-to branched expression where each branch is terminated with assignment/return/method call
-
-
\ No newline at end of file
diff --git a/idea/resources/intentionDescriptions/UnfoldReturnToIfIntention/after.kt.template b/idea/resources/intentionDescriptions/UnfoldReturnToIfIntention/after.kt.template
new file mode 100644
index 00000000000..2cdc1aaaa9f
--- /dev/null
+++ b/idea/resources/intentionDescriptions/UnfoldReturnToIfIntention/after.kt.template
@@ -0,0 +1,5 @@
+if (ok) {
+ return "ok"
+} else {
+ return "failed"
+}
\ No newline at end of file
diff --git a/idea/resources/intentionDescriptions/UnfoldReturnToIfIntention/before.kt.template b/idea/resources/intentionDescriptions/UnfoldReturnToIfIntention/before.kt.template
new file mode 100644
index 00000000000..0394cfc84c6
--- /dev/null
+++ b/idea/resources/intentionDescriptions/UnfoldReturnToIfIntention/before.kt.template
@@ -0,0 +1,5 @@
+return if (ok) {
+ "ok"
+} else {
+ "failed"
+}
\ No newline at end of file
diff --git a/idea/resources/intentionDescriptions/UnfoldReturnToIfIntention/description.html b/idea/resources/intentionDescriptions/UnfoldReturnToIfIntention/description.html
new file mode 100644
index 00000000000..b6ed03a21f3
--- /dev/null
+++ b/idea/resources/intentionDescriptions/UnfoldReturnToIfIntention/description.html
@@ -0,0 +1,5 @@
+
+
+This intention converts 'return' with 'if' expression as a result to 'if' expression where each branch is terminated with 'return'
+
+
\ No newline at end of file
diff --git a/idea/resources/intentionDescriptions/UnfoldReturnToWhenIntention/after.kt.template b/idea/resources/intentionDescriptions/UnfoldReturnToWhenIntention/after.kt.template
new file mode 100644
index 00000000000..9ea6721ea13
--- /dev/null
+++ b/idea/resources/intentionDescriptions/UnfoldReturnToWhenIntention/after.kt.template
@@ -0,0 +1,5 @@
+when (n) {
+ 1 -> return "one"
+ 2 -> return "two"
+ else -> return "many"
+}
\ No newline at end of file
diff --git a/idea/resources/intentionDescriptions/UnfoldReturnToWhenIntention/before.kt.template b/idea/resources/intentionDescriptions/UnfoldReturnToWhenIntention/before.kt.template
new file mode 100644
index 00000000000..ec9b48b8a9b
--- /dev/null
+++ b/idea/resources/intentionDescriptions/UnfoldReturnToWhenIntention/before.kt.template
@@ -0,0 +1,5 @@
+return when (n) {
+ 1 -> "one"
+ 2 -> "two"
+ else -> "many"
+}
\ No newline at end of file
diff --git a/idea/resources/intentionDescriptions/UnfoldReturnToWhenIntention/description.html b/idea/resources/intentionDescriptions/UnfoldReturnToWhenIntention/description.html
new file mode 100644
index 00000000000..d28fc706aa2
--- /dev/null
+++ b/idea/resources/intentionDescriptions/UnfoldReturnToWhenIntention/description.html
@@ -0,0 +1,5 @@
+
+
+This intention converts 'return' with 'when' expression as a result to 'when' expression where each branch is terminated with 'return'
+
+
\ No newline at end of file
diff --git a/idea/src/META-INF/plugin.xml b/idea/src/META-INF/plugin.xml
index abc42486aad..56dd14cd602 100644
--- a/idea/src/META-INF/plugin.xml
+++ b/idea/src/META-INF/plugin.xml
@@ -292,12 +292,47 @@
- org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.FoldBranchedExpressionIntention
+ org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.intentions.FoldIfToAssignmentIntention
Kotlin
- org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.UnfoldBranchedExpressionIntention
+ org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.intentions.FoldIfToReturnAsymmetricallyIntention
+ Kotlin
+
+
+
+ org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.intentions.FoldIfToReturnIntention
+ Kotlin
+
+
+
+ org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.intentions.FoldWhenToAssignmentIntention
+ Kotlin
+
+
+
+ org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.intentions.FoldWhenToReturnIntention
+ Kotlin
+
+
+
+ org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.intentions.UnfoldAssignmentToIfIntention
+ Kotlin
+
+
+
+ org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.intentions.UnfoldAssignmentToWhenIntention
+ Kotlin
+
+
+
+ org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.intentions.UnfoldReturnToIfIntention
+ Kotlin
+
+
+
+ org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.intentions.UnfoldReturnToWhenIntention
Kotlin
diff --git a/idea/src/org/jetbrains/jet/plugin/JetBundle.properties b/idea/src/org/jetbrains/jet/plugin/JetBundle.properties
index 4447e0f40c9..39c51b4092c 100644
--- a/idea/src/org/jetbrains/jet/plugin/JetBundle.properties
+++ b/idea/src/org/jetbrains/jet/plugin/JetBundle.properties
@@ -152,6 +152,30 @@ surround.with.cannot.perform.action=Cannot perform Surround With action to the c
remove.variable.family.name=Remove variable
remove.variable.action=Remove variable ''{0}''
kotlin.code.transformations=Kotlin Code Transformations
+fold.if.to.assignment=Replace 'if' expression with assignment
+fold.if.to.assignment.family=Replace 'if' Expression with Assignment
+fold.if.to.return=Replace 'if' expression with return
+fold.if.to.return.family=Replace 'if' Expression with Return
+fold.if.to.call=Replace 'if' expression with method call
+fold.if.to.call.family=Replace 'if' Expression with Method Call
+fold.when.to.assignment=Replace 'when' expression with assignment
+fold.when.to.assignment.family=Replace 'when' Expression with Assignment
+fold.when.to.return=Replace 'when' expression with return
+fold.when.to.return.family=Replace 'when' Expression with Return
+fold.when.to.call=Replace 'when' expression with method call
+fold.when.to.call.family=Replace 'when' Expression with Method Call
+unfold.assignment.to.if=Replace assignment with 'if' expression
+unfold.assignment.to.if.family=Replace Assignment with 'if' Expression
+unfold.return.to.if=Replace return with 'if' expression
+unfold.return.to.if.family=Replace Return with 'if' Expression
+unfold.call.to.if=Replace method call with 'if' expression
+unfold.call.to.if.family=Replace Method Call with 'if' Expression
+unfold.assignment.to.when=Replace assignment with 'when' expression
+unfold.assignment.to.when.family=Replace Assignment with 'when' Expression
+unfold.return.to.when=Replace return with 'when' expression
+unfold.return.to.when.family=Replace Return with 'when' Expression
+unfold.call.to.when=Replace method call with 'when' expression
+unfold.call.to.when.family=Replace Method Call with 'when' Expressiontransform.if.statement.with.assignments.to.expression=Transform 'if' statement with assignments to expression
transform.if.statement.with.assignments.to.expression=Transform 'if' statement with assignments to expression
transform.assignment.with.if.expression.to.statement=Transform assignment with 'if' expression to statement
transform.if.statement.with.assignments.to.expression.family=Transform 'if' Statement with Assignments to Expression
diff --git a/idea/src/org/jetbrains/jet/plugin/codeInsight/codeTransformations/branchedTransformations/FoldBranchedExpressionIntention.java b/idea/src/org/jetbrains/jet/plugin/codeInsight/codeTransformations/branchedTransformations/AbstractCodeTransformationIntention.java
similarity index 59%
rename from idea/src/org/jetbrains/jet/plugin/codeInsight/codeTransformations/branchedTransformations/FoldBranchedExpressionIntention.java
rename to idea/src/org/jetbrains/jet/plugin/codeInsight/codeTransformations/branchedTransformations/AbstractCodeTransformationIntention.java
index 89e67823803..72aace46d98 100644
--- a/idea/src/org/jetbrains/jet/plugin/codeInsight/codeTransformations/branchedTransformations/FoldBranchedExpressionIntention.java
+++ b/idea/src/org/jetbrains/jet/plugin/codeInsight/codeTransformations/branchedTransformations/AbstractCodeTransformationIntention.java
@@ -16,6 +16,7 @@
package org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations;
+import com.google.common.base.Predicate;
import com.intellij.codeInsight.intention.impl.BaseIntentionAction;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
@@ -25,25 +26,38 @@ import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.psi.JetElement;
-import org.jetbrains.jet.lang.psi.JetExpression;
import org.jetbrains.jet.lang.psi.JetPsiUtil;
import org.jetbrains.jet.plugin.JetBundle;
+import org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.core.Transformer;
-public class FoldBranchedExpressionIntention extends BaseIntentionAction {
- public FoldBranchedExpressionIntention() {
- setText(JetBundle.message("fold.branched.expression"));
+public abstract class AbstractCodeTransformationIntention extends BaseIntentionAction {
+ private final T transformer;
+ private final Predicate filter;
+
+ protected AbstractCodeTransformationIntention(@NotNull T transformer, @NotNull Predicate filter) {
+ this.transformer = transformer;
+ this.filter = filter;
+ setText(JetBundle.message(transformer.getKey()));
+ }
+
+ @Nullable
+ private PsiElement getTarget(@NotNull Editor editor, @NotNull PsiFile file) {
+ PsiElement element = file.findElementAt(editor.getCaretModel().getOffset());
+ return JetPsiUtil.getParentByTypeAndPredicate(element, JetElement.class, filter, false);
+ }
+
+ protected final T getTransformer() {
+ return transformer;
+ }
+
+ protected final Predicate getFilter() {
+ return filter;
}
@NotNull
@Override
public String getFamilyName() {
- return JetBundle.message("fold.branched.expression.family");
- }
-
- @Nullable
- private static JetExpression getTarget(@NotNull Editor editor, @NotNull PsiFile file) {
- PsiElement element = file.findElementAt(editor.getCaretModel().getOffset());
- return (JetExpression)JetPsiUtil.getParentByTypeAndPredicate(element, JetElement.class, BranchedFoldingUtils.FOLDABLE_EXPRESSION, false);
+ return JetBundle.message(transformer.getKey() + ".family");
}
@Override
@@ -53,10 +67,10 @@ public class FoldBranchedExpressionIntention extends BaseIntentionAction {
@Override
public void invoke(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) throws IncorrectOperationException {
- JetExpression target = getTarget(editor, file);
+ PsiElement target = getTarget(editor, file);
- assert target != null;
+ assert target != null : "Intention is not applicable";
- BranchedFoldingUtils.foldExpression(target);
+ transformer.transform(target);
}
}
diff --git a/idea/src/org/jetbrains/jet/plugin/codeInsight/codeTransformations/branchedTransformations/BranchedFoldingUtils.java b/idea/src/org/jetbrains/jet/plugin/codeInsight/codeTransformations/branchedTransformations/BranchedFoldingUtils.java
index 0ffb6a9188d..98b9c363e6c 100644
--- a/idea/src/org/jetbrains/jet/plugin/codeInsight/codeTransformations/branchedTransformations/BranchedFoldingUtils.java
+++ b/idea/src/org/jetbrains/jet/plugin/codeInsight/codeTransformations/branchedTransformations/BranchedFoldingUtils.java
@@ -138,26 +138,27 @@ public class BranchedFoldingUtils {
return (nextElement instanceof JetExpression) && checkAndGetFoldableBranchedReturn((JetExpression)nextElement) != null;
}
- public static boolean checkFoldableExpression(@Nullable JetExpression root) {
+ @Nullable
+ public static FoldableKind getFoldableExpressionKind(@Nullable JetExpression root) {
if (root instanceof JetIfExpression) {
JetIfExpression ifExpression = (JetIfExpression)root;
- return checkFoldableIfExpressionWithAssignments(ifExpression) ||
- checkFoldableIfExpressionWithReturns(ifExpression) ||
- checkFoldableIfExpressionWithAsymmetricReturns(ifExpression) ;
- }
- if (root instanceof JetWhenExpression) {
+ if (checkFoldableIfExpressionWithAssignments(ifExpression)) return FoldableKind.IF_TO_ASSIGNMENT;
+ if (checkFoldableIfExpressionWithReturns(ifExpression)) return FoldableKind.IF_TO_RETURN;
+ if (checkFoldableIfExpressionWithAsymmetricReturns(ifExpression)) return FoldableKind.IF_TO_RETURN_ASYMMETRICALLY;
+ } else if (root instanceof JetWhenExpression) {
JetWhenExpression whenExpression = (JetWhenExpression)root;
- return checkFoldableWhenExpressionWithAssignments(whenExpression) ||
- checkFoldableWhenExpressionWithReturns(whenExpression);
+
+ if (checkFoldableWhenExpressionWithAssignments(whenExpression)) return FoldableKind.WHEN_TO_ASSIGNMENT;
+ if (checkFoldableWhenExpressionWithReturns(whenExpression)) return FoldableKind.WHEN_TO_RETURN;
}
- return false;
+ return null;
}
public static final String FOLD_WITHOUT_CHECK = "Expression must be checked before folding";
- private static void foldIfExpressionWithAssignments(JetIfExpression ifExpression) {
+ public static void foldIfExpressionWithAssignments(JetIfExpression ifExpression) {
Project project = ifExpression.getProject();
JetBinaryExpression thenAssignment = checkAndGetFoldableBranchedAssignment(ifExpression.getThen());
@@ -189,7 +190,7 @@ public class BranchedFoldingUtils {
elseAssignment.replace(elseRhs);
}
- private static void foldIfExpressionWithReturns(JetIfExpression ifExpression) {
+ public static void foldIfExpressionWithReturns(JetIfExpression ifExpression) {
Project project = ifExpression.getProject();
JetReturnExpression returnExpr = (JetReturnExpression)ifExpression.replace(JetPsiFactory.createReturn(project, ifExpression));
@@ -213,7 +214,7 @@ public class BranchedFoldingUtils {
elseReturn.replace(elseExpr);
}
- private static void foldIfExpressionWithAsymmetricReturns(JetIfExpression ifExpression) {
+ public static void foldIfExpressionWithAsymmetricReturns(JetIfExpression ifExpression) {
Project project = ifExpression.getProject();
JetExpression condition = ifExpression.getCondition();
@@ -254,7 +255,7 @@ public class BranchedFoldingUtils {
elseReturn.replace(elseExpr);
}
- private static void foldWhenExpressionWithAssignments(JetWhenExpression whenExpression) {
+ public static void foldWhenExpressionWithAssignments(JetWhenExpression whenExpression) {
Project project = whenExpression.getProject();
assert !whenExpression.getEntries().isEmpty() : FOLD_WITHOUT_CHECK;
@@ -285,7 +286,7 @@ public class BranchedFoldingUtils {
}
}
- private static void foldWhenExpressionWithReturns(JetWhenExpression whenExpression) {
+ public static void foldWhenExpressionWithReturns(JetWhenExpression whenExpression) {
Project project = whenExpression.getProject();
assert !whenExpression.getEntries().isEmpty() : FOLD_WITHOUT_CHECK;
@@ -307,33 +308,4 @@ public class BranchedFoldingUtils {
currReturn.replace(currExpr);
}
}
-
- public static void foldExpression(@Nullable JetExpression root) {
- if (root instanceof JetIfExpression) {
- JetIfExpression ifExpression = (JetIfExpression)root;
- if (checkFoldableIfExpressionWithAssignments(ifExpression)) {
- foldIfExpressionWithAssignments(ifExpression);
- } else if (checkFoldableIfExpressionWithReturns(ifExpression)) {
- foldIfExpressionWithReturns(ifExpression);
- } else if (checkFoldableIfExpressionWithAsymmetricReturns(ifExpression)) {
- foldIfExpressionWithAsymmetricReturns(ifExpression);
- }
- }
-
- if (root instanceof JetWhenExpression) {
- JetWhenExpression whenExpression = (JetWhenExpression)root;
- if (checkFoldableWhenExpressionWithAssignments(whenExpression)) {
- foldWhenExpressionWithAssignments(whenExpression);
- } else if (checkFoldableWhenExpressionWithReturns(whenExpression)) {
- foldWhenExpressionWithReturns(whenExpression);
- }
- }
- }
-
- public static final Predicate FOLDABLE_EXPRESSION = new Predicate() {
- @Override
- public boolean apply(@Nullable PsiElement input) {
- return (input instanceof JetExpression) && checkFoldableExpression((JetExpression)input);
- }
- };
}
diff --git a/idea/src/org/jetbrains/jet/plugin/codeInsight/codeTransformations/branchedTransformations/BranchedUnfoldingUtils.java b/idea/src/org/jetbrains/jet/plugin/codeInsight/codeTransformations/branchedTransformations/BranchedUnfoldingUtils.java
index da88e10dc1b..074f383d385 100644
--- a/idea/src/org/jetbrains/jet/plugin/codeInsight/codeTransformations/branchedTransformations/BranchedUnfoldingUtils.java
+++ b/idea/src/org/jetbrains/jet/plugin/codeInsight/codeTransformations/branchedTransformations/BranchedUnfoldingUtils.java
@@ -27,31 +27,36 @@ public class BranchedUnfoldingUtils {
private BranchedUnfoldingUtils() {
}
- private static boolean checkUnfoldableAssignment(@NotNull JetExpression expression) {
- if (!JetPsiUtil.isAssignment(expression)) return false;
-
- JetBinaryExpression assignment = (JetBinaryExpression)expression;
- return assignment.getLeft() instanceof JetSimpleNameExpression && JetPsiUtil.isBranchedExpression(assignment.getRight());
- }
-
- private static boolean checkUnfoldableReturn(@NotNull JetExpression expression) {
- if (!(expression instanceof JetReturnExpression)) return false;
-
- JetReturnExpression returnExpression = (JetReturnExpression)expression;
- return JetPsiUtil.isBranchedExpression(returnExpression.getReturnedExpression());
- }
-
- public static boolean checkUnfoldableExpression(@NotNull JetExpression root) {
- return checkUnfoldableAssignment(root) || checkUnfoldableReturn(root);
- }
-
private static JetExpression getOutermostLastBlockElement(@Nullable JetExpression expression) {
return (JetExpression) JetPsiUtil.getOutermostLastBlockElement(expression, JetPsiUtil.ANY_JET_ELEMENT);
}
+ @Nullable
+ public static UnfoldableKind getUnfoldableExpressionKind(@Nullable JetExpression root) {
+ if (root == null) return null;
+
+ if (JetPsiUtil.isAssignment(root)) {
+ JetBinaryExpression assignment = (JetBinaryExpression)root;
+ JetExpression lhs = assignment.getLeft();
+ JetExpression rhs = assignment.getRight();
+
+ if (!(lhs instanceof JetSimpleNameExpression)) return null;
+
+ if (rhs instanceof JetIfExpression) return UnfoldableKind.ASSIGNMENT_TO_IF;
+ if (rhs instanceof JetWhenExpression) return UnfoldableKind.ASSIGNMENT_TO_WHEN;
+ } else if (root instanceof JetReturnExpression) {
+ JetExpression resultExpr = ((JetReturnExpression)root).getReturnedExpression();
+
+ if (resultExpr instanceof JetIfExpression) return UnfoldableKind.RETURN_TO_IF;
+ if (resultExpr instanceof JetWhenExpression) return UnfoldableKind.RETURN_TO_WHEN;
+ }
+
+ return null;
+ }
+
public static final String UNFOLD_WITHOUT_CHECK = "Expression must be checked before unfolding";
- private static void unfoldAssignmentToIf(@NotNull JetBinaryExpression assignment) {
+ public static void unfoldAssignmentToIf(@NotNull JetBinaryExpression assignment) {
Project project = assignment.getProject();
String op = assignment.getOperationReference().getText();
String lhsText = assignment.getLeft().getText();
@@ -71,7 +76,7 @@ public class BranchedUnfoldingUtils {
elseExpr.replace(JetPsiFactory.createBinaryExpression(project, JetPsiFactory.createExpression(project, lhsText), op, elseExpr));
}
- private static void unfoldAssignmentToWhen(@NotNull JetBinaryExpression assignment) {
+ public static void unfoldAssignmentToWhen(@NotNull JetBinaryExpression assignment) {
Project project = assignment.getProject();
String op = assignment.getOperationReference().getText();
JetExpression lhs = (JetExpression)assignment.getLeft().copy();
@@ -90,7 +95,7 @@ public class BranchedUnfoldingUtils {
}
}
- private static void unfoldReturnToIf(@NotNull JetReturnExpression returnExpression) {
+ public static void unfoldReturnToIf(@NotNull JetReturnExpression returnExpression) {
Project project = returnExpression.getProject();
JetIfExpression ifExpression = (JetIfExpression)returnExpression.getReturnedExpression();
@@ -108,7 +113,7 @@ public class BranchedUnfoldingUtils {
elseExpr.replace(JetPsiFactory.createReturn(project, elseExpr));
}
- private static void unfoldReturnToWhen(@NotNull JetReturnExpression returnExpression) {
+ public static void unfoldReturnToWhen(@NotNull JetReturnExpression returnExpression) {
Project project = returnExpression.getProject();
JetWhenExpression whenExpression = (JetWhenExpression)returnExpression.getReturnedExpression();
@@ -124,29 +129,4 @@ public class BranchedUnfoldingUtils {
currExpr.replace(JetPsiFactory.createReturn(project, currExpr));
}
}
-
- public static void unfoldExpression(@NotNull JetExpression root) {
- if (checkUnfoldableAssignment(root)) {
- JetBinaryExpression assignment = (JetBinaryExpression)root;
- if (assignment.getRight() instanceof JetIfExpression) {
- unfoldAssignmentToIf(assignment);
- } else if (assignment.getRight() instanceof JetWhenExpression) {
- unfoldAssignmentToWhen(assignment);
- }
- } else if (checkUnfoldableReturn(root)) {
- JetReturnExpression returnExpression = (JetReturnExpression)root;
- if (returnExpression.getReturnedExpression() instanceof JetIfExpression) {
- unfoldReturnToIf(returnExpression);
- } else if (returnExpression.getReturnedExpression() instanceof JetWhenExpression) {
- unfoldReturnToWhen(returnExpression);
- }
- }
- }
-
- public static final Predicate UNFOLDABLE_EXPRESSION = new Predicate() {
- @Override
- public boolean apply(@Nullable PsiElement input) {
- return (input instanceof JetExpression) && checkUnfoldableExpression((JetExpression)input);
- }
- };
}
diff --git a/idea/src/org/jetbrains/jet/plugin/codeInsight/codeTransformations/branchedTransformations/FoldableKind.java b/idea/src/org/jetbrains/jet/plugin/codeInsight/codeTransformations/branchedTransformations/FoldableKind.java
new file mode 100644
index 00000000000..0bc3b8e9ac1
--- /dev/null
+++ b/idea/src/org/jetbrains/jet/plugin/codeInsight/codeTransformations/branchedTransformations/FoldableKind.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2010-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance TO the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * TOOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations;
+
+import com.intellij.psi.PsiElement;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.jet.lang.psi.JetIfExpression;
+import org.jetbrains.jet.lang.psi.JetWhenExpression;
+import org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.core.Transformer;
+
+public enum FoldableKind implements Transformer {
+ IF_TO_ASSIGNMENT("fold.if.to.assignment") {
+ @Override
+ public void transform(@NotNull PsiElement element) {
+ BranchedFoldingUtils.foldIfExpressionWithAssignments((JetIfExpression) element);
+ }
+ },
+ IF_TO_RETURN("fold.if.to.return") {
+ @Override
+ public void transform(@NotNull PsiElement element) {
+ BranchedFoldingUtils.foldIfExpressionWithReturns((JetIfExpression) element);
+ }
+ },
+ IF_TO_RETURN_ASYMMETRICALLY("fold.if.to.return") {
+ @Override
+ public void transform(@NotNull PsiElement element) {
+ BranchedFoldingUtils.foldIfExpressionWithAsymmetricReturns((JetIfExpression) element);
+ }
+ },
+ WHEN_TO_ASSIGNMENT("fold.when.to.assignment") {
+ @Override
+ public void transform(@NotNull PsiElement element) {
+ BranchedFoldingUtils.foldWhenExpressionWithAssignments((JetWhenExpression) element);
+ }
+ },
+ WHEN_TO_RETURN("fold.when.to.return") {
+ @Override
+ public void transform(@NotNull PsiElement element) {
+ BranchedFoldingUtils.foldWhenExpressionWithReturns((JetWhenExpression) element);
+ }
+ };
+
+ private final String key;
+
+ private FoldableKind(String key) {
+ this.key = key;
+ }
+
+ @NotNull
+ @Override
+ public String getKey() {
+ return key;
+ }
+}
diff --git a/idea/src/org/jetbrains/jet/plugin/codeInsight/codeTransformations/branchedTransformations/UnfoldBranchedExpressionIntention.java b/idea/src/org/jetbrains/jet/plugin/codeInsight/codeTransformations/branchedTransformations/UnfoldBranchedExpressionIntention.java
deleted file mode 100644
index 61cd20886e5..00000000000
--- a/idea/src/org/jetbrains/jet/plugin/codeInsight/codeTransformations/branchedTransformations/UnfoldBranchedExpressionIntention.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright 2010-2013 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations;
-
-import com.intellij.codeInsight.intention.impl.BaseIntentionAction;
-import com.intellij.openapi.editor.Editor;
-import com.intellij.openapi.project.Project;
-import com.intellij.psi.PsiElement;
-import com.intellij.psi.PsiFile;
-import com.intellij.util.IncorrectOperationException;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-import org.jetbrains.jet.lang.psi.JetElement;
-import org.jetbrains.jet.lang.psi.JetExpression;
-import org.jetbrains.jet.lang.psi.JetPsiUtil;
-import org.jetbrains.jet.plugin.JetBundle;
-
-public class UnfoldBranchedExpressionIntention extends BaseIntentionAction {
- public UnfoldBranchedExpressionIntention() {
- setText(JetBundle.message("unfold.branched.expression"));
- }
-
- @NotNull
- @Override
- public String getFamilyName() {
- return JetBundle.message("unfold.branched.expression.family");
- }
-
- @Nullable
- private static JetExpression getTarget(@NotNull Editor editor, @NotNull PsiFile file) {
- PsiElement element = file.findElementAt(editor.getCaretModel().getOffset());
- return (JetExpression)JetPsiUtil.getParentByTypeAndPredicate(element, JetElement.class, BranchedUnfoldingUtils.UNFOLDABLE_EXPRESSION, false);
- }
-
- @Override
- public boolean isAvailable(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) {
- return getTarget(editor, file) != null;
- }
-
- @Override
- public void invoke(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) throws IncorrectOperationException {
- JetExpression target = getTarget(editor, file);
-
- assert target != null;
-
- BranchedUnfoldingUtils.unfoldExpression(target);
- }
-}
diff --git a/idea/src/org/jetbrains/jet/plugin/codeInsight/codeTransformations/branchedTransformations/UnfoldableKind.java b/idea/src/org/jetbrains/jet/plugin/codeInsight/codeTransformations/branchedTransformations/UnfoldableKind.java
new file mode 100644
index 00000000000..c27b330118f
--- /dev/null
+++ b/idea/src/org/jetbrains/jet/plugin/codeInsight/codeTransformations/branchedTransformations/UnfoldableKind.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2010-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations;
+
+import com.intellij.psi.PsiElement;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.jet.lang.psi.JetBinaryExpression;
+import org.jetbrains.jet.lang.psi.JetReturnExpression;
+import org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.core.Transformer;
+
+public enum UnfoldableKind implements Transformer {
+ ASSIGNMENT_TO_IF("unfold.assignment.to.if") {
+ @Override
+ public void transform(@NotNull PsiElement element) {
+ BranchedUnfoldingUtils.unfoldAssignmentToIf((JetBinaryExpression) element);
+ }
+ },
+ RETURN_TO_IF("unfold.return.to.if") {
+ @Override
+ public void transform(@NotNull PsiElement element) {
+ BranchedUnfoldingUtils.unfoldReturnToIf((JetReturnExpression) element);
+ }
+ },
+ ASSIGNMENT_TO_WHEN("unfold.assignment.to.when") {
+ @Override
+ public void transform(@NotNull PsiElement element) {
+ BranchedUnfoldingUtils.unfoldAssignmentToWhen((JetBinaryExpression) element);
+ }
+ },
+ RETURN_TO_WHEN("unfold.return.to.when") {
+ @Override
+ public void transform(@NotNull PsiElement element) {
+ BranchedUnfoldingUtils.unfoldReturnToWhen((JetReturnExpression) element);
+ }
+ };
+
+ private final String key;
+
+ private UnfoldableKind(String key) {
+ this.key = key;
+ }
+
+ @NotNull
+ @Override
+ public String getKey() {
+ return key;
+ }
+}
diff --git a/idea/src/org/jetbrains/jet/plugin/codeInsight/codeTransformations/branchedTransformations/core/Transformer.java b/idea/src/org/jetbrains/jet/plugin/codeInsight/codeTransformations/branchedTransformations/core/Transformer.java
new file mode 100644
index 00000000000..a2ce45fed31
--- /dev/null
+++ b/idea/src/org/jetbrains/jet/plugin/codeInsight/codeTransformations/branchedTransformations/core/Transformer.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2010-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.core;
+
+import com.intellij.psi.PsiElement;
+import org.jetbrains.annotations.NotNull;
+
+public interface Transformer {
+ public @NotNull String getKey();
+ public void transform(@NotNull PsiElement element);
+}
diff --git a/idea/src/org/jetbrains/jet/plugin/codeInsight/codeTransformations/branchedTransformations/intentions/FoldBranchedExpressionIntention.java b/idea/src/org/jetbrains/jet/plugin/codeInsight/codeTransformations/branchedTransformations/intentions/FoldBranchedExpressionIntention.java
new file mode 100644
index 00000000000..e61bcce509f
--- /dev/null
+++ b/idea/src/org/jetbrains/jet/plugin/codeInsight/codeTransformations/branchedTransformations/intentions/FoldBranchedExpressionIntention.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2010-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.intentions;
+
+import com.google.common.base.Predicate;
+import com.intellij.psi.PsiElement;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.jet.lang.psi.JetExpression;
+import org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.AbstractCodeTransformationIntention;
+import org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.BranchedFoldingUtils;
+import org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.FoldableKind;
+
+public abstract class FoldBranchedExpressionIntention extends AbstractCodeTransformationIntention {
+ protected FoldBranchedExpressionIntention(@NotNull final FoldableKind foldableKind) {
+ super(
+ foldableKind,
+ new Predicate() {
+ @Override
+ public boolean apply(@Nullable PsiElement input) {
+ return (input instanceof JetExpression) && BranchedFoldingUtils.getFoldableExpressionKind((JetExpression) input) == foldableKind;
+ }
+ }
+ );
+ }
+}
diff --git a/idea/src/org/jetbrains/jet/plugin/codeInsight/codeTransformations/branchedTransformations/intentions/FoldIfToAssignmentIntention.java b/idea/src/org/jetbrains/jet/plugin/codeInsight/codeTransformations/branchedTransformations/intentions/FoldIfToAssignmentIntention.java
new file mode 100644
index 00000000000..30b2466f232
--- /dev/null
+++ b/idea/src/org/jetbrains/jet/plugin/codeInsight/codeTransformations/branchedTransformations/intentions/FoldIfToAssignmentIntention.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2010-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.intentions;
+
+import org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.FoldableKind;
+
+public class FoldIfToAssignmentIntention extends FoldBranchedExpressionIntention {
+ public FoldIfToAssignmentIntention() {
+ super(FoldableKind.IF_TO_ASSIGNMENT);
+ }
+}
diff --git a/idea/src/org/jetbrains/jet/plugin/codeInsight/codeTransformations/branchedTransformations/intentions/FoldIfToReturnAsymmetricallyIntention.java b/idea/src/org/jetbrains/jet/plugin/codeInsight/codeTransformations/branchedTransformations/intentions/FoldIfToReturnAsymmetricallyIntention.java
new file mode 100644
index 00000000000..128ecf8a25a
--- /dev/null
+++ b/idea/src/org/jetbrains/jet/plugin/codeInsight/codeTransformations/branchedTransformations/intentions/FoldIfToReturnAsymmetricallyIntention.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2010-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.intentions;
+
+import org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.FoldableKind;
+
+public class FoldIfToReturnAsymmetricallyIntention extends FoldBranchedExpressionIntention {
+ public FoldIfToReturnAsymmetricallyIntention() {
+ super(FoldableKind.IF_TO_RETURN_ASYMMETRICALLY);
+ }
+}
diff --git a/idea/src/org/jetbrains/jet/plugin/codeInsight/codeTransformations/branchedTransformations/intentions/FoldIfToReturnIntention.java b/idea/src/org/jetbrains/jet/plugin/codeInsight/codeTransformations/branchedTransformations/intentions/FoldIfToReturnIntention.java
new file mode 100644
index 00000000000..a63fd84b868
--- /dev/null
+++ b/idea/src/org/jetbrains/jet/plugin/codeInsight/codeTransformations/branchedTransformations/intentions/FoldIfToReturnIntention.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2010-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.intentions;
+
+import org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.FoldableKind;
+
+public class FoldIfToReturnIntention extends FoldBranchedExpressionIntention {
+ public FoldIfToReturnIntention() {
+ super(FoldableKind.IF_TO_RETURN);
+ }
+}
diff --git a/idea/src/org/jetbrains/jet/plugin/codeInsight/codeTransformations/branchedTransformations/intentions/FoldWhenToAssignmentIntention.java b/idea/src/org/jetbrains/jet/plugin/codeInsight/codeTransformations/branchedTransformations/intentions/FoldWhenToAssignmentIntention.java
new file mode 100644
index 00000000000..3c307dc3b3d
--- /dev/null
+++ b/idea/src/org/jetbrains/jet/plugin/codeInsight/codeTransformations/branchedTransformations/intentions/FoldWhenToAssignmentIntention.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2010-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.intentions;
+
+import org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.FoldableKind;
+
+public class FoldWhenToAssignmentIntention extends FoldBranchedExpressionIntention {
+ public FoldWhenToAssignmentIntention() {
+ super(FoldableKind.WHEN_TO_ASSIGNMENT);
+ }
+}
diff --git a/idea/src/org/jetbrains/jet/plugin/codeInsight/codeTransformations/branchedTransformations/intentions/FoldWhenToReturnIntention.java b/idea/src/org/jetbrains/jet/plugin/codeInsight/codeTransformations/branchedTransformations/intentions/FoldWhenToReturnIntention.java
new file mode 100644
index 00000000000..fd1bc61726c
--- /dev/null
+++ b/idea/src/org/jetbrains/jet/plugin/codeInsight/codeTransformations/branchedTransformations/intentions/FoldWhenToReturnIntention.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2010-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.intentions;
+
+import org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.FoldableKind;
+
+public class FoldWhenToReturnIntention extends FoldBranchedExpressionIntention {
+ public FoldWhenToReturnIntention() {
+ super(FoldableKind.WHEN_TO_RETURN);
+ }
+}
diff --git a/idea/src/org/jetbrains/jet/plugin/codeInsight/codeTransformations/branchedTransformations/intentions/UnfoldAssignmentToIfIntention.java b/idea/src/org/jetbrains/jet/plugin/codeInsight/codeTransformations/branchedTransformations/intentions/UnfoldAssignmentToIfIntention.java
new file mode 100644
index 00000000000..a0db1a07526
--- /dev/null
+++ b/idea/src/org/jetbrains/jet/plugin/codeInsight/codeTransformations/branchedTransformations/intentions/UnfoldAssignmentToIfIntention.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2010-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.intentions;
+
+import org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.UnfoldableKind;
+
+public class UnfoldAssignmentToIfIntention extends UnfoldBranchedExpressionIntention {
+ public UnfoldAssignmentToIfIntention() {
+ super(UnfoldableKind.ASSIGNMENT_TO_IF);
+ }
+}
diff --git a/idea/src/org/jetbrains/jet/plugin/codeInsight/codeTransformations/branchedTransformations/intentions/UnfoldAssignmentToWhenIntention.java b/idea/src/org/jetbrains/jet/plugin/codeInsight/codeTransformations/branchedTransformations/intentions/UnfoldAssignmentToWhenIntention.java
new file mode 100644
index 00000000000..102c65ddd1f
--- /dev/null
+++ b/idea/src/org/jetbrains/jet/plugin/codeInsight/codeTransformations/branchedTransformations/intentions/UnfoldAssignmentToWhenIntention.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2010-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.intentions;
+
+import org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.UnfoldableKind;
+
+public class UnfoldAssignmentToWhenIntention extends UnfoldBranchedExpressionIntention {
+ public UnfoldAssignmentToWhenIntention() {
+ super(UnfoldableKind.ASSIGNMENT_TO_WHEN);
+ }
+}
diff --git a/idea/src/org/jetbrains/jet/plugin/codeInsight/codeTransformations/branchedTransformations/intentions/UnfoldBranchedExpressionIntention.java b/idea/src/org/jetbrains/jet/plugin/codeInsight/codeTransformations/branchedTransformations/intentions/UnfoldBranchedExpressionIntention.java
new file mode 100644
index 00000000000..6d21ec4afa9
--- /dev/null
+++ b/idea/src/org/jetbrains/jet/plugin/codeInsight/codeTransformations/branchedTransformations/intentions/UnfoldBranchedExpressionIntention.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2010-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.intentions;
+
+import com.google.common.base.Predicate;
+import com.intellij.psi.PsiElement;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.jet.lang.psi.JetExpression;
+import org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.*;
+
+public abstract class UnfoldBranchedExpressionIntention extends AbstractCodeTransformationIntention {
+ protected UnfoldBranchedExpressionIntention(@NotNull final UnfoldableKind unfoldableKind) {
+ super(
+ unfoldableKind,
+ new Predicate() {
+ @Override
+ public boolean apply(@Nullable PsiElement input) {
+ return (input instanceof JetExpression) && BranchedUnfoldingUtils.getUnfoldableExpressionKind((JetExpression) input) == unfoldableKind;
+ }
+ }
+ );
+ }
+}
diff --git a/idea/src/org/jetbrains/jet/plugin/codeInsight/codeTransformations/branchedTransformations/intentions/UnfoldReturnToIfIntention.java b/idea/src/org/jetbrains/jet/plugin/codeInsight/codeTransformations/branchedTransformations/intentions/UnfoldReturnToIfIntention.java
new file mode 100644
index 00000000000..4018d2dcfc2
--- /dev/null
+++ b/idea/src/org/jetbrains/jet/plugin/codeInsight/codeTransformations/branchedTransformations/intentions/UnfoldReturnToIfIntention.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2010-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.intentions;
+
+import org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.UnfoldableKind;
+
+public class UnfoldReturnToIfIntention extends UnfoldBranchedExpressionIntention {
+ public UnfoldReturnToIfIntention() {
+ super(UnfoldableKind.RETURN_TO_IF);
+ }
+}
diff --git a/idea/src/org/jetbrains/jet/plugin/codeInsight/codeTransformations/branchedTransformations/intentions/UnfoldReturnToWhenIntention.java b/idea/src/org/jetbrains/jet/plugin/codeInsight/codeTransformations/branchedTransformations/intentions/UnfoldReturnToWhenIntention.java
new file mode 100644
index 00000000000..156954aada1
--- /dev/null
+++ b/idea/src/org/jetbrains/jet/plugin/codeInsight/codeTransformations/branchedTransformations/intentions/UnfoldReturnToWhenIntention.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2010-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.intentions;
+
+import org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.UnfoldableKind;
+
+public class UnfoldReturnToWhenIntention extends UnfoldBranchedExpressionIntention {
+ public UnfoldReturnToWhenIntention() {
+ super(UnfoldableKind.RETURN_TO_WHEN);
+ }
+}
diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/innerIfTransformed.kt b/idea/testData/codeInsight/codeTransformations/branched/folding/ifToAssignment/innerIfTransformed.kt
similarity index 100%
rename from idea/testData/codeInsight/codeTransformations/branched/folding/assignment/innerIfTransformed.kt
rename to idea/testData/codeInsight/codeTransformations/branched/folding/ifToAssignment/innerIfTransformed.kt
diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/innerIfTransformed.kt.after b/idea/testData/codeInsight/codeTransformations/branched/folding/ifToAssignment/innerIfTransformed.kt.after
similarity index 100%
rename from idea/testData/codeInsight/codeTransformations/branched/folding/assignment/innerIfTransformed.kt.after
rename to idea/testData/codeInsight/codeTransformations/branched/folding/ifToAssignment/innerIfTransformed.kt.after
diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleIf.kt b/idea/testData/codeInsight/codeTransformations/branched/folding/ifToAssignment/simpleIf.kt
similarity index 100%
rename from idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleIf.kt
rename to idea/testData/codeInsight/codeTransformations/branched/folding/ifToAssignment/simpleIf.kt
diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleIf.kt.after b/idea/testData/codeInsight/codeTransformations/branched/folding/ifToAssignment/simpleIf.kt.after
similarity index 100%
rename from idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleIf.kt.after
rename to idea/testData/codeInsight/codeTransformations/branched/folding/ifToAssignment/simpleIf.kt.after
diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleIfWithAugmentedAssignment.kt b/idea/testData/codeInsight/codeTransformations/branched/folding/ifToAssignment/simpleIfWithAugmentedAssignment.kt
similarity index 100%
rename from idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleIfWithAugmentedAssignment.kt
rename to idea/testData/codeInsight/codeTransformations/branched/folding/ifToAssignment/simpleIfWithAugmentedAssignment.kt
diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleIfWithAugmentedAssignment.kt.after b/idea/testData/codeInsight/codeTransformations/branched/folding/ifToAssignment/simpleIfWithAugmentedAssignment.kt.after
similarity index 100%
rename from idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleIfWithAugmentedAssignment.kt.after
rename to idea/testData/codeInsight/codeTransformations/branched/folding/ifToAssignment/simpleIfWithAugmentedAssignment.kt.after
diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleIfWithBlocks.kt b/idea/testData/codeInsight/codeTransformations/branched/folding/ifToAssignment/simpleIfWithBlocks.kt
similarity index 100%
rename from idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleIfWithBlocks.kt
rename to idea/testData/codeInsight/codeTransformations/branched/folding/ifToAssignment/simpleIfWithBlocks.kt
diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleIfWithBlocks.kt.after b/idea/testData/codeInsight/codeTransformations/branched/folding/ifToAssignment/simpleIfWithBlocks.kt.after
similarity index 100%
rename from idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleIfWithBlocks.kt.after
rename to idea/testData/codeInsight/codeTransformations/branched/folding/ifToAssignment/simpleIfWithBlocks.kt.after
diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleIfWithShadowedVar.kt b/idea/testData/codeInsight/codeTransformations/branched/folding/ifToAssignment/simpleIfWithShadowedVar.kt
similarity index 100%
rename from idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleIfWithShadowedVar.kt
rename to idea/testData/codeInsight/codeTransformations/branched/folding/ifToAssignment/simpleIfWithShadowedVar.kt
diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleIfWithUnmatchedAssignmentOps.kt b/idea/testData/codeInsight/codeTransformations/branched/folding/ifToAssignment/simpleIfWithUnmatchedAssignmentOps.kt
similarity index 100%
rename from idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleIfWithUnmatchedAssignmentOps.kt
rename to idea/testData/codeInsight/codeTransformations/branched/folding/ifToAssignment/simpleIfWithUnmatchedAssignmentOps.kt
diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleIfWithUnmatchedAssignments.kt b/idea/testData/codeInsight/codeTransformations/branched/folding/ifToAssignment/simpleIfWithUnmatchedAssignments.kt
similarity index 100%
rename from idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleIfWithUnmatchedAssignments.kt
rename to idea/testData/codeInsight/codeTransformations/branched/folding/ifToAssignment/simpleIfWithUnmatchedAssignments.kt
diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleIfWithoutElse.kt b/idea/testData/codeInsight/codeTransformations/branched/folding/ifToAssignment/simpleIfWithoutElse.kt
similarity index 100%
rename from idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleIfWithoutElse.kt
rename to idea/testData/codeInsight/codeTransformations/branched/folding/ifToAssignment/simpleIfWithoutElse.kt
diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleIfWithoutTerminatingAssignment.kt b/idea/testData/codeInsight/codeTransformations/branched/folding/ifToAssignment/simpleIfWithoutTerminatingAssignment.kt
similarity index 100%
rename from idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleIfWithoutTerminatingAssignment.kt
rename to idea/testData/codeInsight/codeTransformations/branched/folding/ifToAssignment/simpleIfWithoutTerminatingAssignment.kt
diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/return/innerIfTransformed.kt b/idea/testData/codeInsight/codeTransformations/branched/folding/ifToReturn/innerIfTransformed.kt
similarity index 100%
rename from idea/testData/codeInsight/codeTransformations/branched/folding/return/innerIfTransformed.kt
rename to idea/testData/codeInsight/codeTransformations/branched/folding/ifToReturn/innerIfTransformed.kt
diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/return/innerIfTransformed.kt.after b/idea/testData/codeInsight/codeTransformations/branched/folding/ifToReturn/innerIfTransformed.kt.after
similarity index 100%
rename from idea/testData/codeInsight/codeTransformations/branched/folding/return/innerIfTransformed.kt.after
rename to idea/testData/codeInsight/codeTransformations/branched/folding/ifToReturn/innerIfTransformed.kt.after
diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/return/simpleIf.kt b/idea/testData/codeInsight/codeTransformations/branched/folding/ifToReturn/simpleIf.kt
similarity index 100%
rename from idea/testData/codeInsight/codeTransformations/branched/folding/return/simpleIf.kt
rename to idea/testData/codeInsight/codeTransformations/branched/folding/ifToReturn/simpleIf.kt
diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/return/simpleIf.kt.after b/idea/testData/codeInsight/codeTransformations/branched/folding/ifToReturn/simpleIf.kt.after
similarity index 100%
rename from idea/testData/codeInsight/codeTransformations/branched/folding/return/simpleIf.kt.after
rename to idea/testData/codeInsight/codeTransformations/branched/folding/ifToReturn/simpleIf.kt.after
diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/return/simpleIfWithBlocks.kt b/idea/testData/codeInsight/codeTransformations/branched/folding/ifToReturn/simpleIfWithBlocks.kt
similarity index 100%
rename from idea/testData/codeInsight/codeTransformations/branched/folding/return/simpleIfWithBlocks.kt
rename to idea/testData/codeInsight/codeTransformations/branched/folding/ifToReturn/simpleIfWithBlocks.kt
diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/return/simpleIfWithBlocks.kt.after b/idea/testData/codeInsight/codeTransformations/branched/folding/ifToReturn/simpleIfWithBlocks.kt.after
similarity index 100%
rename from idea/testData/codeInsight/codeTransformations/branched/folding/return/simpleIfWithBlocks.kt.after
rename to idea/testData/codeInsight/codeTransformations/branched/folding/ifToReturn/simpleIfWithBlocks.kt.after
diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/asymmetricReturn/simpleIf.kt b/idea/testData/codeInsight/codeTransformations/branched/folding/ifToReturnAsymmetrically/simpleIf.kt
similarity index 100%
rename from idea/testData/codeInsight/codeTransformations/branched/folding/asymmetricReturn/simpleIf.kt
rename to idea/testData/codeInsight/codeTransformations/branched/folding/ifToReturnAsymmetrically/simpleIf.kt
diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/asymmetricReturn/simpleIf.kt.after b/idea/testData/codeInsight/codeTransformations/branched/folding/ifToReturnAsymmetrically/simpleIf.kt.after
similarity index 100%
rename from idea/testData/codeInsight/codeTransformations/branched/folding/asymmetricReturn/simpleIf.kt.after
rename to idea/testData/codeInsight/codeTransformations/branched/folding/ifToReturnAsymmetrically/simpleIf.kt.after
diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/asymmetricReturn/simpleIfWithBlocks.kt b/idea/testData/codeInsight/codeTransformations/branched/folding/ifToReturnAsymmetrically/simpleIfWithBlocks.kt
similarity index 100%
rename from idea/testData/codeInsight/codeTransformations/branched/folding/asymmetricReturn/simpleIfWithBlocks.kt
rename to idea/testData/codeInsight/codeTransformations/branched/folding/ifToReturnAsymmetrically/simpleIfWithBlocks.kt
diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/asymmetricReturn/simpleIfWithBlocks.kt.after b/idea/testData/codeInsight/codeTransformations/branched/folding/ifToReturnAsymmetrically/simpleIfWithBlocks.kt.after
similarity index 100%
rename from idea/testData/codeInsight/codeTransformations/branched/folding/asymmetricReturn/simpleIfWithBlocks.kt.after
rename to idea/testData/codeInsight/codeTransformations/branched/folding/ifToReturnAsymmetrically/simpleIfWithBlocks.kt.after
diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/asymmetricReturn/simpleIfWithComments.kt b/idea/testData/codeInsight/codeTransformations/branched/folding/ifToReturnAsymmetrically/simpleIfWithComments.kt
similarity index 100%
rename from idea/testData/codeInsight/codeTransformations/branched/folding/asymmetricReturn/simpleIfWithComments.kt
rename to idea/testData/codeInsight/codeTransformations/branched/folding/ifToReturnAsymmetrically/simpleIfWithComments.kt
diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/asymmetricReturn/simpleIfWithComments.kt.after b/idea/testData/codeInsight/codeTransformations/branched/folding/ifToReturnAsymmetrically/simpleIfWithComments.kt.after
similarity index 100%
rename from idea/testData/codeInsight/codeTransformations/branched/folding/asymmetricReturn/simpleIfWithComments.kt.after
rename to idea/testData/codeInsight/codeTransformations/branched/folding/ifToReturnAsymmetrically/simpleIfWithComments.kt.after
diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/innerWhenTransformed.kt b/idea/testData/codeInsight/codeTransformations/branched/folding/whenToAssignment/innerWhenTransformed.kt
similarity index 100%
rename from idea/testData/codeInsight/codeTransformations/branched/folding/assignment/innerWhenTransformed.kt
rename to idea/testData/codeInsight/codeTransformations/branched/folding/whenToAssignment/innerWhenTransformed.kt
diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/innerWhenTransformed.kt.after b/idea/testData/codeInsight/codeTransformations/branched/folding/whenToAssignment/innerWhenTransformed.kt.after
similarity index 100%
rename from idea/testData/codeInsight/codeTransformations/branched/folding/assignment/innerWhenTransformed.kt.after
rename to idea/testData/codeInsight/codeTransformations/branched/folding/whenToAssignment/innerWhenTransformed.kt.after
diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleWhen.kt b/idea/testData/codeInsight/codeTransformations/branched/folding/whenToAssignment/simpleWhen.kt
similarity index 100%
rename from idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleWhen.kt
rename to idea/testData/codeInsight/codeTransformations/branched/folding/whenToAssignment/simpleWhen.kt
diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleWhen.kt.after b/idea/testData/codeInsight/codeTransformations/branched/folding/whenToAssignment/simpleWhen.kt.after
similarity index 100%
rename from idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleWhen.kt.after
rename to idea/testData/codeInsight/codeTransformations/branched/folding/whenToAssignment/simpleWhen.kt.after
diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleWhenWithBlocks.kt b/idea/testData/codeInsight/codeTransformations/branched/folding/whenToAssignment/simpleWhenWithBlocks.kt
similarity index 100%
rename from idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleWhenWithBlocks.kt
rename to idea/testData/codeInsight/codeTransformations/branched/folding/whenToAssignment/simpleWhenWithBlocks.kt
diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleWhenWithBlocks.kt.after b/idea/testData/codeInsight/codeTransformations/branched/folding/whenToAssignment/simpleWhenWithBlocks.kt.after
similarity index 100%
rename from idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleWhenWithBlocks.kt.after
rename to idea/testData/codeInsight/codeTransformations/branched/folding/whenToAssignment/simpleWhenWithBlocks.kt.after
diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleWhenWithShadowedVar.kt b/idea/testData/codeInsight/codeTransformations/branched/folding/whenToAssignment/simpleWhenWithShadowedVar.kt
similarity index 100%
rename from idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleWhenWithShadowedVar.kt
rename to idea/testData/codeInsight/codeTransformations/branched/folding/whenToAssignment/simpleWhenWithShadowedVar.kt
diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleWhenWithUnmatchedAssignments.kt b/idea/testData/codeInsight/codeTransformations/branched/folding/whenToAssignment/simpleWhenWithUnmatchedAssignments.kt
similarity index 100%
rename from idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleWhenWithUnmatchedAssignments.kt
rename to idea/testData/codeInsight/codeTransformations/branched/folding/whenToAssignment/simpleWhenWithUnmatchedAssignments.kt
diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleWhenWithoutTerminatingAssignment.kt b/idea/testData/codeInsight/codeTransformations/branched/folding/whenToAssignment/simpleWhenWithoutTerminatingAssignment.kt
similarity index 100%
rename from idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleWhenWithoutTerminatingAssignment.kt
rename to idea/testData/codeInsight/codeTransformations/branched/folding/whenToAssignment/simpleWhenWithoutTerminatingAssignment.kt
diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/return/innerWhenTransformed.kt b/idea/testData/codeInsight/codeTransformations/branched/folding/whenToReturn/innerWhenTransformed.kt
similarity index 100%
rename from idea/testData/codeInsight/codeTransformations/branched/folding/return/innerWhenTransformed.kt
rename to idea/testData/codeInsight/codeTransformations/branched/folding/whenToReturn/innerWhenTransformed.kt
diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/return/innerWhenTransformed.kt.after b/idea/testData/codeInsight/codeTransformations/branched/folding/whenToReturn/innerWhenTransformed.kt.after
similarity index 100%
rename from idea/testData/codeInsight/codeTransformations/branched/folding/return/innerWhenTransformed.kt.after
rename to idea/testData/codeInsight/codeTransformations/branched/folding/whenToReturn/innerWhenTransformed.kt.after
diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/return/simpleWhen.kt b/idea/testData/codeInsight/codeTransformations/branched/folding/whenToReturn/simpleWhen.kt
similarity index 100%
rename from idea/testData/codeInsight/codeTransformations/branched/folding/return/simpleWhen.kt
rename to idea/testData/codeInsight/codeTransformations/branched/folding/whenToReturn/simpleWhen.kt
diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/return/simpleWhen.kt.after b/idea/testData/codeInsight/codeTransformations/branched/folding/whenToReturn/simpleWhen.kt.after
similarity index 100%
rename from idea/testData/codeInsight/codeTransformations/branched/folding/return/simpleWhen.kt.after
rename to idea/testData/codeInsight/codeTransformations/branched/folding/whenToReturn/simpleWhen.kt.after
diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/return/simpleWhenWithBlocks.kt b/idea/testData/codeInsight/codeTransformations/branched/folding/whenToReturn/simpleWhenWithBlocks.kt
similarity index 100%
rename from idea/testData/codeInsight/codeTransformations/branched/folding/return/simpleWhenWithBlocks.kt
rename to idea/testData/codeInsight/codeTransformations/branched/folding/whenToReturn/simpleWhenWithBlocks.kt
diff --git a/idea/testData/codeInsight/codeTransformations/branched/folding/return/simpleWhenWithBlocks.kt.after b/idea/testData/codeInsight/codeTransformations/branched/folding/whenToReturn/simpleWhenWithBlocks.kt.after
similarity index 100%
rename from idea/testData/codeInsight/codeTransformations/branched/folding/return/simpleWhenWithBlocks.kt.after
rename to idea/testData/codeInsight/codeTransformations/branched/folding/whenToReturn/simpleWhenWithBlocks.kt.after
diff --git a/idea/testData/codeInsight/codeTransformations/branched/unfolding/assignment/innerIfTransformed.kt b/idea/testData/codeInsight/codeTransformations/branched/unfolding/assignmentToIf/innerIfTransformed.kt
similarity index 100%
rename from idea/testData/codeInsight/codeTransformations/branched/unfolding/assignment/innerIfTransformed.kt
rename to idea/testData/codeInsight/codeTransformations/branched/unfolding/assignmentToIf/innerIfTransformed.kt
diff --git a/idea/testData/codeInsight/codeTransformations/branched/unfolding/assignment/innerIfTransformed.kt.after b/idea/testData/codeInsight/codeTransformations/branched/unfolding/assignmentToIf/innerIfTransformed.kt.after
similarity index 100%
rename from idea/testData/codeInsight/codeTransformations/branched/unfolding/assignment/innerIfTransformed.kt.after
rename to idea/testData/codeInsight/codeTransformations/branched/unfolding/assignmentToIf/innerIfTransformed.kt.after
diff --git a/idea/testData/codeInsight/codeTransformations/branched/unfolding/assignment/nestedIfs.kt b/idea/testData/codeInsight/codeTransformations/branched/unfolding/assignmentToIf/nestedIfs.kt
similarity index 100%
rename from idea/testData/codeInsight/codeTransformations/branched/unfolding/assignment/nestedIfs.kt
rename to idea/testData/codeInsight/codeTransformations/branched/unfolding/assignmentToIf/nestedIfs.kt
diff --git a/idea/testData/codeInsight/codeTransformations/branched/unfolding/assignment/nestedIfs.kt.after b/idea/testData/codeInsight/codeTransformations/branched/unfolding/assignmentToIf/nestedIfs.kt.after
similarity index 100%
rename from idea/testData/codeInsight/codeTransformations/branched/unfolding/assignment/nestedIfs.kt.after
rename to idea/testData/codeInsight/codeTransformations/branched/unfolding/assignmentToIf/nestedIfs.kt.after
diff --git a/idea/testData/codeInsight/codeTransformations/branched/unfolding/assignment/simpleIf.kt b/idea/testData/codeInsight/codeTransformations/branched/unfolding/assignmentToIf/simpleIf.kt
similarity index 100%
rename from idea/testData/codeInsight/codeTransformations/branched/unfolding/assignment/simpleIf.kt
rename to idea/testData/codeInsight/codeTransformations/branched/unfolding/assignmentToIf/simpleIf.kt
diff --git a/idea/testData/codeInsight/codeTransformations/branched/unfolding/assignment/simpleIf.kt.after b/idea/testData/codeInsight/codeTransformations/branched/unfolding/assignmentToIf/simpleIf.kt.after
similarity index 100%
rename from idea/testData/codeInsight/codeTransformations/branched/unfolding/assignment/simpleIf.kt.after
rename to idea/testData/codeInsight/codeTransformations/branched/unfolding/assignmentToIf/simpleIf.kt.after
diff --git a/idea/testData/codeInsight/codeTransformations/branched/unfolding/assignment/simpleIfWithAugmentedAssignment.kt b/idea/testData/codeInsight/codeTransformations/branched/unfolding/assignmentToIf/simpleIfWithAugmentedAssignment.kt
similarity index 100%
rename from idea/testData/codeInsight/codeTransformations/branched/unfolding/assignment/simpleIfWithAugmentedAssignment.kt
rename to idea/testData/codeInsight/codeTransformations/branched/unfolding/assignmentToIf/simpleIfWithAugmentedAssignment.kt
diff --git a/idea/testData/codeInsight/codeTransformations/branched/unfolding/assignment/simpleIfWithAugmentedAssignment.kt.after b/idea/testData/codeInsight/codeTransformations/branched/unfolding/assignmentToIf/simpleIfWithAugmentedAssignment.kt.after
similarity index 100%
rename from idea/testData/codeInsight/codeTransformations/branched/unfolding/assignment/simpleIfWithAugmentedAssignment.kt.after
rename to idea/testData/codeInsight/codeTransformations/branched/unfolding/assignmentToIf/simpleIfWithAugmentedAssignment.kt.after
diff --git a/idea/testData/codeInsight/codeTransformations/branched/unfolding/assignment/simpleIfWithBlocks.kt b/idea/testData/codeInsight/codeTransformations/branched/unfolding/assignmentToIf/simpleIfWithBlocks.kt
similarity index 100%
rename from idea/testData/codeInsight/codeTransformations/branched/unfolding/assignment/simpleIfWithBlocks.kt
rename to idea/testData/codeInsight/codeTransformations/branched/unfolding/assignmentToIf/simpleIfWithBlocks.kt
diff --git a/idea/testData/codeInsight/codeTransformations/branched/unfolding/assignment/simpleIfWithBlocks.kt.after b/idea/testData/codeInsight/codeTransformations/branched/unfolding/assignmentToIf/simpleIfWithBlocks.kt.after
similarity index 100%
rename from idea/testData/codeInsight/codeTransformations/branched/unfolding/assignment/simpleIfWithBlocks.kt.after
rename to idea/testData/codeInsight/codeTransformations/branched/unfolding/assignmentToIf/simpleIfWithBlocks.kt.after
diff --git a/idea/testData/codeInsight/codeTransformations/branched/unfolding/assignment/simpleIfWithoutAssignment.kt b/idea/testData/codeInsight/codeTransformations/branched/unfolding/assignmentToIf/simpleIfWithoutAssignment.kt
similarity index 100%
rename from idea/testData/codeInsight/codeTransformations/branched/unfolding/assignment/simpleIfWithoutAssignment.kt
rename to idea/testData/codeInsight/codeTransformations/branched/unfolding/assignmentToIf/simpleIfWithoutAssignment.kt
diff --git a/idea/testData/codeInsight/codeTransformations/branched/unfolding/return/innerIfTransformed.kt b/idea/testData/codeInsight/codeTransformations/branched/unfolding/returnToIf/innerIfTransformed.kt
similarity index 100%
rename from idea/testData/codeInsight/codeTransformations/branched/unfolding/return/innerIfTransformed.kt
rename to idea/testData/codeInsight/codeTransformations/branched/unfolding/returnToIf/innerIfTransformed.kt
diff --git a/idea/testData/codeInsight/codeTransformations/branched/unfolding/return/innerIfTransformed.kt.after b/idea/testData/codeInsight/codeTransformations/branched/unfolding/returnToIf/innerIfTransformed.kt.after
similarity index 100%
rename from idea/testData/codeInsight/codeTransformations/branched/unfolding/return/innerIfTransformed.kt.after
rename to idea/testData/codeInsight/codeTransformations/branched/unfolding/returnToIf/innerIfTransformed.kt.after
diff --git a/idea/testData/codeInsight/codeTransformations/branched/unfolding/return/simpleIf.kt b/idea/testData/codeInsight/codeTransformations/branched/unfolding/returnToIf/simpleIf.kt
similarity index 100%
rename from idea/testData/codeInsight/codeTransformations/branched/unfolding/return/simpleIf.kt
rename to idea/testData/codeInsight/codeTransformations/branched/unfolding/returnToIf/simpleIf.kt
diff --git a/idea/testData/codeInsight/codeTransformations/branched/unfolding/return/simpleIf.kt.after b/idea/testData/codeInsight/codeTransformations/branched/unfolding/returnToIf/simpleIf.kt.after
similarity index 100%
rename from idea/testData/codeInsight/codeTransformations/branched/unfolding/return/simpleIf.kt.after
rename to idea/testData/codeInsight/codeTransformations/branched/unfolding/returnToIf/simpleIf.kt.after
diff --git a/idea/testData/codeInsight/codeTransformations/branched/unfolding/return/simpleIfWithBlocks.kt b/idea/testData/codeInsight/codeTransformations/branched/unfolding/returnToIf/simpleIfWithBlocks.kt
similarity index 100%
rename from idea/testData/codeInsight/codeTransformations/branched/unfolding/return/simpleIfWithBlocks.kt
rename to idea/testData/codeInsight/codeTransformations/branched/unfolding/returnToIf/simpleIfWithBlocks.kt
diff --git a/idea/testData/codeInsight/codeTransformations/branched/unfolding/return/simpleIfWithBlocks.kt.after b/idea/testData/codeInsight/codeTransformations/branched/unfolding/returnToIf/simpleIfWithBlocks.kt.after
similarity index 100%
rename from idea/testData/codeInsight/codeTransformations/branched/unfolding/return/simpleIfWithBlocks.kt.after
rename to idea/testData/codeInsight/codeTransformations/branched/unfolding/returnToIf/simpleIfWithBlocks.kt.after
diff --git a/idea/tests/org/jetbrains/jet/plugin/codeInsight/codeTransformations/AbstractCodeTransformationTest.java b/idea/tests/org/jetbrains/jet/plugin/codeInsight/codeTransformations/AbstractCodeTransformationTest.java
index 4c904907a81..4d7e40e9de1 100644
--- a/idea/tests/org/jetbrains/jet/plugin/codeInsight/codeTransformations/AbstractCodeTransformationTest.java
+++ b/idea/tests/org/jetbrains/jet/plugin/codeInsight/codeTransformations/AbstractCodeTransformationTest.java
@@ -21,18 +21,45 @@ import com.intellij.openapi.util.io.FileUtil;
import com.intellij.testFramework.LightCodeInsightTestCase;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.InTextDirectivesUtils;
-import org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.FoldBranchedExpressionIntention;
-import org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.UnfoldBranchedExpressionIntention;
+import org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.intentions.*;
import java.io.File;
public abstract class AbstractCodeTransformationTest extends LightCodeInsightTestCase {
- public void doTestBranchedFolding(@NotNull String path) throws Exception {
- doTest(path, new FoldBranchedExpressionIntention());
+ public void doTestFoldIfToAssignment(@NotNull String path) throws Exception {
+ doTest(path, new FoldIfToAssignmentIntention());
}
- public void doTestBranchedUnfolding(@NotNull String path) throws Exception {
- doTest(path, new UnfoldBranchedExpressionIntention());
+ public void doTestFoldIfToReturn(@NotNull String path) throws Exception {
+ doTest(path, new FoldIfToReturnIntention());
+ }
+
+ public void doTestFoldIfToReturnAsymmetrically(@NotNull String path) throws Exception {
+ doTest(path, new FoldIfToReturnAsymmetricallyIntention());
+ }
+
+ public void doTestFoldWhenToAssignment(@NotNull String path) throws Exception {
+ doTest(path, new FoldWhenToAssignmentIntention());
+ }
+
+ public void doTestFoldWhenToReturn(@NotNull String path) throws Exception {
+ doTest(path, new FoldWhenToReturnIntention());
+ }
+
+ public void doTestUnfoldAssignmentToIf(@NotNull String path) throws Exception {
+ doTest(path, new UnfoldAssignmentToIfIntention());
+ }
+
+ public void doTestUnfoldAssignmentToWhen(@NotNull String path) throws Exception {
+ doTest(path, new UnfoldAssignmentToWhenIntention());
+ }
+
+ public void doTestUnfoldReturnToIf(@NotNull String path) throws Exception {
+ doTest(path, new UnfoldReturnToIfIntention());
+ }
+
+ public void doTestUnfoldReturnToWhen(@NotNull String path) throws Exception {
+ doTest(path, new UnfoldAssignmentToIfIntention());
}
public void doTestRemoveUnnecessaryParentheses(@NotNull String path) throws Exception {
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 573c6bdaa89..7313beab78e 100644
--- a/idea/tests/org/jetbrains/jet/plugin/codeInsight/codeTransformations/CodeTransformationsTestGenerated.java
+++ b/idea/tests/org/jetbrains/jet/plugin/codeInsight/codeTransformations/CodeTransformationsTestGenerated.java
@@ -30,250 +30,238 @@ 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.Folding.class, CodeTransformationsTestGenerated.Unfolding.class})
+@InnerTestClasses({CodeTransformationsTestGenerated.IfToAssignment.class, CodeTransformationsTestGenerated.IfToReturn.class, CodeTransformationsTestGenerated.IfToReturnAsymmetrically.class, CodeTransformationsTestGenerated.WhenToAssignment.class, CodeTransformationsTestGenerated.WhenToReturn.class, CodeTransformationsTestGenerated.AssignmentToIf.class, CodeTransformationsTestGenerated.ReturnToIf.class})
public class CodeTransformationsTestGenerated extends AbstractCodeTransformationTest {
- @TestMetadata("idea/testData/codeInsight/codeTransformations/branched/folding")
- @InnerTestClasses({Folding.Assignment.class, Folding.AsymmetricReturn.class, Folding.Return.class})
- public static class Folding extends AbstractCodeTransformationTest {
- public void testAllFilesPresentInFolding() throws Exception {
- JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/codeInsight/codeTransformations/branched/folding"), Pattern.compile("^(.+)\\.kt$"), true);
+ @TestMetadata("idea/testData/codeInsight/codeTransformations/branched/folding/ifToAssignment")
+ public static class IfToAssignment extends AbstractCodeTransformationTest {
+ public void testAllFilesPresentInIfToAssignment() throws Exception {
+ JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/codeInsight/codeTransformations/branched/folding/ifToAssignment"), Pattern.compile("^(.+)\\.kt$"), true);
}
- @TestMetadata("idea/testData/codeInsight/codeTransformations/branched/folding/assignment")
- public static class Assignment extends AbstractCodeTransformationTest {
- public void testAllFilesPresentInAssignment() throws Exception {
- JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/codeInsight/codeTransformations/branched/folding/assignment"), Pattern.compile("^(.+)\\.kt$"), true);
- }
-
- @TestMetadata("innerIfTransformed.kt")
- public void testInnerIfTransformed() throws Exception {
- doTestBranchedFolding("idea/testData/codeInsight/codeTransformations/branched/folding/assignment/innerIfTransformed.kt");
- }
-
- @TestMetadata("innerWhenTransformed.kt")
- public void testInnerWhenTransformed() throws Exception {
- doTestBranchedFolding("idea/testData/codeInsight/codeTransformations/branched/folding/assignment/innerWhenTransformed.kt");
- }
-
- @TestMetadata("simpleIf.kt")
- public void testSimpleIf() throws Exception {
- doTestBranchedFolding("idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleIf.kt");
- }
-
- @TestMetadata("simpleIfWithAugmentedAssignment.kt")
- public void testSimpleIfWithAugmentedAssignment() throws Exception {
- doTestBranchedFolding("idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleIfWithAugmentedAssignment.kt");
- }
-
- @TestMetadata("simpleIfWithBlocks.kt")
- public void testSimpleIfWithBlocks() throws Exception {
- doTestBranchedFolding("idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleIfWithBlocks.kt");
- }
-
- @TestMetadata("simpleIfWithShadowedVar.kt")
- public void testSimpleIfWithShadowedVar() throws Exception {
- doTestBranchedFolding("idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleIfWithShadowedVar.kt");
- }
-
- @TestMetadata("simpleIfWithUnmatchedAssignmentOps.kt")
- public void testSimpleIfWithUnmatchedAssignmentOps() throws Exception {
- doTestBranchedFolding("idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleIfWithUnmatchedAssignmentOps.kt");
- }
-
- @TestMetadata("simpleIfWithUnmatchedAssignments.kt")
- public void testSimpleIfWithUnmatchedAssignments() throws Exception {
- doTestBranchedFolding("idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleIfWithUnmatchedAssignments.kt");
- }
-
- @TestMetadata("simpleIfWithoutElse.kt")
- public void testSimpleIfWithoutElse() throws Exception {
- doTestBranchedFolding("idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleIfWithoutElse.kt");
- }
-
- @TestMetadata("simpleIfWithoutTerminatingAssignment.kt")
- public void testSimpleIfWithoutTerminatingAssignment() throws Exception {
- doTestBranchedFolding("idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleIfWithoutTerminatingAssignment.kt");
- }
-
- @TestMetadata("simpleWhen.kt")
- public void testSimpleWhen() throws Exception {
- doTestBranchedFolding("idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleWhen.kt");
- }
-
- @TestMetadata("simpleWhenWithBlocks.kt")
- public void testSimpleWhenWithBlocks() throws Exception {
- doTestBranchedFolding("idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleWhenWithBlocks.kt");
- }
-
- @TestMetadata("simpleWhenWithShadowedVar.kt")
- public void testSimpleWhenWithShadowedVar() throws Exception {
- doTestBranchedFolding("idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleWhenWithShadowedVar.kt");
- }
-
- @TestMetadata("simpleWhenWithUnmatchedAssignments.kt")
- public void testSimpleWhenWithUnmatchedAssignments() throws Exception {
- doTestBranchedFolding("idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleWhenWithUnmatchedAssignments.kt");
- }
-
- @TestMetadata("simpleWhenWithoutTerminatingAssignment.kt")
- public void testSimpleWhenWithoutTerminatingAssignment() throws Exception {
- doTestBranchedFolding("idea/testData/codeInsight/codeTransformations/branched/folding/assignment/simpleWhenWithoutTerminatingAssignment.kt");
- }
-
+ @TestMetadata("innerIfTransformed.kt")
+ public void testInnerIfTransformed() throws Exception {
+ doTestFoldIfToAssignment("idea/testData/codeInsight/codeTransformations/branched/folding/ifToAssignment/innerIfTransformed.kt");
}
- @TestMetadata("idea/testData/codeInsight/codeTransformations/branched/folding/asymmetricReturn")
- public static class AsymmetricReturn extends AbstractCodeTransformationTest {
- public void testAllFilesPresentInAsymmetricReturn() throws Exception {
- JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/codeInsight/codeTransformations/branched/folding/asymmetricReturn"), Pattern.compile("^(.+)\\.kt$"), true);
- }
-
- @TestMetadata("simpleIf.kt")
- public void testSimpleIf() throws Exception {
- doTestBranchedFolding("idea/testData/codeInsight/codeTransformations/branched/folding/asymmetricReturn/simpleIf.kt");
- }
-
- @TestMetadata("simpleIfWithBlocks.kt")
- public void testSimpleIfWithBlocks() throws Exception {
- doTestBranchedFolding("idea/testData/codeInsight/codeTransformations/branched/folding/asymmetricReturn/simpleIfWithBlocks.kt");
- }
-
- @TestMetadata("simpleIfWithComments.kt")
- public void testSimpleIfWithComments() throws Exception {
- doTestBranchedFolding("idea/testData/codeInsight/codeTransformations/branched/folding/asymmetricReturn/simpleIfWithComments.kt");
- }
-
+ @TestMetadata("simpleIf.kt")
+ public void testSimpleIf() throws Exception {
+ doTestFoldIfToAssignment("idea/testData/codeInsight/codeTransformations/branched/folding/ifToAssignment/simpleIf.kt");
}
- @TestMetadata("idea/testData/codeInsight/codeTransformations/branched/folding/return")
- public static class Return extends AbstractCodeTransformationTest {
- public void testAllFilesPresentInReturn() throws Exception {
- JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/codeInsight/codeTransformations/branched/folding/return"), Pattern.compile("^(.+)\\.kt$"), true);
- }
-
- @TestMetadata("innerIfTransformed.kt")
- public void testInnerIfTransformed() throws Exception {
- doTestBranchedFolding("idea/testData/codeInsight/codeTransformations/branched/folding/return/innerIfTransformed.kt");
- }
-
- @TestMetadata("innerWhenTransformed.kt")
- public void testInnerWhenTransformed() throws Exception {
- doTestBranchedFolding("idea/testData/codeInsight/codeTransformations/branched/folding/return/innerWhenTransformed.kt");
- }
-
- @TestMetadata("simpleIf.kt")
- public void testSimpleIf() throws Exception {
- doTestBranchedFolding("idea/testData/codeInsight/codeTransformations/branched/folding/return/simpleIf.kt");
- }
-
- @TestMetadata("simpleIfWithBlocks.kt")
- public void testSimpleIfWithBlocks() throws Exception {
- doTestBranchedFolding("idea/testData/codeInsight/codeTransformations/branched/folding/return/simpleIfWithBlocks.kt");
- }
-
- @TestMetadata("simpleWhen.kt")
- public void testSimpleWhen() throws Exception {
- doTestBranchedFolding("idea/testData/codeInsight/codeTransformations/branched/folding/return/simpleWhen.kt");
- }
-
- @TestMetadata("simpleWhenWithBlocks.kt")
- public void testSimpleWhenWithBlocks() throws Exception {
- doTestBranchedFolding("idea/testData/codeInsight/codeTransformations/branched/folding/return/simpleWhenWithBlocks.kt");
- }
-
+ @TestMetadata("simpleIfWithAugmentedAssignment.kt")
+ public void testSimpleIfWithAugmentedAssignment() throws Exception {
+ doTestFoldIfToAssignment("idea/testData/codeInsight/codeTransformations/branched/folding/ifToAssignment/simpleIfWithAugmentedAssignment.kt");
}
- public static Test innerSuite() {
- TestSuite suite = new TestSuite("Folding");
- suite.addTestSuite(Folding.class);
- suite.addTestSuite(Assignment.class);
- suite.addTestSuite(AsymmetricReturn.class);
- suite.addTestSuite(Return.class);
- return suite;
+ @TestMetadata("simpleIfWithBlocks.kt")
+ public void testSimpleIfWithBlocks() throws Exception {
+ doTestFoldIfToAssignment("idea/testData/codeInsight/codeTransformations/branched/folding/ifToAssignment/simpleIfWithBlocks.kt");
}
+
+ @TestMetadata("simpleIfWithShadowedVar.kt")
+ public void testSimpleIfWithShadowedVar() throws Exception {
+ doTestFoldIfToAssignment("idea/testData/codeInsight/codeTransformations/branched/folding/ifToAssignment/simpleIfWithShadowedVar.kt");
+ }
+
+ @TestMetadata("simpleIfWithUnmatchedAssignmentOps.kt")
+ public void testSimpleIfWithUnmatchedAssignmentOps() throws Exception {
+ doTestFoldIfToAssignment("idea/testData/codeInsight/codeTransformations/branched/folding/ifToAssignment/simpleIfWithUnmatchedAssignmentOps.kt");
+ }
+
+ @TestMetadata("simpleIfWithUnmatchedAssignments.kt")
+ public void testSimpleIfWithUnmatchedAssignments() throws Exception {
+ doTestFoldIfToAssignment("idea/testData/codeInsight/codeTransformations/branched/folding/ifToAssignment/simpleIfWithUnmatchedAssignments.kt");
+ }
+
+ @TestMetadata("simpleIfWithoutElse.kt")
+ public void testSimpleIfWithoutElse() throws Exception {
+ doTestFoldIfToAssignment("idea/testData/codeInsight/codeTransformations/branched/folding/ifToAssignment/simpleIfWithoutElse.kt");
+ }
+
+ @TestMetadata("simpleIfWithoutTerminatingAssignment.kt")
+ public void testSimpleIfWithoutTerminatingAssignment() throws Exception {
+ doTestFoldIfToAssignment("idea/testData/codeInsight/codeTransformations/branched/folding/ifToAssignment/simpleIfWithoutTerminatingAssignment.kt");
+ }
+
}
- @TestMetadata("idea/testData/codeInsight/codeTransformations/branched/unfolding")
- @InnerTestClasses({Unfolding.Assignment.class, Unfolding.Return.class})
- public static class Unfolding extends AbstractCodeTransformationTest {
- public void testAllFilesPresentInUnfolding() throws Exception {
- JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/codeInsight/codeTransformations/branched/unfolding"), Pattern.compile("^(.+)\\.kt$"), true);
+ @TestMetadata("idea/testData/codeInsight/codeTransformations/branched/folding/ifToReturn")
+ public static class IfToReturn extends AbstractCodeTransformationTest {
+ public void testAllFilesPresentInIfToReturn() throws Exception {
+ JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/codeInsight/codeTransformations/branched/folding/ifToReturn"), Pattern.compile("^(.+)\\.kt$"), true);
}
- @TestMetadata("idea/testData/codeInsight/codeTransformations/branched/unfolding/assignment")
- public static class Assignment extends AbstractCodeTransformationTest {
- public void testAllFilesPresentInAssignment() throws Exception {
- JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/codeInsight/codeTransformations/branched/unfolding/assignment"), Pattern.compile("^(.+)\\.kt$"), true);
- }
-
- @TestMetadata("innerIfTransformed.kt")
- public void testInnerIfTransformed() throws Exception {
- doTestBranchedUnfolding("idea/testData/codeInsight/codeTransformations/branched/unfolding/assignment/innerIfTransformed.kt");
- }
-
- @TestMetadata("nestedIfs.kt")
- public void testNestedIfs() throws Exception {
- doTestBranchedUnfolding("idea/testData/codeInsight/codeTransformations/branched/unfolding/assignment/nestedIfs.kt");
- }
-
- @TestMetadata("simpleIf.kt")
- public void testSimpleIf() throws Exception {
- doTestBranchedUnfolding("idea/testData/codeInsight/codeTransformations/branched/unfolding/assignment/simpleIf.kt");
- }
-
- @TestMetadata("simpleIfWithAugmentedAssignment.kt")
- public void testSimpleIfWithAugmentedAssignment() throws Exception {
- doTestBranchedUnfolding("idea/testData/codeInsight/codeTransformations/branched/unfolding/assignment/simpleIfWithAugmentedAssignment.kt");
- }
-
- @TestMetadata("simpleIfWithBlocks.kt")
- public void testSimpleIfWithBlocks() throws Exception {
- doTestBranchedUnfolding("idea/testData/codeInsight/codeTransformations/branched/unfolding/assignment/simpleIfWithBlocks.kt");
- }
-
- @TestMetadata("simpleIfWithoutAssignment.kt")
- public void testSimpleIfWithoutAssignment() throws Exception {
- doTestBranchedUnfolding("idea/testData/codeInsight/codeTransformations/branched/unfolding/assignment/simpleIfWithoutAssignment.kt");
- }
-
+ @TestMetadata("innerIfTransformed.kt")
+ public void testInnerIfTransformed() throws Exception {
+ doTestFoldIfToReturn("idea/testData/codeInsight/codeTransformations/branched/folding/ifToReturn/innerIfTransformed.kt");
}
- @TestMetadata("idea/testData/codeInsight/codeTransformations/branched/unfolding/return")
- public static class Return extends AbstractCodeTransformationTest {
- public void testAllFilesPresentInReturn() throws Exception {
- JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/codeInsight/codeTransformations/branched/unfolding/return"), Pattern.compile("^(.+)\\.kt$"), true);
- }
-
- @TestMetadata("innerIfTransformed.kt")
- public void testInnerIfTransformed() throws Exception {
- doTestBranchedUnfolding("idea/testData/codeInsight/codeTransformations/branched/unfolding/return/innerIfTransformed.kt");
- }
-
- @TestMetadata("simpleIf.kt")
- public void testSimpleIf() throws Exception {
- doTestBranchedUnfolding("idea/testData/codeInsight/codeTransformations/branched/unfolding/return/simpleIf.kt");
- }
-
- @TestMetadata("simpleIfWithBlocks.kt")
- public void testSimpleIfWithBlocks() throws Exception {
- doTestBranchedUnfolding("idea/testData/codeInsight/codeTransformations/branched/unfolding/return/simpleIfWithBlocks.kt");
- }
-
+ @TestMetadata("simpleIf.kt")
+ public void testSimpleIf() throws Exception {
+ doTestFoldIfToReturn("idea/testData/codeInsight/codeTransformations/branched/folding/ifToReturn/simpleIf.kt");
}
- public static Test innerSuite() {
- TestSuite suite = new TestSuite("Unfolding");
- suite.addTestSuite(Unfolding.class);
- suite.addTestSuite(Assignment.class);
- suite.addTestSuite(Return.class);
- return suite;
+ @TestMetadata("simpleIfWithBlocks.kt")
+ public void testSimpleIfWithBlocks() throws Exception {
+ doTestFoldIfToReturn("idea/testData/codeInsight/codeTransformations/branched/folding/ifToReturn/simpleIfWithBlocks.kt");
}
+
+ }
+
+ @TestMetadata("idea/testData/codeInsight/codeTransformations/branched/folding/ifToReturnAsymmetrically")
+ public static class IfToReturnAsymmetrically extends AbstractCodeTransformationTest {
+ public void testAllFilesPresentInIfToReturnAsymmetrically() throws Exception {
+ JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/codeInsight/codeTransformations/branched/folding/ifToReturnAsymmetrically"), Pattern.compile("^(.+)\\.kt$"), true);
+ }
+
+ @TestMetadata("simpleIf.kt")
+ public void testSimpleIf() throws Exception {
+ doTestFoldIfToReturnAsymmetrically("idea/testData/codeInsight/codeTransformations/branched/folding/ifToReturnAsymmetrically/simpleIf.kt");
+ }
+
+ @TestMetadata("simpleIfWithBlocks.kt")
+ public void testSimpleIfWithBlocks() throws Exception {
+ doTestFoldIfToReturnAsymmetrically("idea/testData/codeInsight/codeTransformations/branched/folding/ifToReturnAsymmetrically/simpleIfWithBlocks.kt");
+ }
+
+ @TestMetadata("simpleIfWithComments.kt")
+ public void testSimpleIfWithComments() throws Exception {
+ doTestFoldIfToReturnAsymmetrically("idea/testData/codeInsight/codeTransformations/branched/folding/ifToReturnAsymmetrically/simpleIfWithComments.kt");
+ }
+
+ }
+
+ @TestMetadata("idea/testData/codeInsight/codeTransformations/branched/folding/whenToAssignment")
+ public static class WhenToAssignment extends AbstractCodeTransformationTest {
+ public void testAllFilesPresentInWhenToAssignment() throws Exception {
+ JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/codeInsight/codeTransformations/branched/folding/whenToAssignment"), Pattern.compile("^(.+)\\.kt$"), true);
+ }
+
+ @TestMetadata("innerWhenTransformed.kt")
+ public void testInnerWhenTransformed() throws Exception {
+ doTestFoldWhenToAssignment("idea/testData/codeInsight/codeTransformations/branched/folding/whenToAssignment/innerWhenTransformed.kt");
+ }
+
+ @TestMetadata("simpleWhen.kt")
+ public void testSimpleWhen() throws Exception {
+ doTestFoldWhenToAssignment("idea/testData/codeInsight/codeTransformations/branched/folding/whenToAssignment/simpleWhen.kt");
+ }
+
+ @TestMetadata("simpleWhenWithBlocks.kt")
+ public void testSimpleWhenWithBlocks() throws Exception {
+ doTestFoldWhenToAssignment("idea/testData/codeInsight/codeTransformations/branched/folding/whenToAssignment/simpleWhenWithBlocks.kt");
+ }
+
+ @TestMetadata("simpleWhenWithShadowedVar.kt")
+ public void testSimpleWhenWithShadowedVar() throws Exception {
+ doTestFoldWhenToAssignment("idea/testData/codeInsight/codeTransformations/branched/folding/whenToAssignment/simpleWhenWithShadowedVar.kt");
+ }
+
+ @TestMetadata("simpleWhenWithUnmatchedAssignments.kt")
+ public void testSimpleWhenWithUnmatchedAssignments() throws Exception {
+ doTestFoldWhenToAssignment("idea/testData/codeInsight/codeTransformations/branched/folding/whenToAssignment/simpleWhenWithUnmatchedAssignments.kt");
+ }
+
+ @TestMetadata("simpleWhenWithoutTerminatingAssignment.kt")
+ public void testSimpleWhenWithoutTerminatingAssignment() throws Exception {
+ doTestFoldWhenToAssignment("idea/testData/codeInsight/codeTransformations/branched/folding/whenToAssignment/simpleWhenWithoutTerminatingAssignment.kt");
+ }
+
+ }
+
+ @TestMetadata("idea/testData/codeInsight/codeTransformations/branched/folding/whenToReturn")
+ public static class WhenToReturn extends AbstractCodeTransformationTest {
+ public void testAllFilesPresentInWhenToReturn() throws Exception {
+ JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/codeInsight/codeTransformations/branched/folding/whenToReturn"), Pattern.compile("^(.+)\\.kt$"), true);
+ }
+
+ @TestMetadata("innerWhenTransformed.kt")
+ public void testInnerWhenTransformed() throws Exception {
+ doTestFoldWhenToReturn("idea/testData/codeInsight/codeTransformations/branched/folding/whenToReturn/innerWhenTransformed.kt");
+ }
+
+ @TestMetadata("simpleWhen.kt")
+ public void testSimpleWhen() throws Exception {
+ doTestFoldWhenToReturn("idea/testData/codeInsight/codeTransformations/branched/folding/whenToReturn/simpleWhen.kt");
+ }
+
+ @TestMetadata("simpleWhenWithBlocks.kt")
+ public void testSimpleWhenWithBlocks() throws Exception {
+ doTestFoldWhenToReturn("idea/testData/codeInsight/codeTransformations/branched/folding/whenToReturn/simpleWhenWithBlocks.kt");
+ }
+
+ }
+
+ @TestMetadata("idea/testData/codeInsight/codeTransformations/branched/unfolding/assignmentToIf")
+ public static class AssignmentToIf extends AbstractCodeTransformationTest {
+ public void testAllFilesPresentInAssignmentToIf() throws Exception {
+ JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/codeInsight/codeTransformations/branched/unfolding/assignmentToIf"), Pattern.compile("^(.+)\\.kt$"), true);
+ }
+
+ @TestMetadata("innerIfTransformed.kt")
+ public void testInnerIfTransformed() throws Exception {
+ doTestUnfoldAssignmentToIf("idea/testData/codeInsight/codeTransformations/branched/unfolding/assignmentToIf/innerIfTransformed.kt");
+ }
+
+ @TestMetadata("nestedIfs.kt")
+ public void testNestedIfs() throws Exception {
+ doTestUnfoldAssignmentToIf("idea/testData/codeInsight/codeTransformations/branched/unfolding/assignmentToIf/nestedIfs.kt");
+ }
+
+ @TestMetadata("simpleIf.kt")
+ public void testSimpleIf() throws Exception {
+ doTestUnfoldAssignmentToIf("idea/testData/codeInsight/codeTransformations/branched/unfolding/assignmentToIf/simpleIf.kt");
+ }
+
+ @TestMetadata("simpleIfWithAugmentedAssignment.kt")
+ public void testSimpleIfWithAugmentedAssignment() throws Exception {
+ doTestUnfoldAssignmentToIf("idea/testData/codeInsight/codeTransformations/branched/unfolding/assignmentToIf/simpleIfWithAugmentedAssignment.kt");
+ }
+
+ @TestMetadata("simpleIfWithBlocks.kt")
+ public void testSimpleIfWithBlocks() throws Exception {
+ doTestUnfoldAssignmentToIf("idea/testData/codeInsight/codeTransformations/branched/unfolding/assignmentToIf/simpleIfWithBlocks.kt");
+ }
+
+ @TestMetadata("simpleIfWithoutAssignment.kt")
+ public void testSimpleIfWithoutAssignment() throws Exception {
+ doTestUnfoldAssignmentToIf("idea/testData/codeInsight/codeTransformations/branched/unfolding/assignmentToIf/simpleIfWithoutAssignment.kt");
+ }
+
+ }
+
+ @TestMetadata("idea/testData/codeInsight/codeTransformations/branched/unfolding/returnToIf")
+ public static class ReturnToIf extends AbstractCodeTransformationTest {
+ public void testAllFilesPresentInReturnToIf() throws Exception {
+ JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/codeInsight/codeTransformations/branched/unfolding/returnToIf"), Pattern.compile("^(.+)\\.kt$"), true);
+ }
+
+ @TestMetadata("innerIfTransformed.kt")
+ public void testInnerIfTransformed() throws Exception {
+ doTestUnfoldReturnToIf("idea/testData/codeInsight/codeTransformations/branched/unfolding/returnToIf/innerIfTransformed.kt");
+ }
+
+ @TestMetadata("simpleIf.kt")
+ public void testSimpleIf() throws Exception {
+ doTestUnfoldReturnToIf("idea/testData/codeInsight/codeTransformations/branched/unfolding/returnToIf/simpleIf.kt");
+ }
+
+ @TestMetadata("simpleIfWithBlocks.kt")
+ public void testSimpleIfWithBlocks() throws Exception {
+ doTestUnfoldReturnToIf("idea/testData/codeInsight/codeTransformations/branched/unfolding/returnToIf/simpleIfWithBlocks.kt");
+ }
+
}
public static Test suite() {
TestSuite suite = new TestSuite("CodeTransformationsTestGenerated");
- suite.addTest(Folding.innerSuite());
- suite.addTest(Unfolding.innerSuite());
+ suite.addTestSuite(IfToAssignment.class);
+ suite.addTestSuite(IfToReturn.class);
+ suite.addTestSuite(IfToReturnAsymmetrically.class);
+ suite.addTestSuite(WhenToAssignment.class);
+ suite.addTestSuite(WhenToReturn.class);
+ suite.addTestSuite(AssignmentToIf.class);
+ suite.addTestSuite(ReturnToIf.class);
return suite;
}
}