public CodeBlockTranslation(ITranslation translation)
 {
     NodeType        = translation.NodeType;
     _translation    = translation;
     _startOnNewLine = true;
     _writeBraces    = IsMultiStatement = translation.IsMultiStatement();
     CalculateEstimatedSize();
 }
Example #2
0
 public CodeBlockTranslation(ITranslation translation, ITranslationContext context)
 {
     NodeType            = translation.NodeType;
     _translation        = translation;
     _isEmptyTranslation = translation is IPotentialEmptyTranslatable empty && empty.IsEmpty;
     _context            = context;
     _startOnNewLine     = true;
     _writeBraces        = IsMultiStatement = translation.IsMultiStatement();
     CalculateSizes();
 }
Example #3
0
        public void WriteTo(TranslationWriter writer)
        {
            if (_writeBraces)
            {
                writer.WriteOpeningBraceToTranslation(_startOnNewLine);

                if (WriteEmptyCodeBlock(writer))
                {
                    return;
                }
            }

            if (_indentContents)
            {
                writer.Indent();
            }

            if (_writeBraces && _ensureReturnKeyword && !_translation.IsMultiStatement())
            {
                writer.WriteReturnToTranslation();
            }

            _translation.WriteTo(writer);

            if (EnsureTerminated())
            {
                writer.WriteToTranslation(';');
            }

            if (_writeBraces)
            {
                writer.WriteClosingBraceToTranslation();
            }

            if (_indentContents)
            {
                writer.Unindent();
            }
        }
 protected override bool IsMultiStatement()
 => _targetTranslation.IsMultiStatement() || _valueTranslation.IsMultiStatement();