mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
IDEA-203119 Unwrap switch statement: support rule-cases and multiple expression cases
This commit is contained in:
+25
@@ -0,0 +1,25 @@
|
||||
// "Unwrap 'switch' statement" "true"
|
||||
class Main {
|
||||
static void fff(int x) {
|
||||
if (x == 5) {
|
||||
switch (x) {
|
||||
//1
|
||||
//2
|
||||
//3
|
||||
//4
|
||||
case 5:
|
||||
if (Math.random() > 0.5) break;
|
||||
System.out.println("five-ten-fifteen"); //5
|
||||
System.out.println("six"); //6
|
||||
System.out.println("seven"); //7
|
||||
break;
|
||||
//other
|
||||
}
|
||||
System.out.println("oops");
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
fff();
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
// "Unwrap 'switch' statement" "true"
|
||||
class Main {
|
||||
static void fff(int x) {
|
||||
if (x == 5) {
|
||||
int i = 5;
|
||||
//1
|
||||
//2
|
||||
//3
|
||||
//4
|
||||
//6
|
||||
//7
|
||||
//other
|
||||
{
|
||||
if (Math.random() > 0.5) return;
|
||||
int i = 6;
|
||||
System.out.println("five-ten-fifteen"); //5
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
fff();
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// "Unwrap 'switch' statement" "true"
|
||||
class Main {
|
||||
static void fff(int x) {
|
||||
if (x == 5) {
|
||||
//1
|
||||
//2
|
||||
//3
|
||||
//4
|
||||
System.out.println("five-ten-fifteen"); //5
|
||||
//6
|
||||
//7
|
||||
//other
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
fff();
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
// "Unwrap 'switch' statement" "true"
|
||||
class Main {
|
||||
static void fff(int x) {
|
||||
if (x == 5) {
|
||||
//1
|
||||
//2
|
||||
//3
|
||||
//4
|
||||
//6
|
||||
//7
|
||||
//other
|
||||
if (Math.random() > 0.5) return;
|
||||
System.out.println("five-ten-fifteen"); //5
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
fff();
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// "Unwrap 'switch' statement" "true"
|
||||
class Main {
|
||||
static void fff(int x) {
|
||||
if (x == 5) {
|
||||
switch (x) {
|
||||
case 1: System.out.println("one"); //1
|
||||
case 2: System.out.println("two"); //2
|
||||
case 3: System.out.println("three"); //3
|
||||
case 4: System.out.println("four"); //4
|
||||
case 0:case <caret>5:case 10:
|
||||
if (Math.random() > 0.5) break;
|
||||
System.out.println("five-ten-fifteen"); //5
|
||||
case 6: System.out.println("six"); //6
|
||||
case 7: System.out.println("seven"); //7
|
||||
break;
|
||||
default: System.out.println("and more"); //other
|
||||
}
|
||||
System.out.println("oops");
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
fff();
|
||||
}
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
// "Unwrap 'switch' statement" "true"
|
||||
class Main {
|
||||
static void fff(int x) {
|
||||
if (x == 5) {
|
||||
int i = 5;
|
||||
switch (x) {
|
||||
case 1 -> System.out.println("one"); //1
|
||||
case 2 -> System.out.println("two"); //2
|
||||
case 3 -> System.out.println("three"); //3
|
||||
case 4 -> System.out.println("four"); //4
|
||||
case 0, <caret>5, 10 -> {
|
||||
if (Math.random() > 0.5) break;
|
||||
int i = 6;
|
||||
System.out.println("five-ten-fifteen"); //5
|
||||
}
|
||||
case 6 -> System.out.println("six"); //6
|
||||
case 7 -> System.out.println("seven"); //7
|
||||
default -> System.out.println("and more"); //other
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
fff();
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
// "Unwrap 'switch' statement" "true"
|
||||
class Main {
|
||||
static void fff(int x) {
|
||||
if (x == 5) {
|
||||
switch (x) {
|
||||
case 1 -> System.out.println("one"); //1
|
||||
case 2 -> System.out.println("two"); //2
|
||||
case 3 -> System.out.println("three"); //3
|
||||
case 4 -> System.out.println("four"); //4
|
||||
case 0, <caret>5, 10 -> System.out.println("five-ten-fifteen"); //5
|
||||
case 6 -> System.out.println("six"); //6
|
||||
case 7 -> System.out.println("seven"); //7
|
||||
default -> System.out.println("and more"); //other
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
fff();
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
// "Unwrap 'switch' statement" "true"
|
||||
class Main {
|
||||
static void fff(int x) {
|
||||
if (x == 5) {
|
||||
switch (x) {
|
||||
case 1 -> System.out.println("one"); //1
|
||||
case 2 -> System.out.println("two"); //2
|
||||
case 3 -> System.out.println("three"); //3
|
||||
case 4 -> System.out.println("four"); //4
|
||||
case 0, <caret>5, 10 -> {
|
||||
if (Math.random() > 0.5) break;
|
||||
System.out.println("five-ten-fifteen"); //5
|
||||
}
|
||||
case 6 -> System.out.println("six"); //6
|
||||
case 7 -> System.out.println("seven"); //7
|
||||
default -> System.out.println("and more"); //other
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
fff();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user