Exemple #1
0
        public static string GetIndent(this SyntaxToken token)
        {
            var precedingTrivia = token.GetAllPrecedingTriviaToPreviousToken();

            // indent is the spaces/tabs between last new line (if there is one) and end of trivia
            var indent         = precedingTrivia.AsString();
            int lastNewLinePos = indent.LastIndexOf(NewLine);

            if (lastNewLinePos != -1)
            {
                int start = lastNewLinePos + NewLine.Length;
                indent = indent.Substring(start, indent.Length - start);
            }

            return(indent);
        }