mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
Basic support of switch expressions in StatementExtractor/SideEffectChecker
Fixes IDEA-204138 Exception in "statement with empty body" inspection with switch expression Fixes EA-133610 - REWA: StatementExtractor.createNode
This commit is contained in:
+17
@@ -0,0 +1,17 @@
|
||||
// "Extract side effects as an 'if' statement" "true"
|
||||
class Z {
|
||||
|
||||
void z() {
|
||||
if (foo) {
|
||||
switch (0) {
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
break;
|
||||
default:
|
||||
new Foo().getBar();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
// "Extract side effect" "true"
|
||||
class Z {
|
||||
|
||||
void z() {
|
||||
switch (0) {
|
||||
case 0 -> {
|
||||
}
|
||||
case 1 -> {
|
||||
System.out.println("oops");
|
||||
}
|
||||
case 2 -> {
|
||||
System.out.println("bar");
|
||||
if (Math.random() > 0.5) {
|
||||
new Foo().getBar();
|
||||
}
|
||||
}
|
||||
case 3 -> {
|
||||
if (Math.random() > 0.5) {
|
||||
} else {
|
||||
}
|
||||
}
|
||||
case 4 -> {
|
||||
if (Math.random() > 0.5) break;
|
||||
System.out.println("four");
|
||||
}
|
||||
default -> new Foo();
|
||||
}
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// "Extract side effects as an 'if' statement" "true"
|
||||
class Z {
|
||||
|
||||
void z() {
|
||||
i<caret>f (foo ? switch(0) {
|
||||
case 0: break false;
|
||||
case 1: break true;
|
||||
default: break new Foo().getBar();
|
||||
} : switch(0) {
|
||||
case 0: break false;
|
||||
case 1: break true;
|
||||
default: break false;}) {}
|
||||
}
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
// "Extract side effect" "true"
|
||||
class Z {
|
||||
|
||||
void z() {
|
||||
i<caret>f (switch(0) {
|
||||
case 0 -> false;
|
||||
case 1 -> {
|
||||
System.out.println("oops");
|
||||
break true;
|
||||
}
|
||||
case 2 -> {
|
||||
System.out.println("bar");
|
||||
break Math.random() > 0.5 && new Foo().getBar();
|
||||
}
|
||||
case 3 -> {
|
||||
if(Math.random() > 0.5) break true;
|
||||
else break false;
|
||||
}
|
||||
case 4 -> {
|
||||
if(Math.random() > 0.5) break true;
|
||||
System.out.println("four");
|
||||
break false;
|
||||
}
|
||||
default -> "foo"+(new Foo());
|
||||
}) {}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user