mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
extract class: do not qualify enums in switches (IDEA-76587 )
This commit is contained in:
@@ -422,7 +422,9 @@ class ExtractedClassBuilder {
|
||||
}
|
||||
else {
|
||||
if (field.hasModifierProperty(PsiModifier.STATIC)) {
|
||||
if (staticImported) {
|
||||
if (field instanceof PsiEnumConstant) {
|
||||
out.append(field.getName());
|
||||
} else if (staticImported) {
|
||||
final PsiImportStaticStatement importStaticStatement = (PsiImportStaticStatement)resolveResult.getCurrentFileResolveScope();
|
||||
final PsiClass targetClass = importStaticStatement.resolveTargetClass();
|
||||
out.append(targetClass != null ? targetClass.getQualifiedName() : "").append(".").append(field.getName());
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
public class Extracted {
|
||||
static void foo(Test t) {
|
||||
switch (p) {
|
||||
case FRED:
|
||||
break;
|
||||
|
||||
case GEORGE:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
public class Test {
|
||||
|
||||
}
|
||||
|
||||
enum Person {
|
||||
FRED, GEORGE;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
public class Test {
|
||||
|
||||
static void foo(Test t) {
|
||||
switch (p) {
|
||||
case FRED:
|
||||
break;
|
||||
|
||||
case GEORGE:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum Person {
|
||||
FRED, GEORGE;
|
||||
}
|
||||
@@ -97,6 +97,10 @@ public class ExtractClassTest extends MultiFileTestCase{
|
||||
doTestMethod();
|
||||
}
|
||||
|
||||
public void testEnumSwitch() throws Exception {
|
||||
doTestMethod();
|
||||
}
|
||||
|
||||
private void doTestFieldAndMethod() throws Exception {
|
||||
doTestFieldAndMethod("bar");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user