mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
move left/right a few more java constructs
This commit is contained in:
+18
@@ -17,8 +17,11 @@ package com.intellij.codeInsight.editorActions.moveLeftRight;
|
||||
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class JavaMoveLeftRightHandler extends MoveElementLeftRightHandler {
|
||||
@NotNull
|
||||
@Override
|
||||
@@ -53,6 +56,21 @@ public class JavaMoveLeftRightHandler extends MoveElementLeftRightHandler {
|
||||
else if (element instanceof PsiPolyadicExpression) {
|
||||
return ((PsiPolyadicExpression)element).getOperands();
|
||||
}
|
||||
else if (element instanceof PsiReferenceParameterList) {
|
||||
return ((PsiReferenceParameterList)element).getTypeParameterElements();
|
||||
}
|
||||
else if (element instanceof PsiTypeParameterList) {
|
||||
return ((PsiTypeParameterList)element).getTypeParameters();
|
||||
}
|
||||
else if (element instanceof PsiModifierList) {
|
||||
final List<PsiElement> result = ContainerUtil.newSmartList();
|
||||
for (PsiElement child = element.getFirstChild(); child != null; child = child.getNextSibling()) {
|
||||
if (child instanceof PsiKeyword || child instanceof PsiAnnotation) {
|
||||
result.add(child);
|
||||
}
|
||||
}
|
||||
return result.toArray(PsiElement.EMPTY_ARRAY);
|
||||
}
|
||||
return PsiElement.EMPTY_ARRAY;
|
||||
}
|
||||
}
|
||||
|
||||
+15
@@ -111,6 +111,21 @@ public class MoveElementLeftRightTest extends AbstractMoveElementLeftRightTest {
|
||||
"class C { int i = 2 + 3 + <caret>1; }");
|
||||
}
|
||||
|
||||
public void testMoveTypeParameter() throws Exception {
|
||||
doTestFromLeftToRight("class C {{ java.util.Map<Object<caret>, String> map; }}",
|
||||
"class C {{ java.util.Map<String, Object<caret>> map; }}");
|
||||
}
|
||||
|
||||
public void testMoveClassTypeParameter() throws Exception {
|
||||
doTestFromLeftToRight("class C<<caret>A, B> {}",
|
||||
"class C<B, <caret>A> {}");
|
||||
}
|
||||
|
||||
public void testMoveModifier() throws Exception {
|
||||
doTestFromLeftToRight("@Suppress<caret>Warnings(\"ALL\") final class C {}",
|
||||
"final @Suppress<caret>Warnings(\"ALL\") class C {}");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configureEditor(String contents) throws Exception {
|
||||
init(contents, TestFileType.JAVA);
|
||||
|
||||
Reference in New Issue
Block a user