mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-05-06 05:10:22 +07:00
Test and comment for IDEA-176340 "Optional.isPresent not highlighted"
Actually was fixed in 0234c70
This commit is contained in:
@@ -194,6 +194,8 @@ public class OptionalIsPresentInspection extends BaseJavaBatchLocalInspectionToo
|
||||
if (!hasOptionalReference.get() || !(lambdaCandidate instanceof PsiExpression)) return ProblemType.INFO;
|
||||
PsiExpression expression = (PsiExpression)lambdaCandidate;
|
||||
if (falseExpression != null && NullnessUtil.getExpressionNullness(expression) != Nullness.NOT_NULL) {
|
||||
// falseExpression == null is "consumer" case (to be replaced with ifPresent()),
|
||||
// in this case we don't care about expression nullness
|
||||
return ProblemType.INFO;
|
||||
}
|
||||
return ProblemType.WARNING;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace Optional.isPresent() condition with functional style expression" "true"
|
||||
// "Replace Optional.isPresent() condition with functional style expression" "GENERIC_ERROR_OR_WARNING"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -6,6 +6,6 @@ public class Main {
|
||||
String myString;
|
||||
|
||||
public void testOptional(Optional<String> str) {
|
||||
str.ifPresent(s -> myString = s);
|
||||
str.ifPresent(s -> myString = s.isEmpty() ? null : s);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace Optional.isPresent() condition with functional style expression" "true"
|
||||
// "Replace Optional.isPresent() condition with functional style expression" "GENERIC_ERROR_OR_WARNING"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -7,7 +7,7 @@ public class Main {
|
||||
|
||||
public void testOptional(Optional<String> str) {
|
||||
if (str.isPrese<caret>nt()) {
|
||||
myString = str.get();
|
||||
myString = str.get().isEmpty() ? null : str.get();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user