public static Expression rewrite(Expression expression, VariableAllocator variableAllocator)
    {
        return ExpressionTreeRewriter.rewriteWith(new Visitor(variableAllocator), expression, new Context());
    }
@Test
    public void testRewriteBasicLambda()
    {
        final List<VariableReferenceExpression> variables = ImmutableList.of(new VariableReferenceExpression(Optional.empty(), "a", BIGINT), new VariableReferenceExpression(Optional.empty(), "x", BIGINT));
        final VariableAllocator allocator = new VariableAllocator(variables);

        assertEquals(rewrite(expression("x -> a + x"), allocator),
                new BindExpression(
                        ImmutableList.of(expression("a")),
                        new LambdaExpression(
                                Stream.of("a_0", "x")
                                        .map(Identifier::new)
                                        .map(LambdaArgumentDeclaration::new)
                                        .collect(toList()),
                                expression("a_0 + x"))));
    }