diff --git a/generators/src/org/jetbrains/jet/generators/tests/GenerateTests.kt b/generators/src/org/jetbrains/jet/generators/tests/GenerateTests.kt index 3d1731ce731..126de54734a 100644 --- a/generators/src/org/jetbrains/jet/generators/tests/GenerateTests.kt +++ b/generators/src/org/jetbrains/jet/generators/tests/GenerateTests.kt @@ -383,6 +383,7 @@ fun main(args: Array) { model("intentions/convertNegatedBooleanSequence", testMethod="doTestConvertNegatedBooleanSequence") model("intentions/convertNegatedExpressionWithDemorgansLaw", testMethod = "doTestConvertNegatedExpressionWithDemorgansLaw") model("intentions/swapBinaryExpression", testMethod = "doTestSwapBinaryExpression") + model("intentions/splitIf", testMethod = "doTestSplitIf") } testClass(javaClass()) { diff --git a/idea/resources/intentionDescriptions/SplitIfIntention/after.kt.template b/idea/resources/intentionDescriptions/SplitIfIntention/after.kt.template new file mode 100644 index 00000000000..c47fa497c11 --- /dev/null +++ b/idea/resources/intentionDescriptions/SplitIfIntention/after.kt.template @@ -0,0 +1,2 @@ +if (a) + if (b) return 1 \ No newline at end of file diff --git a/idea/resources/intentionDescriptions/SplitIfIntention/before.kt.template b/idea/resources/intentionDescriptions/SplitIfIntention/before.kt.template new file mode 100644 index 00000000000..788fe8cceda --- /dev/null +++ b/idea/resources/intentionDescriptions/SplitIfIntention/before.kt.template @@ -0,0 +1 @@ +if (a && b) return 1 diff --git a/idea/resources/intentionDescriptions/SplitIfIntention/description.html b/idea/resources/intentionDescriptions/SplitIfIntention/description.html new file mode 100644 index 00000000000..bb579113f10 --- /dev/null +++ b/idea/resources/intentionDescriptions/SplitIfIntention/description.html @@ -0,0 +1,6 @@ + + +This intention converts if statement containing conjuction operation in it its condition +into two nested if statements with simplified conditions.

+ + \ No newline at end of file diff --git a/idea/src/META-INF/plugin.xml b/idea/src/META-INF/plugin.xml index 18464131428..18ee0204808 100644 --- a/idea/src/META-INF/plugin.xml +++ b/idea/src/META-INF/plugin.xml @@ -640,6 +640,11 @@ Kotlin + + org.jetbrains.jet.plugin.intentions.SplitIfIntention + Kotlin + + diff --git a/idea/src/org/jetbrains/jet/plugin/JetBundle.properties b/idea/src/org/jetbrains/jet/plugin/JetBundle.properties index 921cc97a64d..197e7b925ff 100644 --- a/idea/src/org/jetbrains/jet/plugin/JetBundle.properties +++ b/idea/src/org/jetbrains/jet/plugin/JetBundle.properties @@ -285,7 +285,8 @@ convert.negated.boolean.sequence=Replace negated sequence with DeMorgan equivale convert.negated.boolean.sequence.family=Replace negated sequence with DeMorgan equivalent convert.negated.expression.with.demorgans.law=Convert negated expression to DeMorgan's equivalent convert.negated.expression.with.demorgans.law.family=Convert negated expression to DeMorgan's equivalent - +split.if=Split into 2 if's +split.if.family=Split If property.is.implemented.too.many=Has implementations property.is.overridden.too.many=Is overridden in subclasses diff --git a/idea/src/org/jetbrains/jet/plugin/intentions/SplitIfIntention.kt b/idea/src/org/jetbrains/jet/plugin/intentions/SplitIfIntention.kt new file mode 100644 index 00000000000..23f977e8f12 --- /dev/null +++ b/idea/src/org/jetbrains/jet/plugin/intentions/SplitIfIntention.kt @@ -0,0 +1,84 @@ +/* + * Copyright 2010-2014 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.intentions + +import org.jetbrains.jet.lang.psi.JetIfExpression +import com.intellij.openapi.editor.Editor +import org.jetbrains.jet.lang.psi.JetBinaryExpression +import org.jetbrains.jet.lang.psi.JetPsiFactory +import org.jetbrains.jet.lexer.JetTokens +import org.jetbrains.jet.lang.psi.psiUtil.getParentByType +import org.jetbrains.jet.lang.psi.JetExpression +import com.intellij.psi.util.PsiTreeUtil +import org.jetbrains.jet.lang.psi.JetSimpleNameExpression + +public class SplitIfIntention : JetSelfTargetingIntention("split.if", javaClass()) { + + override fun isApplicableTo(element: JetSimpleNameExpression): Boolean { + val operator = element.getReferencedNameElementType() + if (operator != JetTokens.ANDAND && operator != JetTokens.OROR) return false + + if (element.getParent() !is JetBinaryExpression) return false + var expression = element.getParent() as JetBinaryExpression + + if (expression.getRight() == null || expression.getLeft() == null) return false + + while (expression.getParent() is JetBinaryExpression) { + expression = expression.getParent() as JetBinaryExpression + if (operator == JetTokens.ANDAND && expression.getOperationToken() != JetTokens.ANDAND) return false + if (operator == JetTokens.OROR && expression.getOperationToken() != JetTokens.OROR) return false + } + + if (expression.getParent()?.getParent() !is JetIfExpression) return false + val ifExpression = expression.getParent()?.getParent() as JetIfExpression + + if (ifExpression.getCondition() == null) return false + if (!PsiTreeUtil.isAncestor(ifExpression.getCondition(), element, false)) return false + + if (ifExpression.getThen() == null) return false + + return true + } + + override fun applyTo(element: JetSimpleNameExpression, editor: Editor) { + val ifExpression = element.getParentByType(javaClass()) + val expression = element.getParent() as JetBinaryExpression + val rightExpression = getRight(expression, ifExpression!!.getCondition() as JetExpression) + val leftExpression = expression.getLeft() + val elseExpression = ifExpression.getElse() + val thenExpression = ifExpression.getThen() + + if (element.getReferencedNameElementType() == JetTokens.ANDAND) { + ifExpression.replace(JetPsiFactory.createIf(element.getProject(), leftExpression, + JetPsiFactory.wrapInABlock(JetPsiFactory.createIf(element.getProject(), rightExpression, thenExpression, + elseExpression)), elseExpression)) + } + else { + ifExpression.replace(JetPsiFactory.createIf(element.getProject(), leftExpression, thenExpression, + JetPsiFactory.createIf(element.getProject(), rightExpression, thenExpression, elseExpression))) + } + } + + fun getRight(element: JetBinaryExpression, condition: JetExpression): JetExpression { + //gets the textOffset of the right side of the JetBinaryExpression in context to condition + val startOffset = element.getRight()!!.getTextOffset() - condition.getTextOffset() + val rightString = condition.getText()!![startOffset, condition.getTextLength()].toString() + + return JetPsiFactory.createExpression(element.getProject(), rightString) + } +} + diff --git a/idea/testData/intentions/splitIf/splitIfAndOr.kt b/idea/testData/intentions/splitIf/splitIfAndOr.kt new file mode 100644 index 00000000000..3687f241674 --- /dev/null +++ b/idea/testData/intentions/splitIf/splitIfAndOr.kt @@ -0,0 +1,9 @@ +// IS_APPLICABLE: false +fun foo() { + val a = true + val b = false + val c = true + if (a && b || c) { + println("test") + } +} \ No newline at end of file diff --git a/idea/testData/intentions/splitIf/splitIfNotIf.kt b/idea/testData/intentions/splitIf/splitIfNotIf.kt new file mode 100644 index 00000000000..dedb80d7622 --- /dev/null +++ b/idea/testData/intentions/splitIf/splitIfNotIf.kt @@ -0,0 +1,8 @@ +// IS_APPLICABLE: false +fun foo() { + val a = true + val b = false + when (a && b) { + println("test") + } +} \ No newline at end of file diff --git a/idea/testData/intentions/splitIf/splitIfOneAND.kt b/idea/testData/intentions/splitIf/splitIfOneAND.kt new file mode 100644 index 00000000000..d0587605453 --- /dev/null +++ b/idea/testData/intentions/splitIf/splitIfOneAND.kt @@ -0,0 +1,7 @@ +fun foo() { + val a = true + val b = false + if (a && b) { + println("test") + } +} \ No newline at end of file diff --git a/idea/testData/intentions/splitIf/splitIfOneAND.kt.after b/idea/testData/intentions/splitIf/splitIfOneAND.kt.after new file mode 100644 index 00000000000..6704f257fc6 --- /dev/null +++ b/idea/testData/intentions/splitIf/splitIfOneAND.kt.after @@ -0,0 +1,9 @@ +fun foo() { + val a = true + val b = false + if (a) { + if (b) { + println("test") + } + } +} \ No newline at end of file diff --git a/idea/testData/intentions/splitIf/splitIfOperatorAsFunctionParam.kt b/idea/testData/intentions/splitIf/splitIfOperatorAsFunctionParam.kt new file mode 100644 index 00000000000..1ed0bad61b6 --- /dev/null +++ b/idea/testData/intentions/splitIf/splitIfOperatorAsFunctionParam.kt @@ -0,0 +1,9 @@ +// IS_APPLICABLE: false +fun foo() { + val a = true + val b = false + fun test(a: Boolean, b: Boolean): Boolean { return false } + if (test(a && b)) { + println("test") + } +} \ No newline at end of file diff --git a/idea/testData/intentions/splitIf/splitIfOperatorOutsideIf.kt b/idea/testData/intentions/splitIf/splitIfOperatorOutsideIf.kt new file mode 100644 index 00000000000..12e73625463 --- /dev/null +++ b/idea/testData/intentions/splitIf/splitIfOperatorOutsideIf.kt @@ -0,0 +1,8 @@ +// IS_APPLICABLE: false +fun foo() { + val a = true + val b = false + if (a) { + val v = a && b + } +} \ No newline at end of file diff --git a/idea/testData/intentions/splitIf/splitIfOrAnd.kt b/idea/testData/intentions/splitIf/splitIfOrAnd.kt new file mode 100644 index 00000000000..15ffc159d80 --- /dev/null +++ b/idea/testData/intentions/splitIf/splitIfOrAnd.kt @@ -0,0 +1,8 @@ +fun foo() { + val a = true + val b = false + val c = true + if (a || b && c) { + println("test") + } +} \ No newline at end of file diff --git a/idea/testData/intentions/splitIf/splitIfOrAnd.kt.after b/idea/testData/intentions/splitIf/splitIfOrAnd.kt.after new file mode 100644 index 00000000000..2a84f6a17b2 --- /dev/null +++ b/idea/testData/intentions/splitIf/splitIfOrAnd.kt.after @@ -0,0 +1,10 @@ +fun foo() { + val a = true + val b = false + val c = true + if (a) { + println("test") + } else if (b && c) { + println("test") + } +} \ No newline at end of file diff --git a/idea/testData/intentions/splitIf/splitIfTwoOperatorsFirst.kt b/idea/testData/intentions/splitIf/splitIfTwoOperatorsFirst.kt new file mode 100644 index 00000000000..30947780810 --- /dev/null +++ b/idea/testData/intentions/splitIf/splitIfTwoOperatorsFirst.kt @@ -0,0 +1,8 @@ +fun foo() { + val a = true + val b = false + val c = true + if (a && b && c) { + println("test") + } +} \ No newline at end of file diff --git a/idea/testData/intentions/splitIf/splitIfTwoOperatorsFirst.kt.after b/idea/testData/intentions/splitIf/splitIfTwoOperatorsFirst.kt.after new file mode 100644 index 00000000000..55bbe15f182 --- /dev/null +++ b/idea/testData/intentions/splitIf/splitIfTwoOperatorsFirst.kt.after @@ -0,0 +1,10 @@ +fun foo() { + val a = true + val b = false + val c = true + if (a) { + if (b && c) { + println("test") + } + } +} \ No newline at end of file diff --git a/idea/testData/intentions/splitIf/splitIfTwoOperatorsSecond.kt b/idea/testData/intentions/splitIf/splitIfTwoOperatorsSecond.kt new file mode 100644 index 00000000000..36e8991d8c9 --- /dev/null +++ b/idea/testData/intentions/splitIf/splitIfTwoOperatorsSecond.kt @@ -0,0 +1,8 @@ +fun foo() { + val a = true + val b = false + val c = true + if (a && b && c) { + println("test") + } +} \ No newline at end of file diff --git a/idea/testData/intentions/splitIf/splitIfTwoOperatorsSecond.kt.after b/idea/testData/intentions/splitIf/splitIfTwoOperatorsSecond.kt.after new file mode 100644 index 00000000000..2a456cc8cf6 --- /dev/null +++ b/idea/testData/intentions/splitIf/splitIfTwoOperatorsSecond.kt.after @@ -0,0 +1,10 @@ +fun foo() { + val a = true + val b = false + val c = true + if (a && b) { + if (c) { + println("test") + } + } +} \ No newline at end of file diff --git a/idea/testData/intentions/splitIf/splitIfWithElse.kt b/idea/testData/intentions/splitIf/splitIfWithElse.kt new file mode 100644 index 00000000000..ad69755d06a --- /dev/null +++ b/idea/testData/intentions/splitIf/splitIfWithElse.kt @@ -0,0 +1,9 @@ +fun foo() { + val a = true + val b = false + if (a && b) { + println("test") + } else { + println("test2") + } +} \ No newline at end of file diff --git a/idea/testData/intentions/splitIf/splitIfWithElse.kt.after b/idea/testData/intentions/splitIf/splitIfWithElse.kt.after new file mode 100644 index 00000000000..32e007e1bbf --- /dev/null +++ b/idea/testData/intentions/splitIf/splitIfWithElse.kt.after @@ -0,0 +1,13 @@ +fun foo() { + val a = true + val b = false + if (a) { + if (b) { + println("test") + } else { + println("test2") + } + } else { + println("test2") + } +} \ No newline at end of file diff --git a/idea/testData/intentions/splitIf/splitIfWithFunction.kt b/idea/testData/intentions/splitIf/splitIfWithFunction.kt new file mode 100644 index 00000000000..ce5f4a4aff8 --- /dev/null +++ b/idea/testData/intentions/splitIf/splitIfWithFunction.kt @@ -0,0 +1,7 @@ +fun foo() { + fun test(): Boolean { return false } + val a = true + if (test() && a) { + println("test") + } +} \ No newline at end of file diff --git a/idea/testData/intentions/splitIf/splitIfWithFunction.kt.after b/idea/testData/intentions/splitIf/splitIfWithFunction.kt.after new file mode 100644 index 00000000000..375e7c19d25 --- /dev/null +++ b/idea/testData/intentions/splitIf/splitIfWithFunction.kt.after @@ -0,0 +1,9 @@ +fun foo() { + fun test(): Boolean { return false } + val a = true + if (test()) { + if (a) { + println("test") + } + } +} \ No newline at end of file diff --git a/idea/testData/intentions/splitIf/splitIfWithNotOperator.kt b/idea/testData/intentions/splitIf/splitIfWithNotOperator.kt new file mode 100644 index 00000000000..df9f6e96dd1 --- /dev/null +++ b/idea/testData/intentions/splitIf/splitIfWithNotOperator.kt @@ -0,0 +1,8 @@ +// IS_APPLICABLE: false +fun foo() { + val a = true + val b = false + if (!(a && b)) { + println("test") + } +} \ No newline at end of file diff --git a/idea/testData/intentions/splitIf/splitIfWithNotOperatorGood.kt b/idea/testData/intentions/splitIf/splitIfWithNotOperatorGood.kt new file mode 100644 index 00000000000..8c08dc4b79e --- /dev/null +++ b/idea/testData/intentions/splitIf/splitIfWithNotOperatorGood.kt @@ -0,0 +1,7 @@ +fun foo() { + val a = true + val b = false + if (a && !b) { + println("test") + } +} \ No newline at end of file diff --git a/idea/testData/intentions/splitIf/splitIfWithNotOperatorGood.kt.after b/idea/testData/intentions/splitIf/splitIfWithNotOperatorGood.kt.after new file mode 100644 index 00000000000..61de17d4a0b --- /dev/null +++ b/idea/testData/intentions/splitIf/splitIfWithNotOperatorGood.kt.after @@ -0,0 +1,9 @@ +fun foo() { + val a = true + val b = false + if (a) { + if (!b) { + println("test") + } + } +} \ No newline at end of file diff --git a/idea/testData/intentions/splitIf/splitIfWithOR.kt b/idea/testData/intentions/splitIf/splitIfWithOR.kt new file mode 100644 index 00000000000..1810d2b907c --- /dev/null +++ b/idea/testData/intentions/splitIf/splitIfWithOR.kt @@ -0,0 +1,7 @@ +fun foo() { + val a = true + val b = false + if (a || b) { + println("test") + } +} \ No newline at end of file diff --git a/idea/testData/intentions/splitIf/splitIfWithOR.kt.after b/idea/testData/intentions/splitIf/splitIfWithOR.kt.after new file mode 100644 index 00000000000..4bd7bc01931 --- /dev/null +++ b/idea/testData/intentions/splitIf/splitIfWithOR.kt.after @@ -0,0 +1,9 @@ +fun foo() { + val a = true + val b = false + if (a) { + println("test") + } else if (b) { + println("test") + } +} \ No newline at end of file diff --git a/idea/testData/intentions/splitIf/splitIfWithORElse.kt b/idea/testData/intentions/splitIf/splitIfWithORElse.kt new file mode 100644 index 00000000000..e7055a9e3b0 --- /dev/null +++ b/idea/testData/intentions/splitIf/splitIfWithORElse.kt @@ -0,0 +1,9 @@ +fun foo() { + val a = true + val b = false + if (a || b) { + println("test") + } else { + println("test2") + } +} \ No newline at end of file diff --git a/idea/testData/intentions/splitIf/splitIfWithORElse.kt.after b/idea/testData/intentions/splitIf/splitIfWithORElse.kt.after new file mode 100644 index 00000000000..b2c72ce67ce --- /dev/null +++ b/idea/testData/intentions/splitIf/splitIfWithORElse.kt.after @@ -0,0 +1,11 @@ +fun foo() { + val a = true + val b = false + if (a) { + println("test") + } else if (b) { + println("test") + } else { + println("test2") + } +} \ No newline at end of file diff --git a/idea/testData/intentions/splitIf/splitIfWrongCaretLocation.kt b/idea/testData/intentions/splitIf/splitIfWrongCaretLocation.kt new file mode 100644 index 00000000000..5f962362e23 --- /dev/null +++ b/idea/testData/intentions/splitIf/splitIfWrongCaretLocation.kt @@ -0,0 +1,8 @@ +// IS_APPLICABLE: false +fun foo() { + val a = true + val b = false + if (a && b) { + println("test") + } +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/jet/plugin/intentions/AbstractCodeTransformationTest.java b/idea/tests/org/jetbrains/jet/plugin/intentions/AbstractCodeTransformationTest.java index 21ae638af39..015b39149bd 100644 --- a/idea/tests/org/jetbrains/jet/plugin/intentions/AbstractCodeTransformationTest.java +++ b/idea/tests/org/jetbrains/jet/plugin/intentions/AbstractCodeTransformationTest.java @@ -208,6 +208,10 @@ public abstract class AbstractCodeTransformationTest extends LightCodeInsightTes doTestIntention(path, new SimplifyNegatedBinaryExpressionIntention()); } + public void doTestSplitIf(@NotNull String path) throws Exception { + doTestIntention(path, new SplitIfIntention()); + } + private void doTestIntention(@NotNull String path, @NotNull IntentionAction intentionAction) throws Exception { configureByFile(path); diff --git a/idea/tests/org/jetbrains/jet/plugin/intentions/CodeTransformationTestGenerated.java b/idea/tests/org/jetbrains/jet/plugin/intentions/CodeTransformationTestGenerated.java index fa9ae2df933..59a7a4adfb9 100644 --- a/idea/tests/org/jetbrains/jet/plugin/intentions/CodeTransformationTestGenerated.java +++ b/idea/tests/org/jetbrains/jet/plugin/intentions/CodeTransformationTestGenerated.java @@ -30,7 +30,7 @@ import org.jetbrains.jet.plugin.intentions.AbstractCodeTransformationTest; /** This class is generated by {@link org.jetbrains.jet.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */ @SuppressWarnings("all") -@InnerTestClasses({CodeTransformationTestGenerated.ElvisToIfThen.class, CodeTransformationTestGenerated.IfThenToElvis.class, CodeTransformationTestGenerated.SafeAccessToIfThen.class, CodeTransformationTestGenerated.IfThenToSafeAccess.class, CodeTransformationTestGenerated.IfToAssignment.class, CodeTransformationTestGenerated.IfToReturn.class, CodeTransformationTestGenerated.IfToReturnAsymmetrically.class, CodeTransformationTestGenerated.WhenToAssignment.class, CodeTransformationTestGenerated.WhenToReturn.class, CodeTransformationTestGenerated.AssignmentToIf.class, CodeTransformationTestGenerated.AssignmentToWhen.class, CodeTransformationTestGenerated.PropertyToIf.class, CodeTransformationTestGenerated.PropertyToWhen.class, CodeTransformationTestGenerated.ReturnToIf.class, CodeTransformationTestGenerated.ReturnToWhen.class, CodeTransformationTestGenerated.IfToWhen.class, CodeTransformationTestGenerated.WhenToIf.class, CodeTransformationTestGenerated.Flatten.class, CodeTransformationTestGenerated.Merge.class, CodeTransformationTestGenerated.IntroduceSubject.class, CodeTransformationTestGenerated.EliminateSubject.class, CodeTransformationTestGenerated.Split.class, CodeTransformationTestGenerated.Join.class, CodeTransformationTestGenerated.ConvertMemberToExtension.class, CodeTransformationTestGenerated.ReconstructedType.class, CodeTransformationTestGenerated.RemoveUnnecessaryParentheses.class, CodeTransformationTestGenerated.ReplaceWithDotQualifiedMethodCall.class, CodeTransformationTestGenerated.ReplaceWithInfixFunctionCall.class, CodeTransformationTestGenerated.RemoveCurlyBracesFromTemplate.class, CodeTransformationTestGenerated.MoveLambdaInsideParentheses.class, CodeTransformationTestGenerated.MoveLambdaOutsideParentheses.class, CodeTransformationTestGenerated.ReplaceExplicitFunctionLiteralParamWithIt.class, CodeTransformationTestGenerated.ReplaceItWithExplicitFunctionLiteralParam.class, CodeTransformationTestGenerated.RemoveBraces.class, CodeTransformationTestGenerated.AddBraces.class, CodeTransformationTestGenerated.ReplaceGetIntention.class, CodeTransformationTestGenerated.ReplaceContainsIntention.class, CodeTransformationTestGenerated.ReplaceBinaryInfixIntention.class, CodeTransformationTestGenerated.ReplaceUnaryPrefixIntention.class, CodeTransformationTestGenerated.ReplaceInvokeIntention.class, CodeTransformationTestGenerated.SimplifyNegatedBinaryExpressionIntention.class, CodeTransformationTestGenerated.ConvertNegatedBooleanSequence.class, CodeTransformationTestGenerated.ConvertNegatedExpressionWithDemorgansLaw.class, CodeTransformationTestGenerated.SwapBinaryExpression.class}) +@InnerTestClasses({CodeTransformationTestGenerated.ElvisToIfThen.class, CodeTransformationTestGenerated.IfThenToElvis.class, CodeTransformationTestGenerated.SafeAccessToIfThen.class, CodeTransformationTestGenerated.IfThenToSafeAccess.class, CodeTransformationTestGenerated.IfToAssignment.class, CodeTransformationTestGenerated.IfToReturn.class, CodeTransformationTestGenerated.IfToReturnAsymmetrically.class, CodeTransformationTestGenerated.WhenToAssignment.class, CodeTransformationTestGenerated.WhenToReturn.class, CodeTransformationTestGenerated.AssignmentToIf.class, CodeTransformationTestGenerated.AssignmentToWhen.class, CodeTransformationTestGenerated.PropertyToIf.class, CodeTransformationTestGenerated.PropertyToWhen.class, CodeTransformationTestGenerated.ReturnToIf.class, CodeTransformationTestGenerated.ReturnToWhen.class, CodeTransformationTestGenerated.IfToWhen.class, CodeTransformationTestGenerated.WhenToIf.class, CodeTransformationTestGenerated.Flatten.class, CodeTransformationTestGenerated.Merge.class, CodeTransformationTestGenerated.IntroduceSubject.class, CodeTransformationTestGenerated.EliminateSubject.class, CodeTransformationTestGenerated.Split.class, CodeTransformationTestGenerated.Join.class, CodeTransformationTestGenerated.ConvertMemberToExtension.class, CodeTransformationTestGenerated.ReconstructedType.class, CodeTransformationTestGenerated.RemoveUnnecessaryParentheses.class, CodeTransformationTestGenerated.ReplaceWithDotQualifiedMethodCall.class, CodeTransformationTestGenerated.ReplaceWithInfixFunctionCall.class, CodeTransformationTestGenerated.RemoveCurlyBracesFromTemplate.class, CodeTransformationTestGenerated.MoveLambdaInsideParentheses.class, CodeTransformationTestGenerated.MoveLambdaOutsideParentheses.class, CodeTransformationTestGenerated.ReplaceExplicitFunctionLiteralParamWithIt.class, CodeTransformationTestGenerated.ReplaceItWithExplicitFunctionLiteralParam.class, CodeTransformationTestGenerated.RemoveBraces.class, CodeTransformationTestGenerated.AddBraces.class, CodeTransformationTestGenerated.ReplaceGetIntention.class, CodeTransformationTestGenerated.ReplaceContainsIntention.class, CodeTransformationTestGenerated.ReplaceBinaryInfixIntention.class, CodeTransformationTestGenerated.ReplaceUnaryPrefixIntention.class, CodeTransformationTestGenerated.ReplaceInvokeIntention.class, CodeTransformationTestGenerated.SimplifyNegatedBinaryExpressionIntention.class, CodeTransformationTestGenerated.ConvertNegatedBooleanSequence.class, CodeTransformationTestGenerated.ConvertNegatedExpressionWithDemorgansLaw.class, CodeTransformationTestGenerated.SwapBinaryExpression.class, CodeTransformationTestGenerated.SplitIf.class}) public class CodeTransformationTestGenerated extends AbstractCodeTransformationTest { @TestMetadata("idea/testData/intentions/branched/elvisToIfThen") public static class ElvisToIfThen extends AbstractCodeTransformationTest { @@ -3009,6 +3009,89 @@ public class CodeTransformationTestGenerated extends AbstractCodeTransformationT } + @TestMetadata("idea/testData/intentions/splitIf") + public static class SplitIf extends AbstractCodeTransformationTest { + public void testAllFilesPresentInSplitIf() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("idea/testData/intentions/splitIf"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("splitIfAndOr.kt") + public void testSplitIfAndOr() throws Exception { + doTestSplitIf("idea/testData/intentions/splitIf/splitIfAndOr.kt"); + } + + @TestMetadata("splitIfNotIf.kt") + public void testSplitIfNotIf() throws Exception { + doTestSplitIf("idea/testData/intentions/splitIf/splitIfNotIf.kt"); + } + + @TestMetadata("splitIfOneAND.kt") + public void testSplitIfOneAND() throws Exception { + doTestSplitIf("idea/testData/intentions/splitIf/splitIfOneAND.kt"); + } + + @TestMetadata("splitIfOperatorAsFunctionParam.kt") + public void testSplitIfOperatorAsFunctionParam() throws Exception { + doTestSplitIf("idea/testData/intentions/splitIf/splitIfOperatorAsFunctionParam.kt"); + } + + @TestMetadata("splitIfOperatorOutsideIf.kt") + public void testSplitIfOperatorOutsideIf() throws Exception { + doTestSplitIf("idea/testData/intentions/splitIf/splitIfOperatorOutsideIf.kt"); + } + + @TestMetadata("splitIfOrAnd.kt") + public void testSplitIfOrAnd() throws Exception { + doTestSplitIf("idea/testData/intentions/splitIf/splitIfOrAnd.kt"); + } + + @TestMetadata("splitIfTwoOperatorsFirst.kt") + public void testSplitIfTwoOperatorsFirst() throws Exception { + doTestSplitIf("idea/testData/intentions/splitIf/splitIfTwoOperatorsFirst.kt"); + } + + @TestMetadata("splitIfTwoOperatorsSecond.kt") + public void testSplitIfTwoOperatorsSecond() throws Exception { + doTestSplitIf("idea/testData/intentions/splitIf/splitIfTwoOperatorsSecond.kt"); + } + + @TestMetadata("splitIfWithElse.kt") + public void testSplitIfWithElse() throws Exception { + doTestSplitIf("idea/testData/intentions/splitIf/splitIfWithElse.kt"); + } + + @TestMetadata("splitIfWithFunction.kt") + public void testSplitIfWithFunction() throws Exception { + doTestSplitIf("idea/testData/intentions/splitIf/splitIfWithFunction.kt"); + } + + @TestMetadata("splitIfWithNotOperator.kt") + public void testSplitIfWithNotOperator() throws Exception { + doTestSplitIf("idea/testData/intentions/splitIf/splitIfWithNotOperator.kt"); + } + + @TestMetadata("splitIfWithNotOperatorGood.kt") + public void testSplitIfWithNotOperatorGood() throws Exception { + doTestSplitIf("idea/testData/intentions/splitIf/splitIfWithNotOperatorGood.kt"); + } + + @TestMetadata("splitIfWithOR.kt") + public void testSplitIfWithOR() throws Exception { + doTestSplitIf("idea/testData/intentions/splitIf/splitIfWithOR.kt"); + } + + @TestMetadata("splitIfWithORElse.kt") + public void testSplitIfWithORElse() throws Exception { + doTestSplitIf("idea/testData/intentions/splitIf/splitIfWithORElse.kt"); + } + + @TestMetadata("splitIfWrongCaretLocation.kt") + public void testSplitIfWrongCaretLocation() throws Exception { + doTestSplitIf("idea/testData/intentions/splitIf/splitIfWrongCaretLocation.kt"); + } + + } + public static Test suite() { TestSuite suite = new TestSuite("CodeTransformationTestGenerated"); suite.addTestSuite(ElvisToIfThen.class); @@ -3055,6 +3138,7 @@ public class CodeTransformationTestGenerated extends AbstractCodeTransformationT suite.addTestSuite(ConvertNegatedBooleanSequence.class); suite.addTestSuite(ConvertNegatedExpressionWithDemorgansLaw.class); suite.addTestSuite(SwapBinaryExpression.class); + suite.addTestSuite(SplitIf.class); return suite; } }