Source:
<code>public Result apply(ProjectNode parent, Captures captures, Context context) { ProjectNode child = captures.get(CHILD); Sets.SetView<VariableReferenceExpression> targets = extractInliningTargets(parent, child, context); if (targets.isEmpty()) { return Result.empty(); } Assignments assignments = child.getAssignments().filter(targets::contains); Map<VariableReferenceExpression, RowExpression> parentAssignments = parent.getAssignments() .entrySet().stream() .collect(Collectors.toMap( Map.Entry::getKey, entry -> inlineReferences(entry.getValue(), assignments, context.getVariableAllocator().getTypes()))); boolean allTranslated = child.getAssignments().entrySet() .stream() .map(Map.Entry::getValue) .noneMatch(OriginalExpressionUtils::isExpression); Set<VariableReferenceExpression> inputs = child.getAssignments() .entrySet().stream() .filter(entry -> targets.contains(entry.getKey())) .map(Map.Entry::getValue) .flatMap(entry -> isExpression(entry) ? VariablesExtractor.extractAll(castToExpression(entry), context.getVariableAllocator().getTypes()).stream() <START> : VariablesExtractor.extractAll(entry).stream()) <END> .collect(toSet()); Builder childAssignments = Assignments.builder(); for (Map.Entry<VariableReferenceExpression, RowExpression> assignment : child.getAssignments().entrySet()) { if (!targets.contains(assignment.getKey())) { childAssignments.put(assignment); } } for (VariableReferenceExpression input : inputs) { if (allTranslated) { childAssignments.put(input, input); } else { childAssignments.put(identityAsSymbolReference(input)); } } return Result.ofPlanNode( new ProjectNode( parent.getId(), new ProjectNode( child.getId(), child.getSource(), childAssignments.build()), Assignments.copyOf(parentAssignments))); }</code><technical_language>if/else if ?/: is long for a line</technical_language>

Target:
public Result apply(ProjectNode parent, Captures captures, Context context) { ProjectNode child = captures.get(CHILD); Sets.SetView<VariableReferenceExpression> targets = extractInliningTargets(parent, child, context); if (targets.isEmpty()) { return Result.empty(); } Assignments assignments = child.getAssignments().filter(targets::contains); Map<VariableReferenceExpression, RowExpression> parentAssignments = parent.getAssignments() .entrySet().stream() .collect(Collectors.toMap( Map.Entry::getKey, entry -> inlineReferences(entry.getValue(), assignments, context.getVariableAllocator().getTypes()))); Set<VariableReferenceExpression> inputs = child.getAssignments() .entrySet().stream() .filter(entry -> targets.contains(entry.getKey())) .map(Map.Entry::getValue) .flatMap(expression -> extractInputs(expression, context.getVariableAllocator().getTypes()).stream()) .collect(toSet()); Builder childAssignments = Assignments.builder(); for (Map.Entry<VariableReferenceExpression, RowExpression> assignment : child.getAssignments().entrySet()) { if (!targets.contains(assignment.getKey())) { childAssignments.put(assignment); } } boolean allTranslated = child.getAssignments().entrySet() .stream() .map(Map.Entry::getValue) .noneMatch(OriginalExpressionUtils::isExpression); for (VariableReferenceExpression input : inputs) { if (allTranslated) { childAssignments.put(input, input); } else { childAssignments.put(identityAsSymbolReference(input)); } } return Result.ofPlanNode( new ProjectNode( parent.getId(), new ProjectNode( child.getId(), child.getSource(), childAssignments.build()), Assignments.copyOf(parentAssignments))); }