Support of enhanced Java 12 switch statements in DFA (IDEA-202132, no expressions yet)

This commit is contained in:
Tagir Valeev
2018-11-16 12:06:16 +07:00
parent 0e852a203d
commit 6bc07438c6
20 changed files with 285 additions and 58 deletions
@@ -0,0 +1,11 @@
// "Remove switch label '0-/*x*/1'" "true"
class Main {
static void fff(int x) {
if (x > 0) {
switch (x) {
case 1, 3 /*x*/: System.out.println("one"); //1
case 2: System.out.println("two"); //2
}
}
}
}
@@ -0,0 +1,12 @@
// "Remove switch branch '-/*x*/1'" "true"
class Main {
static void fff(int x) {
if (x > 0) {
switch (x) {
case 2 -> System.out.println("two"); //2
//1
/*x*/
}
}
}
}
@@ -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
System.out.println("six"); //6
System.out.println("seven"); //7
//other
}
}
public static void main(String[] args) {
fff();
}
}
@@ -0,0 +1,11 @@
// "Remove switch label '0-/*x*/1'" "true"
class Main {
static void fff(int x) {
if (x > 0) {
switch (x) {
case 1, 3, 0-<caret>/*x*/1: System.out.println("one"); //1
case 2: System.out.println("two"); //2
}
}
}
}
@@ -0,0 +1,11 @@
// "Remove switch branch '-/*x*/1'" "true"
class Main {
static void fff(int x) {
if (x > 0) {
switch (x) {
case 2 -> System.out.println("two"); //2
case -<caret>/*x*/1 -> System.out.println("one"); //1
}
}
}
}
@@ -3,7 +3,7 @@ class Main {
void t() {
int i = 5;
switch(i) {
c<caret>ase 1: case 3: // Apply 'Fix all problems in the file'
case <caret>1: case 3: // Apply 'Fix all problems in the file'
System.out.println("odd");
break;
}
@@ -0,0 +1,22 @@
// "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
break;
default: System.out.println("and more"); //other
}
}
}
public static void main(String[] args) {
fff();
}
}