public void WriteTo(TranslationBuffer buffer) { _binaryConditionLeftTranslation.WriteInParenthesesIfRequired(buffer); buffer.WriteToTranslation(_binaryConditionOperator.TrimEnd()); buffer.WriteNewLineToTranslation(); buffer.Indent(); _binaryConditionRightTranslation.WriteInParenthesesIfRequired(buffer); buffer.Unindent(); }
public static void WriteOpeningBraceToTranslation(this TranslationBuffer buffer, bool startOnNewLine = true) { if (startOnNewLine && buffer.TranslationQuery(q => !q.TranslationEndsWith('{'))) { buffer.WriteNewLineToTranslation(); } buffer.WriteToTranslation('{'); buffer.WriteNewLineToTranslation(); buffer.Indent(); }
private static void WriteCaseBody(ITranslation bodyTranslation, TranslationBuffer buffer) { buffer.Indent(); bodyTranslation.WriteTo(buffer); if (WriteBreak(bodyTranslation)) { buffer.WriteNewLineToTranslation(); buffer.WriteToTranslation("break;"); } buffer.Unindent(); }
private void WriteMultiLineTernary(TranslationBuffer buffer) { TestTranslation.WriteInParenthesesIfRequired(buffer); buffer.WriteNewLineToTranslation(); buffer.Indent(); buffer.WriteToTranslation("? "); IfTrueTranslation.WriteTo(buffer); buffer.WriteNewLineToTranslation(); buffer.WriteToTranslation(": "); IfFalseTranslation.WriteTo(buffer); buffer.Unindent(); }
public void WriteTo(TranslationBuffer buffer) { _subjectTranslation.WriteInParenthesesIfRequired(buffer); if (_isPartOfMethodCallChain) { buffer.WriteNewLineToTranslation(); buffer.Indent(); } buffer.WriteToTranslation('.'); _methodInvocationTranslatable.WriteTo(buffer); if (_isPartOfMethodCallChain) { buffer.Unindent(); } }
public void WriteTo(TranslationBuffer buffer) { if (_writeBraces) { buffer.WriteOpeningBraceToTranslation(_startOnNewLine); if (WriteEmptyCodeBlock(buffer)) { return; } } if (_indentContents) { buffer.Indent(); } if (_writeBraces && _ensureReturnKeyword && !_translation.IsMultiStatement()) { buffer.WriteToTranslation("return "); } _translation.WriteTo(buffer); if (EnsureTerminated()) { buffer.WriteToTranslation(';'); } if (_writeBraces) { buffer.WriteClosingBraceToTranslation(); } if (_indentContents) { buffer.Unindent(); } }