move left/right a few more java constructs

This commit is contained in:
Bas Leijdekkers
2016-04-04 20:55:28 +02:00
parent 77425f305d
commit 2456ffff2f
2 changed files with 33 additions and 0 deletions
@@ -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;
}
}
@@ -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);