102 references to TriviaLocation
Microsoft.CodeAnalysis.Features (102)
ExtractMethod\AbstractSyntaxTriviaService.cs (44)
31
Debug.Assert(Enum.GetNames(typeof(
TriviaLocation
)).Length == TriviaLocationsCount);
36
Contract.ThrowIfFalse(textSpan.Contains(tokens[
TriviaLocation
.AfterBeginningOfSpan].Span) && textSpan.Contains(tokens[
TriviaLocation
.BeforeEndOfSpan].Span));
40
var annotations = Enumerable.Range((int)
TriviaLocation
.BeforeBeginningOfSpan, TriviaLocationsCount)
41
.Cast<
TriviaLocation
>()
64
Dictionary<
TriviaLocation
, SyntaxAnnotation> annotations,
65
Dictionary<
TriviaLocation
, IEnumerable<SyntaxTrivia>> triviaList)
71
Dictionary<
TriviaLocation
, SyntaxToken> tokens,
72
Dictionary<
TriviaLocation
, SyntaxAnnotation> annotations)
78
token = map.GetOrAdd(tokens[
TriviaLocation
.BeforeBeginningOfSpan], _ => tokens[
TriviaLocation
.BeforeBeginningOfSpan]);
79
map[tokens[
TriviaLocation
.BeforeBeginningOfSpan]] = token.WithTrailingTrivia(emptyList).WithAdditionalAnnotations(annotations[
TriviaLocation
.BeforeBeginningOfSpan]);
81
token = map.GetOrAdd(tokens[
TriviaLocation
.AfterBeginningOfSpan], _ => tokens[
TriviaLocation
.AfterBeginningOfSpan]);
82
map[tokens[
TriviaLocation
.AfterBeginningOfSpan]] = token.WithLeadingTrivia(emptyList).WithAdditionalAnnotations(annotations[
TriviaLocation
.AfterBeginningOfSpan]);
84
token = map.GetOrAdd(tokens[
TriviaLocation
.BeforeEndOfSpan], _ => tokens[
TriviaLocation
.BeforeEndOfSpan]);
85
map[tokens[
TriviaLocation
.BeforeEndOfSpan]] = token.WithTrailingTrivia(emptyList).WithAdditionalAnnotations(annotations[
TriviaLocation
.BeforeEndOfSpan]);
87
token = map.GetOrAdd(tokens[
TriviaLocation
.AfterEndOfSpan], _ => tokens[
TriviaLocation
.AfterEndOfSpan]);
88
map[tokens[
TriviaLocation
.AfterEndOfSpan]] = token.WithLeadingTrivia(emptyList).WithAdditionalAnnotations(annotations[
TriviaLocation
.AfterEndOfSpan]);
93
private static Dictionary<
TriviaLocation
, IEnumerable<SyntaxTrivia>> GetTriviaAtEdges(Dictionary<
TriviaLocation
, SyntaxToken> tokens, TextSpan textSpan)
95
var triviaAtBeginning = SplitTrivia(tokens[
TriviaLocation
.BeforeBeginningOfSpan], tokens[
TriviaLocation
.AfterBeginningOfSpan], t => t.FullSpan.End <= textSpan.Start);
96
var triviaAtEnd = SplitTrivia(tokens[
TriviaLocation
.BeforeEndOfSpan], tokens[
TriviaLocation
.AfterEndOfSpan], t => t.FullSpan.Start < textSpan.End);
98
var triviaList = new Dictionary<
TriviaLocation
, IEnumerable<SyntaxTrivia>>
100
[
TriviaLocation
.BeforeBeginningOfSpan] = triviaAtBeginning.Item1,
101
[
TriviaLocation
.AfterBeginningOfSpan] = triviaAtBeginning.Item2,
103
[
TriviaLocation
.BeforeEndOfSpan] = triviaAtEnd.Item1,
104
[
TriviaLocation
.AfterEndOfSpan] = triviaAtEnd.Item2
109
private static Dictionary<
TriviaLocation
, SyntaxToken> GetTokensAtEdges(SyntaxNode root, TextSpan textSpan)
111
var tokens = new Dictionary<
TriviaLocation
, SyntaxToken>
113
[
TriviaLocation
.AfterBeginningOfSpan] = root.FindTokenOnRightOfPosition(textSpan.Start, includeSkipped: false)
115
tokens[
TriviaLocation
.BeforeBeginningOfSpan] = tokens[
TriviaLocation
.AfterBeginningOfSpan].GetPreviousToken(includeZeroWidth: true);
116
tokens[
TriviaLocation
.BeforeEndOfSpan] = root.FindTokenOnLeftOfPosition(textSpan.End, includeSkipped: false);
117
tokens[
TriviaLocation
.AfterEndOfSpan] = tokens[
TriviaLocation
.BeforeEndOfSpan].GetNextToken(includeZeroWidth: true);
ExtractMethod\AbstractSyntaxTriviaService.Result.cs (56)
22
private readonly Dictionary<
TriviaLocation
, SyntaxAnnotation> _annotations;
23
private readonly Dictionary<
TriviaLocation
, IEnumerable<SyntaxTrivia>> _triviaList;
28
Dictionary<
TriviaLocation
, SyntaxAnnotation> annotations,
29
Dictionary<
TriviaLocation
, IEnumerable<SyntaxTrivia>> triviaList)
56
Dictionary<
TriviaLocation
, PreviousNextTokenPair> tokenPairs,
57
Dictionary<
TriviaLocation
, LeadingTrailingTriviaPair> triviaPairs)
100
private Dictionary<
TriviaLocation
, SyntaxToken> RecoverTokensAtEdges(
106
var tokens = Enumerable.Range((int)
TriviaLocation
.BeforeBeginningOfSpan, TriviaLocationsCount)
107
.Cast<
TriviaLocation
>()
113
tokens[
TriviaLocation
.AfterBeginningOfSpan].RawKind == 0 /* don't care */ ||
114
tokens[
TriviaLocation
.BeforeEndOfSpan].RawKind == 0 /* don't care */ ||
115
tokens[
TriviaLocation
.AfterBeginningOfSpan] == tokens[
TriviaLocation
.BeforeEndOfSpan] ||
116
tokens[
TriviaLocation
.AfterBeginningOfSpan].GetPreviousToken(includeZeroWidth: true) == tokens[
TriviaLocation
.BeforeEndOfSpan] ||
117
tokens[
TriviaLocation
.AfterBeginningOfSpan].Span.End <= tokens[
TriviaLocation
.BeforeEndOfSpan].SpanStart);
123
Dictionary<
TriviaLocation
, SyntaxToken> tokens,
131
var triviaPairs = Enumerable.Range((int)
TriviaLocation
.BeforeBeginningOfSpan, TriviaLocationsCount)
132
.Cast<
TriviaLocation
>()
154
Dictionary<
TriviaLocation
, PreviousNextTokenPair> tokenPairs,
155
Dictionary<
TriviaLocation
, LeadingTrailingTriviaPair> triviaPairs)
159
for (var i = (int)
TriviaLocation
.BeforeBeginningOfSpan; i <= (int)
TriviaLocation
.AfterEndOfSpan; i++)
161
var
location = (
TriviaLocation
)i;
174
Dictionary<
TriviaLocation
, SyntaxToken> tokens)
179
tuple = map.GetOrAdd(tokens[
TriviaLocation
.BeforeBeginningOfSpan], _ => default);
180
map[tokens[
TriviaLocation
.BeforeBeginningOfSpan]] = new LeadingTrailingTriviaPair
183
TrailingTrivia = _triviaList[
TriviaLocation
.BeforeBeginningOfSpan]
186
tuple = map.GetOrAdd(tokens[
TriviaLocation
.AfterBeginningOfSpan], _ => default);
187
map[tokens[
TriviaLocation
.AfterBeginningOfSpan]] = new LeadingTrailingTriviaPair
189
LeadingTrivia = _triviaList[
TriviaLocation
.AfterBeginningOfSpan],
193
tuple = map.GetOrAdd(tokens[
TriviaLocation
.BeforeEndOfSpan], _ => default);
194
map[tokens[
TriviaLocation
.BeforeEndOfSpan]] = new LeadingTrailingTriviaPair
197
TrailingTrivia = _triviaList[
TriviaLocation
.BeforeEndOfSpan]
200
tuple = map.GetOrAdd(tokens[
TriviaLocation
.AfterEndOfSpan], _ => default);
201
map[tokens[
TriviaLocation
.AfterEndOfSpan]] = new LeadingTrailingTriviaPair
203
LeadingTrivia = _triviaList[
TriviaLocation
.AfterEndOfSpan],
210
private static Dictionary<
TriviaLocation
, PreviousNextTokenPair> CreatePreviousNextTokenPairs(
211
Dictionary<
TriviaLocation
, SyntaxToken> tokens)
213
var tokenPairs = new Dictionary<
TriviaLocation
, PreviousNextTokenPair>
215
[
TriviaLocation
.BeforeBeginningOfSpan] = new PreviousNextTokenPair
217
PreviousToken = tokens[
TriviaLocation
.BeforeBeginningOfSpan],
218
NextToken = tokens[
TriviaLocation
.BeforeBeginningOfSpan].GetNextToken(includeZeroWidth: true)
221
[
TriviaLocation
.AfterBeginningOfSpan] = new PreviousNextTokenPair
223
PreviousToken = tokens[
TriviaLocation
.AfterBeginningOfSpan].GetPreviousToken(includeZeroWidth: true),
224
NextToken = tokens[
TriviaLocation
.AfterBeginningOfSpan]
227
[
TriviaLocation
.BeforeEndOfSpan] = new PreviousNextTokenPair
229
PreviousToken = tokens[
TriviaLocation
.BeforeEndOfSpan],
230
NextToken = tokens[
TriviaLocation
.BeforeEndOfSpan].GetNextToken(includeZeroWidth: true)
233
[
TriviaLocation
.AfterEndOfSpan] = new PreviousNextTokenPair
235
PreviousToken = tokens[
TriviaLocation
.AfterEndOfSpan].GetPreviousToken(includeZeroWidth: true),
236
NextToken = tokens[
TriviaLocation
.AfterEndOfSpan]
261
TriviaLocation
location,
268
TriviaLocation
location,
ExtractMethod\ISyntaxTriviaService.cs (2)
33
internal delegate SyntaxToken AnnotationResolver(SyntaxNode root,
TriviaLocation
location, SyntaxAnnotation annotation);
34
internal delegate IEnumerable<SyntaxTrivia> TriviaResolver(
TriviaLocation
location, PreviousNextTokenPair tokenPair, Dictionary<SyntaxToken, LeadingTrailingTriviaPair> triviaMap);