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