mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
allow to move left/right more java constructs
This commit is contained in:
+14
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
+26
@@ -80,6 +80,32 @@ public class MoveElementLeftRightTest extends AbstractMoveElementLeftRightTest {
|
||||
"@SomeAnnotation(p2 = \"2\", p1=<caret>1) class C {}");
|
||||
}
|
||||
|
||||
public void testMoveThrowsExceptions() throws Exception {
|
||||
doTestFromLeftToRight("class C { void m() throws RuntimeExceptio<caret>n, Exception {} }",
|
||||
"class C { void m() throws Exception, RuntimeExceptio<caret>n {} }");
|
||||
}
|
||||
|
||||
public void testMoveImplementsClause() throws Exception {
|
||||
doTestFromLeftToRight("class C implements Cl<caret>oneable, java.io.Serializable {}",
|
||||
"class C implements java.io.Serializable, Cl<caret>oneable {}");
|
||||
}
|
||||
|
||||
public void testMoveMulticatch() throws Exception {
|
||||
doTestFromLeftToRight("class C { void m() { try {} catch (Runtime<caret>Exception | Exception e) {}",
|
||||
"class C { void m() { try {} catch (Exception | Runtime<caret>Exception e) {}");
|
||||
}
|
||||
|
||||
public void testMoveTryResource() throws Exception {
|
||||
doTestFromLeftToRight("class C { void m(AutoCloseable a) { try (Auto<caret>Closeable b = a; AutoCloseable c = null) {} } }",
|
||||
"class C { void m(AutoCloseable a) { try (AutoCloseable c = null; Auto<caret>Closeable b = a) {} } }");
|
||||
}
|
||||
|
||||
public void testMovePolyadicExpressionOperand() throws Exception {
|
||||
doTestFromLeftToRight("class C { int i = <caret>1 + 2 + 3; }",
|
||||
"class C { int i = 2 + <caret>1 + 3; }",
|
||||
"class C { int i = 2 + 3 + <caret>1; }");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configureEditor(String contents) throws Exception {
|
||||
init(contents, TestFileType.JAVA);
|
||||
|
||||
Reference in New Issue
Block a user