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;
109
=>
TextWindow
.GetText(LexemeStartPosition, intern: false);
112
=>
TextWindow
.GetText(LexemeStartPosition, intern: true);
115
=> 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);
295
this.LexSyntaxTrivia(isFollowingToken:
TextWindow
.Position > 0, isTrailing: false, triviaList: ref _leadingTriviaCache);
314
this.LexSyntaxTrivia(isFollowingToken:
TextWindow
.Position > 0, isTrailing: false, triviaList: ref _leadingTriviaCache);
434
int startingPosition =
TextWindow
.Position;
437
character =
TextWindow
.PeekChar();
446
TextWindow
.AdvanceChar();
447
info.Kind =
TextWindow
.TryAdvance('=') ? SyntaxKind.SlashEqualsToken : SyntaxKind.SlashToken;
451
if (this.
TextWindow
.PeekChar(1) is >= '0' and <= '9')
453
var atDotPosition = this.
TextWindow
.Position;
463
if (this.
TextWindow
.PreviousChar() is '.')
466
TextWindow
.AdvanceChar();
477
TextWindow
.AdvanceChar();
484
TextWindow
.AdvanceChar();
489
TextWindow
.AdvanceChar();
490
info.Kind =
TextWindow
.TryAdvance(':') ? SyntaxKind.ColonColonToken : SyntaxKind.ColonToken;
494
TextWindow
.AdvanceChar();
499
TextWindow
.AdvanceChar();
504
TextWindow
.AdvanceChar();
505
info.Kind =
TextWindow
.TryAdvance('=') ? SyntaxKind.ExclamationEqualsToken : SyntaxKind.ExclamationToken;
509
TextWindow
.AdvanceChar();
511
TextWindow
.TryAdvance('=') ? SyntaxKind.EqualsEqualsToken :
512
TextWindow
.TryAdvance('>') ? SyntaxKind.EqualsGreaterThanToken : SyntaxKind.EqualsToken;
516
TextWindow
.AdvanceChar();
517
info.Kind =
TextWindow
.TryAdvance('=') ? SyntaxKind.AsteriskEqualsToken : SyntaxKind.AsteriskToken;
521
TextWindow
.AdvanceChar();
526
TextWindow
.AdvanceChar();
531
TextWindow
.AdvanceChar();
536
TextWindow
.AdvanceChar();
541
TextWindow
.AdvanceChar();
546
TextWindow
.AdvanceChar();
551
TextWindow
.AdvanceChar();
552
info.Kind =
TextWindow
.TryAdvance('?')
553
?
TextWindow
.TryAdvance('=') ? SyntaxKind.QuestionQuestionEqualsToken : SyntaxKind.QuestionQuestionToken
558
TextWindow
.AdvanceChar();
560
TextWindow
.TryAdvance('=') ? SyntaxKind.PlusEqualsToken :
561
TextWindow
.TryAdvance('+') ? SyntaxKind.PlusPlusToken : SyntaxKind.PlusToken;
565
TextWindow
.AdvanceChar();
567
TextWindow
.TryAdvance('=') ? SyntaxKind.MinusEqualsToken :
568
TextWindow
.TryAdvance('-') ? SyntaxKind.MinusMinusToken :
569
TextWindow
.TryAdvance('>') ? SyntaxKind.MinusGreaterThanToken : SyntaxKind.MinusToken;
573
TextWindow
.AdvanceChar();
574
info.Kind =
TextWindow
.TryAdvance('=') ? SyntaxKind.PercentEqualsToken : SyntaxKind.PercentToken;
578
TextWindow
.AdvanceChar();
580
TextWindow
.TryAdvance('=') ? SyntaxKind.AmpersandEqualsToken :
581
TextWindow
.TryAdvance('&') ? SyntaxKind.AmpersandAmpersandToken : SyntaxKind.AmpersandToken;
585
TextWindow
.AdvanceChar();
586
info.Kind =
TextWindow
.TryAdvance('=') ? SyntaxKind.CaretEqualsToken : SyntaxKind.CaretToken;
590
TextWindow
.AdvanceChar();
592
TextWindow
.TryAdvance('=') ? SyntaxKind.BarEqualsToken :
593
TextWindow
.TryAdvance('|') ? SyntaxKind.BarBarToken : SyntaxKind.BarToken;
597
TextWindow
.AdvanceChar();
599
TextWindow
.TryAdvance('=') ? SyntaxKind.LessThanEqualsToken :
600
TextWindow
.TryAdvance('<')
601
?
TextWindow
.TryAdvance('=') ? SyntaxKind.LessThanLessThanEqualsToken : SyntaxKind.LessThanLessThanToken
606
TextWindow
.AdvanceChar();
607
info.Kind =
TextWindow
.TryAdvance('=') ? SyntaxKind.GreaterThanEqualsToken : SyntaxKind.GreaterThanToken;
614
Debug.Assert(
TextWindow
.PeekChar() == '@');
616
if (
TextWindow
.PeekChar(1) == ':')
621
this.AddError(
TextWindow
.Position + 1, width: 1, ErrorCode.ERR_ExpectedVerbatimLiteral);
670
if (!
TextWindow
.IsReallyAtEnd())
701
TextWindow
.AdvanceChar();
706
if (char.IsHighSurrogate(character) && char.IsLowSurrogate(
TextWindow
.PeekChar()))
707
TextWindow
.AdvanceChar();
719
int end =
TextWindow
.Text.Length;
720
info.Text =
TextWindow
.Text.ToString(TextSpan.FromBounds(startingPosition, end));
721
TextWindow
.Reset(end);
738
Debug.Assert(
TextWindow
.PeekChar() == '@');
741
while (
TextWindow
.PeekChar(index) == '@')
746
if (
TextWindow
.PeekChar(index) == '"')
752
else if (
TextWindow
.PeekChar(index) == '$')
764
Debug.Assert(
TextWindow
.PeekChar() == '$');
766
if (
TextWindow
.PeekChar(1) is '$' or '@' or '"')
791
int start =
TextWindow
.Position;
792
while (
TextWindow
.PeekChar() is >= '0' and <= '9')
794
TextWindow
.AdvanceChar();
797
return start <
TextWindow
.Position;
803
if (
TextWindow
.PeekChar() == '_')
818
char ch =
TextWindow
.PeekChar();
835
TextWindow
.AdvanceChar();
846
int start =
TextWindow
.Position;
861
ch =
TextWindow
.PeekChar();
864
ch =
TextWindow
.PeekChar(1);
867
TextWindow
.AdvanceChar(2);
873
TextWindow
.AdvanceChar(2);
884
if (
TextWindow
.PeekChar() is 'L' or 'l')
886
TextWindow
.AdvanceChar();
888
if (
TextWindow
.PeekChar() is 'u' or 'U')
890
TextWindow
.AdvanceChar();
894
else if (
TextWindow
.PeekChar() is 'u' or 'U')
896
TextWindow
.AdvanceChar();
898
if (
TextWindow
.PeekChar() is 'L' or 'l')
900
TextWindow
.AdvanceChar();
909
if (this.ModeIs(LexerMode.DebuggerSyntax) &&
TextWindow
.PeekChar() == '#')
912
TextWindow
.AdvanceChar();
919
if ((ch =
TextWindow
.PeekChar()) == '.')
921
var ch2 =
TextWindow
.PeekChar(1);
926
TextWindow
.AdvanceChar();
933
TextWindow
.Reset(start);
938
if ((ch =
TextWindow
.PeekChar()) is 'E' or 'e')
941
TextWindow
.AdvanceChar();
943
if ((ch =
TextWindow
.PeekChar()) is '-' or '+')
946
TextWindow
.AdvanceChar();
949
if (!(((ch =
TextWindow
.PeekChar()) >= '0' && ch <= '9') || ch == '_'))
962
ch =
TextWindow
.PeekChar();
967
TextWindow
.AdvanceChar();
972
TextWindow
.AdvanceChar();
977
TextWindow
.AdvanceChar();
987
TextWindow
.AdvanceChar();
992
TextWindow
.AdvanceChar();
997
TextWindow
.AdvanceChar();
1002
TextWindow
.AdvanceChar();
1004
if (
TextWindow
.PeekChar() is 'u' or 'U')
1006
TextWindow
.AdvanceChar();
1013
TextWindow
.AdvanceChar();
1014
if (
TextWindow
.PeekChar() is 'L' or 'l')
1016
TextWindow
.AdvanceChar();
1024
this.AddError(MakeError(start,
TextWindow
.Position - start, ErrorCode.ERR_InvalidNumber));
1038
var valueText =
TextWindow
.Intern(_builder);
1049
info.DecimalValue = this.GetValueDecimal(valueText, start,
TextWindow
.Position);
1329
var textWindowCharSpan = this.
TextWindow
.CurrentWindowSpan;
1390
TextWindow
.AdvanceChar(length);
1391
info.Text = info.StringValue =
TextWindow
.Intern(textWindowCharSpan[..length]);
1423
int start =
TextWindow
.Position;
1426
while (
TextWindow
.PeekChar() == '@')
1428
TextWindow
.AdvanceChar();
1431
var atCount =
TextWindow
.Position - start;
1439
char ch =
TextWindow
.PeekChar();
1462
if (!
TextWindow
.IsReallyAtEnd())
1482
(char.ToLower(
TextWindow
.PeekChar(1)) == 'x'))
1516
if (_identLen == 0 && this.ModeIs(LexerMode.DebuggerSyntax) &&
TextWindow
.PeekChar(1) == '>')
1519
TextWindow
.AdvanceChar(2);
1546
TextWindow
.AdvanceChar();
1570
TextWindow
.AdvanceChar();
1593
info.StringValue =
TextWindow
.Intern(_identBuffer, 0, _identLen);
1601
var valueText =
TextWindow
.Intern(_identBuffer, objectAddressOffset, _identLen - objectAddressOffset);
1622
TextWindow
.Reset(start);
1638
int start =
TextWindow
.Position;
1657
int beforeConsumed =
TextWindow
.Position;
1661
if (
TextWindow
.PeekChar() == '&')
1666
TextWindow
.Reset(beforeConsumed);
1672
consumedChar =
TextWindow
.NextChar();
1692
if (!isEscaped && (
TextWindow
.Position == beforeConsumed + 1) &&
1693
TextWindow
.PeekChar() is 'u' or 'U')
1699
TextWindow
.Reset(beforeConsumed);
1721
TextWindow
.Reset(beforeConsumed);
1739
TextWindow
.Reset(beforeConsumed);
1742
if (!
TextWindow
.IsReallyAtEnd())
1747
TextWindow
.Reset(beforeConsumed);
1769
TextWindow
.Reset(beforeConsumed);
1800
info.StringValue =
TextWindow
.Intern(_identBuffer, 0, _identLen);
1810
TextWindow
.Reset(start);
1879
char ch =
TextWindow
.PeekChar();
1907
if ((ch =
TextWindow
.PeekChar(1)) == '/')
1909
if (!this.SuppressDocumentationCommentParse &&
TextWindow
.PeekChar(2) == '/' &&
TextWindow
.PeekChar(3) != '/')
1929
if (!this.SuppressDocumentationCommentParse &&
TextWindow
.PeekChar(2) == '*' &&
1930
TextWindow
.PeekChar(3) != '*' &&
TextWindow
.PeekChar(3) != '/')
1951
if ((ch =
TextWindow
.PeekChar(1)) == '*')
1954
this.AddError(
TextWindow
.Position, width: 1, ErrorCode.ERR_UnexpectedCharacter, '@');
1985
var savePosition =
TextWindow
.Position;
1991
var text =
TextWindow
.Text.GetSubText(TextSpan.FromBounds(savePosition,
TextWindow
.Position));
2065
var position =
TextWindow
.Position;
2066
var text =
TextWindow
.Text;
2099
this.AddError(
TextWindow
.Position, s_conflictMarkerLength,
2102
var startCh = this.
TextWindow
.PeekChar();
2128
var ch = this.
TextWindow
.PeekChar();
2147
this.
TextWindow
.AdvanceChar();
2166
while (SyntaxFacts.IsNewLine(this.
TextWindow
.PeekChar()))
2168
this.
TextWindow
.AdvanceChar();
2181
var ch = this.
TextWindow
.PeekChar();
2187
this.
TextWindow
.AdvanceChar();
2211
Debug.Assert(
TextWindow
.PeekChar() == delimiter &&
TextWindow
.PeekChar(1) == '*');
2212
TextWindow
.AdvanceChar(2);
2217
if ((ch =
TextWindow
.PeekChar()) == SlidingTextWindow.InvalidCharacter &&
TextWindow
.IsReallyAtEnd())
2222
else if (ch == '*' &&
TextWindow
.PeekChar(1) == delimiter)
2224
TextWindow
.AdvanceChar(2);
2230
TextWindow
.AdvanceChar();
2238
while (!SyntaxFacts.IsNewLine(ch =
TextWindow
.PeekChar()) &&
2239
(ch != SlidingTextWindow.InvalidCharacter || !
TextWindow
.IsReallyAtEnd()))
2241
TextWindow
.AdvanceChar();
2252
switch (ch =
TextWindow
.PeekChar())
2255
TextWindow
.AdvanceChar();
2256
return
TextWindow
.TryAdvance('\n') ? SyntaxFactory.CarriageReturnLineFeed : SyntaxFactory.CarriageReturn;
2258
TextWindow
.AdvanceChar();
2263
TextWindow
.AdvanceChar();
2277
Debug.Assert(SyntaxFacts.IsWhitespace(
TextWindow
.PeekChar()));
2283
char ch =
TextWindow
.PeekChar();
2295
TextWindow
.AdvanceChar();
2325
TextWindow
,
2385
if (SyntaxFacts.IsWhitespace(
TextWindow
.PeekChar()))
2419
int lastLineStart =
TextWindow
.Position;
2425
char ch =
TextWindow
.PeekChar();
2429
if (!
TextWindow
.IsReallyAtEnd())
2439
if (lastLineStart <
TextWindow
.Position && !allWhitespace)
2444
TextWindow
.Reset(lastLineStart); // reset so directive parser can consume the starting whitespace on this line
2449
lastLineStart =
TextWindow
.Position;
2460
TextWindow
.AdvanceChar();
2492
var ch = this.
TextWindow
.PeekChar();
2498
else if (ch is SlidingTextWindow.InvalidCharacter && this.
TextWindow
.IsReallyAtEnd())
2506
this.
TextWindow
.AdvanceChar();
2551
switch (character =
TextWindow
.PeekChar())
2554
if (!
TextWindow
.IsReallyAtEnd())
2569
TextWindow
.AdvanceChar();
2574
TextWindow
.AdvanceChar();
2579
TextWindow
.AdvanceChar();
2584
TextWindow
.AdvanceChar();
2589
TextWindow
.AdvanceChar();
2594
TextWindow
.AdvanceChar();
2599
TextWindow
.AdvanceChar();
2600
if (
TextWindow
.PeekChar() == '=')
2602
TextWindow
.AdvanceChar();
2613
TextWindow
.AdvanceChar();
2614
if (
TextWindow
.PeekChar() == '=')
2616
TextWindow
.AdvanceChar();
2627
if (
TextWindow
.PeekChar(1) == '&')
2629
TextWindow
.AdvanceChar(2);
2637
if (
TextWindow
.PeekChar(1) == '|')
2639
TextWindow
.AdvanceChar(2);
2702
TextWindow
.AdvanceChar();
2721
var pos =
TextWindow
.Position;
2736
TextWindow
.Reset(pos);
2753
char ch =
TextWindow
.PeekChar();
2757
if (
TextWindow
.PeekChar(1) == '/')
2807
Debug.Assert(this.LocationIs(XmlDocCommentLocation.End) ||
TextWindow
.PeekChar() == SlidingTextWindow.InvalidCharacter);
2852
switch (ch =
TextWindow
.PeekChar())
2869
if (!
TextWindow
.IsReallyAtEnd())
2902
Debug.Assert(
TextWindow
.PeekChar() == '<');
2904
if (
TextWindow
.PeekChar(1) == '!')
2906
if (
TextWindow
.PeekChar(2) == '-'
2907
&&
TextWindow
.PeekChar(3) == '-')
2909
TextWindow
.AdvanceChar(4);
2912
else if (
TextWindow
.PeekChar(2) == '['
2913
&&
TextWindow
.PeekChar(3) == 'C'
2914
&&
TextWindow
.PeekChar(4) == 'D'
2915
&&
TextWindow
.PeekChar(5) == 'A'
2916
&&
TextWindow
.PeekChar(6) == 'T'
2917
&&
TextWindow
.PeekChar(7) == 'A'
2918
&&
TextWindow
.PeekChar(8) == '[')
2920
TextWindow
.AdvanceChar(9);
2926
TextWindow
.AdvanceChar();
2930
else if (
TextWindow
.PeekChar(1) == '/')
2932
TextWindow
.AdvanceChar(2);
2935
else if (
TextWindow
.PeekChar(1) == '?')
2937
TextWindow
.AdvanceChar(2);
2942
TextWindow
.AdvanceChar();
2951
Debug.Assert(
TextWindow
.PeekChar() == '&');
2952
TextWindow
.AdvanceChar();
2958
if (IsXmlNameStartChar(ch =
TextWindow
.PeekChar()))
2960
while (IsXmlNameChar(ch =
TextWindow
.PeekChar()))
2968
TextWindow
.AdvanceChar();
2997
TextWindow
.AdvanceChar();
2998
bool isHex =
TextWindow
.PeekChar() == 'x';
3003
TextWindow
.AdvanceChar(); // x
3004
while (SyntaxFacts.IsHexDigit(ch =
TextWindow
.PeekChar()))
3006
TextWindow
.AdvanceChar();
3017
while (SyntaxFacts.IsDecDigit(ch =
TextWindow
.PeekChar()))
3019
TextWindow
.AdvanceChar();
3029
if (
TextWindow
.PeekChar() != ';')
3074
ch =
TextWindow
.PeekChar();
3077
TextWindow
.AdvanceChar();
3119
if (
TextWindow
.PeekChar() == ']' &&
TextWindow
.PeekChar(1) == ']' &&
TextWindow
.PeekChar(2) == '>')
3121
TextWindow
.AdvanceChar(3);
3129
var ch =
TextWindow
.PeekChar();
3133
if (!
TextWindow
.IsReallyAtEnd())
3148
if (this.StyleIs(XmlDocCommentStyle.Delimited) &&
TextWindow
.PeekChar(1) == '/')
3158
if (
TextWindow
.PeekChar(1) == ']' &&
TextWindow
.PeekChar(2) == '>')
3172
TextWindow
.AdvanceChar();
3219
switch (ch =
TextWindow
.PeekChar())
3226
TextWindow
.AdvanceChar();
3231
if (
TextWindow
.PeekChar(1) == '>')
3233
TextWindow
.AdvanceChar(2);
3241
TextWindow
.AdvanceChar();
3246
TextWindow
.AdvanceChar();
3251
TextWindow
.AdvanceChar();
3256
TextWindow
.AdvanceChar();
3266
if (!
TextWindow
.IsReallyAtEnd())
3275
if (this.StyleIs(XmlDocCommentStyle.Delimited) &&
TextWindow
.PeekChar(1) == '/')
3298
TextWindow
.AdvanceChar();
3312
int start =
TextWindow
.Position;
3316
char ch =
TextWindow
.PeekChar();
3328
TextWindow
.AdvanceChar();
3336
info.Text =
TextWindow
.GetText(start,
TextWindow
.Position - start, intern: true);
3393
switch (ch =
TextWindow
.PeekChar())
3398
TextWindow
.AdvanceChar();
3408
TextWindow
.AdvanceChar();
3421
TextWindow
.AdvanceChar();
3431
if (!
TextWindow
.IsReallyAtEnd())
3458
var ch =
TextWindow
.PeekChar();
3487
if (!
TextWindow
.IsReallyAtEnd())
3496
if (this.StyleIs(XmlDocCommentStyle.Delimited) &&
TextWindow
.PeekChar(1) == '/')
3511
TextWindow
.AdvanceChar();
3550
switch (
TextWindow
.PeekChar())
3557
if (!
TextWindow
.IsReallyAtEnd())
3565
info.Text = info.StringValue =
TextWindow
.NextChar().ToString();
3610
int beforeConsumed =
TextWindow
.Position;
3611
char consumedChar =
TextWindow
.NextChar();
3642
if (!
TextWindow
.IsReallyAtEnd())
3652
TextWindow
.Reset(beforeConsumed);
3657
TextWindow
.Reset(beforeConsumed);
3660
TextWindow
.Reset(beforeConsumed);
3686
Debug.Assert(
TextWindow
.Position > beforeConsumed, "First character or entity has been consumed.");
3716
if (
TextWindow
.PeekChar() == '.')
3814
TextWindow
.Reset(beforeConsumed);
3847
if (
TextWindow
.PeekChar() == '@')
3849
TextWindow
.NextChar();
3860
else if (
TextWindow
.PeekChar() == '&')
3869
char bad =
TextWindow
.NextChar();
3898
char peekCh =
TextWindow
.PeekChar();
3903
TextWindow
.AdvanceChar();
3909
int pos =
TextWindow
.Position;
3919
TextWindow
.Reset(pos);
4016
switch (ch =
TextWindow
.PeekChar())
4019
if (
TextWindow
.PeekChar(1) == ']' &&
TextWindow
.PeekChar(2) == '>')
4021
TextWindow
.AdvanceChar(3);
4034
if (!
TextWindow
.IsReallyAtEnd())
4060
var ch =
TextWindow
.PeekChar();
4064
if (
TextWindow
.PeekChar(1) == ']' &&
TextWindow
.PeekChar(2) == '>')
4078
if (!
TextWindow
.IsReallyAtEnd())
4087
if (this.StyleIs(XmlDocCommentStyle.Delimited) &&
TextWindow
.PeekChar(1) == '/')
4102
TextWindow
.AdvanceChar();
4138
switch (ch =
TextWindow
.PeekChar())
4141
if (
TextWindow
.PeekChar(1) == '-')
4143
if (
TextWindow
.PeekChar(2) == '>')
4145
TextWindow
.AdvanceChar(3);
4151
TextWindow
.AdvanceChar(2);
4165
if (!
TextWindow
.IsReallyAtEnd())
4190
var ch =
TextWindow
.PeekChar();
4194
if (
TextWindow
.PeekChar(1) == '-')
4208
if (!
TextWindow
.IsReallyAtEnd())
4217
if (this.StyleIs(XmlDocCommentStyle.Delimited) &&
TextWindow
.PeekChar(1) == '/')
4232
TextWindow
.AdvanceChar();
4269
switch (ch =
TextWindow
.PeekChar())
4272
if (
TextWindow
.PeekChar(1) == '>')
4274
TextWindow
.AdvanceChar(2);
4287
if (!
TextWindow
.IsReallyAtEnd())
4314
var ch =
TextWindow
.PeekChar();
4318
if (
TextWindow
.PeekChar(1) == '>')
4332
if (!
TextWindow
.IsReallyAtEnd())
4341
if (this.StyleIs(XmlDocCommentStyle.Delimited) &&
TextWindow
.PeekChar(1) == '/')
4356
TextWindow
.AdvanceChar();
4368
var start =
TextWindow
.Position;
4377
if (
TextWindow
.PeekChar() == '/'
4378
&&
TextWindow
.PeekChar(1) == '*'
4379
&&
TextWindow
.PeekChar(2) == '*'
4380
&&
TextWindow
.PeekChar(3) != '*')
4382
TextWindow
.AdvanceChar(3);
4398
char ch =
TextWindow
.PeekChar();
4405
TextWindow
.AdvanceChar();
4409
if (this.StyleIs(XmlDocCommentStyle.SingleLine) &&
TextWindow
.PeekChar(1) == '/' &&
TextWindow
.PeekChar(2) == '/' &&
TextWindow
.PeekChar(3) != '/')
4411
TextWindow
.AdvanceChar(3);
4423
while (
TextWindow
.PeekChar() == '*' &&
TextWindow
.PeekChar(1) != '/')
4425
TextWindow
.AdvanceChar();
4438
if (
TextWindow
.PeekChar() == '*' &&
TextWindow
.PeekChar(1) == '/')
4440
TextWindow
.AdvanceChar(2);
4467
TextWindow
.Reset(start);
4486
if (
TextWindow
.PeekChar() == '*' &&
TextWindow
.PeekChar(1) == '/')
4488
TextWindow
.AdvanceChar(2);
4502
char ch =
TextWindow
.PeekChar();
4524
char ch =
TextWindow
.PeekChar();
4543
if (this.StyleIs(XmlDocCommentStyle.Delimited) &&
TextWindow
.PeekChar(1) == '/')
4569
if (
TextWindow
.PeekChar() == '\\')
4571
var ch2 =
TextWindow
.PeekChar(1);
4590
return
TextWindow
.PeekChar();
4596
int position =
TextWindow
.Position;
4602
TextWindow
.Reset(position);
4608
var ch =
TextWindow
.PeekChar();
4612
var ch2 =
TextWindow
.PeekChar(1);
4621
TextWindow
.AdvanceChar();
4635
int start =
TextWindow
.Position;
4636
char character =
TextWindow
.PeekChar();
4638
TextWindow
.AdvanceChar();
4640
character =
TextWindow
.PeekChar();
4645
TextWindow
.AdvanceChar();
4646
if (!SyntaxFacts.IsHexDigit(
TextWindow
.PeekChar()))
4657
character =
TextWindow
.PeekChar();
4669
TextWindow
.AdvanceChar();
4690
TextWindow
.AdvanceChar();
4691
if (!SyntaxFacts.IsHexDigit(
TextWindow
.PeekChar()))
4702
char ch2 =
TextWindow
.PeekChar();
4717
TextWindow
.AdvanceChar();
4741
Debug.Assert(
TextWindow
.PeekChar() == '&');
4744
TextWindow
.AdvanceChar();
4748
switch (
TextWindow
.PeekChar())
4751
if (
TextWindow
.AdvanceIfMatches("lt;"))
4758
if (
TextWindow
.AdvanceIfMatches("gt;"))
4765
if (
TextWindow
.AdvanceIfMatches("amp;"))
4770
else if (
TextWindow
.AdvanceIfMatches("apos;"))
4777
if (
TextWindow
.AdvanceIfMatches("quot;"))
4785
TextWindow
.AdvanceChar(); //#
4789
if (
TextWindow
.AdvanceIfMatches("x"))
4792
while (SyntaxFacts.IsHexDigit(digit =
TextWindow
.PeekChar()))
4794
TextWindow
.AdvanceChar();
4810
while (SyntaxFacts.IsDecDigit(digit =
TextWindow
.PeekChar()))
4812
TextWindow
.AdvanceChar();
4826
if (
TextWindow
.AdvanceIfMatches(";"))
4842
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());