PsiExpression (Java8MigrationUtils.MapCheckCondition condition, PsiStatement statement) { PsiAssignmentExpression assignment; PsiExpression putValue = extractPutValue(condition, statement); if (putValue != null) { // like map.put(key, val = new ArrayList<>()); assignment = ExpressionUtils.getAssignment(putValue); } else { if (!(statement instanceof PsiBlockStatement)) return null; // like val = new ArrayList<>(); map.put(key, val); PsiStatement[] statements = ((PsiBlockStatement)statement).getCodeBlock().getStatements(); if (statements.length != 2) return null; putValue = extractPutValue(condition, statements[1]); if (!condition.isValueReference(putValue)) return null; assignment = ExpressionUtils.getAssignment(statements[0]); } if (assignment == null) return null; PsiExpression lambdaCandidate = assignment.getRExpression(); if (lambdaCandidate == null || !condition.isValueReference(assignment.getLExpression())) return null; if (!LambdaGenerationUtil.canBeUncheckedLambda(lambdaCandidate)) return null; return lambdaCandidate; }