ConditionalExpression (ConditionalExpression.Optional condition, boolean unwrapLazilyEvaluated) { if (myChainExpression instanceof PsiExpression) { PsiMethodCallExpression call = ExpressionUtils.getCallForQualifier((PsiExpression)myChainExpression); if (call != null && !(call.getParent() instanceof PsiExpressionStatement)) { String name = call.getMethodExpression().getReferenceName(); PsiExpression[] args = call.getArgumentList().getExpressions(); if (args.length == 0 && "isPresent".equals(name)) { myChainExpression = call; return new ConditionalExpression.Boolean(condition.getCondition(), false); } if (args.length == 1) { String absentExpression = null; if ("orElse".equals(name)) { absentExpression = args[0].getText(); } else if (unwrapLazilyEvaluated && "orElseGet".equals(name)) { FunctionHelper helper = FunctionHelper.create(args[0], 0); if (helper != null) { helper.transform(this); absentExpression = helper.getText(); } } if (absentExpression != null) { myChainExpression = call; return condition.unwrap(absentExpression); } } } } return condition; }