protected static ITranslation GetCodeBlockTranslation(ITranslation translation, bool withReturnKeyword) { var codeBlockTranslation = new CodeBlockTranslation(translation) .WithTermination() .WithBraces(); if (withReturnKeyword) { codeBlockTranslation = codeBlockTranslation.WithReturnKeyword(); } return(codeBlockTranslation); }
public CatchBlockTranslation(CatchBlock catchBlock, ITranslationContext context) { _catchBodyTranslation = GetBlockTranslation(catchBlock.Body, context); _exceptionClause = GetExceptionClauseOrNullFor(catchBlock, context); if ((_catchBodyTranslation.NodeType != ExpressionType.Throw) && catchBlock.Body.IsReturnable()) { _catchBodyTranslation.WithReturnKeyword(); } EstimatedSize = _catchBodyTranslation.EstimatedSize; if (_exceptionClause != null) { EstimatedSize += _exceptionClause.EstimatedSize; } }
public CatchBlockTranslation(CatchBlock catchBlock, ITranslationContext context) { _catchBodyTranslation = GetBlockTranslation(catchBlock.Body, context); _exceptionClause = GetExceptionClauseOrNullFor(catchBlock, context); if ((_catchBodyTranslation.NodeType != ExpressionType.Throw) && catchBlock.Body.IsReturnable()) { _catchBodyTranslation.WithReturnKeyword(); } var keywordFormattingSize = context.GetKeywordFormattingSize(); TranslationSize = _catchBodyTranslation.TranslationSize; FormattingSize = keywordFormattingSize + _catchBodyTranslation.FormattingSize; if (_exceptionClause != null) { TranslationSize += _exceptionClause.TranslationSize; FormattingSize += keywordFormattingSize + _exceptionClause.FormattingSize; } }