mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
move member: restore qualifier in switch labels for non-enum constants (IDEA-147539)
This commit is contained in:
+9
-8
@@ -179,14 +179,15 @@ public class MoveJavaMemberHandler implements MoveMemberHandler {
|
||||
changeQualifier(refExpr, usage.qualifierClass, usage.member);
|
||||
}
|
||||
else {
|
||||
final PsiReferenceParameterList parameterList = refExpr.getParameterList();
|
||||
if (parameterList != null && parameterList.getTypeArguments().length == 0 && !(refExpr instanceof PsiMethodReferenceExpression)){
|
||||
refExpr.setQualifierExpression(null);
|
||||
} else {
|
||||
final Project project = element.getProject();
|
||||
final PsiClass targetClass =
|
||||
JavaPsiFacade.getInstance(project).findClass(options.getTargetClassName(), GlobalSearchScope.projectScope(project));
|
||||
if (targetClass != null) {
|
||||
final Project project = element.getProject();
|
||||
final PsiClass targetClass =
|
||||
JavaPsiFacade.getInstance(project).findClass(options.getTargetClassName(), GlobalSearchScope.projectScope(project));
|
||||
if (targetClass != null) {
|
||||
final PsiReferenceParameterList parameterList = refExpr.getParameterList();
|
||||
if ((targetClass.isEnum() || PsiTreeUtil.isAncestor(targetClass, element, true)) && parameterList != null && parameterList.getTypeArguments().length == 0 && !(refExpr instanceof PsiMethodReferenceExpression)) {
|
||||
refExpr.setQualifierExpression(null);
|
||||
}
|
||||
else {
|
||||
changeQualifier(refExpr, targetClass, usage.member);
|
||||
}
|
||||
}
|
||||
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
public interface A {
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
public class B {
|
||||
|
||||
public static final String FOO = "FOO";
|
||||
}
|
||||
|
||||
class U {
|
||||
public void example(String foo) {
|
||||
switch (foo) {
|
||||
case B.FOO:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
public interface A {
|
||||
public static final String FOO = "FOO";
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
public class B {
|
||||
|
||||
}
|
||||
|
||||
class U {
|
||||
public void example(String foo) {
|
||||
switch (foo) {
|
||||
case A.FOO:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,6 @@ package com.intellij.refactoring;
|
||||
import com.intellij.JavaTestUtil;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiElement;
|
||||
@@ -174,7 +173,11 @@ public class MoveMembersTest extends MultiFileTestCase {
|
||||
public void testEscalateVisibility1() throws Exception {
|
||||
doTest("A", "B", true, VisibilityUtil.ESCALATE_VISIBILITY, 0);
|
||||
}
|
||||
|
||||
|
||||
public void testStringConstantInSwitchLabelExpression() throws Exception {
|
||||
doTest("A", "B", true, VisibilityUtil.ESCALATE_VISIBILITY, 0);
|
||||
}
|
||||
|
||||
public void testMultipleWithDependencies() throws Exception {
|
||||
doTest("A", "B", true, VisibilityUtil.ESCALATE_VISIBILITY, 0, 1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user