Example #1
0
        internal void AppendCodeString(StringBuilder res, JAst ast, CodeFormattingOptions format, string start, string end, Expression item)
        {
            if (!String.IsNullOrEmpty(start)) {
                format.ReflowComment(res, this.GetProceedingWhiteSpace(ast));
                res.Append(start);
            }

            item.AppendCodeString(res, ast, format);

            for (int i = 0; i < Iterators.Count; i++) {
                Iterators[i].AppendCodeString(res, ast, format);
            }

            if (!String.IsNullOrEmpty(end)) {
                res.Append(this.GetSecondWhiteSpace(ast));
                res.Append(end);
            }
        }
Example #2
0
        internal static void BinaryToCodeString(StringBuilder res, JAst ast, CodeFormattingOptions format, Expression node, Expression left, Expression right, string op1, string op2 = null)
        {
            left.AppendCodeString(res, ast, format);

            format.Append(
                res,
                format.SpacesAroundBinaryOperators,
                " ",
                Char.IsLetter(op1[0]) ? " " : "",   // spaces required for is not, not in, etc...
                node.GetProceedingWhiteSpace(ast)
            );

            if (op2 == null) {
                res.Append(op1);
                right.AppendCodeString(
                    res,
                    ast,
                    format,
                    format.SpacesAroundBinaryOperators != null ?
                        format.SpacesAroundBinaryOperators.Value ?
                            " " :
                            (Char.IsLetter(op1[0]) ? " " : "") :
                        null
                );
            } else {
                Debug.Assert(Char.IsLetter(op1[0]));

                res.Append(op1);
                res.Append(node.GetSecondWhiteSpace(ast));
                res.Append(op2);
                right.AppendCodeString(res, ast, format, format.SpacesAroundBinaryOperators != null ? " " : null); // force single space if setting is on or off
            }
        }