diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetBlockExpression.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetBlockExpression.java index 6ab402a5e88..bbceac0a464 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetBlockExpression.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetBlockExpression.java @@ -54,7 +54,17 @@ public class JetBlockExpression extends JetExpressionImpl implements JetStatemen @Nullable public TextRange getLastBracketRange() { - PsiElement rBrace = findChildByType(JetTokens.RBRACE); + PsiElement rBrace = getRBrace(); return rBrace != null ? rBrace.getTextRange() : null; } + + @Nullable + public PsiElement getRBrace() { + return findChildByType(JetTokens.RBRACE); + } + + @Nullable + public PsiElement getLBrace() { + return findChildByType(JetTokens.LBRACE); + } } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetPsiUtil.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetPsiUtil.java index 379a1e36630..d95e66fcf47 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetPsiUtil.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetPsiUtil.java @@ -756,6 +756,59 @@ public class JetPsiUtil { return CommentUtilCore.isComment(element) || element instanceof KDocElement; } + @Nullable + public static PsiElement getOutermostParent(@NotNull PsiElement element, @NotNull PsiElement upperBound, boolean strict) { + PsiElement parent = strict ? element.getParent() : element; + while (parent != null && parent.getParent() != upperBound) { + parent = parent.getParent(); + } + + return parent; + } + + public static T getLastChildByType(@NotNull PsiElement root, @NotNull Class... elementTypes) { + PsiElement[] children = root.getChildren(); + + for (int i = children.length - 1; i >= 0; i--) { + if (PsiTreeUtil.instanceOf(children[i], elementTypes)) { + //noinspection unchecked + return (T) children[i]; + } + } + + return null; + } + + @Nullable + public static T getOutermostJetElement( + @Nullable PsiElement root, + boolean first, + @NotNull final Class... elementTypes + ) { + if (!(root instanceof JetElement)) return null; + + final List results = Lists.newArrayList(); + + ((JetElement) root).accept( + new JetVisitorVoid() { + @Override + public void visitJetElement(JetElement element) { + if (PsiTreeUtil.instanceOf(element, elementTypes)) { + //noinspection unchecked + results.add((T) element); + } + else { + element.acceptChildren(this); + } + } + } + ); + + if (results.isEmpty()) return null; + + return first ? results.get(0) : results.get(results.size() - 1); + } + @Nullable public static JetExpression getCalleeExpressionIfAny(@NotNull JetExpression expression) { if (expression instanceof JetCallElement) { diff --git a/generators/org/jetbrains/jet/generators/tests/GenerateTests.java b/generators/org/jetbrains/jet/generators/tests/GenerateTests.java index 46224ddf2f9..08afc8565f7 100644 --- a/generators/org/jetbrains/jet/generators/tests/GenerateTests.java +++ b/generators/org/jetbrains/jet/generators/tests/GenerateTests.java @@ -344,7 +344,9 @@ public class GenerateTests { "idea/tests/", "CodeMoverTestGenerated", AbstractCodeMoverTest.class, - testModel("idea/testData/codeInsight/moveUpDown/classBodyDeclarations", "doTestClassBodyDeclaration") + testModel("idea/testData/codeInsight/moveUpDown/classBodyDeclarations", "doTestClassBodyDeclaration"), + testModel("idea/testData/codeInsight/moveUpDown/closingBraces", "doTestExpression"), + testModel("idea/testData/codeInsight/moveUpDown/expressions", "doTestExpression") ); } diff --git a/idea/src/META-INF/plugin.xml b/idea/src/META-INF/plugin.xml index 18f3e23205a..1148214b80e 100644 --- a/idea/src/META-INF/plugin.xml +++ b/idea/src/META-INF/plugin.xml @@ -283,6 +283,10 @@ serviceImplementation="org.jetbrains.jet.plugin.editor.JetEditorOptions"/> + + diff --git a/idea/src/org/jetbrains/jet/plugin/codeInsight/upDownMover/JetExpressionMover.java b/idea/src/org/jetbrains/jet/plugin/codeInsight/upDownMover/JetExpressionMover.java new file mode 100644 index 00000000000..419cab627e4 --- /dev/null +++ b/idea/src/org/jetbrains/jet/plugin/codeInsight/upDownMover/JetExpressionMover.java @@ -0,0 +1,333 @@ +package org.jetbrains.jet.plugin.codeInsight.upDownMover; + +import com.intellij.codeInsight.editorActions.moveUpDown.LineRange; +import com.intellij.openapi.editor.Document; +import com.intellij.openapi.editor.Editor; +import com.intellij.openapi.util.Pair; +import com.intellij.openapi.util.TextRange; +import com.intellij.psi.PsiComment; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiFile; +import com.intellij.psi.util.PsiTreeUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.lang.psi.*; +import org.jetbrains.jet.lexer.JetTokens; + +public class JetExpressionMover extends AbstractJetUpDownMover { + public JetExpressionMover() { + } + + @SuppressWarnings("FieldMayBeFinal") + private static Class[] MOVABLE_ELEMENT_CLASSES = {JetExpression.class, JetWhenEntry.class, PsiComment.class}; + + @SuppressWarnings("FieldMayBeFinal") + private static Class[] BLOCKLIKE_ELEMENT_CLASSES = + {JetBlockExpression.class, JetWhenExpression.class, JetPropertyAccessor.class, JetClassBody.class, JetFile.class}; + + @SuppressWarnings("FieldMayBeFinal") + private static Class[] FUNCTIONLIKE_ELEMENT_CLASSES = + {JetFunction.class, JetPropertyAccessor.class, JetClassInitializer.class}; + + @Nullable + private static LineRange getLineRange(@NotNull PsiElement element, @NotNull Editor editor) { + TextRange textRange = element.getTextRange(); + if (editor.getDocument().getTextLength() < textRange.getEndOffset()) return null; + + int startLine = editor.offsetToLogicalPosition(textRange.getStartOffset()).line; + int endLine = editor.offsetToLogicalPosition(textRange.getEndOffset()).line + 1; + + return new LineRange(startLine, endLine); + } + + @Nullable + private static PsiElement getStandaloneClosingBrace(@NotNull PsiFile file, @NotNull Editor editor) { + LineRange range = getLineRangeFromSelection(editor); + if (range.endLine - range.startLine != 1) return null; + int offset = editor.getCaretModel().getOffset(); + Document document = editor.getDocument(); + int line = document.getLineNumber(offset); + int lineStartOffset = document.getLineStartOffset(line); + String lineText = document.getText().substring(lineStartOffset, document.getLineEndOffset(line)); + if (!lineText.trim().equals("}")) return null; + + return file.findElementAt(lineStartOffset + lineText.indexOf('}')); + } + + private static boolean checkForMovableDownClosingBrace( + @NotNull PsiElement closingBrace, + @NotNull PsiElement block, + @NotNull Editor editor, + @NotNull MoveInfo info + ) { + PsiElement current = block; + PsiElement nextElement = null; + PsiElement nextExpression = null; + do { + PsiElement sibling = firstNonWhiteElement(current.getNextSibling(), true); + if (sibling != null && nextElement == null) { + nextElement = sibling; + } + + if (sibling instanceof JetExpression) { + nextExpression = sibling; + break; + } + + current = current.getParent(); + } + while (current != null && !(PsiTreeUtil.instanceOf(current, BLOCKLIKE_ELEMENT_CLASSES))); + + if (nextExpression == null) return false; + + Document doc = editor.getDocument(); + + info.toMove = new LineRange(closingBrace, closingBrace, doc); + info.toMove2 = new LineRange(nextElement, nextExpression); + info.indentSource = true; + + return true; + } + + private static boolean checkForMovableUpClosingBrace( + @NotNull PsiElement closingBrace, + PsiElement block, + @NotNull Editor editor, + @NotNull MoveInfo info + ) { + //noinspection unchecked + PsiElement prev = JetPsiUtil.getLastChildByType(block, JetExpression.class); + if (prev == null) return false; + + Document doc = editor.getDocument(); + + info.toMove = new LineRange(closingBrace, closingBrace, doc); + info.toMove2 = new LineRange(prev, prev, doc); + info.indentSource = true; + + return true; + } + + // Returns null if standalone closing brace is not found + private static Boolean checkForMovableClosingBrace( + @NotNull Editor editor, + @NotNull PsiFile file, + @NotNull MoveInfo info, + boolean down + ) { + PsiElement closingBrace = getStandaloneClosingBrace(file, editor); + if (closingBrace == null) return null; + + PsiElement blockLikeElement = closingBrace.getParent(); + if (!(blockLikeElement instanceof JetBlockExpression)) return false; + if (blockLikeElement.getParent() instanceof JetWhenEntry) return false; + + PsiElement enclosingExpression = PsiTreeUtil.getParentOfType(blockLikeElement, JetExpression.class); + + if (enclosingExpression instanceof JetDoWhileExpression) return false; + + if (enclosingExpression instanceof JetIfExpression) { + JetIfExpression ifExpression = (JetIfExpression) enclosingExpression; + + if (blockLikeElement == ifExpression.getThen() && ifExpression.getElse() != null) return false; + } + + return down ? checkForMovableDownClosingBrace(closingBrace, blockLikeElement, editor, info) : + checkForMovableUpClosingBrace(closingBrace, blockLikeElement, editor, info); + } + + @Nullable + private static JetBlockExpression findClosestBlock(@NotNull PsiElement anchor, boolean down) { + PsiElement current = PsiTreeUtil.getParentOfType(anchor, JetBlockExpression.class); + while (current != null) { + PsiElement parent = current.getParent(); + if (parent instanceof JetClassBody || + parent instanceof JetClassInitializer || + parent instanceof JetFunction || + parent instanceof JetProperty) { + return null; + } + + if (parent instanceof JetBlockExpression) return (JetBlockExpression) parent; + + PsiElement sibling = down ? current.getNextSibling() : current.getPrevSibling(); + if (sibling != null) { + //noinspection unchecked + JetBlockExpression block = JetPsiUtil.getOutermostJetElement(sibling, down, JetBlockExpression.class); + if (block != null) return block; + + current = sibling; + } + else { + current = parent; + } + } + + return null; + } + + @Nullable + private static LineRange getExpressionTargetRange(@NotNull Editor editor, @NotNull PsiElement sibling, boolean down) { + PsiElement start = sibling; + PsiElement end = sibling; + + // moving out of code block + if (sibling.getNode().getElementType() == (down ? JetTokens.RBRACE : JetTokens.LBRACE)) { + PsiElement parent = sibling.getParent(); + if (!(parent instanceof JetBlockExpression)) return null; + + JetBlockExpression block = (JetBlockExpression) parent; + + JetBlockExpression newBlock = findClosestBlock(sibling, down); + if (newBlock == null) return null; + + if (PsiTreeUtil.isAncestor(newBlock, block, true)) { + PsiElement outermostParent = JetPsiUtil.getOutermostParent(block, newBlock, true); + + if (down) { + end = outermostParent; + } + else { + start = outermostParent; + } + } + else { + if (down) { + end = newBlock.getLBrace(); + } + else { + start = newBlock.getRBrace(); + } + } + } + else { + // moving into code block + //noinspection unchecked + JetElement blockLikeElement = JetPsiUtil.getOutermostJetElement(sibling, down, JetBlockExpression.class, JetWhenExpression.class); + if (blockLikeElement != null && + !(PsiTreeUtil.instanceOf(blockLikeElement, FUNCTIONLIKE_ELEMENT_CLASSES))) { + if (blockLikeElement instanceof JetWhenExpression) { + //noinspection unchecked + blockLikeElement = JetPsiUtil.getOutermostJetElement(blockLikeElement, down, JetBlockExpression.class); + } + + if (blockLikeElement != null) { + JetBlockExpression block = (JetBlockExpression) blockLikeElement; + + if (down) { + end = block.getLBrace(); + } + else { + start = block.getRBrace(); + } + } + } + } + + return start != null && end != null ? new LineRange(start, end, editor.getDocument()) : null; + } + + @Nullable + private static LineRange getWhenEntryTargetRange(@NotNull Editor editor, @NotNull PsiElement sibling, boolean down) { + if (sibling.getNode().getElementType() == (down ? JetTokens.RBRACE : JetTokens.LBRACE) && + PsiTreeUtil.getParentOfType(sibling, JetWhenEntry.class) == null) { + return null; + } + + return new LineRange(sibling, sibling, editor.getDocument()); + } + + @Nullable + private static LineRange getTargetRange( + @NotNull Editor editor, + @Nullable PsiElement elementToCheck, + @NotNull PsiElement sibling, + boolean down + ) { + if (elementToCheck instanceof JetExpression || elementToCheck instanceof PsiComment) { + return getExpressionTargetRange(editor, sibling, down); + } + + if (elementToCheck instanceof JetWhenEntry) { + return getWhenEntryTargetRange(editor, sibling, down); + } + + return null; + } + + @Nullable + private static LineRange getSourceRange(@NotNull PsiElement firstElement, @NotNull PsiElement lastElement, @NotNull Editor editor) { + if (firstElement == lastElement) { + //noinspection ConstantConditions + LineRange sourceRange = getLineRange(firstElement, editor); + + if (sourceRange != null) { + sourceRange.firstElement = sourceRange.lastElement = firstElement; + } + + return sourceRange; + } + + //noinspection ConstantConditions + PsiElement parent = PsiTreeUtil.findCommonParent(firstElement, lastElement); + if (parent == null) return null; + + Pair combinedRange = getElementRange(parent, firstElement, lastElement); + + if (combinedRange == null + || !(PsiTreeUtil.instanceOf(combinedRange.first, MOVABLE_ELEMENT_CLASSES)) + || !(PsiTreeUtil.instanceOf(combinedRange.second, MOVABLE_ELEMENT_CLASSES))) { + return null; + } + + LineRange lineRange1 = getLineRange(combinedRange.first, editor); + if (lineRange1 == null) return null; + + LineRange lineRange2 = getLineRange(combinedRange.second, editor); + if (lineRange2 == null) return null; + + LineRange sourceRange = new LineRange(lineRange1.startLine, lineRange2.endLine); + sourceRange.firstElement = combinedRange.first; + sourceRange.lastElement = combinedRange.second; + + return sourceRange; + } + + @Override + public boolean checkAvailable(@NotNull Editor editor, @NotNull PsiFile file, @NotNull MoveInfo info, boolean down) { + if (!super.checkAvailable(editor, file, info, down)) return false; + + Boolean closingBraceWin = checkForMovableClosingBrace(editor, file, info, down); + if (closingBraceWin != null) { + if (!closingBraceWin) { + info.toMove2 = null; + } + return true; + } + + LineRange oldRange = info.toMove; + + Pair psiRange = getElementRange(editor, file, oldRange); + if (psiRange == null) return false; + + //noinspection unchecked + PsiElement firstElement = PsiTreeUtil.getNonStrictParentOfType(psiRange.getFirst(), MOVABLE_ELEMENT_CLASSES); + if (firstElement == null) return false; + + //noinspection unchecked + PsiElement lastElement = PsiTreeUtil.getNonStrictParentOfType(psiRange.getSecond(), MOVABLE_ELEMENT_CLASSES); + if (lastElement == null) return false; + + LineRange sourceRange = getSourceRange(firstElement, lastElement, editor); + if (sourceRange == null) return false; + + PsiElement sibling = adjustWhiteSpaceSibling(editor, sourceRange, info, down); + + // Either reached last sibling, or jumped over multi-line whitespace + if (sibling == null) return true; + + info.toMove = sourceRange; + info.toMove2 = getTargetRange(editor, sourceRange.firstElement, sibling, down); + return true; + } +} diff --git a/idea/testData/codeInsight/moveUpDown/closingBraces/for/for1.kt b/idea/testData/codeInsight/moveUpDown/closingBraces/for/for1.kt new file mode 100644 index 00000000000..eae0ea27cec --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/closingBraces/for/for1.kt @@ -0,0 +1,7 @@ +// MOVE: down +fun(n: Int) { + for (i in 0..n) { + + } + val x = "" +} \ No newline at end of file diff --git a/idea/testData/codeInsight/moveUpDown/closingBraces/for/for1.kt.after b/idea/testData/codeInsight/moveUpDown/closingBraces/for/for1.kt.after new file mode 100644 index 00000000000..756d6cee613 --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/closingBraces/for/for1.kt.after @@ -0,0 +1,7 @@ +// MOVE: down +fun(n: Int) { + for (i in 0..n) { + + val x = "" + } +} \ No newline at end of file diff --git a/idea/testData/codeInsight/moveUpDown/closingBraces/for/for2.kt b/idea/testData/codeInsight/moveUpDown/closingBraces/for/for2.kt new file mode 100644 index 00000000000..bf2aeb7c808 --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/closingBraces/for/for2.kt @@ -0,0 +1,8 @@ +// MOVE: up +// IS_APPLICABLE: false +fun(n: Int) { + for (i in 0..n) { + + } + val x = "" +} \ No newline at end of file diff --git a/idea/testData/codeInsight/moveUpDown/closingBraces/if/if1.kt b/idea/testData/codeInsight/moveUpDown/closingBraces/if/if1.kt new file mode 100644 index 00000000000..a5583bc773f --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/closingBraces/if/if1.kt @@ -0,0 +1,10 @@ +// MOVE: down +fun(n: Int) { + if (n > 0) { + + } + else { + + } + val x = "" +} \ No newline at end of file diff --git a/idea/testData/codeInsight/moveUpDown/closingBraces/if/if1.kt.after b/idea/testData/codeInsight/moveUpDown/closingBraces/if/if1.kt.after new file mode 100644 index 00000000000..5bca3816643 --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/closingBraces/if/if1.kt.after @@ -0,0 +1,10 @@ +// MOVE: down +fun(n: Int) { + if (n > 0) { + + } + else { + + val x = "" + } +} \ No newline at end of file diff --git a/idea/testData/codeInsight/moveUpDown/closingBraces/if/if2.kt b/idea/testData/codeInsight/moveUpDown/closingBraces/if/if2.kt new file mode 100644 index 00000000000..0d5fcedafc0 --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/closingBraces/if/if2.kt @@ -0,0 +1,11 @@ +// MOVE: up +// IS_APPLICABLE: false +fun(n: Int) { + if (n > 0) { + + } + else { + + } + val x = "" +} \ No newline at end of file diff --git a/idea/testData/codeInsight/moveUpDown/closingBraces/if/if3.kt b/idea/testData/codeInsight/moveUpDown/closingBraces/if/if3.kt new file mode 100644 index 00000000000..ff9a2c7d9e2 --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/closingBraces/if/if3.kt @@ -0,0 +1,11 @@ +// MOVE: down +// IS_APPLICABLE: false +fun(n: Int) { + if (n > 0) { + + } + else { + + } + val x = "" +} \ No newline at end of file diff --git a/idea/testData/codeInsight/moveUpDown/closingBraces/if/if4.kt b/idea/testData/codeInsight/moveUpDown/closingBraces/if/if4.kt new file mode 100644 index 00000000000..b738d13d3a9 --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/closingBraces/if/if4.kt @@ -0,0 +1,11 @@ +// MOVE: up +// IS_APPLICABLE: false +fun(n: Int) { + if (n > 0) { + + } + else { + + } + val x = "" +} \ No newline at end of file diff --git a/idea/testData/codeInsight/moveUpDown/closingBraces/nested/nested1.kt b/idea/testData/codeInsight/moveUpDown/closingBraces/nested/nested1.kt new file mode 100644 index 00000000000..7373ab8af34 --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/closingBraces/nested/nested1.kt @@ -0,0 +1,11 @@ +// MOVE: down +fun foo(n: Int) { + if (n > 0) { + + } else { + + } + while (n > 0) { + + } +} \ No newline at end of file diff --git a/idea/testData/codeInsight/moveUpDown/closingBraces/nested/nested1.kt.after b/idea/testData/codeInsight/moveUpDown/closingBraces/nested/nested1.kt.after new file mode 100644 index 00000000000..9c43a1014cc --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/closingBraces/nested/nested1.kt.after @@ -0,0 +1,11 @@ +// MOVE: down +fun foo(n: Int) { + if (n > 0) { + + } else { + + while (n > 0) { + + } + } +} \ No newline at end of file diff --git a/idea/testData/codeInsight/moveUpDown/closingBraces/nested/nested2.kt b/idea/testData/codeInsight/moveUpDown/closingBraces/nested/nested2.kt new file mode 100644 index 00000000000..9ae75a6dd88 --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/closingBraces/nested/nested2.kt @@ -0,0 +1,12 @@ +// MOVE: down +// IS_APPLICABLE: false +fun foo(n: Int) { + if (n > 0) { + + } else { + + } + while (n > 0) { + + } +} \ No newline at end of file diff --git a/idea/testData/codeInsight/moveUpDown/closingBraces/when/when1.kt b/idea/testData/codeInsight/moveUpDown/closingBraces/when/when1.kt new file mode 100644 index 00000000000..37e4b329134 --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/closingBraces/when/when1.kt @@ -0,0 +1,17 @@ +// IS_APPLICABLE: false +// MOVE: down + +fun foo(n: Int) { + when (n) { + 0 -> { + + } + 1 -> { + + } + else -> { + + } + } + val x = "" +} \ No newline at end of file diff --git a/idea/testData/codeInsight/moveUpDown/closingBraces/when/when2.kt b/idea/testData/codeInsight/moveUpDown/closingBraces/when/when2.kt new file mode 100644 index 00000000000..3e40febebf3 --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/closingBraces/when/when2.kt @@ -0,0 +1,17 @@ +// IS_APPLICABLE: false +// MOVE: up + +fun foo(n: Int) { + when (n) { + 0 -> { + + } + 1 -> { + + } + else -> { + + } + } + val x = "" +} \ No newline at end of file diff --git a/idea/testData/codeInsight/moveUpDown/closingBraces/when/whenEntry1.kt b/idea/testData/codeInsight/moveUpDown/closingBraces/when/whenEntry1.kt new file mode 100644 index 00000000000..3c5f5775bb8 --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/closingBraces/when/whenEntry1.kt @@ -0,0 +1,17 @@ +// IS_APPLICABLE: false +// MOVE: down + +fun foo(n: Int) { + when (n) { + 0 -> { + + } + 1 -> { + + } + else -> { + + } + } + val x = "" +} \ No newline at end of file diff --git a/idea/testData/codeInsight/moveUpDown/closingBraces/when/whenEntry2.kt b/idea/testData/codeInsight/moveUpDown/closingBraces/when/whenEntry2.kt new file mode 100644 index 00000000000..a8f199fbc69 --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/closingBraces/when/whenEntry2.kt @@ -0,0 +1,17 @@ +// IS_APPLICABLE: false +// MOVE: up + +fun foo(n: Int) { + when (n) { + 0 -> { + + } + 1 -> { + + } + else -> { + + } + } + 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 new file mode 100644 index 00000000000..e357586805d --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/closingBraces/when/whenEntry3.kt @@ -0,0 +1,17 @@ +// IS_APPLICABLE: false +// MOVE: down + +fun foo(n: Int) { + when (n) { + 0 -> { + + } + 1 -> { + + } + else -> { + + } + } + 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 new file mode 100644 index 00000000000..b54c1574f67 --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/closingBraces/when/whenEntry4.kt @@ -0,0 +1,17 @@ +// IS_APPLICABLE: false +// MOVE: up + +fun foo(n: Int) { + when (n) { + 0 -> { + + } + 1 -> { + + } + else -> { + + } + } + val x = "" +} \ No newline at end of file diff --git a/idea/testData/codeInsight/moveUpDown/closingBraces/while/while1.kt b/idea/testData/codeInsight/moveUpDown/closingBraces/while/while1.kt new file mode 100644 index 00000000000..f3a44d20769 --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/closingBraces/while/while1.kt @@ -0,0 +1,7 @@ +// MOVE: down +fun(n: Int) { + while (true) { + + } + val x = "" +} \ No newline at end of file diff --git a/idea/testData/codeInsight/moveUpDown/closingBraces/while/while1.kt.after b/idea/testData/codeInsight/moveUpDown/closingBraces/while/while1.kt.after new file mode 100644 index 00000000000..99dd7cfaca5 --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/closingBraces/while/while1.kt.after @@ -0,0 +1,7 @@ +// MOVE: down +fun(n: Int) { + while (true) { + + val x = "" + } +} \ No newline at end of file diff --git a/idea/testData/codeInsight/moveUpDown/closingBraces/while/while2.kt b/idea/testData/codeInsight/moveUpDown/closingBraces/while/while2.kt new file mode 100644 index 00000000000..254f34c7b1f --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/closingBraces/while/while2.kt @@ -0,0 +1,8 @@ +// MOVE: up +// IS_APPLICABLE: false +fun(n: Int) { + while (true) { + + } + val x = "" +} \ No newline at end of file diff --git a/idea/testData/codeInsight/moveUpDown/closingBraces/while/while3.kt b/idea/testData/codeInsight/moveUpDown/closingBraces/while/while3.kt new file mode 100644 index 00000000000..8adc8b57da9 --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/closingBraces/while/while3.kt @@ -0,0 +1,9 @@ +// MOVE: down +// IS_APPLICABLE: false +fun(n: Int) { + do { + + } + while (true) + val x = "" +} \ No newline at end of file diff --git a/idea/testData/codeInsight/moveUpDown/closingBraces/while/while4.kt b/idea/testData/codeInsight/moveUpDown/closingBraces/while/while4.kt new file mode 100644 index 00000000000..22af102194b --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/closingBraces/while/while4.kt @@ -0,0 +1,9 @@ +// MOVE: up +// IS_APPLICABLE: false +fun(n: Int) { + do { + + } + while (true) + val x = "" +} \ No newline at end of file diff --git a/idea/testData/codeInsight/moveUpDown/expressions/If1.kt b/idea/testData/codeInsight/moveUpDown/expressions/If1.kt new file mode 100644 index 00000000000..dc363c3a5c9 --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/expressions/If1.kt @@ -0,0 +1,11 @@ +// MOVE: down + +fun foo(x: Boolean) { + // test + if (x) { + + } + else { + + } +} diff --git a/idea/testData/codeInsight/moveUpDown/expressions/If1.kt.after b/idea/testData/codeInsight/moveUpDown/expressions/If1.kt.after new file mode 100644 index 00000000000..42673921651 --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/expressions/If1.kt.after @@ -0,0 +1,11 @@ +// MOVE: down + +fun foo(x: Boolean) { + if (x) { + // test + + } + else { + + } +} diff --git a/idea/testData/codeInsight/moveUpDown/expressions/declaration1.kt b/idea/testData/codeInsight/moveUpDown/expressions/declaration1.kt new file mode 100644 index 00000000000..ff51a8e408d --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/expressions/declaration1.kt @@ -0,0 +1,5 @@ +// MOVE: down +fun foo() { + // test + val x = "" +} diff --git a/idea/testData/codeInsight/moveUpDown/expressions/declaration1.kt.after b/idea/testData/codeInsight/moveUpDown/expressions/declaration1.kt.after new file mode 100644 index 00000000000..7540c6285d0 --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/expressions/declaration1.kt.after @@ -0,0 +1,5 @@ +// MOVE: down +fun foo() { + val x = "" + // test +} diff --git a/idea/testData/codeInsight/moveUpDown/expressions/declaration2.kt b/idea/testData/codeInsight/moveUpDown/expressions/declaration2.kt new file mode 100644 index 00000000000..4e791764e35 --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/expressions/declaration2.kt @@ -0,0 +1,5 @@ +// MOVE: up +fun foo() { + val x = "" + // test +} diff --git a/idea/testData/codeInsight/moveUpDown/expressions/declaration2.kt.after b/idea/testData/codeInsight/moveUpDown/expressions/declaration2.kt.after new file mode 100644 index 00000000000..e46650fce17 --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/expressions/declaration2.kt.after @@ -0,0 +1,5 @@ +// MOVE: up +fun foo() { + // test + val x = "" +} diff --git a/idea/testData/codeInsight/moveUpDown/expressions/if2.kt b/idea/testData/codeInsight/moveUpDown/expressions/if2.kt new file mode 100644 index 00000000000..4517ef16f9b --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/expressions/if2.kt @@ -0,0 +1,10 @@ +// MOVE: up +fun foo(x: Boolean) { + if (x) { + + } + else { + + } + // test +} diff --git a/idea/testData/codeInsight/moveUpDown/expressions/if2.kt.after b/idea/testData/codeInsight/moveUpDown/expressions/if2.kt.after new file mode 100644 index 00000000000..e88441309f2 --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/expressions/if2.kt.after @@ -0,0 +1,10 @@ +// MOVE: up +fun foo(x: Boolean) { + if (x) { + + } + else { + + // test + } +} diff --git a/idea/testData/codeInsight/moveUpDown/expressions/if3.kt b/idea/testData/codeInsight/moveUpDown/expressions/if3.kt new file mode 100644 index 00000000000..c659bd2d03d --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/expressions/if3.kt @@ -0,0 +1,9 @@ +// MOVE: down + +fun foo(x: Boolean) { + if (x) { + // test + } + else { + } +} diff --git a/idea/testData/codeInsight/moveUpDown/expressions/if3.kt.after b/idea/testData/codeInsight/moveUpDown/expressions/if3.kt.after new file mode 100644 index 00000000000..54b18882ec8 --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/expressions/if3.kt.after @@ -0,0 +1,9 @@ +// MOVE: down + +fun foo(x: Boolean) { + if (x) { + } + else { + // test + } +} diff --git a/idea/testData/codeInsight/moveUpDown/expressions/if4.kt b/idea/testData/codeInsight/moveUpDown/expressions/if4.kt new file mode 100644 index 00000000000..63ffdabe366 --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/expressions/if4.kt @@ -0,0 +1,9 @@ +// MOVE: up + +fun foo(x: Boolean) { + if (x) { + } + else { + // test + } +} diff --git a/idea/testData/codeInsight/moveUpDown/expressions/if4.kt.after b/idea/testData/codeInsight/moveUpDown/expressions/if4.kt.after new file mode 100644 index 00000000000..5483bf42414 --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/expressions/if4.kt.after @@ -0,0 +1,9 @@ +// MOVE: up + +fun foo(x: Boolean) { + if (x) { + // test + } + else { + } +} diff --git a/idea/testData/codeInsight/moveUpDown/expressions/when1.kt b/idea/testData/codeInsight/moveUpDown/expressions/when1.kt new file mode 100644 index 00000000000..f05655dbafd --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/expressions/when1.kt @@ -0,0 +1,16 @@ +// MOVE: down + +fun foo(x: Boolean) { + // test + when (x) { + false -> { + + } + true -> { + + } + else -> { + + } + } +} diff --git a/idea/testData/codeInsight/moveUpDown/expressions/when1.kt.after b/idea/testData/codeInsight/moveUpDown/expressions/when1.kt.after new file mode 100644 index 00000000000..80eaaac0b28 --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/expressions/when1.kt.after @@ -0,0 +1,16 @@ +// MOVE: down + +fun foo(x: Boolean) { + when (x) { + false -> { + // test + + } + true -> { + + } + else -> { + + } + } +} diff --git a/idea/testData/codeInsight/moveUpDown/expressions/when2.kt b/idea/testData/codeInsight/moveUpDown/expressions/when2.kt new file mode 100644 index 00000000000..f8fef0d66a4 --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/expressions/when2.kt @@ -0,0 +1,16 @@ +// MOVE: up + +fun foo(x: Boolean) { + when (x) { + false -> { + + } + true -> { + + } + else -> { + + } + } + // test +} diff --git a/idea/testData/codeInsight/moveUpDown/expressions/when2.kt.after b/idea/testData/codeInsight/moveUpDown/expressions/when2.kt.after new file mode 100644 index 00000000000..bac9bf0cc9d --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/expressions/when2.kt.after @@ -0,0 +1,16 @@ +// MOVE: up + +fun foo(x: Boolean) { + when (x) { + false -> { + + } + true -> { + + } + else -> { + + // test + } + } +} diff --git a/idea/testData/codeInsight/moveUpDown/expressions/whenEntry1.kt b/idea/testData/codeInsight/moveUpDown/expressions/whenEntry1.kt new file mode 100644 index 00000000000..7a7c2610296 --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/expressions/whenEntry1.kt @@ -0,0 +1,16 @@ +// MOVE: down + +fun foo(x: Boolean) { + when (x) { + // test + false -> { + + } + true -> { + + } + else -> { + + } + } +} diff --git a/idea/testData/codeInsight/moveUpDown/expressions/whenEntry1.kt.after b/idea/testData/codeInsight/moveUpDown/expressions/whenEntry1.kt.after new file mode 100644 index 00000000000..80eaaac0b28 --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/expressions/whenEntry1.kt.after @@ -0,0 +1,16 @@ +// MOVE: down + +fun foo(x: Boolean) { + when (x) { + false -> { + // test + + } + true -> { + + } + else -> { + + } + } +} diff --git a/idea/testData/codeInsight/moveUpDown/expressions/whenEntry2.kt b/idea/testData/codeInsight/moveUpDown/expressions/whenEntry2.kt new file mode 100644 index 00000000000..a8ae614ee51 --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/expressions/whenEntry2.kt @@ -0,0 +1,13 @@ +// MOVE: down + +fun foo(x: Boolean) { + when (x) { + false -> { + // test + } + true -> { + } + else -> { + } + } +} diff --git a/idea/testData/codeInsight/moveUpDown/expressions/whenEntry2.kt.after b/idea/testData/codeInsight/moveUpDown/expressions/whenEntry2.kt.after new file mode 100644 index 00000000000..8dbe015f785 --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/expressions/whenEntry2.kt.after @@ -0,0 +1,13 @@ +// MOVE: down + +fun foo(x: Boolean) { + when (x) { + false -> { + } + true -> { + // test + } + else -> { + } + } +} diff --git a/idea/testData/codeInsight/moveUpDown/expressions/whenEntry3.kt b/idea/testData/codeInsight/moveUpDown/expressions/whenEntry3.kt new file mode 100644 index 00000000000..083664a07df --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/expressions/whenEntry3.kt @@ -0,0 +1,15 @@ +// MOVE: down + +fun foo(x: Boolean) { + when (x) { + false -> { + + } + true -> { + + } + else -> { + // test + } + } +} diff --git a/idea/testData/codeInsight/moveUpDown/expressions/whenEntry3.kt.after b/idea/testData/codeInsight/moveUpDown/expressions/whenEntry3.kt.after new file mode 100644 index 00000000000..77de8a9f66d --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/expressions/whenEntry3.kt.after @@ -0,0 +1,15 @@ +// MOVE: down + +fun foo(x: Boolean) { + when (x) { + false -> { + + } + true -> { + + } + else -> { + } + } + // test +} diff --git a/idea/testData/codeInsight/moveUpDown/expressions/whenEntry4.kt b/idea/testData/codeInsight/moveUpDown/expressions/whenEntry4.kt new file mode 100644 index 00000000000..88fe7d65d15 --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/expressions/whenEntry4.kt @@ -0,0 +1,16 @@ +// MOVE: up + +fun foo(x: Boolean) { + when (x) { + false -> { + + } + true -> { + + } + else -> { + + } + // test + } +} diff --git a/idea/testData/codeInsight/moveUpDown/expressions/whenEntry4.kt.after b/idea/testData/codeInsight/moveUpDown/expressions/whenEntry4.kt.after new file mode 100644 index 00000000000..bac9bf0cc9d --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/expressions/whenEntry4.kt.after @@ -0,0 +1,16 @@ +// MOVE: up + +fun foo(x: Boolean) { + when (x) { + false -> { + + } + true -> { + + } + else -> { + + // test + } + } +} diff --git a/idea/testData/codeInsight/moveUpDown/expressions/whenEntry5.kt b/idea/testData/codeInsight/moveUpDown/expressions/whenEntry5.kt new file mode 100644 index 00000000000..8fbc8cdbf7d --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/expressions/whenEntry5.kt @@ -0,0 +1,15 @@ +// MOVE: up + +fun foo(x: Boolean) { + when (x) { + false -> { + + } + true -> { + + } + else -> { + // test + } + } +} diff --git a/idea/testData/codeInsight/moveUpDown/expressions/whenEntry5.kt.after b/idea/testData/codeInsight/moveUpDown/expressions/whenEntry5.kt.after new file mode 100644 index 00000000000..9418f7325a0 --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/expressions/whenEntry5.kt.after @@ -0,0 +1,15 @@ +// MOVE: up + +fun foo(x: Boolean) { + when (x) { + false -> { + + } + true -> { + + // test + } + else -> { + } + } +} diff --git a/idea/testData/codeInsight/moveUpDown/expressions/whenEntry6.kt b/idea/testData/codeInsight/moveUpDown/expressions/whenEntry6.kt new file mode 100644 index 00000000000..6c285ac6988 --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/expressions/whenEntry6.kt @@ -0,0 +1,15 @@ +// MOVE: up + +fun foo(x: Boolean) { + when (x) { + false -> { + // test + } + true -> { + + } + else -> { + + } + } +} diff --git a/idea/testData/codeInsight/moveUpDown/expressions/whenEntry6.kt.after b/idea/testData/codeInsight/moveUpDown/expressions/whenEntry6.kt.after new file mode 100644 index 00000000000..a2e1088cb2e --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/expressions/whenEntry6.kt.after @@ -0,0 +1,15 @@ +// MOVE: up + +fun foo(x: Boolean) { + // test + when (x) { + false -> { + } + true -> { + + } + else -> { + + } + } +} diff --git a/idea/testData/codeInsight/moveUpDown/expressions/while1.kt b/idea/testData/codeInsight/moveUpDown/expressions/while1.kt new file mode 100644 index 00000000000..5b5801b65b8 --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/expressions/while1.kt @@ -0,0 +1,8 @@ +// MOVE: down + +fun foo(x: Boolean) { + // test + while (x) { + + } +} diff --git a/idea/testData/codeInsight/moveUpDown/expressions/while1.kt.after b/idea/testData/codeInsight/moveUpDown/expressions/while1.kt.after new file mode 100644 index 00000000000..6a399a964ea --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/expressions/while1.kt.after @@ -0,0 +1,8 @@ +// MOVE: down + +fun foo(x: Boolean) { + while (x) { + // test + + } +} diff --git a/idea/testData/codeInsight/moveUpDown/expressions/while2.kt b/idea/testData/codeInsight/moveUpDown/expressions/while2.kt new file mode 100644 index 00000000000..1141e224018 --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/expressions/while2.kt @@ -0,0 +1,7 @@ +// MOVE: up +fun foo(x: Boolean) { + while (x) { + + } + // test +} diff --git a/idea/testData/codeInsight/moveUpDown/expressions/while2.kt.after b/idea/testData/codeInsight/moveUpDown/expressions/while2.kt.after new file mode 100644 index 00000000000..9c90bd924fe --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/expressions/while2.kt.after @@ -0,0 +1,7 @@ +// MOVE: up +fun foo(x: Boolean) { + while (x) { + + // test + } +} diff --git a/idea/tests/org/jetbrains/jet/plugin/codeInsight/moveUpDown/AbstractCodeMoverTest.java b/idea/tests/org/jetbrains/jet/plugin/codeInsight/moveUpDown/AbstractCodeMoverTest.java index b1271d50891..329bf8489e8 100644 --- a/idea/tests/org/jetbrains/jet/plugin/codeInsight/moveUpDown/AbstractCodeMoverTest.java +++ b/idea/tests/org/jetbrains/jet/plugin/codeInsight/moveUpDown/AbstractCodeMoverTest.java @@ -26,6 +26,7 @@ import com.intellij.testFramework.LightCodeInsightTestCase; import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.InTextDirectivesUtils; import org.jetbrains.jet.plugin.codeInsight.upDownMover.JetDeclarationMover; +import org.jetbrains.jet.plugin.codeInsight.upDownMover.JetExpressionMover; import java.io.File; @@ -34,6 +35,10 @@ public abstract class AbstractCodeMoverTest extends LightCodeInsightTestCase { doTest(path, JetDeclarationMover.class); } + public void doTestExpression(@NotNull String path) throws Exception { + doTest(path, JetExpressionMover.class); + } + private void doTest(@NotNull String path, @NotNull Class moverClass) throws Exception { configureByFile(path); 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 44c810ed49d..6b4ca6785ef 100644 --- a/idea/tests/org/jetbrains/jet/plugin/codeInsight/moveUpDown/CodeMoverTestGenerated.java +++ b/idea/tests/org/jetbrains/jet/plugin/codeInsight/moveUpDown/CodeMoverTestGenerated.java @@ -30,7 +30,7 @@ import org.jetbrains.jet.plugin.codeInsight.moveUpDown.AbstractCodeMoverTest; /** This class is generated by {@link org.jetbrains.jet.generators.tests.GenerateTests}. DO NOT MODIFY MANUALLY */ @SuppressWarnings("all") -@InnerTestClasses({CodeMoverTestGenerated.ClassBodyDeclarations.class}) +@InnerTestClasses({CodeMoverTestGenerated.ClassBodyDeclarations.class, CodeMoverTestGenerated.ClosingBraces.class, CodeMoverTestGenerated.Expressions.class}) public class CodeMoverTestGenerated extends AbstractCodeMoverTest { @TestMetadata("idea/testData/codeInsight/moveUpDown/classBodyDeclarations") @InnerTestClasses({ClassBodyDeclarations.Accessors.class, ClassBodyDeclarations.Class.class, ClassBodyDeclarations.ClassInitializer.class, ClassBodyDeclarations.Enums.class, ClassBodyDeclarations.Function.class, ClassBodyDeclarations.Property.class}) @@ -450,9 +450,248 @@ 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}) + 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); + } + + @TestMetadata("idea/testData/codeInsight/moveUpDown/closingBraces/for") + public static class For extends AbstractCodeMoverTest { + public void testAllFilesPresentInFor() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/codeInsight/moveUpDown/closingBraces/for"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("for1.kt") + public void testFor1() throws Exception { + doTestExpression("idea/testData/codeInsight/moveUpDown/closingBraces/for/for1.kt"); + } + + @TestMetadata("for2.kt") + public void testFor2() throws Exception { + doTestExpression("idea/testData/codeInsight/moveUpDown/closingBraces/for/for2.kt"); + } + + } + + @TestMetadata("idea/testData/codeInsight/moveUpDown/closingBraces/if") + public static class If extends AbstractCodeMoverTest { + public void testAllFilesPresentInIf() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/codeInsight/moveUpDown/closingBraces/if"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("if1.kt") + public void testIf1() throws Exception { + doTestExpression("idea/testData/codeInsight/moveUpDown/closingBraces/if/if1.kt"); + } + + @TestMetadata("if2.kt") + public void testIf2() throws Exception { + doTestExpression("idea/testData/codeInsight/moveUpDown/closingBraces/if/if2.kt"); + } + + @TestMetadata("if3.kt") + public void testIf3() throws Exception { + doTestExpression("idea/testData/codeInsight/moveUpDown/closingBraces/if/if3.kt"); + } + + @TestMetadata("if4.kt") + public void testIf4() throws Exception { + doTestExpression("idea/testData/codeInsight/moveUpDown/closingBraces/if/if4.kt"); + } + + } + + @TestMetadata("idea/testData/codeInsight/moveUpDown/closingBraces/nested") + public static class Nested extends AbstractCodeMoverTest { + public void testAllFilesPresentInNested() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/codeInsight/moveUpDown/closingBraces/nested"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("nested1.kt") + public void testNested1() throws Exception { + doTestExpression("idea/testData/codeInsight/moveUpDown/closingBraces/nested/nested1.kt"); + } + + @TestMetadata("nested2.kt") + public void testNested2() throws Exception { + doTestExpression("idea/testData/codeInsight/moveUpDown/closingBraces/nested/nested2.kt"); + } + + } + + @TestMetadata("idea/testData/codeInsight/moveUpDown/closingBraces/when") + public static class When extends AbstractCodeMoverTest { + public void testAllFilesPresentInWhen() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/codeInsight/moveUpDown/closingBraces/when"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("when1.kt") + public void testWhen1() throws Exception { + doTestExpression("idea/testData/codeInsight/moveUpDown/closingBraces/when/when1.kt"); + } + + @TestMetadata("when2.kt") + public void testWhen2() throws Exception { + doTestExpression("idea/testData/codeInsight/moveUpDown/closingBraces/when/when2.kt"); + } + + @TestMetadata("whenEntry1.kt") + public void testWhenEntry1() throws Exception { + doTestExpression("idea/testData/codeInsight/moveUpDown/closingBraces/when/whenEntry1.kt"); + } + + @TestMetadata("whenEntry2.kt") + public void testWhenEntry2() throws Exception { + doTestExpression("idea/testData/codeInsight/moveUpDown/closingBraces/when/whenEntry2.kt"); + } + + @TestMetadata("whenEntry3.kt") + public void testWhenEntry3() throws Exception { + doTestExpression("idea/testData/codeInsight/moveUpDown/closingBraces/when/whenEntry3.kt"); + } + + @TestMetadata("whenEntry4.kt") + public void testWhenEntry4() throws Exception { + doTestExpression("idea/testData/codeInsight/moveUpDown/closingBraces/when/whenEntry4.kt"); + } + + } + + @TestMetadata("idea/testData/codeInsight/moveUpDown/closingBraces/while") + public static class While extends AbstractCodeMoverTest { + public void testAllFilesPresentInWhile() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/codeInsight/moveUpDown/closingBraces/while"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("while1.kt") + public void testWhile1() throws Exception { + doTestExpression("idea/testData/codeInsight/moveUpDown/closingBraces/while/while1.kt"); + } + + @TestMetadata("while2.kt") + public void testWhile2() throws Exception { + doTestExpression("idea/testData/codeInsight/moveUpDown/closingBraces/while/while2.kt"); + } + + @TestMetadata("while3.kt") + public void testWhile3() throws Exception { + doTestExpression("idea/testData/codeInsight/moveUpDown/closingBraces/while/while3.kt"); + } + + @TestMetadata("while4.kt") + public void testWhile4() throws Exception { + doTestExpression("idea/testData/codeInsight/moveUpDown/closingBraces/while/while4.kt"); + } + + } + + public static Test innerSuite() { + TestSuite suite = new TestSuite("ClosingBraces"); + suite.addTestSuite(ClosingBraces.class); + suite.addTestSuite(For.class); + suite.addTestSuite(If.class); + suite.addTestSuite(Nested.class); + suite.addTestSuite(When.class); + suite.addTestSuite(While.class); + return suite; + } + } + + @TestMetadata("idea/testData/codeInsight/moveUpDown/expressions") + public static class Expressions extends AbstractCodeMoverTest { + public void testAllFilesPresentInExpressions() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/codeInsight/moveUpDown/expressions"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("declaration1.kt") + public void testDeclaration1() throws Exception { + doTestExpression("idea/testData/codeInsight/moveUpDown/expressions/declaration1.kt"); + } + + @TestMetadata("declaration2.kt") + public void testDeclaration2() throws Exception { + doTestExpression("idea/testData/codeInsight/moveUpDown/expressions/declaration2.kt"); + } + + @TestMetadata("If1.kt") + public void testIf1() throws Exception { + doTestExpression("idea/testData/codeInsight/moveUpDown/expressions/If1.kt"); + } + + @TestMetadata("if2.kt") + public void testIf2() throws Exception { + doTestExpression("idea/testData/codeInsight/moveUpDown/expressions/if2.kt"); + } + + @TestMetadata("if3.kt") + public void testIf3() throws Exception { + doTestExpression("idea/testData/codeInsight/moveUpDown/expressions/if3.kt"); + } + + @TestMetadata("if4.kt") + public void testIf4() throws Exception { + doTestExpression("idea/testData/codeInsight/moveUpDown/expressions/if4.kt"); + } + + @TestMetadata("when1.kt") + public void testWhen1() throws Exception { + doTestExpression("idea/testData/codeInsight/moveUpDown/expressions/when1.kt"); + } + + @TestMetadata("when2.kt") + public void testWhen2() throws Exception { + doTestExpression("idea/testData/codeInsight/moveUpDown/expressions/when2.kt"); + } + + @TestMetadata("whenEntry1.kt") + public void testWhenEntry1() throws Exception { + doTestExpression("idea/testData/codeInsight/moveUpDown/expressions/whenEntry1.kt"); + } + + @TestMetadata("whenEntry2.kt") + public void testWhenEntry2() throws Exception { + doTestExpression("idea/testData/codeInsight/moveUpDown/expressions/whenEntry2.kt"); + } + + @TestMetadata("whenEntry3.kt") + public void testWhenEntry3() throws Exception { + doTestExpression("idea/testData/codeInsight/moveUpDown/expressions/whenEntry3.kt"); + } + + @TestMetadata("whenEntry4.kt") + public void testWhenEntry4() throws Exception { + doTestExpression("idea/testData/codeInsight/moveUpDown/expressions/whenEntry4.kt"); + } + + @TestMetadata("whenEntry5.kt") + public void testWhenEntry5() throws Exception { + doTestExpression("idea/testData/codeInsight/moveUpDown/expressions/whenEntry5.kt"); + } + + @TestMetadata("whenEntry6.kt") + public void testWhenEntry6() throws Exception { + doTestExpression("idea/testData/codeInsight/moveUpDown/expressions/whenEntry6.kt"); + } + + @TestMetadata("while1.kt") + public void testWhile1() throws Exception { + doTestExpression("idea/testData/codeInsight/moveUpDown/expressions/while1.kt"); + } + + @TestMetadata("while2.kt") + public void testWhile2() throws Exception { + doTestExpression("idea/testData/codeInsight/moveUpDown/expressions/while2.kt"); + } + + } + public static Test suite() { TestSuite suite = new TestSuite("CodeMoverTestGenerated"); suite.addTest(ClassBodyDeclarations.innerSuite()); + suite.addTest(ClosingBraces.innerSuite()); + suite.addTestSuite(Expressions.class); return suite; } }