diff --git a/java/java-impl/src/com/intellij/codeInsight/editorActions/moveLeftRight/JavaMoveLeftRightHandler.java b/java/java-impl/src/com/intellij/codeInsight/editorActions/moveLeftRight/JavaMoveLeftRightHandler.java index 9f0ecca280d4..54045d011043 100644 --- a/java/java-impl/src/com/intellij/codeInsight/editorActions/moveLeftRight/JavaMoveLeftRightHandler.java +++ b/java/java-impl/src/com/intellij/codeInsight/editorActions/moveLeftRight/JavaMoveLeftRightHandler.java @@ -41,6 +41,20 @@ public class JavaMoveLeftRightHandler extends MoveElementLeftRightHandler { return enumConstants; } } + else if (element instanceof PsiReferenceList) { + return ((PsiReferenceList)element).getReferenceElements(); + } + else if (element instanceof PsiTypeElement) { + final PsiTypeElement[] result = PsiTreeUtil.getChildrenOfType(element, PsiTypeElement.class); + return result == null ? PsiElement.EMPTY_ARRAY : result; + } + else if (element instanceof PsiResourceList) { + final PsiElement[] result = PsiTreeUtil.getChildrenOfType(element, PsiResourceListElement.class); + return result == null ? PsiElement.EMPTY_ARRAY : result; + } + else if (element instanceof PsiPolyadicExpression) { + return ((PsiPolyadicExpression)element).getOperands(); + } return PsiElement.EMPTY_ARRAY; } } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/editorActions/MoveElementLeftRightTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/editorActions/MoveElementLeftRightTest.java index d3926e0e3cc1..40881411b329 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/editorActions/MoveElementLeftRightTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/editorActions/MoveElementLeftRightTest.java @@ -80,6 +80,32 @@ public class MoveElementLeftRightTest extends AbstractMoveElementLeftRightTest { "@SomeAnnotation(p2 = \"2\", p1=1) class C {}"); } + public void testMoveThrowsExceptions() throws Exception { + doTestFromLeftToRight("class C { void m() throws RuntimeException, Exception {} }", + "class C { void m() throws Exception, RuntimeException {} }"); + } + + public void testMoveImplementsClause() throws Exception { + doTestFromLeftToRight("class C implements Cloneable, java.io.Serializable {}", + "class C implements java.io.Serializable, Cloneable {}"); + } + + public void testMoveMulticatch() throws Exception { + doTestFromLeftToRight("class C { void m() { try {} catch (RuntimeException | Exception e) {}", + "class C { void m() { try {} catch (Exception | RuntimeException e) {}"); + } + + public void testMoveTryResource() throws Exception { + doTestFromLeftToRight("class C { void m(AutoCloseable a) { try (AutoCloseable b = a; AutoCloseable c = null) {} } }", + "class C { void m(AutoCloseable a) { try (AutoCloseable c = null; AutoCloseable b = a) {} } }"); + } + + public void testMovePolyadicExpressionOperand() throws Exception { + doTestFromLeftToRight("class C { int i = 1 + 2 + 3; }", + "class C { int i = 2 + 1 + 3; }", + "class C { int i = 2 + 3 + 1; }"); + } + @Override protected void configureEditor(String contents) throws Exception { init(contents, TestFileType.JAVA);