Context (@NotNull Project project, @NotNull PsiMethodCallExpression call) { PsiExpression orElseArgument = getOrElseArgument(call, myType); if (!ExpressionUtils.isNullLiteral(orElseArgument)) return null; PsiLocalVariable returnVar = tryCast(PsiUtil.skipParenthesizedExprUp(call.getParent()), PsiLocalVariable.class); if (returnVar == null) return null; PsiStatement statement = PsiTreeUtil.getParentOfType(returnVar, PsiStatement.class, true); if (statement == null) return null; PsiStatement nextStatement = tryCast(PsiTreeUtil.skipWhitespacesForward(returnVar.getParent()), PsiStatement.class); if (nextStatement == null) return null; PsiExpression lambdaExpr = extractMappingExpression(nextStatement, returnVar); if (!LambdaGenerationUtil.canBeUncheckedLambda(lambdaExpr)) return null; if (!ReferencesSearch.search(returnVar).allMatch(reference -> PsiTreeUtil.isAncestor(statement, reference.getElement(), false) || PsiTreeUtil.isAncestor(nextStatement, reference.getElement(), false))) { return null; } return new Context(lambdaExpr, nextStatement, statement, returnVar, call); }