mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
OptionalToIfInspection: added inspection to desugar optional chain to sequence of if statements (IDEA-212269)
GitOrigin-RevId: c83b70e05544529b3dfffe24bc87997910edcb56
This commit is contained in:
committed by
intellij-monorepo-bot
parent
987f5c84d3
commit
6f1efb8fc0
+24
@@ -0,0 +1,24 @@
|
||||
// "Fix all 'Optional can be replaced with sequence of if statements' problems in file" "true"
|
||||
|
||||
class Test {
|
||||
|
||||
void assignment(String in) {
|
||||
String out = "foo";
|
||||
if (in != null && in.length() > 2) out = in;
|
||||
}
|
||||
|
||||
|
||||
void assignmentWithSideEffect(String in) {
|
||||
String result = null;
|
||||
if (in != null && in.length() > 2) result = in;
|
||||
if (result == null) result = sideEffect();
|
||||
String out = result;
|
||||
}
|
||||
|
||||
private String sideEffect() {
|
||||
System.out.println("side effect");
|
||||
return "foo";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user