EnhancedSwitchBackwardMigration: generate multiple case labels: IDEA-205529

This commit is contained in:
Roman.Ivanov
2019-02-11 10:26:46 +07:00
parent f6207ec11a
commit edb5e0f4ba
10 changed files with 63 additions and 15 deletions
@@ -0,0 +1,13 @@
// "Replace with old style 'switch' statement" "true"
import java.util.*;
class SwitchExpressionMigration {
int foo(int n) {
switch (n) {
case :
return 12;
default:
return 0;
}
}
}
@@ -11,7 +11,8 @@ class SwitchExpressionMigration {
return 1;
case 2:
return 2;
case 3, 4:
case 3:
case 4:
System.out.println("asda");
return 3;
default:
@@ -14,7 +14,8 @@ class SwitchExpressionMigration {
/*16*/
case 2:
return 2 +/*17*/ 2;
case 3, 4:
case 3 /*in1*/ + 1:
case 4 /*in2*/ + 33:
System.out.println("asda");
return 3;
/*19*/
@@ -4,7 +4,8 @@ import java.util.*;
public class Main {
void foo(E e) {
switch (e) {
case E1, E2:
case E1:
case E2:
System.out.println("oops");
break;
default:
@@ -4,7 +4,8 @@ import java.util.*;
public class Main {
void foo(E e) {
switch (e) {
case E1, E2:
case E1:
case E2:
System.out.println("oops");
break;
default:
@@ -16,7 +16,8 @@ class SwitchExpressionMigration {
case 2:
x = 2;
break;
case 3, 4:
case 3:
case 4:
System.out.println("asda");
x = 3;
break;
@@ -20,7 +20,8 @@ class SwitchExpressionMigration {
case 2:
x = 2;
break;
case 3, 4:
case 3:
case 4:
System.out.println("asda");
x = 3;
break;
@@ -0,0 +1,11 @@
// "Replace with old style 'switch' statement" "true"
import java.util.*;
class SwitchExpressionMigration {
int foo(int n) {
return switch<caret> (n) {
case -> 12;
default -> 0;
};
}
}
@@ -10,7 +10,7 @@ class SwitchExpressionMigration {
break 1;
}
case/*15*/ 2 -> /*16*/2 +/*17*/ 2;
case 3, 4 -> {
case 3 /*in1*/ + 1, 4 /*in2*/+ 33 -> {
System.out.println("asda");
break 3;
}