FoldExpressionIntoStreamInspection: deparenthesize when testing whether it's too simple case

This commit is contained in:
Tagir Valeev
2018-07-06 10:52:22 +07:00
parent cf64d92692
commit d327e1acdc
2 changed files with 8 additions and 2 deletions

View File

@@ -79,8 +79,8 @@ public class FoldExpressionIntoStreamInspection extends AbstractBaseJavaLocalIns
if (!StreamApiUtil.isSupportedStreamElement(left.getType()) || !ExpressionUtils.isSafelyRecomputableExpression(left)) {
return Collections.emptyList();
}
if (operands[0] instanceof PsiBinaryExpression) {
PsiBinaryExpression binOp = (PsiBinaryExpression)operands[0];
PsiBinaryExpression binOp = tryCast(PsiUtil.skipParenthesizedExprDown(operands[0]), PsiBinaryExpression.class);
if (binOp != null) {
if (ComparisonUtils.isComparison(binOp) &&
(left == binOp.getLOperand() && ExpressionUtils.isSafelyRecomputableExpression(binOp.getROperand())) ||
(left == binOp.getROperand() && ExpressionUtils.isSafelyRecomputableExpression(binOp.getLOperand()))) {

View File

@@ -0,0 +1,6 @@
// "Fold expression into Stream chain" "false"
class Test {
boolean foo(String a, String b, String c, String d) {
return ((a) == (null)) || b == null || c == null || d == <caret>null;
}
}