Esempio n. 1
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
            }
        }