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