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