public CodeBlockTranslation(ITranslation translation) { NodeType = translation.NodeType; _translation = translation; _startOnNewLine = true; _writeBraces = IsMultiStatement = translation.IsMultiStatement(); CalculateEstimatedSize(); }
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(); }
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();