1 write to TextWindow
Microsoft.CodeAnalysis.CSharp (1)
Parser\AbstractLexer.cs (1)
19
this.
TextWindow
= new SlidingTextWindow(text);
620 references to TextWindow
Microsoft.CodeAnalysis.CSharp (601)
Parser\AbstractLexer.cs (6)
22
protected int LexemeStartPosition => this.
TextWindow
.LexemeStartPosition;
26
this.
TextWindow
.Dispose();
31
TextWindow
.Start();
138
=>
TextWindow
.GetText(intern: false);
141
=>
TextWindow
.GetText(intern: true);
144
=> 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 (415)
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 currentOffset =
TextWindow
.Offset;
1345
var characterWindow =
TextWindow
.CharacterWindow;
1346
var characterWindowCount =
TextWindow
.CharacterWindowCount;
1409
TextWindow
.AdvanceChar(length);
1410
info.Text = info.StringValue =
TextWindow
.Intern(characterWindow, startOffset, length);
1442
int start =
TextWindow
.Position;
1445
while (
TextWindow
.PeekChar() == '@')
1447
TextWindow
.AdvanceChar();
1450
var atCount =
TextWindow
.Position - start;
1458
char ch =
TextWindow
.PeekChar();
1481
if (!
TextWindow
.IsReallyAtEnd())
1501
(char.ToLower(
TextWindow
.PeekChar(1)) == 'x'))
1535
if (_identLen == 0 && this.ModeIs(LexerMode.DebuggerSyntax) &&
TextWindow
.PeekChar(1) == '>')
1538
TextWindow
.AdvanceChar(2);
1565
TextWindow
.AdvanceChar();
1589
TextWindow
.AdvanceChar();
1612
info.StringValue =
TextWindow
.Intern(_identBuffer, 0, _identLen);
1620
var valueText =
TextWindow
.Intern(_identBuffer, objectAddressOffset, _identLen - objectAddressOffset);
1641
TextWindow
.Reset(start);
1657
int start =
TextWindow
.Position;
1676
int beforeConsumed =
TextWindow
.Position;
1680
if (
TextWindow
.PeekChar() == '&')
1685
TextWindow
.Reset(beforeConsumed);
1691
consumedChar =
TextWindow
.NextChar();
1711
if (!isEscaped && (
TextWindow
.Position == beforeConsumed + 1) &&
1712
TextWindow
.PeekChar() is 'u' or 'U')
1718
TextWindow
.Reset(beforeConsumed);
1740
TextWindow
.Reset(beforeConsumed);
1758
TextWindow
.Reset(beforeConsumed);
1761
if (!
TextWindow
.IsReallyAtEnd())
1766
TextWindow
.Reset(beforeConsumed);
1788
TextWindow
.Reset(beforeConsumed);
1819
info.StringValue =
TextWindow
.Intern(_identBuffer, 0, _identLen);
1829
TextWindow
.Reset(start);
1898
char ch =
TextWindow
.PeekChar();
1926
if ((ch =
TextWindow
.PeekChar(1)) == '/')
1928
if (!this.SuppressDocumentationCommentParse &&
TextWindow
.PeekChar(2) == '/' &&
TextWindow
.PeekChar(3) != '/')
1948
if (!this.SuppressDocumentationCommentParse &&
TextWindow
.PeekChar(2) == '*' &&
1949
TextWindow
.PeekChar(3) != '*' &&
TextWindow
.PeekChar(3) != '/')
1970
if ((ch =
TextWindow
.PeekChar(1)) == '*')
1973
this.AddError(
TextWindow
.Position, width: 1, ErrorCode.ERR_UnexpectedCharacter, '@');
2004
var savePosition =
TextWindow
.Position;
2010
var text =
TextWindow
.Text.GetSubText(TextSpan.FromBounds(savePosition,
TextWindow
.Position));
2084
var position =
TextWindow
.Position;
2085
var text =
TextWindow
.Text;
2118
this.AddError(
TextWindow
.Position, s_conflictMarkerLength,
2121
var startCh = this.
TextWindow
.PeekChar();
2147
var ch = this.
TextWindow
.PeekChar();
2166
this.
TextWindow
.AdvanceChar();
2185
while (SyntaxFacts.IsNewLine(this.
TextWindow
.PeekChar()))
2187
this.
TextWindow
.AdvanceChar();
2200
var ch = this.
TextWindow
.PeekChar();
2206
this.
TextWindow
.AdvanceChar();
2230
Debug.Assert(
TextWindow
.PeekChar() == delimiter &&
TextWindow
.PeekChar(1) == '*');
2231
TextWindow
.AdvanceChar(2);
2236
if ((ch =
TextWindow
.PeekChar()) == SlidingTextWindow.InvalidCharacter &&
TextWindow
.IsReallyAtEnd())
2241
else if (ch == '*' &&
TextWindow
.PeekChar(1) == delimiter)
2243
TextWindow
.AdvanceChar(2);
2249
TextWindow
.AdvanceChar();
2257
while (!SyntaxFacts.IsNewLine(ch =
TextWindow
.PeekChar()) &&
2258
(ch != SlidingTextWindow.InvalidCharacter || !
TextWindow
.IsReallyAtEnd()))
2260
TextWindow
.AdvanceChar();
2271
switch (ch =
TextWindow
.PeekChar())
2274
TextWindow
.AdvanceChar();
2275
return
TextWindow
.TryAdvance('\n') ? SyntaxFactory.CarriageReturnLineFeed : SyntaxFactory.CarriageReturn;
2277
TextWindow
.AdvanceChar();
2282
TextWindow
.AdvanceChar();
2300
char ch =
TextWindow
.PeekChar();
2312
TextWindow
.AdvanceChar();
2340
TextWindow
.CharacterWindow.AsSpan(
TextWindow
.LexemeRelativeStart, width),
2343
TextWindow
);
2347
return CreateWhitespaceTrivia(
TextWindow
);
2406
if (SyntaxFacts.IsWhitespace(
TextWindow
.PeekChar()))
2440
int lastLineStart =
TextWindow
.Position;
2446
char ch =
TextWindow
.PeekChar();
2450
if (!
TextWindow
.IsReallyAtEnd())
2460
if (lastLineStart <
TextWindow
.Position && !allWhitespace)
2465
TextWindow
.Reset(lastLineStart); // reset so directive parser can consume the starting whitespace on this line
2470
lastLineStart =
TextWindow
.Position;
2481
TextWindow
.AdvanceChar();
2513
var ch = this.
TextWindow
.PeekChar();
2519
else if (ch is SlidingTextWindow.InvalidCharacter && this.
TextWindow
.IsReallyAtEnd())
2527
this.
TextWindow
.AdvanceChar();
2572
switch (character =
TextWindow
.PeekChar())
2575
if (!
TextWindow
.IsReallyAtEnd())
2590
TextWindow
.AdvanceChar();
2595
TextWindow
.AdvanceChar();
2600
TextWindow
.AdvanceChar();
2605
TextWindow
.AdvanceChar();
2610
TextWindow
.AdvanceChar();
2615
TextWindow
.AdvanceChar();
2620
TextWindow
.AdvanceChar();
2621
if (
TextWindow
.PeekChar() == '=')
2623
TextWindow
.AdvanceChar();
2634
TextWindow
.AdvanceChar();
2635
if (
TextWindow
.PeekChar() == '=')
2637
TextWindow
.AdvanceChar();
2648
if (
TextWindow
.PeekChar(1) == '&')
2650
TextWindow
.AdvanceChar(2);
2658
if (
TextWindow
.PeekChar(1) == '|')
2660
TextWindow
.AdvanceChar(2);
2723
TextWindow
.AdvanceChar();
2742
var pos =
TextWindow
.Position;
2757
TextWindow
.Reset(pos);
2774
char ch =
TextWindow
.PeekChar();
2778
if (
TextWindow
.PeekChar(1) == '/')
2828
Debug.Assert(this.LocationIs(XmlDocCommentLocation.End) ||
TextWindow
.PeekChar() == SlidingTextWindow.InvalidCharacter);
2873
switch (ch =
TextWindow
.PeekChar())
2890
if (!
TextWindow
.IsReallyAtEnd())
2923
Debug.Assert(
TextWindow
.PeekChar() == '<');
2925
if (
TextWindow
.PeekChar(1) == '!')
2927
if (
TextWindow
.PeekChar(2) == '-'
2928
&&
TextWindow
.PeekChar(3) == '-')
2930
TextWindow
.AdvanceChar(4);
2933
else if (
TextWindow
.PeekChar(2) == '['
2934
&&
TextWindow
.PeekChar(3) == 'C'
2935
&&
TextWindow
.PeekChar(4) == 'D'
2936
&&
TextWindow
.PeekChar(5) == 'A'
2937
&&
TextWindow
.PeekChar(6) == 'T'
2938
&&
TextWindow
.PeekChar(7) == 'A'
2939
&&
TextWindow
.PeekChar(8) == '[')
2941
TextWindow
.AdvanceChar(9);
2947
TextWindow
.AdvanceChar();
2951
else if (
TextWindow
.PeekChar(1) == '/')
2953
TextWindow
.AdvanceChar(2);
2956
else if (
TextWindow
.PeekChar(1) == '?')
2958
TextWindow
.AdvanceChar(2);
2963
TextWindow
.AdvanceChar();
2972
Debug.Assert(
TextWindow
.PeekChar() == '&');
2973
TextWindow
.AdvanceChar();
2979
if (IsXmlNameStartChar(ch =
TextWindow
.PeekChar()))
2981
while (IsXmlNameChar(ch =
TextWindow
.PeekChar()))
2989
TextWindow
.AdvanceChar();
3018
TextWindow
.AdvanceChar();
3019
bool isHex =
TextWindow
.PeekChar() == 'x';
3024
TextWindow
.AdvanceChar(); // x
3025
while (SyntaxFacts.IsHexDigit(ch =
TextWindow
.PeekChar()))
3027
TextWindow
.AdvanceChar();
3038
while (SyntaxFacts.IsDecDigit(ch =
TextWindow
.PeekChar()))
3040
TextWindow
.AdvanceChar();
3050
if (
TextWindow
.PeekChar() != ';')
3095
ch =
TextWindow
.PeekChar();
3098
TextWindow
.AdvanceChar();
3140
if (
TextWindow
.PeekChar() == ']' &&
TextWindow
.PeekChar(1) == ']' &&
TextWindow
.PeekChar(2) == '>')
3142
TextWindow
.AdvanceChar(3);
3150
var ch =
TextWindow
.PeekChar();
3154
if (!
TextWindow
.IsReallyAtEnd())
3169
if (this.StyleIs(XmlDocCommentStyle.Delimited) &&
TextWindow
.PeekChar(1) == '/')
3179
if (
TextWindow
.PeekChar(1) == ']' &&
TextWindow
.PeekChar(2) == '>')
3193
TextWindow
.AdvanceChar();
3240
switch (ch =
TextWindow
.PeekChar())
3247
TextWindow
.AdvanceChar();
3252
if (
TextWindow
.PeekChar(1) == '>')
3254
TextWindow
.AdvanceChar(2);
3262
TextWindow
.AdvanceChar();
3267
TextWindow
.AdvanceChar();
3272
TextWindow
.AdvanceChar();
3277
TextWindow
.AdvanceChar();
3287
if (!
TextWindow
.IsReallyAtEnd())
3296
if (this.StyleIs(XmlDocCommentStyle.Delimited) &&
TextWindow
.PeekChar(1) == '/')
3319
TextWindow
.AdvanceChar();
3333
int start =
TextWindow
.Position;
3337
char ch =
TextWindow
.PeekChar();
3349
TextWindow
.AdvanceChar();
3357
info.Text =
TextWindow
.GetText(start,
TextWindow
.Position - start, intern: true);
3414
switch (ch =
TextWindow
.PeekChar())
3419
TextWindow
.AdvanceChar();
3429
TextWindow
.AdvanceChar();
3442
TextWindow
.AdvanceChar();
3452
if (!
TextWindow
.IsReallyAtEnd())
3479
var ch =
TextWindow
.PeekChar();
3508
if (!
TextWindow
.IsReallyAtEnd())
3517
if (this.StyleIs(XmlDocCommentStyle.Delimited) &&
TextWindow
.PeekChar(1) == '/')
3532
TextWindow
.AdvanceChar();
3571
switch (
TextWindow
.PeekChar())
3578
if (!
TextWindow
.IsReallyAtEnd())
3586
info.Text = info.StringValue =
TextWindow
.NextChar().ToString();
3631
int beforeConsumed =
TextWindow
.Position;
3632
char consumedChar =
TextWindow
.NextChar();
3663
if (!
TextWindow
.IsReallyAtEnd())
3673
TextWindow
.Reset(beforeConsumed);
3678
TextWindow
.Reset(beforeConsumed);
3681
TextWindow
.Reset(beforeConsumed);
3707
Debug.Assert(
TextWindow
.Position > beforeConsumed, "First character or entity has been consumed.");
3737
if (
TextWindow
.PeekChar() == '.')
3835
TextWindow
.Reset(beforeConsumed);
3868
if (
TextWindow
.PeekChar() == '@')
3870
TextWindow
.NextChar();
3881
else if (
TextWindow
.PeekChar() == '&')
3890
char bad =
TextWindow
.NextChar();
3919
char peekCh =
TextWindow
.PeekChar();
3924
TextWindow
.AdvanceChar();
3930
int pos =
TextWindow
.Position;
3940
TextWindow
.Reset(pos);
4037
switch (ch =
TextWindow
.PeekChar())
4040
if (
TextWindow
.PeekChar(1) == ']' &&
TextWindow
.PeekChar(2) == '>')
4042
TextWindow
.AdvanceChar(3);
4055
if (!
TextWindow
.IsReallyAtEnd())
4081
var ch =
TextWindow
.PeekChar();
4085
if (
TextWindow
.PeekChar(1) == ']' &&
TextWindow
.PeekChar(2) == '>')
4099
if (!
TextWindow
.IsReallyAtEnd())
4108
if (this.StyleIs(XmlDocCommentStyle.Delimited) &&
TextWindow
.PeekChar(1) == '/')
4123
TextWindow
.AdvanceChar();
4159
switch (ch =
TextWindow
.PeekChar())
4162
if (
TextWindow
.PeekChar(1) == '-')
4164
if (
TextWindow
.PeekChar(2) == '>')
4166
TextWindow
.AdvanceChar(3);
4172
TextWindow
.AdvanceChar(2);
4186
if (!
TextWindow
.IsReallyAtEnd())
4211
var ch =
TextWindow
.PeekChar();
4215
if (
TextWindow
.PeekChar(1) == '-')
4229
if (!
TextWindow
.IsReallyAtEnd())
4238
if (this.StyleIs(XmlDocCommentStyle.Delimited) &&
TextWindow
.PeekChar(1) == '/')
4253
TextWindow
.AdvanceChar();
4290
switch (ch =
TextWindow
.PeekChar())
4293
if (
TextWindow
.PeekChar(1) == '>')
4295
TextWindow
.AdvanceChar(2);
4308
if (!
TextWindow
.IsReallyAtEnd())
4335
var ch =
TextWindow
.PeekChar();
4339
if (
TextWindow
.PeekChar(1) == '>')
4353
if (!
TextWindow
.IsReallyAtEnd())
4362
if (this.StyleIs(XmlDocCommentStyle.Delimited) &&
TextWindow
.PeekChar(1) == '/')
4377
TextWindow
.AdvanceChar();
4389
var start =
TextWindow
.Position;
4398
if (
TextWindow
.PeekChar() == '/'
4399
&&
TextWindow
.PeekChar(1) == '*'
4400
&&
TextWindow
.PeekChar(2) == '*'
4401
&&
TextWindow
.PeekChar(3) != '*')
4403
TextWindow
.AdvanceChar(3);
4419
char ch =
TextWindow
.PeekChar();
4426
TextWindow
.AdvanceChar();
4430
if (this.StyleIs(XmlDocCommentStyle.SingleLine) &&
TextWindow
.PeekChar(1) == '/' &&
TextWindow
.PeekChar(2) == '/' &&
TextWindow
.PeekChar(3) != '/')
4432
TextWindow
.AdvanceChar(3);
4444
while (
TextWindow
.PeekChar() == '*' &&
TextWindow
.PeekChar(1) != '/')
4446
TextWindow
.AdvanceChar();
4459
if (
TextWindow
.PeekChar() == '*' &&
TextWindow
.PeekChar(1) == '/')
4461
TextWindow
.AdvanceChar(2);
4488
TextWindow
.Reset(start);
4507
if (
TextWindow
.PeekChar() == '*' &&
TextWindow
.PeekChar(1) == '/')
4509
TextWindow
.AdvanceChar(2);
4523
char ch =
TextWindow
.PeekChar();
4545
char ch =
TextWindow
.PeekChar();
4564
if (this.StyleIs(XmlDocCommentStyle.Delimited) &&
TextWindow
.PeekChar(1) == '/')
4590
if (
TextWindow
.PeekChar() == '\\')
4592
var ch2 =
TextWindow
.PeekChar(1);
4611
return
TextWindow
.PeekChar();
4617
int position =
TextWindow
.Position;
4623
TextWindow
.Reset(position);
4629
var ch =
TextWindow
.PeekChar();
4633
var ch2 =
TextWindow
.PeekChar(1);
4642
TextWindow
.AdvanceChar();
4656
int start =
TextWindow
.Position;
4657
char character =
TextWindow
.PeekChar();
4659
TextWindow
.AdvanceChar();
4661
character =
TextWindow
.PeekChar();
4666
TextWindow
.AdvanceChar();
4667
if (!SyntaxFacts.IsHexDigit(
TextWindow
.PeekChar()))
4678
character =
TextWindow
.PeekChar();
4690
TextWindow
.AdvanceChar();
4711
TextWindow
.AdvanceChar();
4712
if (!SyntaxFacts.IsHexDigit(
TextWindow
.PeekChar()))
4723
char ch2 =
TextWindow
.PeekChar();
4738
TextWindow
.AdvanceChar();
4762
Debug.Assert(
TextWindow
.PeekChar() == '&');
4765
TextWindow
.AdvanceChar();
4769
switch (
TextWindow
.PeekChar())
4772
if (
TextWindow
.AdvanceIfMatches("lt;"))
4779
if (
TextWindow
.AdvanceIfMatches("gt;"))
4786
if (
TextWindow
.AdvanceIfMatches("amp;"))
4791
else if (
TextWindow
.AdvanceIfMatches("apos;"))
4798
if (
TextWindow
.AdvanceIfMatches("quot;"))
4806
TextWindow
.AdvanceChar(); //#
4810
if (
TextWindow
.AdvanceIfMatches("x"))
4813
while (SyntaxFacts.IsHexDigit(digit =
TextWindow
.PeekChar()))
4815
TextWindow
.AdvanceChar();
4831
while (SyntaxFacts.IsDecDigit(digit =
TextWindow
.PeekChar()))
4833
TextWindow
.AdvanceChar();
4847
if (
TextWindow
.AdvanceIfMatches(";"))
4863
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 (114)
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;
414
var window = _lexer.
TextWindow
;
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 (13)
196
int i =
TextWindow
.Offset;
197
int n =
TextWindow
.CharacterWindowCount;
203
var charWindow =
TextWindow
.CharacterWindow;
231
TextWindow
.AdvanceChar(i -
TextWindow
.Offset);
238
TextWindow
.CharacterWindow.AsSpan(
TextWindow
.LexemeRelativeStart, i -
TextWindow
.LexemeRelativeStart),
246
TextWindow
.Reset(
TextWindow
.LexemeStartPosition);
254
var quickWidth = lexer.
TextWindow
.Width;
256
lexer.
TextWindow
.Reset(lexer.
TextWindow
.LexemeStartPosition);
Parser\SyntaxParser.cs (1)
141
var size = Math.Min(CachedTokenArraySize, this.lexer.
TextWindow
.Text.Length / 2);
Syntax\SyntaxTokenParser.cs (5)
54
var startingPosition = _lexer.
TextWindow
.Position;
68
var startingPosition = _lexer.
TextWindow
.Position;
83
var startingPosition = _lexer.
TextWindow
.Position;
96
if (position < _lexer.
TextWindow
.Position)
99
_lexer.
TextWindow
.Reset(position);
Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests (19)
LexicalAndXml\LexicalTests.cs (19)
4599
lexer.
TextWindow
.GetTestAccessor().SetDefaultCharacterWindow();
4615
lexer.
TextWindow
.GetTestAccessor().SetDefaultCharacterWindow();
4622
Assert.Equal(0, lexer.
TextWindow
.Offset);
4625
Assert.Equal(205, lexer.
TextWindow
.CharacterWindowCount);
4628
Assert.Equal(10199, lexer.
TextWindow
.Position);
4631
Assert.Equal(lexer.
TextWindow
.Text.Length, lexer.
TextWindow
.Position + lexer.
TextWindow
.CharacterWindowCount);
4634
Assert.Equal(lexer.
TextWindow
.LexemeStartPosition, lexer.
TextWindow
.Position);
4638
Assert.True(lexer.
TextWindow
.CharacterWindow is ['.', '0', '3', ',', ..], $"Start of window was '{new string(lexer.
TextWindow
.CharacterWindow, 0, 4)}'");
4646
Assert.Equal(3, lexer.
TextWindow
.Offset);
4649
Assert.Equal(205, lexer.
TextWindow
.CharacterWindowCount);
4652
Assert.Equal(10202, lexer.
TextWindow
.Position);
4655
Assert.Equal(lexer.
TextWindow
.LexemeStartPosition, lexer.
TextWindow
.Position);
4658
Assert.True(lexer.
TextWindow
.CharacterWindow is ['.', '0', '3', ',', ..], $"Start of window was '{new string(lexer.
TextWindow
.CharacterWindow, 0, 4)}'");