public override void VisitLambdaExpression(LambdaExpression lambdaExpression)
            {
                base.VisitLambdaExpression(lambdaExpression);
                BlockStatement block;
                Expression     expr;

                if (!ConvertLambdaBodyStatementToExpressionAction.TryGetConvertableExpression(lambdaExpression.Body, out block, out expr))
                {
                    return;
                }
                var node = block.Statements.FirstOrDefault() ?? block;
                var expressionStatement = node as ExpressionStatement;

                if (expressionStatement != null)
                {
                    if (expressionStatement.Expression is AssignmentExpression)
                    {
                        return;
                    }
                }
                var returnTypes = new List <IType>();

                foreach (var type in TypeGuessing.GetValidTypes(ctx.Resolver, lambdaExpression))
                {
                    if (type.Kind != TypeKind.Delegate)
                    {
                        continue;
                    }
                    var invoke = type.GetDelegateInvokeMethod();
                    if (!returnTypes.Contains(invoke.ReturnType))
                    {
                        returnTypes.Add(invoke.ReturnType);
                    }
                }
                if (returnTypes.Count > 1)
                {
                    return;
                }
                // can't convert return statements without expression.
                var returnExpr = node as ReturnStatement;

                if (returnExpr != null && returnExpr.Expression.IsNull)
                {
                    return;
                }

                AddIssue(new CodeIssue(
                             node,
                             ctx.TranslateString("Can be converted to expression"),
                             ConvertLambdaBodyStatementToExpressionAction.CreateAction(ctx, node, block, expr)
                             ));
            }
            public override void VisitAnonymousMethodExpression(AnonymousMethodExpression anonymousMethodExpression)
            {
                base.VisitAnonymousMethodExpression(anonymousMethodExpression);
                if (!anonymousMethodExpression.HasParameterList)
                {
                    return;
                }
                BlockStatement block;
                Expression     expr;

                if (!ConvertLambdaBodyStatementToExpressionAction.TryGetConvertableExpression(anonymousMethodExpression.Body, out block, out expr))
                {
                    return;
                }
                var node        = block.Statements.FirstOrDefault() ?? block;
                var returnTypes = new List <IType>();

                foreach (var type in TypeGuessing.GetValidTypes(ctx.Resolver, anonymousMethodExpression))
                {
                    if (type.Kind != TypeKind.Delegate)
                    {
                        continue;
                    }
                    var invoke = type.GetDelegateInvokeMethod();
                    if (!returnTypes.Contains(invoke.ReturnType))
                    {
                        returnTypes.Add(invoke.ReturnType);
                    }
                }
                if (returnTypes.Count > 1)
                {
                    return;
                }

                AddIssue(new CodeIssue(
                             node,
                             ctx.TranslateString("Can be converted to expression"),
                             ctx.TranslateString("Convert to lambda expression"),
                             script => {
                    var lambdaExpression = new LambdaExpression();
                    foreach (var parameter in anonymousMethodExpression.Parameters)
                    {
                        lambdaExpression.Parameters.Add(parameter.Clone());
                    }
                    lambdaExpression.Body = expr.Clone();
                    script.Replace(anonymousMethodExpression, lambdaExpression);
                }
                             ));
            }
            public override void VisitLambdaExpression(LambdaExpression lambdaExpression)
            {
                base.VisitLambdaExpression(lambdaExpression);
                BlockStatement block;
                Expression     expr;

                if (!ConvertLambdaBodyStatementToExpressionAction.TryGetConvertableExpression(lambdaExpression, out block, out expr))
                {
                    return;
                }
                var node = block.Statements.FirstOrDefault() ?? block;

                AddIssue(
                    node,
                    ctx.TranslateString("Can be converted to expression"),
                    ConvertLambdaBodyStatementToExpressionAction.CreateAction(ctx, node, block, expr)
                    );
            }