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