2 writes to TextWindow
Microsoft.CodeAnalysis.CSharp (2)
Parser\AbstractLexer.cs (1)
24
this.
TextWindow
= new SlidingTextWindow(text);
Parser\Lexer_StringLiteral.cs (1)
414
ref var window = ref _lexer.
TextWindow
;
590 references to TextWindow
Microsoft.CodeAnalysis.CSharp (585)
Parser\AbstractLexer.cs (5)
29
this.
TextWindow
.Free();
34
LexemeStartPosition = this.
TextWindow
.Position;
141
=>
TextWindow
.GetText(LexemeStartPosition, intern: false);
144
=>
TextWindow
.GetText(LexemeStartPosition, intern: true);
147
=> this.
TextWindow
.Position - LexemeStartPosition;
Parser\Blender.cs (1)
69
_newPosition = lexer.
TextWindow
.Position;
Parser\Blender.Reader.cs (1)
165
if (_lexer.
TextWindow
.Position != _newPosition)
Parser\DirectiveParser.cs (1)
36
var hashPosition = lexer.
TextWindow
.Position;
Parser\LanguageParser.cs (2)
219
return CreateForGlobalFailure(lexer.
TextWindow
.Position, createEmptyNodeFunc(this));
229
builder.Add(SyntaxFactory.BadToken(null, lexer.
TextWindow
.Text.ToString(), null));
Parser\Lexer.cs (411)
172
this.
TextWindow
.Reset(position);
310
this.LexSyntaxTrivia(isFollowingToken:
TextWindow
.Position > 0, isTrailing: false, triviaList: ref _leadingTriviaCache);
329
this.LexSyntaxTrivia(isFollowingToken:
TextWindow
.Position > 0, isTrailing: false, triviaList: ref _leadingTriviaCache);
449
int startingPosition =
TextWindow
.Position;
452
character =
TextWindow
.PeekChar();
461
TextWindow
.AdvanceChar();
462
info.Kind =
TextWindow
.TryAdvance('=') ? SyntaxKind.SlashEqualsToken : SyntaxKind.SlashToken;
466
if (this.
TextWindow
.PeekChar(1) is >= '0' and <= '9')
468
var atDotPosition = this.
TextWindow
.Position;
478
if (this.
TextWindow
.PreviousChar() is '.')
481
TextWindow
.AdvanceChar();
492
TextWindow
.AdvanceChar();
499
TextWindow
.AdvanceChar();
504
TextWindow
.AdvanceChar();
505
info.Kind =
TextWindow
.TryAdvance(':') ? SyntaxKind.ColonColonToken : SyntaxKind.ColonToken;
509
TextWindow
.AdvanceChar();
514
TextWindow
.AdvanceChar();
519
TextWindow
.AdvanceChar();
520
info.Kind =
TextWindow
.TryAdvance('=') ? SyntaxKind.ExclamationEqualsToken : SyntaxKind.ExclamationToken;
524
TextWindow
.AdvanceChar();
526
TextWindow
.TryAdvance('=') ? SyntaxKind.EqualsEqualsToken :
527
TextWindow
.TryAdvance('>') ? SyntaxKind.EqualsGreaterThanToken : SyntaxKind.EqualsToken;
531
TextWindow
.AdvanceChar();
532
info.Kind =
TextWindow
.TryAdvance('=') ? SyntaxKind.AsteriskEqualsToken : SyntaxKind.AsteriskToken;
536
TextWindow
.AdvanceChar();
541
TextWindow
.AdvanceChar();
546
TextWindow
.AdvanceChar();
551
TextWindow
.AdvanceChar();
556
TextWindow
.AdvanceChar();
561
TextWindow
.AdvanceChar();
566
TextWindow
.AdvanceChar();
567
info.Kind =
TextWindow
.TryAdvance('?')
568
?
TextWindow
.TryAdvance('=') ? SyntaxKind.QuestionQuestionEqualsToken : SyntaxKind.QuestionQuestionToken
573
TextWindow
.AdvanceChar();
575
TextWindow
.TryAdvance('=') ? SyntaxKind.PlusEqualsToken :
576
TextWindow
.TryAdvance('+') ? SyntaxKind.PlusPlusToken : SyntaxKind.PlusToken;
580
TextWindow
.AdvanceChar();
582
TextWindow
.TryAdvance('=') ? SyntaxKind.MinusEqualsToken :
583
TextWindow
.TryAdvance('-') ? SyntaxKind.MinusMinusToken :
584
TextWindow
.TryAdvance('>') ? SyntaxKind.MinusGreaterThanToken : SyntaxKind.MinusToken;
588
TextWindow
.AdvanceChar();
589
info.Kind =
TextWindow
.TryAdvance('=') ? SyntaxKind.PercentEqualsToken : SyntaxKind.PercentToken;
593
TextWindow
.AdvanceChar();
595
TextWindow
.TryAdvance('=') ? SyntaxKind.AmpersandEqualsToken :
596
TextWindow
.TryAdvance('&') ? SyntaxKind.AmpersandAmpersandToken : SyntaxKind.AmpersandToken;
600
TextWindow
.AdvanceChar();
601
info.Kind =
TextWindow
.TryAdvance('=') ? SyntaxKind.CaretEqualsToken : SyntaxKind.CaretToken;
605
TextWindow
.AdvanceChar();
607
TextWindow
.TryAdvance('=') ? SyntaxKind.BarEqualsToken :
608
TextWindow
.TryAdvance('|') ? SyntaxKind.BarBarToken : SyntaxKind.BarToken;
612
TextWindow
.AdvanceChar();
614
TextWindow
.TryAdvance('=') ? SyntaxKind.LessThanEqualsToken :
615
TextWindow
.TryAdvance('<')
616
?
TextWindow
.TryAdvance('=') ? SyntaxKind.LessThanLessThanEqualsToken : SyntaxKind.LessThanLessThanToken
621
TextWindow
.AdvanceChar();
622
info.Kind =
TextWindow
.TryAdvance('=') ? SyntaxKind.GreaterThanEqualsToken : SyntaxKind.GreaterThanToken;
629
Debug.Assert(
TextWindow
.PeekChar() == '@');
631
if (
TextWindow
.PeekChar(1) == ':')
636
this.AddError(
TextWindow
.Position + 1, width: 1, ErrorCode.ERR_ExpectedVerbatimLiteral);
685
if (!
TextWindow
.IsReallyAtEnd())
716
TextWindow
.AdvanceChar();
721
if (char.IsHighSurrogate(character) && char.IsLowSurrogate(
TextWindow
.PeekChar()))
722
TextWindow
.AdvanceChar();
734
int end =
TextWindow
.Text.Length;
735
info.Text =
TextWindow
.Text.ToString(TextSpan.FromBounds(startingPosition, end));
736
TextWindow
.Reset(end);
753
Debug.Assert(
TextWindow
.PeekChar() == '@');
756
while (
TextWindow
.PeekChar(index) == '@')
761
if (
TextWindow
.PeekChar(index) == '"')
767
else if (
TextWindow
.PeekChar(index) == '$')
779
Debug.Assert(
TextWindow
.PeekChar() == '$');
781
if (
TextWindow
.PeekChar(1) is '$' or '@' or '"')
806
int start =
TextWindow
.Position;
807
while (
TextWindow
.PeekChar() is >= '0' and <= '9')
809
TextWindow
.AdvanceChar();
812
return start <
TextWindow
.Position;
818
if (
TextWindow
.PeekChar() == '_')
833
char ch =
TextWindow
.PeekChar();
850
TextWindow
.AdvanceChar();
861
int start =
TextWindow
.Position;
876
ch =
TextWindow
.PeekChar();
879
ch =
TextWindow
.PeekChar(1);
882
TextWindow
.AdvanceChar(2);
888
TextWindow
.AdvanceChar(2);
899
if (
TextWindow
.PeekChar() is 'L' or 'l')
901
TextWindow
.AdvanceChar();
903
if (
TextWindow
.PeekChar() is 'u' or 'U')
905
TextWindow
.AdvanceChar();
909
else if (
TextWindow
.PeekChar() is 'u' or 'U')
911
TextWindow
.AdvanceChar();
913
if (
TextWindow
.PeekChar() is 'L' or 'l')
915
TextWindow
.AdvanceChar();
924
if (this.ModeIs(LexerMode.DebuggerSyntax) &&
TextWindow
.PeekChar() == '#')
927
TextWindow
.AdvanceChar();
934
if ((ch =
TextWindow
.PeekChar()) == '.')
936
var ch2 =
TextWindow
.PeekChar(1);
941
TextWindow
.AdvanceChar();
948
TextWindow
.Reset(start);
953
if ((ch =
TextWindow
.PeekChar()) is 'E' or 'e')
956
TextWindow
.AdvanceChar();
958
if ((ch =
TextWindow
.PeekChar()) is '-' or '+')
961
TextWindow
.AdvanceChar();
964
if (!(((ch =
TextWindow
.PeekChar()) >= '0' && ch <= '9') || ch == '_'))
977
ch =
TextWindow
.PeekChar();
982
TextWindow
.AdvanceChar();
987
TextWindow
.AdvanceChar();
992
TextWindow
.AdvanceChar();
1002
TextWindow
.AdvanceChar();
1007
TextWindow
.AdvanceChar();
1012
TextWindow
.AdvanceChar();
1017
TextWindow
.AdvanceChar();
1019
if (
TextWindow
.PeekChar() is 'u' or 'U')
1021
TextWindow
.AdvanceChar();
1028
TextWindow
.AdvanceChar();
1029
if (
TextWindow
.PeekChar() is 'L' or 'l')
1031
TextWindow
.AdvanceChar();
1039
this.AddError(MakeError(start,
TextWindow
.Position - start, ErrorCode.ERR_InvalidNumber));
1053
var valueText =
TextWindow
.Intern(_builder);
1064
info.DecimalValue = this.GetValueDecimal(valueText, start,
TextWindow
.Position);
1344
var textWindowCharSpan = this.
TextWindow
.CurrentWindowSpan;
1405
TextWindow
.AdvanceChar(length);
1406
info.Text = info.StringValue =
TextWindow
.Intern(textWindowCharSpan[..length]);
1438
int start =
TextWindow
.Position;
1441
while (
TextWindow
.PeekChar() == '@')
1443
TextWindow
.AdvanceChar();
1446
var atCount =
TextWindow
.Position - start;
1454
char ch =
TextWindow
.PeekChar();
1477
if (!
TextWindow
.IsReallyAtEnd())
1497
(char.ToLower(
TextWindow
.PeekChar(1)) == 'x'))
1531
if (_identLen == 0 && this.ModeIs(LexerMode.DebuggerSyntax) &&
TextWindow
.PeekChar(1) == '>')
1534
TextWindow
.AdvanceChar(2);
1561
TextWindow
.AdvanceChar();
1585
TextWindow
.AdvanceChar();
1608
info.StringValue =
TextWindow
.Intern(_identBuffer, 0, _identLen);
1616
var valueText =
TextWindow
.Intern(_identBuffer, objectAddressOffset, _identLen - objectAddressOffset);
1637
TextWindow
.Reset(start);
1653
int start =
TextWindow
.Position;
1672
int beforeConsumed =
TextWindow
.Position;
1676
if (
TextWindow
.PeekChar() == '&')
1681
TextWindow
.Reset(beforeConsumed);
1687
consumedChar =
TextWindow
.NextChar();
1707
if (!isEscaped && (
TextWindow
.Position == beforeConsumed + 1) &&
1708
TextWindow
.PeekChar() is 'u' or 'U')
1714
TextWindow
.Reset(beforeConsumed);
1736
TextWindow
.Reset(beforeConsumed);
1754
TextWindow
.Reset(beforeConsumed);
1757
if (!
TextWindow
.IsReallyAtEnd())
1762
TextWindow
.Reset(beforeConsumed);
1784
TextWindow
.Reset(beforeConsumed);
1815
info.StringValue =
TextWindow
.Intern(_identBuffer, 0, _identLen);
1825
TextWindow
.Reset(start);
1894
char ch =
TextWindow
.PeekChar();
1922
if ((ch =
TextWindow
.PeekChar(1)) == '/')
1924
if (!this.SuppressDocumentationCommentParse &&
TextWindow
.PeekChar(2) == '/' &&
TextWindow
.PeekChar(3) != '/')
1944
if (!this.SuppressDocumentationCommentParse &&
TextWindow
.PeekChar(2) == '*' &&
1945
TextWindow
.PeekChar(3) != '*' &&
TextWindow
.PeekChar(3) != '/')
1966
if ((ch =
TextWindow
.PeekChar(1)) == '*')
1969
this.AddError(
TextWindow
.Position, width: 1, ErrorCode.ERR_UnexpectedCharacter, '@');
2000
var savePosition =
TextWindow
.Position;
2006
var text =
TextWindow
.Text.GetSubText(TextSpan.FromBounds(savePosition,
TextWindow
.Position));
2080
var position =
TextWindow
.Position;
2081
var text =
TextWindow
.Text;
2114
this.AddError(
TextWindow
.Position, s_conflictMarkerLength,
2117
var startCh = this.
TextWindow
.PeekChar();
2143
var ch = this.
TextWindow
.PeekChar();
2162
this.
TextWindow
.AdvanceChar();
2181
while (SyntaxFacts.IsNewLine(this.
TextWindow
.PeekChar()))
2183
this.
TextWindow
.AdvanceChar();
2196
var ch = this.
TextWindow
.PeekChar();
2202
this.
TextWindow
.AdvanceChar();
2226
Debug.Assert(
TextWindow
.PeekChar() == delimiter &&
TextWindow
.PeekChar(1) == '*');
2227
TextWindow
.AdvanceChar(2);
2232
if ((ch =
TextWindow
.PeekChar()) == SlidingTextWindow.InvalidCharacter &&
TextWindow
.IsReallyAtEnd())
2237
else if (ch == '*' &&
TextWindow
.PeekChar(1) == delimiter)
2239
TextWindow
.AdvanceChar(2);
2245
TextWindow
.AdvanceChar();
2253
while (!SyntaxFacts.IsNewLine(ch =
TextWindow
.PeekChar()) &&
2254
(ch != SlidingTextWindow.InvalidCharacter || !
TextWindow
.IsReallyAtEnd()))
2256
TextWindow
.AdvanceChar();
2267
switch (ch =
TextWindow
.PeekChar())
2270
TextWindow
.AdvanceChar();
2271
return
TextWindow
.TryAdvance('\n') ? SyntaxFactory.CarriageReturnLineFeed : SyntaxFactory.CarriageReturn;
2273
TextWindow
.AdvanceChar();
2278
TextWindow
.AdvanceChar();
2292
Debug.Assert(SyntaxFacts.IsWhitespace(
TextWindow
.PeekChar()));
2298
char ch =
TextWindow
.PeekChar();
2310
TextWindow
.AdvanceChar();
2340
TextWindow
,
2400
if (SyntaxFacts.IsWhitespace(
TextWindow
.PeekChar()))
2434
int lastLineStart =
TextWindow
.Position;
2440
char ch =
TextWindow
.PeekChar();
2444
if (!
TextWindow
.IsReallyAtEnd())
2454
if (lastLineStart <
TextWindow
.Position && !allWhitespace)
2459
TextWindow
.Reset(lastLineStart); // reset so directive parser can consume the starting whitespace on this line
2464
lastLineStart =
TextWindow
.Position;
2475
TextWindow
.AdvanceChar();
2507
var ch = this.
TextWindow
.PeekChar();
2513
else if (ch is SlidingTextWindow.InvalidCharacter && this.
TextWindow
.IsReallyAtEnd())
2521
this.
TextWindow
.AdvanceChar();
2566
switch (character =
TextWindow
.PeekChar())
2569
if (!
TextWindow
.IsReallyAtEnd())
2584
TextWindow
.AdvanceChar();
2589
TextWindow
.AdvanceChar();
2594
TextWindow
.AdvanceChar();
2599
TextWindow
.AdvanceChar();
2604
TextWindow
.AdvanceChar();
2609
TextWindow
.AdvanceChar();
2614
TextWindow
.AdvanceChar();
2615
if (
TextWindow
.PeekChar() == '=')
2617
TextWindow
.AdvanceChar();
2628
TextWindow
.AdvanceChar();
2629
if (
TextWindow
.PeekChar() == '=')
2631
TextWindow
.AdvanceChar();
2642
if (
TextWindow
.PeekChar(1) == '&')
2644
TextWindow
.AdvanceChar(2);
2652
if (
TextWindow
.PeekChar(1) == '|')
2654
TextWindow
.AdvanceChar(2);
2717
TextWindow
.AdvanceChar();
2736
var pos =
TextWindow
.Position;
2751
TextWindow
.Reset(pos);
2768
char ch =
TextWindow
.PeekChar();
2772
if (
TextWindow
.PeekChar(1) == '/')
2822
Debug.Assert(this.LocationIs(XmlDocCommentLocation.End) ||
TextWindow
.PeekChar() == SlidingTextWindow.InvalidCharacter);
2867
switch (ch =
TextWindow
.PeekChar())
2884
if (!
TextWindow
.IsReallyAtEnd())
2917
Debug.Assert(
TextWindow
.PeekChar() == '<');
2919
if (
TextWindow
.PeekChar(1) == '!')
2921
if (
TextWindow
.PeekChar(2) == '-'
2922
&&
TextWindow
.PeekChar(3) == '-')
2924
TextWindow
.AdvanceChar(4);
2927
else if (
TextWindow
.PeekChar(2) == '['
2928
&&
TextWindow
.PeekChar(3) == 'C'
2929
&&
TextWindow
.PeekChar(4) == 'D'
2930
&&
TextWindow
.PeekChar(5) == 'A'
2931
&&
TextWindow
.PeekChar(6) == 'T'
2932
&&
TextWindow
.PeekChar(7) == 'A'
2933
&&
TextWindow
.PeekChar(8) == '[')
2935
TextWindow
.AdvanceChar(9);
2941
TextWindow
.AdvanceChar();
2945
else if (
TextWindow
.PeekChar(1) == '/')
2947
TextWindow
.AdvanceChar(2);
2950
else if (
TextWindow
.PeekChar(1) == '?')
2952
TextWindow
.AdvanceChar(2);
2957
TextWindow
.AdvanceChar();
2966
Debug.Assert(
TextWindow
.PeekChar() == '&');
2967
TextWindow
.AdvanceChar();
2973
if (IsXmlNameStartChar(ch =
TextWindow
.PeekChar()))
2975
while (IsXmlNameChar(ch =
TextWindow
.PeekChar()))
2983
TextWindow
.AdvanceChar();
3012
TextWindow
.AdvanceChar();
3013
bool isHex =
TextWindow
.PeekChar() == 'x';
3018
TextWindow
.AdvanceChar(); // x
3019
while (SyntaxFacts.IsHexDigit(ch =
TextWindow
.PeekChar()))
3021
TextWindow
.AdvanceChar();
3032
while (SyntaxFacts.IsDecDigit(ch =
TextWindow
.PeekChar()))
3034
TextWindow
.AdvanceChar();
3044
if (
TextWindow
.PeekChar() != ';')
3089
ch =
TextWindow
.PeekChar();
3092
TextWindow
.AdvanceChar();
3134
if (
TextWindow
.PeekChar() == ']' &&
TextWindow
.PeekChar(1) == ']' &&
TextWindow
.PeekChar(2) == '>')
3136
TextWindow
.AdvanceChar(3);
3144
var ch =
TextWindow
.PeekChar();
3148
if (!
TextWindow
.IsReallyAtEnd())
3163
if (this.StyleIs(XmlDocCommentStyle.Delimited) &&
TextWindow
.PeekChar(1) == '/')
3173
if (
TextWindow
.PeekChar(1) == ']' &&
TextWindow
.PeekChar(2) == '>')
3187
TextWindow
.AdvanceChar();
3234
switch (ch =
TextWindow
.PeekChar())
3241
TextWindow
.AdvanceChar();
3246
if (
TextWindow
.PeekChar(1) == '>')
3248
TextWindow
.AdvanceChar(2);
3256
TextWindow
.AdvanceChar();
3261
TextWindow
.AdvanceChar();
3266
TextWindow
.AdvanceChar();
3271
TextWindow
.AdvanceChar();
3281
if (!
TextWindow
.IsReallyAtEnd())
3290
if (this.StyleIs(XmlDocCommentStyle.Delimited) &&
TextWindow
.PeekChar(1) == '/')
3313
TextWindow
.AdvanceChar();
3327
int start =
TextWindow
.Position;
3331
char ch =
TextWindow
.PeekChar();
3343
TextWindow
.AdvanceChar();
3351
info.Text =
TextWindow
.GetText(start,
TextWindow
.Position - start, intern: true);
3408
switch (ch =
TextWindow
.PeekChar())
3413
TextWindow
.AdvanceChar();
3423
TextWindow
.AdvanceChar();
3436
TextWindow
.AdvanceChar();
3446
if (!
TextWindow
.IsReallyAtEnd())
3473
var ch =
TextWindow
.PeekChar();
3502
if (!
TextWindow
.IsReallyAtEnd())
3511
if (this.StyleIs(XmlDocCommentStyle.Delimited) &&
TextWindow
.PeekChar(1) == '/')
3526
TextWindow
.AdvanceChar();
3565
switch (
TextWindow
.PeekChar())
3572
if (!
TextWindow
.IsReallyAtEnd())
3580
info.Text = info.StringValue =
TextWindow
.NextChar().ToString();
3625
int beforeConsumed =
TextWindow
.Position;
3626
char consumedChar =
TextWindow
.NextChar();
3657
if (!
TextWindow
.IsReallyAtEnd())
3667
TextWindow
.Reset(beforeConsumed);
3672
TextWindow
.Reset(beforeConsumed);
3675
TextWindow
.Reset(beforeConsumed);
3701
Debug.Assert(
TextWindow
.Position > beforeConsumed, "First character or entity has been consumed.");
3731
if (
TextWindow
.PeekChar() == '.')
3829
TextWindow
.Reset(beforeConsumed);
3862
if (
TextWindow
.PeekChar() == '@')
3864
TextWindow
.NextChar();
3875
else if (
TextWindow
.PeekChar() == '&')
3884
char bad =
TextWindow
.NextChar();
3913
char peekCh =
TextWindow
.PeekChar();
3918
TextWindow
.AdvanceChar();
3924
int pos =
TextWindow
.Position;
3934
TextWindow
.Reset(pos);
4031
switch (ch =
TextWindow
.PeekChar())
4034
if (
TextWindow
.PeekChar(1) == ']' &&
TextWindow
.PeekChar(2) == '>')
4036
TextWindow
.AdvanceChar(3);
4049
if (!
TextWindow
.IsReallyAtEnd())
4075
var ch =
TextWindow
.PeekChar();
4079
if (
TextWindow
.PeekChar(1) == ']' &&
TextWindow
.PeekChar(2) == '>')
4093
if (!
TextWindow
.IsReallyAtEnd())
4102
if (this.StyleIs(XmlDocCommentStyle.Delimited) &&
TextWindow
.PeekChar(1) == '/')
4117
TextWindow
.AdvanceChar();
4153
switch (ch =
TextWindow
.PeekChar())
4156
if (
TextWindow
.PeekChar(1) == '-')
4158
if (
TextWindow
.PeekChar(2) == '>')
4160
TextWindow
.AdvanceChar(3);
4166
TextWindow
.AdvanceChar(2);
4180
if (!
TextWindow
.IsReallyAtEnd())
4205
var ch =
TextWindow
.PeekChar();
4209
if (
TextWindow
.PeekChar(1) == '-')
4223
if (!
TextWindow
.IsReallyAtEnd())
4232
if (this.StyleIs(XmlDocCommentStyle.Delimited) &&
TextWindow
.PeekChar(1) == '/')
4247
TextWindow
.AdvanceChar();
4284
switch (ch =
TextWindow
.PeekChar())
4287
if (
TextWindow
.PeekChar(1) == '>')
4289
TextWindow
.AdvanceChar(2);
4302
if (!
TextWindow
.IsReallyAtEnd())
4329
var ch =
TextWindow
.PeekChar();
4333
if (
TextWindow
.PeekChar(1) == '>')
4347
if (!
TextWindow
.IsReallyAtEnd())
4356
if (this.StyleIs(XmlDocCommentStyle.Delimited) &&
TextWindow
.PeekChar(1) == '/')
4371
TextWindow
.AdvanceChar();
4383
var start =
TextWindow
.Position;
4392
if (
TextWindow
.PeekChar() == '/'
4393
&&
TextWindow
.PeekChar(1) == '*'
4394
&&
TextWindow
.PeekChar(2) == '*'
4395
&&
TextWindow
.PeekChar(3) != '*')
4397
TextWindow
.AdvanceChar(3);
4413
char ch =
TextWindow
.PeekChar();
4420
TextWindow
.AdvanceChar();
4424
if (this.StyleIs(XmlDocCommentStyle.SingleLine) &&
TextWindow
.PeekChar(1) == '/' &&
TextWindow
.PeekChar(2) == '/' &&
TextWindow
.PeekChar(3) != '/')
4426
TextWindow
.AdvanceChar(3);
4438
while (
TextWindow
.PeekChar() == '*' &&
TextWindow
.PeekChar(1) != '/')
4440
TextWindow
.AdvanceChar();
4453
if (
TextWindow
.PeekChar() == '*' &&
TextWindow
.PeekChar(1) == '/')
4455
TextWindow
.AdvanceChar(2);
4482
TextWindow
.Reset(start);
4501
if (
TextWindow
.PeekChar() == '*' &&
TextWindow
.PeekChar(1) == '/')
4503
TextWindow
.AdvanceChar(2);
4517
char ch =
TextWindow
.PeekChar();
4539
char ch =
TextWindow
.PeekChar();
4558
if (this.StyleIs(XmlDocCommentStyle.Delimited) &&
TextWindow
.PeekChar(1) == '/')
4584
if (
TextWindow
.PeekChar() == '\\')
4586
var ch2 =
TextWindow
.PeekChar(1);
4605
return
TextWindow
.PeekChar();
4611
int position =
TextWindow
.Position;
4617
TextWindow
.Reset(position);
4623
var ch =
TextWindow
.PeekChar();
4627
var ch2 =
TextWindow
.PeekChar(1);
4636
TextWindow
.AdvanceChar();
4650
int start =
TextWindow
.Position;
4651
char character =
TextWindow
.PeekChar();
4653
TextWindow
.AdvanceChar();
4655
character =
TextWindow
.PeekChar();
4660
TextWindow
.AdvanceChar();
4661
if (!SyntaxFacts.IsHexDigit(
TextWindow
.PeekChar()))
4672
character =
TextWindow
.PeekChar();
4684
TextWindow
.AdvanceChar();
4705
TextWindow
.AdvanceChar();
4706
if (!SyntaxFacts.IsHexDigit(
TextWindow
.PeekChar()))
4717
char ch2 =
TextWindow
.PeekChar();
4732
TextWindow
.AdvanceChar();
4756
Debug.Assert(
TextWindow
.PeekChar() == '&');
4759
TextWindow
.AdvanceChar();
4763
switch (
TextWindow
.PeekChar())
4766
if (
TextWindow
.AdvanceIfMatches("lt;"))
4773
if (
TextWindow
.AdvanceIfMatches("gt;"))
4780
if (
TextWindow
.AdvanceIfMatches("amp;"))
4785
else if (
TextWindow
.AdvanceIfMatches("apos;"))
4792
if (
TextWindow
.AdvanceIfMatches("quot;"))
4800
TextWindow
.AdvanceChar(); //#
4804
if (
TextWindow
.AdvanceIfMatches("x"))
4807
while (SyntaxFacts.IsHexDigit(digit =
TextWindow
.PeekChar()))
4809
TextWindow
.AdvanceChar();
4825
while (SyntaxFacts.IsDecDigit(digit =
TextWindow
.PeekChar()))
4827
TextWindow
.AdvanceChar();
4841
if (
TextWindow
.AdvanceIfMatches(";"))
4857
TextWindow
.Position - start,
Parser\Lexer_RawStringLiteral.cs (42)
19
var start =
TextWindow
.Position;
20
while (
TextWindow
.PeekChar() == ch)
21
TextWindow
.AdvanceChar();
23
return
TextWindow
.Position - start;
45
var ch =
TextWindow
.PeekChar();
50
TextWindow
.AdvanceChar();
55
=> currentChar == SlidingTextWindow.InvalidCharacter &&
TextWindow
.IsReallyAtEnd();
68
if (SyntaxFacts.IsNewLine(
TextWindow
.PeekChar()))
91
var valueLength =
TextWindow
.Position - afterStartDelimiter;
93
info.StringValue =
TextWindow
.GetText(
132
var currentChar =
TextWindow
.PeekChar();
137
this.AddError(
TextWindow
.Position, width:
TextWindow
.GetNewLineWidth(), ErrorCode.ERR_UnterminatedRawString);
142
this.AddError(
TextWindow
.Position, width: 0, ErrorCode.ERR_UnterminatedRawString);
149
TextWindow
.AdvanceChar();
153
var beforeEndDelimiter =
TextWindow
.Position;
166
position:
TextWindow
.Position - excessQuoteCount,
175
info.StringValue =
TextWindow
.GetText(
196
var afterStartDelimiter =
TextWindow
.Position;
197
Debug.Assert(SyntaxFacts.IsNewLine(
TextWindow
.PeekChar()));
211
position:
TextWindow
.Position - startingQuoteCount,
222
var tokenEnd =
TextWindow
.Position;
223
TextWindow
.Reset(afterStartDelimiter);
224
Debug.Assert(SyntaxFacts.IsNewLine(
TextWindow
.PeekChar()));
238
info.StringValue = this.HasErrors ? "" :
TextWindow
.Intern(_builder);
242
TextWindow
.Reset(tokenEnd);
254
TextWindow
.AdvancePastNewLine();
269
position:
TextWindow
.Position - excessQuoteCount,
282
var currentChar =
TextWindow
.PeekChar();
285
this.AddError(
TextWindow
.Position, width: 0, ErrorCode.ERR_UnterminatedRawString);
299
position:
TextWindow
.Position - currentQuoteCount,
307
TextWindow
.AdvanceChar();
317
Debug.Assert(SyntaxFacts.IsNewLine(
TextWindow
.PeekChar()));
319
var newLineWidth =
TextWindow
.GetNewLineWidth();
324
_builder.Append(
TextWindow
.PeekChar());
326
TextWindow
.AdvanceChar();
329
var lineStartPosition =
TextWindow
.Position;
341
var isBlankLine = SyntaxFacts.IsNewLine(
TextWindow
.PeekChar());
352
width:
TextWindow
.Position - lineStartPosition,
360
width:
TextWindow
.Position - lineStartPosition,
380
var currentChar =
TextWindow
.PeekChar();
386
TextWindow
.AdvanceChar();
Parser\Lexer_StringLiteral.cs (113)
16
var quoteCharacter =
TextWindow
.PeekChar();
19
if (
TextWindow
.PeekChar() == '"' &&
20
TextWindow
.PeekChar(1) == '"' &&
21
TextWindow
.PeekChar(2) == '"')
35
TextWindow
.AdvanceChar();
40
char ch =
TextWindow
.PeekChar();
54
TextWindow
.AdvanceChar();
58
(ch == SlidingTextWindow.InvalidCharacter &&
TextWindow
.IsReallyAtEnd()))
69
TextWindow
.AdvanceChar();
85
info.StringValue =
TextWindow
.Intern(_builder);
109
info.StringValue =
TextWindow
.Intern(_builder);
120
if (
TextWindow
.PeekChar() is ('u' or 'U') &&
TextWindow
.PeekChar(1) == '8')
122
TextWindow
.AdvanceChar(2);
131
var start =
TextWindow
.Position;
133
char ch =
TextWindow
.NextChar();
136
ch =
TextWindow
.NextChar();
157
this.AddError(start,
TextWindow
.Position - start, info.Code, info.Arguments);
179
TextWindow
.Reset(start);
185
this.AddError(start,
TextWindow
.Position - start, ErrorCode.ERR_IllegalEscape);
194
Debug.Assert(
TextWindow
.PeekChar() == '@');
197
var start =
TextWindow
.Position;
198
while (
TextWindow
.PeekChar() == '@')
200
TextWindow
.AdvanceChar();
203
if (
TextWindow
.Position - start >= 2)
205
this.AddError(start, width:
TextWindow
.Position - start, ErrorCode.ERR_IllegalAtSequence);
208
Debug.Assert(
TextWindow
.PeekChar() == '"');
209
TextWindow
.AdvanceChar();
213
var ch =
TextWindow
.PeekChar();
216
TextWindow
.AdvanceChar();
217
if (
TextWindow
.PeekChar() == '"')
220
TextWindow
.AdvanceChar();
229
if (ch == SlidingTextWindow.InvalidCharacter &&
TextWindow
.IsReallyAtEnd())
237
TextWindow
.AdvanceChar();
361
char ch = _lexer.
TextWindow
.PeekChar();
364
(ch == SlidingTextWindow.InvalidCharacter && _lexer.
TextWindow
.IsReallyAtEnd());
381
var start = _lexer.
TextWindow
.Position;
383
Debug.Assert(_lexer.
TextWindow
.Position != start);
385
openQuoteRange = start.._lexer.
TextWindow
.Position;
391
closeQuoteRange = _lexer.
TextWindow
.Position.._lexer.
TextWindow
.Position;
510
var closeQuotePosition = _lexer.
TextWindow
.Position;
524
closeQuoteRange = closeQuotePosition.._lexer.
TextWindow
.Position;
531
if (_lexer.
TextWindow
.PeekChar() != '"')
538
IsAtEnd(allowNewline: true) ? _lexer.
TextWindow
.Position - 1 : _lexer.
TextWindow
.Position,
544
_lexer.
TextWindow
.AdvanceChar(); // "
554
if (_lexer.
TextWindow
.PeekChar() != '"')
561
IsAtEnd(allowNewline: true) ? _lexer.
TextWindow
.Position - 1 : _lexer.
TextWindow
.Position,
579
position: _lexer.
TextWindow
.Position - excessQuoteCount,
596
_lexer.
TextWindow
.Position - 1, width: 1, ErrorCode.ERR_UnterminatedRawString));
598
else if (_lexer.
TextWindow
.PeekChar() == '"')
607
position: _lexer.
TextWindow
.Position - closeQuoteCount,
613
_lexer.
TextWindow
.AdvancePastNewLine();
626
position: _lexer.
TextWindow
.Position - excessQuoteCount,
658
switch (_lexer.
TextWindow
.PeekChar())
678
var escapeStart = _lexer.
TextWindow
.Position;
682
TrySetError(_lexer.MakeError(escapeStart, _lexer.
TextWindow
.Position - escapeStart, ErrorCode.ERR_EscapedCurly, ch));
687
_lexer.
TextWindow
.AdvanceChar();
694
_lexer.
TextWindow
.AdvanceChar();
705
var beforeQuotesPosition = _lexer.
TextWindow
.Position;
713
_lexer.
TextWindow
.Position - closeQuoteCount, closeQuoteCount, ErrorCode.ERR_RawStringMustContainContent));
714
_lexer.
TextWindow
.Reset(beforeQuotesPosition);
728
var startPosition = _lexer.
TextWindow
.Position;
729
if (SyntaxFacts.IsNewLine(_lexer.
TextWindow
.PeekChar()))
731
_lexer.
TextWindow
.AdvancePastNewLine();
735
_lexer.
TextWindow
.Reset(startPosition);
771
if (_lexer.
TextWindow
.PeekChar(1) != '"')
777
_lexer.
TextWindow
.AdvanceChar(2); // ""
783
var beforeQuotePosition = _lexer.
TextWindow
.Position;
790
_lexer.
TextWindow
.Reset(beforeQuotePosition);
803
var pos = _lexer.
TextWindow
.Position;
804
_lexer.
TextWindow
.AdvanceChar(); // }
807
if (_lexer.
TextWindow
.PeekChar() == '}')
809
_lexer.
TextWindow
.AdvanceChar(); // }
829
position: _lexer.
TextWindow
.Position - closeBraceCount,
851
if (_lexer.
TextWindow
.PeekChar(1) == '{')
853
_lexer.
TextWindow
.AdvanceChar(2); // {{
857
int openBracePosition = _lexer.
TextWindow
.Position;
858
_lexer.
TextWindow
.AdvanceChar();
860
int closeBracePosition = _lexer.
TextWindow
.Position;
861
if (_lexer.
TextWindow
.PeekChar() == '}')
863
_lexer.
TextWindow
.AdvanceChar();
873
new Range(closeBracePosition, _lexer.
TextWindow
.Position)));
886
var beforeOpenBracesPosition = _lexer.
TextWindow
.Position;
894
var afterOpenBracePosition = _lexer.
TextWindow
.Position;
908
var beforeCloseBracePosition = _lexer.
TextWindow
.Position;
931
_lexer.
TextWindow
.Reset(beforeCloseBracePosition + startingDollarSignCount);
937
beforeCloseBracePosition.._lexer.
TextWindow
.Position));
953
Debug.Assert(_lexer.
TextWindow
.PeekChar() == ':');
954
_lexer.
TextWindow
.AdvanceChar();
957
char ch = _lexer.
TextWindow
.PeekChar();
961
var pos = _lexer.
TextWindow
.Position;
970
if (kind is InterpolatedStringKind.Verbatim && _lexer.
TextWindow
.PeekChar(1) == '"')
972
_lexer.
TextWindow
.AdvanceChar(2); // ""
982
_lexer.
TextWindow
.Position, 1, ErrorCode.ERR_UnexpectedCharacter, ch));
983
_lexer.
TextWindow
.AdvanceChar();
995
_lexer.
TextWindow
.AdvanceChar();
1008
char ch = _lexer.
TextWindow
.PeekChar();
1022
TrySetError(_lexer.MakeError(_lexer.
TextWindow
.Position, 1, ErrorCode.ERR_SyntaxError, endingChar.ToString()));
1023
_lexer.
TextWindow
.AdvanceChar();
1040
colonRange = new Range(_lexer.
TextWindow
.Position, _lexer.
TextWindow
.Position + 1);
1054
TrySetError(_lexer.MakeError(_lexer.
TextWindow
.Position, 1, ErrorCode.ERR_SyntaxError, endingChar.ToString()));
1080
if (_lexer.
TextWindow
.PeekChar(1) == '*')
1092
switch (_lexer.
TextWindow
.PeekChar(1))
1101
_lexer.
TextWindow
.AdvanceChar();
1118
_lexer.
TextWindow
.AdvanceChar();
1139
Debug.Assert(start == _lexer.
TextWindow
.PeekChar());
1140
_lexer.
TextWindow
.AdvanceChar();
1142
if (_lexer.
TextWindow
.PeekChar() == end)
1144
_lexer.
TextWindow
.AdvanceChar();
Parser\QuickScanner.cs (3)
197
var textWindowCharSpan =
TextWindow
.CurrentWindowSpan;
246
TextWindow
.AdvanceChar(tokenLength);
266
lexer.
TextWindow
.Reset(lexer.LexemeStartPosition);
Parser\SyntaxParser.cs (1)
141
var size = Math.Min(CachedTokenArraySize, this.lexer.
TextWindow
.Text.Length / 2);
Syntax\SyntaxTokenParser.cs (5)
52
var startingPosition = _lexer.
TextWindow
.Position;
66
var startingPosition = _lexer.
TextWindow
.Position;
81
var startingPosition = _lexer.
TextWindow
.Position;
94
if (position < _lexer.
TextWindow
.Position)
97
_lexer.
TextWindow
.Reset(position);
Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests (5)
LexicalAndXml\LexicalTests.cs (5)
4619
Assert.Equal(SlidingTextWindow.DefaultWindowLength - 2, SlidingTextWindow.TestAccessor.GetOffset(lexer.
TextWindow
));
4623
Assert.Equal(SlidingTextWindow.DefaultWindowLength - 1, SlidingTextWindow.TestAccessor.GetOffset(lexer.
TextWindow
));
4628
Assert.Equal(code.IndexOf('.'), SlidingTextWindow.TestAccessor.GetCharacterWindowStartPositionInText(lexer.
TextWindow
));
4629
Assert.Equal(2, SlidingTextWindow.TestAccessor.GetOffset(lexer.
TextWindow
));
4630
Assert.StartsWith("..0;", SlidingTextWindow.TestAccessor.GetCharacterWindow(lexer.
TextWindow
).AsSpan().ToString());