Exemplo n.º 1
0
        public void WriteTo(TranslationBuffer buffer)
        {
            if (_hasVariables)
            {
                foreach (var parametersByType in _variables)
                {
                    parametersByType.Key.WriteTo(buffer);
                    buffer.WriteSpaceToTranslation();
                    parametersByType.Value.WriteTo(buffer);
                    buffer.WriteToTranslation(';');
                    buffer.WriteNewLineToTranslation();
                }

                switch (_statements[0].NodeType)
                {
                case Conditional when !ConditionalTranslation.IsTernary(_statements[0].Expression):
                case Switch:
                    buffer.WriteNewLineToTranslation();
                    break;
                }
            }

            for (var i = 0; ;)
            {
                _statements[i].WriteTo(buffer);

                if (++i == _statementCount)
                {
                    break;
                }

                buffer.WriteNewLineToTranslation();
            }
        }
 public override void WriteTo(TranslationBuffer buffer)
 {
     WriteIfStatement(buffer);
     buffer.WriteNewLineToTranslation();
     buffer.WriteNewLineToTranslation();
     IfFalseTranslation.WriteTo(buffer);
 }
        public void WriteTo(TranslationBuffer buffer)
        {
            buffer.WriteToTranslation("try");
            _bodyTranslation.WriteTo(buffer);

            for (int i = 0, l = _catchBlockTranslations.Count; i < l; ++i)
            {
                buffer.WriteNewLineToTranslation();
                _catchBlockTranslations[i].WriteTo(buffer);
            }

            if (_hasFault)
            {
                buffer.WriteNewLineToTranslation();
                buffer.WriteToTranslation("fault");
                _faultTranslation.WriteTo(buffer);
            }

            if (_hasFinally)
            {
                buffer.WriteNewLineToTranslation();
                buffer.WriteToTranslation("finally");
                _finallyTranslation.WriteTo(buffer);
            }
        }
        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 void WriteDefaultIfPresent(TranslationBuffer buffer)
        {
            if (_defaultCaseTranslation == null)
            {
                return;
            }

            buffer.WriteNewLineToTranslation();
            buffer.WriteNewLineToTranslation();
            buffer.WriteToTranslation("default:");
            buffer.WriteNewLineToTranslation();

            WriteCaseBody(_defaultCaseTranslation, buffer);
        }
            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();
            }
Exemplo n.º 7
0
 public void WriteTo(TranslationBuffer buffer)
 {
     _binaryConditionLeftTranslation.WriteInParenthesesIfRequired(buffer);
     buffer.WriteToTranslation(_binaryConditionOperator.TrimEnd());
     buffer.WriteNewLineToTranslation();
     buffer.Indent();
     _binaryConditionRightTranslation.WriteInParenthesesIfRequired(buffer);
     buffer.Unindent();
 }
        public static void WriteClosingBraceToTranslation(this TranslationBuffer buffer, bool startOnNewLine = true)
        {
            if (startOnNewLine)
            {
                buffer.WriteNewLineToTranslation();
            }

            buffer.Unindent();
            buffer.WriteToTranslation('}');
        }
Exemplo n.º 9
0
            public void WriteTo(TranslationBuffer buffer)
            {
                if ((_writeBlankLineBefore || buffer.TranslationQuery(q => q.TranslationEndsWith("};"))) &&
                    !buffer.TranslationQuery(q => q.TranslationEndsWithBlankLine()))
                {
                    buffer.WriteNewLineToTranslation();
                }

                if (_writeReturnKeyword)
                {
                    buffer.WriteToTranslation("return ");
                }

                WriteStatementTo(buffer);

                if ((_suppressBlankLineAfter == false) && WriteBlankLineAfter())
                {
                    buffer.WriteNewLineToTranslation();
                }
            }
            public override void WriteTo(TranslationBuffer buffer)
            {
                WriteIfStatement(buffer);
                buffer.WriteNewLineToTranslation();
                buffer.WriteToTranslation("else");

                if (_isElseIf)
                {
                    buffer.WriteSpaceToTranslation();
                }

                IfFalseTranslation.WriteTo(buffer);
            }
        public void WriteTo(TranslationBuffer buffer)
        {
            buffer.WriteToTranslation("switch ");
            _valueTranslation.WriteInParentheses(buffer);
            buffer.WriteOpeningBraceToTranslation();

            for (int i = 0, l = _caseTranslations.Length - 1; ; ++i)
            {
                var caseTestValueTranslations = _caseTestValueTranslations[i];

                for (int j = 0, m = caseTestValueTranslations.Length - 1; ; ++j)
                {
                    buffer.WriteToTranslation("case ");
                    caseTestValueTranslations[j].WriteTo(buffer);
                    buffer.WriteToTranslation(':');
                    buffer.WriteNewLineToTranslation();

                    if (j == m)
                    {
                        break;
                    }
                }

                WriteCaseBody(_caseTranslations[i], buffer);

                if (i == l)
                {
                    break;
                }

                buffer.WriteNewLineToTranslation();
                buffer.WriteNewLineToTranslation();
            }

            WriteDefaultIfPresent(buffer);

            buffer.WriteClosingBraceToTranslation();
        }
        private static void WriteCaseBody(ITranslation bodyTranslation, TranslationBuffer buffer)
        {
            buffer.Indent();

            bodyTranslation.WriteTo(buffer);

            if (WriteBreak(bodyTranslation))
            {
                buffer.WriteNewLineToTranslation();
                buffer.WriteToTranslation("break;");
            }

            buffer.Unindent();
        }
Exemplo n.º 13
0
            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)
 {
     buffer.WriteNewLineToTranslation();
     _quotedLambdaTranslation.WriteTo(buffer);
 }