Java: Improvements in intention to split switch branch with multiple values into separate branches (IDEA-203895)

This commit is contained in:
Pavel Dolgov
2019-02-01 13:11:28 +03:00
parent 7e401bfee5
commit 4c260c88bc
30 changed files with 355 additions and 84 deletions
@@ -1,4 +1,4 @@
// "Split values of 'switch' rule" "true"
// "Split values of 'switch' branch" "true"
class C {
void foo(int n) {
String s = "";
@@ -1,4 +1,4 @@
// "Split values of 'switch' rule" "true"
// "Split values of 'switch' branch" "true"
class C {
void foo(int n) {
String s = "";
@@ -1,4 +1,4 @@
// "Split values of 'switch' rule" "true"
// "Split values of 'switch' branch" "true"
class C {
void foo(int n) {
String s = "";
@@ -0,0 +1,18 @@
// "Split values of 'switch' branch" "true"
class C {
void test(int i) {
switch (i) {
case 1:
System.out.println("hello");
break;
case 2:
System.out.println("hello");
break;
case 3:
System.out.println("hello");
break;
case 4:
System.out.println("bye");
}
}
}
@@ -0,0 +1,13 @@
// "Split values of 'switch' branch" "true"
class C {
void test(int i) {
switch (i) {
case 2:
System.out.println("hello");
break;
<caret>case 1:
System.out.println("hello");
break;
}
}
}
@@ -0,0 +1,17 @@
// "Split values of 'switch' branch" "true"
class C {
void test(int i) {
switch (i) {
// 1
case /*2*/ /*3*/2: // 4
// 5
System.out.println("hello");
break;
case 1:
// 5
System.out.println("hello");
break;
/*6*/
}
}
}
@@ -0,0 +1,13 @@
// "Split values of 'switch' branch" "true"
class C {
void test(int i) {
switch (i) {
case 1:
System.out.println("hello");
break;
<caret>case 2:
System.out.println("hello");
break;
}
}
}
@@ -0,0 +1,13 @@
// "Split values of 'switch' branch" "true"
class C {
void test(int i) {
switch (i) {
case 1:
System.out.println("hello");
break;
case 1 + 1:
System.out.println("hello");
break;
}
}
}
@@ -0,0 +1,23 @@
// "Split values of 'switch' branch" "true"
class C {
void test(int i) {
switch (i) {
// 1
case /*2*/1 /*3*/ /*4*/: //5
// 6
System.out.println("hello");
break;
case 2:
// 6
System.out.println("hello");
break;
case 3:
// 6
System.out.println("hello");
break;
// 7
case 4:
System.out.println("bye");
}
}
}
@@ -1,4 +1,4 @@
// "Split values of 'switch' rule" "true"
// "Split values of 'switch' branch" "true"
class C {
void foo(int n) {
String s = "";
@@ -1,4 +1,4 @@
// "Split values of 'switch' rule" "true"
// "Split values of 'switch' branch" "true"
class C {
void foo(int n) {
String s = switch (n) {
@@ -1,4 +1,4 @@
// "Split values of 'switch' rule" "true"
// "Split values of 'switch' branch" "true"
class C {
void foo(int n) {
String s = "";
@@ -0,0 +1,10 @@
// "Split values of 'switch' branch" "true"
class C {
void foo(int n) {
String s = "";
switch (n) {
case 3 -> s = "x";
case 1 + 1 -> s = "x";
}
}
}
@@ -1,4 +1,4 @@
// "Split values of 'switch' rule" "false"
// "Split values of 'switch' branch" "false"
class C {
void foo(int n) {
String s = "";
@@ -1,4 +1,4 @@
// "Split values of 'switch' rule" "true"
// "Split values of 'switch' branch" "true"
class C {
void foo(int n) {
String s = "";
@@ -1,4 +1,4 @@
// "Split values of 'switch' rule" "true"
// "Split values of 'switch' branch" "true"
class C {
void foo(int n) {
String s = "";
@@ -1,4 +1,4 @@
// "Split values of 'switch' rule" "true"
// "Split values of 'switch' branch" "true"
class C {
void foo(int n) {
String s = "";
@@ -0,0 +1,12 @@
// "Split values of 'switch' branch" "true"
class C {
void test(int i) {
switch (i) {
<caret>case 1, 2, 3:
System.out.println("hello");
break;
case 4:
System.out.println("bye");
}
}
}
@@ -0,0 +1,10 @@
// "Split values of 'switch' branch" "true"
class C {
void test(int i) {
switch (i) {
case 1<caret>, 2:
System.out.println("hello");
break;
}
}
}
@@ -0,0 +1,13 @@
// "Split values of 'switch' branch" "true"
class C {
void test(int i) {
switch (i) {
// 1
case /*2*/1<caret>, /*3*/2: // 4
// 5
System.out.println("hello");
break;
/*6*/
}
}
}
@@ -0,0 +1,10 @@
// "Split values of 'switch' branch" "true"
class C {
void test(int i) {
switch (i) {
case 1, <caret>2:
System.out.println("hello");
break;
}
}
}
@@ -0,0 +1,10 @@
// "Split values of 'switch' branch" "true"
class C {
void test(int i) {
switch (i) {
case 1, 1+1<caret>:
System.out.println("hello");
break;
}
}
}
@@ -0,0 +1,15 @@
// "Split values of 'switch' branch" "true"
class C {
void test(int i) {
switch (i) {
// 1
<caret>case /*2*/1, /*3*/2, /*4*/3: //5
// 6
System.out.println("hello");
break;
// 7
case 4:
System.out.println("bye");
}
}
}
@@ -1,4 +1,4 @@
// "Split values of 'switch' rule" "true"
// "Split values of 'switch' branch" "true"
class C {
void foo(int n) {
String s = "";
@@ -1,4 +1,4 @@
// "Split values of 'switch' rule" "true"
// "Split values of 'switch' branch" "true"
class C {
void foo(int n) {
String s = switch (n) {
@@ -1,4 +1,4 @@
// "Split values of 'switch' rule" "true"
// "Split values of 'switch' branch" "true"
class C {
void foo(int n) {
String s = "";
@@ -0,0 +1,9 @@
// "Split values of 'switch' branch" "true"
class C {
void foo(int n) {
String s = "";
switch (n) {
case <caret>1 + 1, 3 -> s = "x";
}
}
}