Пример #1
0
        private static void GetTriviaClassifications(SyntaxToken token, Action <ClassifiedRange> action)
        {
            if (token.TriviaWidth > 0)
            {
                var trivia = token.Trivia;

                for (int i = 0; i < trivia.Length; i++)
                {
                    // Tag anything that is not whitespace as the start of comment!
                    // if it wasn't the start of a comment, it wouldn't be in the trivia!
                    // TODO: if we ever get more kinds of trivia, this will need updating.
                    if (!TextFacts.IsWhitespace(trivia[i]))
                    {
                        var start = i;
                        for (; i < trivia.Length; i++)
                        {
                            if (TextFacts.IsLineBreakStart(trivia[i]))
                            {
                                break;
                            }
                        }

                        action(new ClassifiedRange(ClassificationKind.Comment, token.TriviaStart + start, i - start));
                    }
                }
            }
        }
        private static int SkipWhitespace(string text, int start)
        {
            int p = start;

            while (p < text.Length &&
                   TextFacts.IsWhitespace(text[p]) &&
                   !TextFacts.IsLineBreakStart(text[p]))
            {
                p++;
            }

            return(p);
        }