Add code transformations for if/when in local property initializers

This commit is contained in:
Alexey Sedunov
2013-06-07 15:43:58 +04:00
parent 70b4fb48bc
commit 3f2ff3eb24
43 changed files with 592 additions and 10 deletions
@@ -54,6 +54,14 @@ public abstract class AbstractCodeTransformationTest extends LightCodeInsightTes
doTest(path, new UnfoldBranchedExpressionIntention.UnfoldAssignmentToWhenIntention());
}
public void doTestUnfoldPropertyToIf(@NotNull String path) throws Exception {
doTest(path, new UnfoldBranchedExpressionIntention.UnfoldPropertyToIfIntention());
}
public void doTestUnfoldPropertyToWhen(@NotNull String path) throws Exception {
doTest(path, new UnfoldBranchedExpressionIntention.UnfoldPropertyToWhenIntention());
}
public void doTestUnfoldReturnToIf(@NotNull String path) throws Exception {
doTest(path, new UnfoldBranchedExpressionIntention.UnfoldReturnToIfIntention());
}
@@ -30,7 +30,7 @@ import org.jetbrains.jet.plugin.codeInsight.codeTransformations.AbstractCodeTran
/** This class is generated by {@link org.jetbrains.jet.generators.tests.GenerateTests}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@InnerTestClasses({CodeTransformationsTestGenerated.IfToAssignment.class, CodeTransformationsTestGenerated.IfToReturn.class, CodeTransformationsTestGenerated.IfToReturnAsymmetrically.class, CodeTransformationsTestGenerated.WhenToAssignment.class, CodeTransformationsTestGenerated.WhenToReturn.class, CodeTransformationsTestGenerated.AssignmentToIf.class, CodeTransformationsTestGenerated.AssignmentToWhen.class, CodeTransformationsTestGenerated.ReturnToIf.class, CodeTransformationsTestGenerated.ReturnToWhen.class, CodeTransformationsTestGenerated.IfToWhen.class, CodeTransformationsTestGenerated.WhenToIf.class, CodeTransformationsTestGenerated.Flatten.class, CodeTransformationsTestGenerated.IntroduceSubject.class, CodeTransformationsTestGenerated.EliminateSubject.class})
@InnerTestClasses({CodeTransformationsTestGenerated.IfToAssignment.class, CodeTransformationsTestGenerated.IfToReturn.class, CodeTransformationsTestGenerated.IfToReturnAsymmetrically.class, CodeTransformationsTestGenerated.WhenToAssignment.class, CodeTransformationsTestGenerated.WhenToReturn.class, CodeTransformationsTestGenerated.AssignmentToIf.class, CodeTransformationsTestGenerated.AssignmentToWhen.class, CodeTransformationsTestGenerated.PropertyToIf.class, CodeTransformationsTestGenerated.PropertyToWhen.class, CodeTransformationsTestGenerated.ReturnToIf.class, CodeTransformationsTestGenerated.ReturnToWhen.class, CodeTransformationsTestGenerated.IfToWhen.class, CodeTransformationsTestGenerated.WhenToIf.class, CodeTransformationsTestGenerated.Flatten.class, CodeTransformationsTestGenerated.IntroduceSubject.class, CodeTransformationsTestGenerated.EliminateSubject.class})
public class CodeTransformationsTestGenerated extends AbstractCodeTransformationTest {
@TestMetadata("idea/testData/codeInsight/codeTransformations/branched/folding/ifToAssignment")
public static class IfToAssignment extends AbstractCodeTransformationTest {
@@ -263,6 +263,102 @@ public class CodeTransformationsTestGenerated extends AbstractCodeTransformation
}
@TestMetadata("idea/testData/codeInsight/codeTransformations/branched/unfolding/propertyToIf")
public static class PropertyToIf extends AbstractCodeTransformationTest {
public void testAllFilesPresentInPropertyToIf() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/codeInsight/codeTransformations/branched/unfolding/propertyToIf"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("nestedIfs.kt")
public void testNestedIfs() throws Exception {
doTestUnfoldPropertyToIf("idea/testData/codeInsight/codeTransformations/branched/unfolding/propertyToIf/nestedIfs.kt");
}
@TestMetadata("nestedIfs2.kt")
public void testNestedIfs2() throws Exception {
doTestUnfoldPropertyToIf("idea/testData/codeInsight/codeTransformations/branched/unfolding/propertyToIf/nestedIfs2.kt");
}
@TestMetadata("nonLocalProperty.kt")
public void testNonLocalProperty() throws Exception {
doTestUnfoldPropertyToIf("idea/testData/codeInsight/codeTransformations/branched/unfolding/propertyToIf/nonLocalProperty.kt");
}
@TestMetadata("nonLocalProperty2.kt")
public void testNonLocalProperty2() throws Exception {
doTestUnfoldPropertyToIf("idea/testData/codeInsight/codeTransformations/branched/unfolding/propertyToIf/nonLocalProperty2.kt");
}
@TestMetadata("simpleIf.kt")
public void testSimpleIf() throws Exception {
doTestUnfoldPropertyToIf("idea/testData/codeInsight/codeTransformations/branched/unfolding/propertyToIf/simpleIf.kt");
}
@TestMetadata("simpleIf2.kt")
public void testSimpleIf2() throws Exception {
doTestUnfoldPropertyToIf("idea/testData/codeInsight/codeTransformations/branched/unfolding/propertyToIf/simpleIf2.kt");
}
@TestMetadata("simpleIfWithBlocks.kt")
public void testSimpleIfWithBlocks() throws Exception {
doTestUnfoldPropertyToIf("idea/testData/codeInsight/codeTransformations/branched/unfolding/propertyToIf/simpleIfWithBlocks.kt");
}
@TestMetadata("simpleIfWithBlocks2.kt")
public void testSimpleIfWithBlocks2() throws Exception {
doTestUnfoldPropertyToIf("idea/testData/codeInsight/codeTransformations/branched/unfolding/propertyToIf/simpleIfWithBlocks2.kt");
}
@TestMetadata("simpleIfWithType.kt")
public void testSimpleIfWithType() throws Exception {
doTestUnfoldPropertyToIf("idea/testData/codeInsight/codeTransformations/branched/unfolding/propertyToIf/simpleIfWithType.kt");
}
}
@TestMetadata("idea/testData/codeInsight/codeTransformations/branched/unfolding/propertyToWhen")
public static class PropertyToWhen extends AbstractCodeTransformationTest {
public void testAllFilesPresentInPropertyToWhen() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/codeInsight/codeTransformations/branched/unfolding/propertyToWhen"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("nonLocalProperty.kt")
public void testNonLocalProperty() throws Exception {
doTestUnfoldPropertyToWhen("idea/testData/codeInsight/codeTransformations/branched/unfolding/propertyToWhen/nonLocalProperty.kt");
}
@TestMetadata("nonLocalProperty2.kt")
public void testNonLocalProperty2() throws Exception {
doTestUnfoldPropertyToWhen("idea/testData/codeInsight/codeTransformations/branched/unfolding/propertyToWhen/nonLocalProperty2.kt");
}
@TestMetadata("simpleWhen.kt")
public void testSimpleWhen() throws Exception {
doTestUnfoldPropertyToWhen("idea/testData/codeInsight/codeTransformations/branched/unfolding/propertyToWhen/simpleWhen.kt");
}
@TestMetadata("simpleWhen2.kt")
public void testSimpleWhen2() throws Exception {
doTestUnfoldPropertyToWhen("idea/testData/codeInsight/codeTransformations/branched/unfolding/propertyToWhen/simpleWhen2.kt");
}
@TestMetadata("simpleWhenWithBlocks.kt")
public void testSimpleWhenWithBlocks() throws Exception {
doTestUnfoldPropertyToWhen("idea/testData/codeInsight/codeTransformations/branched/unfolding/propertyToWhen/simpleWhenWithBlocks.kt");
}
@TestMetadata("simpleWhenWithBlocks2.kt")
public void testSimpleWhenWithBlocks2() throws Exception {
doTestUnfoldPropertyToWhen("idea/testData/codeInsight/codeTransformations/branched/unfolding/propertyToWhen/simpleWhenWithBlocks2.kt");
}
@TestMetadata("simpleWhenWithType.kt")
public void testSimpleWhenWithType() throws Exception {
doTestUnfoldPropertyToWhen("idea/testData/codeInsight/codeTransformations/branched/unfolding/propertyToWhen/simpleWhenWithType.kt");
}
}
@TestMetadata("idea/testData/codeInsight/codeTransformations/branched/unfolding/returnToIf")
public static class ReturnToIf extends AbstractCodeTransformationTest {
public void testAllFilesPresentInReturnToIf() throws Exception {
@@ -553,6 +649,8 @@ public class CodeTransformationsTestGenerated extends AbstractCodeTransformation
suite.addTestSuite(WhenToReturn.class);
suite.addTestSuite(AssignmentToIf.class);
suite.addTestSuite(AssignmentToWhen.class);
suite.addTestSuite(PropertyToIf.class);
suite.addTestSuite(PropertyToWhen.class);
suite.addTestSuite(ReturnToIf.class);
suite.addTestSuite(ReturnToWhen.class);
suite.addTestSuite(IfToWhen.class);