-
Notifications
You must be signed in to change notification settings - Fork 4k
/
SyntaxToken.cs
707 lines (609 loc) · 26.4 KB
/
SyntaxToken.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Runtime.InteropServices;
using Microsoft.CodeAnalysis.Text;
using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis
{
#pragma warning disable CA1200 // Avoid using cref tags with a prefix
/// <summary>
/// Represents a token in the syntax tree. This is the language agnostic equivalent of <see
/// cref="T:Microsoft.CodeAnalysis.CSharp.SyntaxToken"/> and <see cref="T:Microsoft.CodeAnalysis.VisualBasic.SyntaxToken"/>.
/// </summary>
#pragma warning restore CA1200 // Avoid using cref tags with a prefix
[StructLayout(LayoutKind.Auto)]
[DebuggerDisplay("{GetDebuggerDisplay(), nq}")]
public readonly struct SyntaxToken : IEquatable<SyntaxToken>
{
private static readonly Func<DiagnosticInfo, Diagnostic> s_createDiagnosticWithoutLocation = Diagnostic.Create;
internal static readonly Func<SyntaxToken, bool> NonZeroWidth = t => t.Width > 0;
internal static readonly Func<SyntaxToken, bool> Any = t => true;
internal SyntaxToken(SyntaxNode? parent, GreenNode? token, int position, int index)
{
Debug.Assert(parent == null || !parent.Green.IsList, "list cannot be a parent");
Debug.Assert(token == null || token.IsToken, "token must be a token");
Parent = parent;
Node = token;
Position = position;
Index = index;
}
internal SyntaxToken(GreenNode? token)
: this()
{
Debug.Assert(token == null || token.IsToken, "token must be a token");
Node = token;
}
private string GetDebuggerDisplay()
{
return GetType().Name + " " + (Node != null ? Node.KindText : "None") + " " + ToString();
}
/// <summary>
/// An integer representing the language specific kind of this token.
/// </summary>
public int RawKind => Node?.RawKind ?? 0;
/// <summary>
/// The language name that this token is syntax of.
/// </summary>
public string Language => Node?.Language ?? string.Empty;
/// <summary>
/// The kind of token, given its position in the syntax. This differs from <see
/// cref="RawKind"/> when a contextual keyword is used in a place in the syntax that gives it
/// its keyword meaning.
/// </summary>
/// <remarks>
/// The ContextualKind is relevant only on contextual keyword tokens. ContextualKind differs
/// from Kind when a token is used in context where the token should be interpreted as a
/// keyword.
/// </remarks>
internal int RawContextualKind => Node?.RawContextualKind ?? 0;
/// <summary>
/// The node that contains this token in its Children collection.
/// </summary>
public SyntaxNode? Parent { get; }
internal GreenNode? Node { get; }
internal GreenNode RequiredNode
{
get
{
Debug.Assert(Node is object);
return Node;
}
}
internal int Index { get; }
internal int Position { get; }
/// <summary>
/// The width of the token in characters, not including its leading and trailing trivia.
/// </summary>
internal int Width => Node?.Width ?? 0;
/// <summary>
/// The complete width of the token in characters including its leading and trailing trivia.
/// </summary>
internal int FullWidth => Node?.FullWidth ?? 0;
/// <summary>
/// The absolute span of this token in characters, not including its leading and trailing trivia.
/// </summary>
public TextSpan Span
{
get
{
return Node != null ? new TextSpan(Position + Node.GetLeadingTriviaWidth(), Node.Width) : default(TextSpan);
}
}
internal int EndPosition
{
get { return Node != null ? Position + Node.FullWidth : 0; }
}
/// <summary>
/// Same as accessing <see cref="TextSpan.Start"/> on <see cref="Span"/>.
/// </summary>
/// <remarks>
/// Slight performance improvement.
/// </remarks>
public int SpanStart
{
get { return Node != null ? Position + Node.GetLeadingTriviaWidth() : 0; }
}
/// <summary>
/// The absolute span of this token in characters, including its leading and trailing trivia.
/// </summary>
public TextSpan FullSpan => new TextSpan(Position, FullWidth);
/// <summary>
/// Determines whether this token represents a language construct that was actually parsed from source code.
/// Missing tokens are typically generated by the parser in error scenarios to represent constructs that should
/// have been present in the source code for the source code to compile successfully but were actually missing.
/// </summary>
public bool IsMissing => Node?.IsMissing ?? false;
/// <summary>
/// Returns the value of the token. For example, if the token represents an integer literal, then this property
/// would return the actual integer.
/// </summary>
public object? Value => Node?.GetValue();
/// <summary>
/// Returns the text representation of the value of the token. For example, if the token represents an integer
/// literal, then this property would return a string representing the integer.
/// </summary>
public string ValueText => Node?.GetValueText() ?? string.Empty;
public string Text => ToString();
/// <summary>
/// Returns the string representation of this token, not including its leading and trailing trivia.
/// </summary>
/// <returns>The string representation of this token, not including its leading and trailing trivia.</returns>
/// <remarks>The length of the returned string is always the same as Span.Length</remarks>
public override string ToString()
{
return Node != null ? Node.ToString() : string.Empty;
}
/// <summary>
/// Returns the full string representation of this token including its leading and trailing trivia.
/// </summary>
/// <returns>The full string representation of this token including its leading and trailing trivia.</returns>
/// <remarks>The length of the returned string is always the same as FullSpan.Length</remarks>
public string ToFullString()
{
return Node != null ? Node.ToFullString() : string.Empty;
}
/// <summary>
/// Writes the full text of this token to the specified <paramref name="writer"/>.
/// </summary>
public void WriteTo(System.IO.TextWriter writer)
{
Node?.WriteTo(writer);
}
/// <summary>
/// Writes the text of this token to the specified TextWriter, optionally including trivia.
/// </summary>
internal void WriteTo(System.IO.TextWriter writer, bool leading, bool trailing)
{
Node?.WriteTo(writer, leading, trailing);
}
/// <summary>
/// Determines whether this token has any leading trivia.
/// </summary>
public bool HasLeadingTrivia => this.LeadingTrivia.Count > 0;
/// <summary>
/// Determines whether this token has any trailing trivia.
/// </summary>
public bool HasTrailingTrivia => this.TrailingTrivia.Count > 0;
/// <summary>
/// Full width of the leading trivia of this token.
/// </summary>
internal int LeadingWidth => Node?.GetLeadingTriviaWidth() ?? 0;
/// <summary>
/// Full width of the trailing trivia of this token.
/// </summary>
internal int TrailingWidth => Node?.GetTrailingTriviaWidth() ?? 0;
/// <summary>
/// Determines whether this token or any of its descendant trivia have any diagnostics on them.
/// </summary>
public bool ContainsDiagnostics => Node?.ContainsDiagnostics ?? false;
/// <summary>
/// Determines whether this token has any descendant preprocessor directives.
/// </summary>
public bool ContainsDirectives => Node?.ContainsDirectives ?? false;
/// <summary>
/// Determines whether this token is a descendant of a structured trivia.
/// </summary>
public bool IsPartOfStructuredTrivia()
{
return Parent?.IsPartOfStructuredTrivia() ?? false;
}
/// <summary>
/// Determines whether any of this token's trivia is structured.
/// </summary>
public bool HasStructuredTrivia => Node?.ContainsStructuredTrivia ?? false;
#region Annotations
/// <summary>
/// True if this token or its trivia has any annotations.
/// </summary>
public bool ContainsAnnotations => Node?.ContainsAnnotations ?? false;
/// <summary>
/// True if this token has annotations of the specified annotation kind.
/// </summary>
public bool HasAnnotations(string annotationKind)
{
return Node?.HasAnnotations(annotationKind) ?? false;
}
/// <summary>
/// True if this token has annotations of the specified annotation kinds.
/// </summary>
public bool HasAnnotations(params string[] annotationKinds)
{
return Node?.HasAnnotations(annotationKinds) ?? false;
}
/// <summary>
/// True if this token has the specified annotation.
/// </summary>
public bool HasAnnotation([NotNullWhen(true)] SyntaxAnnotation? annotation)
{
return Node?.HasAnnotation(annotation) ?? false;
}
/// <summary>
/// Gets all the annotations of the specified annotation kind.
/// </summary>
public IEnumerable<SyntaxAnnotation> GetAnnotations(string annotationKind)
{
return Node?.GetAnnotations(annotationKind) ?? SpecializedCollections.EmptyEnumerable<SyntaxAnnotation>();
}
/// <summary>
/// Gets all the annotations of the specified annotation kind.
/// </summary>
public IEnumerable<SyntaxAnnotation> GetAnnotations(params string[] annotationKinds)
{
return GetAnnotations((IEnumerable<string>)annotationKinds);
}
/// <summary>
/// Gets all the annotations of the specified annotation kind.
/// </summary>
public IEnumerable<SyntaxAnnotation> GetAnnotations(IEnumerable<string> annotationKinds)
{
return Node?.GetAnnotations(annotationKinds) ?? SpecializedCollections.EmptyEnumerable<SyntaxAnnotation>();
}
/// <summary>
/// Adds this annotation to a given syntax token, creating a new syntax token of the same type with the
/// annotation on it.
/// </summary>
public SyntaxToken WithAdditionalAnnotations(params SyntaxAnnotation[] annotations)
{
return WithAdditionalAnnotations((IEnumerable<SyntaxAnnotation>)annotations);
}
/// <summary>
/// Adds this annotation to a given syntax token, creating a new syntax token of the same type with the
/// annotation on it.
/// </summary>
public SyntaxToken WithAdditionalAnnotations(IEnumerable<SyntaxAnnotation> annotations)
{
if (annotations == null)
{
throw new ArgumentNullException(nameof(annotations));
}
if (this.Node != null)
{
return new SyntaxToken(
parent: null,
token: Node.WithAdditionalAnnotationsGreen(annotations),
position: 0,
index: 0);
}
return default(SyntaxToken);
}
/// <summary>
/// Creates a new syntax token identical to this one without the specified annotations.
/// </summary>
public SyntaxToken WithoutAnnotations(params SyntaxAnnotation[] annotations)
{
return WithoutAnnotations((IEnumerable<SyntaxAnnotation>)annotations);
}
/// <summary>
/// Creates a new syntax token identical to this one without the specified annotations.
/// </summary>
public SyntaxToken WithoutAnnotations(IEnumerable<SyntaxAnnotation> annotations)
{
if (annotations == null)
{
throw new ArgumentNullException(nameof(annotations));
}
if (this.Node != null)
{
return new SyntaxToken(
parent: null,
token: Node.WithoutAnnotationsGreen(annotations),
position: 0,
index: 0);
}
return default(SyntaxToken);
}
/// <summary>
/// Creates a new syntax token identical to this one without annotations of the specified kind.
/// </summary>
public SyntaxToken WithoutAnnotations(string annotationKind)
{
if (annotationKind == null)
{
throw new ArgumentNullException(nameof(annotationKind));
}
if (this.HasAnnotations(annotationKind))
{
return this.WithoutAnnotations(this.GetAnnotations(annotationKind));
}
return this;
}
/// <summary>
/// Copies all SyntaxAnnotations, if any, from this SyntaxToken instance and attaches them to a new instance based on <paramref name="token" />.
/// </summary>
/// <remarks>
/// If no annotations are copied, just returns <paramref name="token" />.
/// </remarks>
public SyntaxToken CopyAnnotationsTo(SyntaxToken token)
{
if (token.Node == null)
{
return default(SyntaxToken);
}
if (Node == null)
{
return token;
}
var annotations = this.Node.GetAnnotations();
if (annotations?.Length > 0)
{
return new SyntaxToken(
parent: null,
token: token.Node.WithAdditionalAnnotationsGreen(annotations),
position: 0,
index: 0);
}
return token;
}
#endregion
/// <summary>
/// The list of trivia that appear before this token in the source code.
/// </summary>
public SyntaxTriviaList LeadingTrivia
{
get
{
return Node != null
? new SyntaxTriviaList(this, Node.GetLeadingTriviaCore(), this.Position)
: default(SyntaxTriviaList);
}
}
/// <summary>
/// The list of trivia that appear after this token in the source code and are attached to this token or any of
/// its descendants.
/// </summary>
public SyntaxTriviaList TrailingTrivia
{
get
{
if (Node == null)
{
return default(SyntaxTriviaList);
}
var leading = Node.GetLeadingTriviaCore();
int index = 0;
if (leading != null)
{
index = leading.IsList ? leading.SlotCount : 1;
}
var trailingGreen = Node.GetTrailingTriviaCore();
int trailingPosition = Position + this.FullWidth;
if (trailingGreen != null)
{
trailingPosition -= trailingGreen.FullWidth;
}
return new SyntaxTriviaList(this,
trailingGreen,
trailingPosition,
index);
}
}
/// <summary>
/// Creates a new token from this token with the leading and trailing trivia from the specified token.
/// </summary>
public SyntaxToken WithTriviaFrom(SyntaxToken token)
{
return this.WithLeadingTrivia(token.LeadingTrivia).WithTrailingTrivia(token.TrailingTrivia);
}
/// <summary>
/// Creates a new token from this token with the leading trivia specified.
/// </summary>
public SyntaxToken WithLeadingTrivia(SyntaxTriviaList trivia)
{
return this.WithLeadingTrivia((IEnumerable<SyntaxTrivia>)trivia);
}
/// <summary>
/// Creates a new token from this token with the leading trivia specified..
/// </summary>
public SyntaxToken WithLeadingTrivia(params SyntaxTrivia[]? trivia)
{
return this.WithLeadingTrivia((IEnumerable<SyntaxTrivia>?)trivia);
}
/// <summary>
/// Creates a new token from this token with the leading trivia specified.
/// </summary>
public SyntaxToken WithLeadingTrivia(IEnumerable<SyntaxTrivia>? trivia)
{
return Node != null
? new SyntaxToken(null, Node.WithLeadingTrivia(GreenNode.CreateList(trivia, static t => t.RequiredUnderlyingNode)), position: 0, index: 0)
: default(SyntaxToken);
}
/// <summary>
/// Creates a new token from this token with the trailing trivia specified.
/// </summary>
public SyntaxToken WithTrailingTrivia(SyntaxTriviaList trivia)
{
return this.WithTrailingTrivia((IEnumerable<SyntaxTrivia>)trivia);
}
/// <summary>
/// Creates a new token from this token with the trailing trivia specified.
/// </summary>
public SyntaxToken WithTrailingTrivia(params SyntaxTrivia[]? trivia)
{
return this.WithTrailingTrivia((IEnumerable<SyntaxTrivia>?)trivia);
}
/// <summary>
/// Creates a new token from this token with the trailing trivia specified.
/// </summary>
public SyntaxToken WithTrailingTrivia(IEnumerable<SyntaxTrivia>? trivia)
{
return Node != null
? new SyntaxToken(null, Node.WithTrailingTrivia(GreenNode.CreateList(trivia, static t => t.RequiredUnderlyingNode)), position: 0, index: 0)
: default(SyntaxToken);
}
/// <summary>
/// Gets a list of all the trivia (both leading and trailing) for this token.
/// </summary>
public IEnumerable<SyntaxTrivia> GetAllTrivia()
{
if (this.HasLeadingTrivia)
{
if (this.HasTrailingTrivia)
{
return this.LeadingTrivia.Concat(this.TrailingTrivia);
}
return this.LeadingTrivia;
}
if (this.HasTrailingTrivia)
{
return this.TrailingTrivia;
}
return SpecializedCollections.EmptyEnumerable<SyntaxTrivia>();
}
/// <summary>
/// Determines whether two <see cref="SyntaxToken"/>s are equal.
/// </summary>
public static bool operator ==(SyntaxToken left, SyntaxToken right)
{
return left.Equals(right);
}
/// <summary>
/// Determines whether two <see cref="SyntaxToken"/>s are unequal.
/// </summary>
public static bool operator !=(SyntaxToken left, SyntaxToken right)
{
return !left.Equals(right);
}
/// <summary>
/// Determines whether the supplied <see cref="SyntaxToken"/> is equal to this
/// <see cref="SyntaxToken"/>.
/// </summary>
public bool Equals(SyntaxToken other)
{
return Parent == other.Parent &&
Node == other.Node &&
Position == other.Position &&
Index == other.Index;
}
/// <summary>
/// Determines whether the supplied <see cref="SyntaxToken"/> is equal to this
/// <see cref="SyntaxToken"/>.
/// </summary>
public override bool Equals(object? obj)
{
return obj is SyntaxToken && Equals((SyntaxToken)obj);
}
/// <summary>
/// Serves as hash function for <see cref="SyntaxToken"/>.
/// </summary>
public override int GetHashCode()
{
return Hash.Combine(Parent, Hash.Combine(Node, Hash.Combine(Position, Index)));
}
/// <summary>
/// Gets the token that follows this token in the syntax tree.
/// </summary>
/// <returns>The token that follows this token in the syntax tree.</returns>
public SyntaxToken GetNextToken(bool includeZeroWidth = false, bool includeSkipped = false, bool includeDirectives = false, bool includeDocumentationComments = false)
{
if (Node == null)
{
return default(SyntaxToken);
}
return SyntaxNavigator.Instance.GetNextToken(this, includeZeroWidth, includeSkipped, includeDirectives, includeDocumentationComments);
}
/// <summary>
/// Returns the token after this token in the syntax tree.
/// </summary>
/// <param name="predicate">Delegate applied to each token. The token is returned if the predicate returns
/// true.</param>
/// <param name="stepInto">Delegate applied to trivia. If this delegate is present then trailing trivia is
/// included in the search.</param>
internal SyntaxToken GetNextToken(Func<SyntaxToken, bool> predicate, Func<SyntaxTrivia, bool>? stepInto = null)
{
if (Node == null)
{
return default(SyntaxToken);
}
return SyntaxNavigator.Instance.GetNextToken(this, predicate, stepInto);
}
/// <summary>
/// Gets the token that precedes this token in the syntax tree.
/// </summary>
/// <returns>The previous token that precedes this token in the syntax tree.</returns>
public SyntaxToken GetPreviousToken(bool includeZeroWidth = false, bool includeSkipped = false, bool includeDirectives = false, bool includeDocumentationComments = false)
{
if (Node == null)
{
return default(SyntaxToken);
}
return SyntaxNavigator.Instance.GetPreviousToken(this, includeZeroWidth, includeSkipped, includeDirectives, includeDocumentationComments);
}
/// <summary>
/// Returns the token before this token in the syntax tree.
/// </summary>
/// <param name="predicate">Delegate applied to each token. The token is returned if the predicate returns
/// true.</param>
/// <param name="stepInto">Delegate applied to trivia. If this delegate is present then trailing trivia is
/// included in the search.</param>
internal SyntaxToken GetPreviousToken(Func<SyntaxToken, bool> predicate, Func<SyntaxTrivia, bool>? stepInto = null)
{
return SyntaxNavigator.Instance.GetPreviousToken(this, predicate, stepInto);
}
/// <summary>
/// The SyntaxTree that contains this token.
/// </summary>
public SyntaxTree? SyntaxTree => Parent?.SyntaxTree;
/// <summary>
/// Gets the location for this token.
/// </summary>
public Location GetLocation()
{
var tree = SyntaxTree;
return tree == null
? Location.None
: tree.GetLocation(Span);
}
/// <summary>
/// Gets a list of all the diagnostics associated with this token and any related trivia.
/// This method does not filter diagnostics based on #pragmas and compiler options
/// like nowarn, warnaserror etc.
/// </summary>
public IEnumerable<Diagnostic> GetDiagnostics()
{
if (Node == null)
{
return SpecializedCollections.EmptyEnumerable<Diagnostic>();
}
var tree = SyntaxTree;
if (tree == null)
{
var diagnostics = Node.GetDiagnostics();
return diagnostics.Length == 0
? SpecializedCollections.EmptyEnumerable<Diagnostic>()
: diagnostics.Select(s_createDiagnosticWithoutLocation);
}
return tree.GetDiagnostics(this);
}
/// <summary>
/// Determines if this token is equivalent to the specified token.
/// </summary>
public bool IsEquivalentTo(SyntaxToken token)
{
return
(Node == null && token.Node == null) ||
(Node != null && token.Node != null && Node.IsEquivalentTo(token.Node));
}
/// <summary>
/// Returns true if these two tokens are considered "incrementally identical". An incrementally identical token
/// occurs when a <see cref="SyntaxTree"/> is incrementally parsed using <see cref="SyntaxTree.WithChangedText"/>
/// and the incremental parser is able to take the token from the original tree and use it in its entirety in the
/// new tree. In this case, the <see cref="SyntaxToken.ToFullString()"/> of each token will be the same, though
/// they could have different parents, and may occur at different positions in the respective trees. If two tokens are
/// incrementally identical, all trivial of each node will be incrementally identical as well.
/// </summary>
/// <remarks>
/// Incrementally identical tokens can also appear within the same syntax tree, or syntax trees that did not arise
/// from <see cref="SyntaxTree.WithChangedText"/>. This can happen as the parser is allowed to construct parse
/// trees using shared tokens for efficiency. In all these cases though, it will still remain true that the incrementally
/// identical tokens could have different parents and may occur at different positions in their respective trees.
/// </remarks>
public bool IsIncrementallyIdenticalTo(SyntaxToken token)
=> this.Node != null && this.Node == token.Node;
}
}