private static bool DoNotAddReturnStatement(BlockExpression block, ICollection <string> lines)
 {
     return((lines.Count <= 1) || !block.IsReturnable());
 }
        private IList <BlockStatementTranslation> GetBlockStatements(
            BlockExpression block,
            ITranslationContext context,
            out bool hasMultiStatementStatement,
            out int statementTranslationsSize,
            out int statementsFormattingSize,
            out bool hasGoto,
            out bool isEmpty)
        {
            var expressions     = block.Expressions;
            var expressionCount = expressions.Count;
            var translations    = new BlockStatementTranslation[expressionCount];
            var statementIndex  = 0;

            hasMultiStatementStatement = false;
            statementTranslationsSize  = 0;
            statementsFormattingSize   = 0;
            hasGoto = false;

            for (int i = 0, lastExpressionIndex = expressionCount - 1; ; ++i)
            {
                var isFinalStatement = i == lastExpressionIndex;
                var expression       = expressions[i];

                if (Include(expression, block, context))
                {
                    var statementTranslation = context.IsJoinedAssignment(expression)
                        ? new BlockAssignmentStatementTranslation((BinaryExpression)expression, context)
                        : new BlockStatementTranslation(expression, context);

                    translations[statementIndex] = statementTranslation;
                    statementTranslationsSize   += statementTranslation.TranslationSize;
                    statementsFormattingSize    += statementTranslation.FormattingSize;
                    hasMultiStatementStatement   = hasMultiStatementStatement || statementTranslation.IsMultiStatement;

                    ++statementIndex;

                    if (statementIndex == 1)
                    {
                        statementTranslation.IsFirstStatement();
                    }

                    if (isFinalStatement)
                    {
                        var isReturnable = block.IsReturnable();

                        if (isReturnable)
                        {
                            ConfigureFinalStatementReturn(statementTranslation, statementIndex, ref hasGoto);
                        }

                        var addBlankLineBefore =
                            isReturnable && AddBlankLineBeforeFinalStatement(statementIndex, translations);

                        statementTranslation.IsFinalStatement(addBlankLineBefore);
                        break;
                    }

                    continue;
                }

                if (isFinalStatement)
                {
                    break;
                }
            }

            if (statementIndex == 0)
            {
                isEmpty = true;
                return(Enumerable <BlockStatementTranslation> .EmptyArray);
            }

            isEmpty = false;

            if (statementIndex == expressionCount)
            {
                return(translations);
            }

            // Statements were skipped; resize the translations array
            var includedTranslations = new BlockStatementTranslation[statementIndex];

            for (var i = 0; i < statementIndex; ++i)
            {
                includedTranslations[i] = translations[i];
            }

            return(includedTranslations);
        }