diff --git a/idea/src/org/jetbrains/jet/plugin/codeInsight/upDownMover/JetExpressionMover.java b/idea/src/org/jetbrains/jet/plugin/codeInsight/upDownMover/JetExpressionMover.java index 6dea19786ba..438622f1c8b 100644 --- a/idea/src/org/jetbrains/jet/plugin/codeInsight/upDownMover/JetExpressionMover.java +++ b/idea/src/org/jetbrains/jet/plugin/codeInsight/upDownMover/JetExpressionMover.java @@ -16,15 +16,12 @@ public class JetExpressionMover extends AbstractJetUpDownMover { public JetExpressionMover() { } - @SuppressWarnings("FieldMayBeFinal") - private static Class[] MOVABLE_ELEMENT_CLASSES = {JetExpression.class, JetWhenEntry.class, JetValueArgument.class, PsiComment.class}; + private final static Class[] MOVABLE_ELEMENT_CLASSES = {JetExpression.class, JetWhenEntry.class, JetValueArgument.class, PsiComment.class}; - @SuppressWarnings("FieldMayBeFinal") - private static Class[] BLOCKLIKE_ELEMENT_CLASSES = + private final static Class[] BLOCKLIKE_ELEMENT_CLASSES = {JetBlockExpression.class, JetWhenExpression.class, JetClassBody.class, JetFile.class}; - @SuppressWarnings("FieldMayBeFinal") - private static Class[] FUNCTIONLIKE_ELEMENT_CLASSES = + private final static Class[] FUNCTIONLIKE_ELEMENT_CLASSES = {JetFunction.class, JetPropertyAccessor.class, JetClassInitializer.class}; @Nullable @@ -113,7 +110,10 @@ public class JetExpressionMover extends AbstractJetUpDownMover { PsiElement blockLikeElement = closingBrace.getParent(); if (!(blockLikeElement instanceof JetBlockExpression)) return BraceStatus.NOT_MOVABLE; - if (blockLikeElement.getParent() instanceof JetWhenEntry) return BraceStatus.NOT_FOUND; + + PsiElement blockParent = blockLikeElement.getParent(); + if (blockParent instanceof JetWhenEntry) return BraceStatus.NOT_FOUND; + if (PsiTreeUtil.instanceOf(blockParent, FUNCTIONLIKE_ELEMENT_CLASSES)) return BraceStatus.NOT_FOUND; PsiElement enclosingExpression = PsiTreeUtil.getParentOfType(blockLikeElement, JetExpression.class); diff --git a/idea/testData/codeInsight/moveUpDown/closingBraces/function/function1.kt b/idea/testData/codeInsight/moveUpDown/closingBraces/function/function1.kt new file mode 100644 index 00000000000..43c0955ee28 --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/closingBraces/function/function1.kt @@ -0,0 +1,10 @@ +// MOVE: down +fun foo() { + val x = "" + + fun bar() { + + } + + val y = "" +} \ No newline at end of file diff --git a/idea/testData/codeInsight/moveUpDown/closingBraces/function/function1.kt.after b/idea/testData/codeInsight/moveUpDown/closingBraces/function/function1.kt.after new file mode 100644 index 00000000000..d4a61584b82 --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/closingBraces/function/function1.kt.after @@ -0,0 +1,10 @@ +// MOVE: down +fun foo() { + val x = "" + + + fun bar() { + + } + val y = "" +} \ No newline at end of file diff --git a/idea/testData/codeInsight/moveUpDown/closingBraces/function/function2.kt b/idea/testData/codeInsight/moveUpDown/closingBraces/function/function2.kt new file mode 100644 index 00000000000..6a0f188cc34 --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/closingBraces/function/function2.kt @@ -0,0 +1,10 @@ +// MOVE: up +fun foo() { + val x = "" + + fun bar() { + + } + + val y = "" +} \ No newline at end of file diff --git a/idea/testData/codeInsight/moveUpDown/closingBraces/function/function2.kt.after b/idea/testData/codeInsight/moveUpDown/closingBraces/function/function2.kt.after new file mode 100644 index 00000000000..d97ba5d9700 --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/closingBraces/function/function2.kt.after @@ -0,0 +1,10 @@ +// MOVE: up +fun foo() { + val x = "" + fun bar() { + + } + + + val y = "" +} \ No newline at end of file diff --git a/idea/testData/codeInsight/moveUpDown/closingBraces/function/function3.kt b/idea/testData/codeInsight/moveUpDown/closingBraces/function/function3.kt new file mode 100644 index 00000000000..d4a61584b82 --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/closingBraces/function/function3.kt @@ -0,0 +1,10 @@ +// MOVE: down +fun foo() { + val x = "" + + + fun bar() { + + } + val y = "" +} \ No newline at end of file diff --git a/idea/testData/codeInsight/moveUpDown/closingBraces/function/function3.kt.after b/idea/testData/codeInsight/moveUpDown/closingBraces/function/function3.kt.after new file mode 100644 index 00000000000..a1c6e7fe4df --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/closingBraces/function/function3.kt.after @@ -0,0 +1,10 @@ +// MOVE: down +fun foo() { + val x = "" + + + val y = "" + fun bar() { + + } +} \ No newline at end of file diff --git a/idea/testData/codeInsight/moveUpDown/closingBraces/function/function4.kt b/idea/testData/codeInsight/moveUpDown/closingBraces/function/function4.kt new file mode 100644 index 00000000000..d97ba5d9700 --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/closingBraces/function/function4.kt @@ -0,0 +1,10 @@ +// MOVE: up +fun foo() { + val x = "" + fun bar() { + + } + + + val y = "" +} \ No newline at end of file diff --git a/idea/testData/codeInsight/moveUpDown/closingBraces/function/function4.kt.after b/idea/testData/codeInsight/moveUpDown/closingBraces/function/function4.kt.after new file mode 100644 index 00000000000..c1a02f68d84 --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/closingBraces/function/function4.kt.after @@ -0,0 +1,10 @@ +// MOVE: up +fun foo() { + fun bar() { + + } + val x = "" + + + val y = "" +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/jet/plugin/codeInsight/moveUpDown/CodeMoverTestGenerated.java b/idea/tests/org/jetbrains/jet/plugin/codeInsight/moveUpDown/CodeMoverTestGenerated.java index c7ca70b13a4..244b9db74ff 100644 --- a/idea/tests/org/jetbrains/jet/plugin/codeInsight/moveUpDown/CodeMoverTestGenerated.java +++ b/idea/tests/org/jetbrains/jet/plugin/codeInsight/moveUpDown/CodeMoverTestGenerated.java @@ -574,7 +574,7 @@ public class CodeMoverTestGenerated extends AbstractCodeMoverTest { } @TestMetadata("idea/testData/codeInsight/moveUpDown/closingBraces") - @InnerTestClasses({ClosingBraces.For.class, ClosingBraces.If.class, ClosingBraces.Nested.class, ClosingBraces.When.class, ClosingBraces.While.class}) + @InnerTestClasses({ClosingBraces.For.class, ClosingBraces.Function.class, ClosingBraces.If.class, ClosingBraces.Nested.class, ClosingBraces.When.class, ClosingBraces.While.class}) public static class ClosingBraces extends AbstractCodeMoverTest { public void testAllFilesPresentInClosingBraces() throws Exception { JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/codeInsight/moveUpDown/closingBraces"), Pattern.compile("^(.+)\\.kt$"), true); @@ -598,6 +598,34 @@ public class CodeMoverTestGenerated extends AbstractCodeMoverTest { } + @TestMetadata("idea/testData/codeInsight/moveUpDown/closingBraces/function") + public static class Function extends AbstractCodeMoverTest { + public void testAllFilesPresentInFunction() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/codeInsight/moveUpDown/closingBraces/function"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("function1.kt") + public void testFunction1() throws Exception { + doTestExpression("idea/testData/codeInsight/moveUpDown/closingBraces/function/function1.kt"); + } + + @TestMetadata("function2.kt") + public void testFunction2() throws Exception { + doTestExpression("idea/testData/codeInsight/moveUpDown/closingBraces/function/function2.kt"); + } + + @TestMetadata("function3.kt") + public void testFunction3() throws Exception { + doTestExpression("idea/testData/codeInsight/moveUpDown/closingBraces/function/function3.kt"); + } + + @TestMetadata("function4.kt") + public void testFunction4() throws Exception { + doTestExpression("idea/testData/codeInsight/moveUpDown/closingBraces/function/function4.kt"); + } + + } + @TestMetadata("idea/testData/codeInsight/moveUpDown/closingBraces/if") public static class If extends AbstractCodeMoverTest { public void testAllFilesPresentInIf() throws Exception { @@ -714,6 +742,7 @@ public class CodeMoverTestGenerated extends AbstractCodeMoverTest { TestSuite suite = new TestSuite("ClosingBraces"); suite.addTestSuite(ClosingBraces.class); suite.addTestSuite(For.class); + suite.addTestSuite(Function.class); suite.addTestSuite(If.class); suite.addTestSuite(Nested.class); suite.addTestSuite(When.class);