mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-05-06 05:10:22 +07:00
IDEA-163767: fixed for assignment, tests for assignment and ternary
This commit is contained in:
@@ -321,7 +321,7 @@ public class OptionalIsPresentInspection extends BaseJavaBatchLocalInspectionToo
|
||||
falseAssignment == null ||
|
||||
!EquivalenceChecker.getCanonicalPsiEquivalence()
|
||||
.expressionsAreEquivalent(trueAssignment.getLExpression(), falseAssignment.getLExpression()) ||
|
||||
!isOptionalLambdaCandidate(optionalVariable, trueAssignment.getRExpression(), falseAssignment.getLExpression())) {
|
||||
!isOptionalLambdaCandidate(optionalVariable, trueAssignment.getRExpression(), falseAssignment.getRExpression())) {
|
||||
return false;
|
||||
}
|
||||
return ExpressionUtils.isSimpleExpression(falseAssignment.getRExpression()) ||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
// "Replace Optional.isPresent() condition with functional style expression" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main<T> {
|
||||
Optional<Object> foo(Optional<Object> first) {
|
||||
Optional<Object> o;
|
||||
o = first;
|
||||
return o;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// "Replace Optional.isPresent() condition with functional style expression" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main<T> {
|
||||
Optional<Object> foo(Optional<Object> first) {
|
||||
Optional<Object> o = first;
|
||||
return o;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// "Replace Optional.isPresent() condition with functional style expression" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main<T> {
|
||||
Optional<Object> foo(Optional<Object> first) {
|
||||
Optional<Object> o;
|
||||
if (first.isPrese<caret>nt())
|
||||
o = first;
|
||||
else
|
||||
o = Optional.empty();
|
||||
return o;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// "Replace Optional.isPresent() condition with functional style expression" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main<T> {
|
||||
Optional<Object> foo(Optional<Object> first) {
|
||||
Optional<Object> o = !first.isPrese<caret>nt() ? Optional.empty() : first;
|
||||
return o;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user