mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 07:40:42 +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
+34
@@ -0,0 +1,34 @@
|
||||
// "Fix all 'Optional can be replaced with sequence of if statements' problems in file" "true"
|
||||
|
||||
class Test {
|
||||
|
||||
String reusesVariable(String in) {
|
||||
String s1 = null;
|
||||
if (in == null) throw new NullPointerException();
|
||||
String s = toName(in);
|
||||
if (s != null) s1 = s;
|
||||
if (s1 == null) {
|
||||
String value = toDefaultName();
|
||||
s1 = value;
|
||||
}
|
||||
return s1;
|
||||
}
|
||||
|
||||
String removesRedundantAssignment(String in) {
|
||||
String s1 = null;
|
||||
String s = null;
|
||||
if (in == null) throw new NullPointerException();
|
||||
s = in;
|
||||
return s;
|
||||
}
|
||||
|
||||
private String toName(String str) {
|
||||
if (str.startsWith("name")) return str.substring(4);
|
||||
return null;
|
||||
}
|
||||
|
||||
private String toDefaultName() {
|
||||
return "defaultName";
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user