From 30e333c67085d598df3dd963ba955b42da75ef42 Mon Sep 17 00:00:00 2001 From: Alexey Sedunov Date: Fri, 31 May 2013 19:23:27 +0400 Subject: [PATCH] Allow to move "when entry" at closing brace --- .../upDownMover/JetExpressionMover.java | 4 ++-- .../moveUpDown/closingBraces/when/whenEntry2.kt | 1 - .../closingBraces/when/whenEntry2.kt.after | 16 ++++++++++++++++ .../moveUpDown/closingBraces/when/whenEntry3.kt | 1 - .../closingBraces/when/whenEntry3.kt.after | 16 ++++++++++++++++ .../moveUpDown/closingBraces/when/whenEntry4.kt | 1 - .../closingBraces/when/whenEntry4.kt.after | 16 ++++++++++++++++ 7 files changed, 50 insertions(+), 5 deletions(-) create mode 100644 idea/testData/codeInsight/moveUpDown/closingBraces/when/whenEntry2.kt.after create mode 100644 idea/testData/codeInsight/moveUpDown/closingBraces/when/whenEntry3.kt.after create mode 100644 idea/testData/codeInsight/moveUpDown/closingBraces/when/whenEntry4.kt.after 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 5d12af20cb8..3f6b65a0a93 100644 --- a/idea/src/org/jetbrains/jet/plugin/codeInsight/upDownMover/JetExpressionMover.java +++ b/idea/src/org/jetbrains/jet/plugin/codeInsight/upDownMover/JetExpressionMover.java @@ -23,7 +23,7 @@ public class JetExpressionMover extends AbstractJetUpDownMover { @SuppressWarnings("FieldMayBeFinal") private static Class[] BLOCKLIKE_ELEMENT_CLASSES = - {JetBlockExpression.class, JetWhenExpression.class, JetPropertyAccessor.class, JetClassBody.class, JetFile.class}; + {JetBlockExpression.class, JetWhenExpression.class, JetClassBody.class, JetFile.class}; @SuppressWarnings("FieldMayBeFinal") private static Class[] FUNCTIONLIKE_ELEMENT_CLASSES = @@ -126,7 +126,7 @@ 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_MOVABLE; + if (blockLikeElement.getParent() instanceof JetWhenEntry) return BraceStatus.NOT_FOUND; PsiElement enclosingExpression = PsiTreeUtil.getParentOfType(blockLikeElement, JetExpression.class); diff --git a/idea/testData/codeInsight/moveUpDown/closingBraces/when/whenEntry2.kt b/idea/testData/codeInsight/moveUpDown/closingBraces/when/whenEntry2.kt index a8f199fbc69..b3d25d5f744 100644 --- a/idea/testData/codeInsight/moveUpDown/closingBraces/when/whenEntry2.kt +++ b/idea/testData/codeInsight/moveUpDown/closingBraces/when/whenEntry2.kt @@ -1,4 +1,3 @@ -// IS_APPLICABLE: false // MOVE: up fun foo(n: Int) { diff --git a/idea/testData/codeInsight/moveUpDown/closingBraces/when/whenEntry2.kt.after b/idea/testData/codeInsight/moveUpDown/closingBraces/when/whenEntry2.kt.after new file mode 100644 index 00000000000..e23769f7213 --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/closingBraces/when/whenEntry2.kt.after @@ -0,0 +1,16 @@ +// MOVE: up + +fun foo(n: Int) { + when (n) { + 0 -> { + + } + else -> { + + } + 1 -> { + + } + } + val x = "" +} \ No newline at end of file diff --git a/idea/testData/codeInsight/moveUpDown/closingBraces/when/whenEntry3.kt b/idea/testData/codeInsight/moveUpDown/closingBraces/when/whenEntry3.kt index e357586805d..d66681a0572 100644 --- a/idea/testData/codeInsight/moveUpDown/closingBraces/when/whenEntry3.kt +++ b/idea/testData/codeInsight/moveUpDown/closingBraces/when/whenEntry3.kt @@ -1,4 +1,3 @@ -// IS_APPLICABLE: false // MOVE: down fun foo(n: Int) { diff --git a/idea/testData/codeInsight/moveUpDown/closingBraces/when/whenEntry3.kt.after b/idea/testData/codeInsight/moveUpDown/closingBraces/when/whenEntry3.kt.after new file mode 100644 index 00000000000..ea3b376f7c6 --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/closingBraces/when/whenEntry3.kt.after @@ -0,0 +1,16 @@ +// MOVE: down + +fun foo(n: Int) { + when (n) { + 0 -> { + + } + else -> { + + } + 1 -> { + + } + } + val x = "" +} \ No newline at end of file diff --git a/idea/testData/codeInsight/moveUpDown/closingBraces/when/whenEntry4.kt b/idea/testData/codeInsight/moveUpDown/closingBraces/when/whenEntry4.kt index b54c1574f67..39fe51c4565 100644 --- a/idea/testData/codeInsight/moveUpDown/closingBraces/when/whenEntry4.kt +++ b/idea/testData/codeInsight/moveUpDown/closingBraces/when/whenEntry4.kt @@ -1,4 +1,3 @@ -// IS_APPLICABLE: false // MOVE: up fun foo(n: Int) { diff --git a/idea/testData/codeInsight/moveUpDown/closingBraces/when/whenEntry4.kt.after b/idea/testData/codeInsight/moveUpDown/closingBraces/when/whenEntry4.kt.after new file mode 100644 index 00000000000..529d20f9b75 --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/closingBraces/when/whenEntry4.kt.after @@ -0,0 +1,16 @@ +// MOVE: up + +fun foo(n: Int) { + when (n) { + 1 -> { + + } + 0 -> { + + } + else -> { + + } + } + val x = "" +} \ No newline at end of file