Exemplo n.º 1
0
        public static SyntaxNodeOrToken WithLeadingWhitespace(this SyntaxNodeOrToken node, string indent)
        {
            var t    = node.GetLeadingTrivia();
            var last = t.Last();

            if (!last.IsKind(SyntaxKind.WhitespaceTrivia))
            {
                t = t.Add(SyntaxFactory.Whitespace(indent));
            }
            else if (last.ToFullString() == indent)
            {
                return(node);
            }
            else
            {
                t = t.Replace(last, SyntaxFactory.Whitespace(indent));
            }

            return(node.WithLeadingTrivia(t));
        }