mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-26 15:27:45 +07:00
extract enum: do not migrate other constants to enum
This commit is contained in:
+19
@@ -0,0 +1,19 @@
|
||||
public class Test {
|
||||
public static final int OK = 0;
|
||||
public static final int ERROR = 1;
|
||||
|
||||
void foo(int status) {
|
||||
switch (status) {
|
||||
case OK:
|
||||
break;
|
||||
case ERROR:
|
||||
break;
|
||||
case Node.WARNING:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
interface Node {
|
||||
int WARNING = 2;
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
public class Test {
|
||||
public static final int OK = 0;
|
||||
public static final int ERROR = 1;
|
||||
|
||||
void foo(int status) {
|
||||
switch (status) {
|
||||
case OK:
|
||||
break;
|
||||
case ERROR:
|
||||
break;
|
||||
case Node.WARNING:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
interface Node {
|
||||
int WARNING = 2;
|
||||
}
|
||||
@@ -60,7 +60,7 @@ public class ExtractEnumTest extends MultiFileTestCase {
|
||||
}
|
||||
|
||||
public void testForwardReferenceConflict() throws Exception {
|
||||
doTest("Enum constant field <b><code>BAR</code></b> would forward reference on field field <b><code>FOO</code></b>", false,
|
||||
doTest("Unable to migrate statement to enum constant.", false,
|
||||
new RefactoringTestUtil.MemberDescriptor("FOO", PsiField.class, false),
|
||||
new RefactoringTestUtil.MemberDescriptor("BAR", PsiField.class, true));
|
||||
}
|
||||
@@ -76,13 +76,19 @@ public class ExtractEnumTest extends MultiFileTestCase {
|
||||
}
|
||||
|
||||
public void testCantChangeMethodParameter() throws Exception {
|
||||
doTest("Failed to migrate", false,
|
||||
doTest("Unable to migrate statement to enum constant.", false,
|
||||
new RefactoringTestUtil.MemberDescriptor("FOO", PsiField.class, true),
|
||||
new RefactoringTestUtil.MemberDescriptor("BAR", PsiField.class, true));
|
||||
}
|
||||
|
||||
public void testDontChangeOtherConstants() throws Exception {
|
||||
doTest("Unable to migrate statement to enum constant. Node.WARNING can not be replaced with enum", false,
|
||||
new RefactoringTestUtil.MemberDescriptor("OK", PsiField.class, true),
|
||||
new RefactoringTestUtil.MemberDescriptor("ERROR", PsiField.class, true));
|
||||
}
|
||||
|
||||
public void testCantChangeMethodParameter1() throws Exception {
|
||||
doTest("Failed to migrate", false,
|
||||
doTest("Unable to migrate statement to enum constant.", false,
|
||||
new RefactoringTestUtil.MemberDescriptor("FOO", PsiField.class, true),
|
||||
new RefactoringTestUtil.MemberDescriptor("BAR", PsiField.class, true));
|
||||
}
|
||||
@@ -115,7 +121,7 @@ public class ExtractEnumTest extends MultiFileTestCase {
|
||||
}
|
||||
|
||||
public void testUnknownSwitchLabel() throws Exception {
|
||||
doTest("Unable to migrate statement to enum constant. 8 can't be replaced with enum", false,
|
||||
doTest("Unable to migrate statement to enum constant. 8 can not be replaced with enum", false,
|
||||
new RefactoringTestUtil.MemberDescriptor("FOO", PsiField.class, true),
|
||||
new RefactoringTestUtil.MemberDescriptor("BAR", PsiField.class, true));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user