mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-26 15:27:45 +07:00
extract enum: do not include constants when user don't ask to; check that variable was already migrated and getter is already not needed (IDEA-103509)
This commit is contained in:
+12
@@ -0,0 +1,12 @@
|
||||
public enum EEnum {
|
||||
FOO(0);
|
||||
private int value;
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
EEnum(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
class Test {
|
||||
public static final int BAR = 2;
|
||||
void foo() {
|
||||
System.out.println(EEnum.FOO.getValue());
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
class Usage {
|
||||
void foo() {
|
||||
EEnum i = EEnum.FOO;
|
||||
}
|
||||
|
||||
void bar(int i ) {
|
||||
i = B;
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
class Test {
|
||||
public static final int FOO = 0;
|
||||
public static final int BAR = 2;
|
||||
void foo() {
|
||||
System.out.println(FOO);
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
class Usage {
|
||||
void foo() {
|
||||
int i = Test.FOO;
|
||||
}
|
||||
|
||||
void bar(int i ) {
|
||||
i = B;
|
||||
}
|
||||
}
|
||||
@@ -59,6 +59,10 @@ public class ExtractEnumTest extends MultiFileTestCase {
|
||||
doTest(new RefactoringTestUtil.MemberDescriptor("FOO", PsiField.class, true));
|
||||
}
|
||||
|
||||
public void testUsageInVariableInitializer() throws Exception {
|
||||
doTest(new RefactoringTestUtil.MemberDescriptor("FOO", PsiField.class, true));
|
||||
}
|
||||
|
||||
public void testForwardReferenceConflict() throws Exception {
|
||||
doTest("Unable to migrate statement to enum constant.", false,
|
||||
new RefactoringTestUtil.MemberDescriptor("FOO", PsiField.class, false),
|
||||
@@ -149,6 +153,7 @@ public class ExtractEnumTest extends MultiFileTestCase {
|
||||
if (member.hasModifierProperty(PsiModifier.STATIC) && member.hasModifierProperty(PsiModifier.FINAL) && ((PsiField)member).hasInitializer()) {
|
||||
if (memberInfo.isToAbstract()) {
|
||||
enumConstants.add(memberInfo);
|
||||
memberInfo.setChecked(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user