コード例 #1
0
        private Dictionary <TriviaLocation, SyntaxToken> GetTokensAtEdges(
            SyntaxNode root,
            TextSpan textSpan
            )
        {
            var tokens = new Dictionary <TriviaLocation, SyntaxToken>();

            tokens[TriviaLocation.AfterBeginningOfSpan] = _syntaxFacts.FindTokenOnRightOfPosition(
                root,
                textSpan.Start,
                includeSkipped: false
                );
            tokens[TriviaLocation.BeforeBeginningOfSpan] = tokens[
                TriviaLocation.AfterBeginningOfSpan
                                                           ].GetPreviousToken(includeZeroWidth: true);
            tokens[TriviaLocation.BeforeEndOfSpan] = _syntaxFacts.FindTokenOnLeftOfPosition(
                root,
                textSpan.End,
                includeSkipped: false
                );
            tokens[TriviaLocation.AfterEndOfSpan] = tokens[
                TriviaLocation.BeforeEndOfSpan
                                                    ].GetNextToken(includeZeroWidth: true);
            return(tokens);
        }