mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-26 03:13:40 +07:00
OptionalIsPresentInspection: simplify isRaw() and isOptionalLambdaCandidate(); fix getComments(); add more tests (IDEA-CR-13980)
This commit is contained in:
+3
-1
@@ -5,7 +5,9 @@ import java.util.*;
|
||||
public class Main {
|
||||
public void testOptional(Optional<String> str) {
|
||||
String val;
|
||||
val = str.map(String::trim).orElse("");
|
||||
val = str.map( // line comment
|
||||
// another line comment
|
||||
/* block comment *//*block comment*/String::trim).orElse("");
|
||||
System.out.println(val);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -12,6 +12,6 @@ public class Main {
|
||||
|
||||
public Number testOptionalComments(Optional<MyList> strList) {
|
||||
/* optional is present *//* optional is absent */
|
||||
return strList.map(/*return something */myList -> myList.size() > /*too big*/ 1 ? myList.get(1) : 1.0).orElse(/* return null*/null);
|
||||
return strList.map( /*return something */ myList -> myList.size() > /*too big*/ 1 ? myList.get(1) : 1.0).orElse( /* return null*/ null);
|
||||
}
|
||||
}
|
||||
+3
-1
@@ -6,7 +6,9 @@ public class Main {
|
||||
public void testOptional(Optional<String> str) {
|
||||
String val;
|
||||
if (str.isPrese<caret>nt()) {
|
||||
val = str.get().trim();
|
||||
val = // line comment
|
||||
// another line comment
|
||||
str.get().trim() /* block comment *//*block comment*/;
|
||||
} else {
|
||||
val = "";
|
||||
}
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// "Replace Optional.isPresent() condition with map().orElse()" "false"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
public String testOptional(Optional<String> str) {
|
||||
int i = 5;
|
||||
if (Math.random() > 0.5) i = 6;
|
||||
if (str.isPre<caret>sent()) {
|
||||
return str.get().substring(i);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user