289 references to RegexKind
Microsoft.CodeAnalysis.Features (289)
EmbeddedLanguages\RegularExpressions\LanguageServices\RegexBraceMatcher.cs (3)
19using RegexToken = EmbeddedSyntaxToken<RegexKind>; 20using RegexTrivia = EmbeddedSyntaxTrivia<RegexKind>; 79if (trivia?.Kind != RegexKind.CommentTrivia)
EmbeddedLanguages\RegularExpressions\LanguageServices\RegexClassifier.cs (3)
19using RegexToken = EmbeddedSyntaxToken<RegexKind>; 20using RegexTrivia = EmbeddedSyntaxTrivia<RegexKind>; 97if (trivia.Kind == RegexKind.CommentTrivia &&
EmbeddedLanguages\RegularExpressions\LanguageServices\RegexDocumentHighlighter.cs (5)
20using RegexToken = EmbeddedSyntaxToken<RegexKind>; 88if (captureToken.Kind == RegexKind.NumberToken) 128if (node.Kind is RegexKind.BackreferenceEscape or 129RegexKind.CaptureEscape or 130RegexKind.KCaptureEscape)
EmbeddedLanguages\RegularExpressions\LanguageServices\RegexEmbeddedCompletionProvider.cs (4)
24using RegexToken = EmbeddedSyntaxToken<RegexKind>; 191case RegexKind.BackslashToken: 194case RegexKind.OpenBracketToken: 197case RegexKind.OpenParenToken:
EmbeddedLanguages\RegularExpressions\RegexHelpers.cs (6)
15using RegexToken = EmbeddedSyntaxToken<RegexKind>; 16using RegexTrivia = EmbeddedSyntaxTrivia<RegexKind>; 23public static RegexToken CreateToken(RegexKind kind, ImmutableArray<RegexTrivia> leadingTrivia, VirtualCharSequence virtualChars) 26public static RegexToken CreateMissingToken(RegexKind kind) 29public static RegexTrivia CreateTrivia(RegexKind kind, VirtualCharSequence virtualChars) 32public static RegexTrivia CreateTrivia(RegexKind kind, VirtualCharSequence virtualChars, ImmutableArray<EmbeddedDiagnostic> diagnostics)
EmbeddedLanguages\RegularExpressions\RegexLexer.cs (38)
17using RegexToken = EmbeddedSyntaxToken<RegexKind>; 18using RegexTrivia = EmbeddedSyntaxTrivia<RegexKind>; 33/// cref="RegexTextNode"/>s in a row (each containing a <see cref="RegexKind.TextToken"/> a 60return CreateToken(RegexKind.EndOfFile, trivia, VirtualCharSequence.Empty); 69private static RegexKind GetKind(VirtualChar ch) 72'|' => RegexKind.BarToken, 73'*' => RegexKind.AsteriskToken, 74'+' => RegexKind.PlusToken, 75'?' => RegexKind.QuestionToken, 76'{' => RegexKind.OpenBraceToken, 77'}' => RegexKind.CloseBraceToken, 78'\\' => RegexKind.BackslashToken, 79'[' => RegexKind.OpenBracketToken, 80']' => RegexKind.CloseBracketToken, 81'.' => RegexKind.DotToken, 82'^' => RegexKind.CaretToken, 83'$' => RegexKind.DollarToken, 84'(' => RegexKind.OpenParenToken, 85')' => RegexKind.CloseParenToken, 86',' => RegexKind.CommaToken, 87':' => RegexKind.ColonToken, 88'=' => RegexKind.EqualsToken, 89'!' => RegexKind.ExclamationToken, 90'<' => RegexKind.LessThanToken, 91'>' => RegexKind.GreaterThanToken, 92'-' => RegexKind.MinusToken, 93'\'' => RegexKind.SingleQuoteToken, 94_ => RegexKind.TextToken, 148return CreateTrivia(RegexKind.CommentTrivia, GetSubPatternToCurrentPos(start)); 166return CreateTrivia(RegexKind.CommentTrivia, GetSubPatternToCurrentPos(start), diagnostics); 170return CreateTrivia(RegexKind.CommentTrivia, GetSubPatternToCurrentPos(start)); 208return CreateTrivia(RegexKind.WhitespaceTrivia, GetSubPatternToCurrentPos(start)); 240var token = CreateToken(RegexKind.EscapeCategoryToken, [], GetSubPatternToCurrentPos(start)); 294var token = CreateToken(RegexKind.NumberToken, [], GetSubPatternToCurrentPos(start)); 325var token = CreateToken(RegexKind.CaptureNameToken, [], GetSubPatternToCurrentPos(start)); 343: CreateToken(RegexKind.OptionsToken, ImmutableArray<RegexTrivia>.Empty, GetSubPatternToCurrentPos(start)); 386RegexKind.TextToken, [], GetSubPatternToCurrentPos(start)); 447RegexKind.TextToken, [], GetSubPatternToCurrentPos(start));
EmbeddedLanguages\RegularExpressions\RegexNode.cs (2)
9internal abstract class RegexNode : EmbeddedSyntaxNode<RegexKind, RegexNode> 11protected RegexNode(RegexKind kind) : base(kind)
EmbeddedLanguages\RegularExpressions\RegexNodes.cs (96)
12using RegexNodeOrToken = EmbeddedSyntaxNodeOrToken<RegexKind, RegexNode>; 13using RegexToken = EmbeddedSyntaxToken<RegexKind>; 14using RegexAlternatingSequenceList = EmbeddedSeparatedSyntaxNodeList<RegexKind, RegexNode, RegexSequenceNode>; 19: base(RegexKind.CompilationUnit) 22Debug.Assert(endOfFileToken.Kind == RegexKind.EndOfFile); 55internal sealed class RegexSequenceNode(ImmutableArray<RegexExpressionNode> children) : RegexExpressionNode(RegexKind.Sequence) 74: base(RegexKind.Text) 76Debug.Assert(textToken.Kind == RegexKind.TextToken); 101RegexKind kind, RegexToken openBracketToken, RegexSequenceNode components, RegexToken closeBracketToken) 104Debug.Assert(openBracketToken.Kind == RegexKind.OpenBracketToken); 106Debug.Assert(closeBracketToken.Kind == RegexKind.CloseBracketToken); 121RegexToken openBracketToken, RegexSequenceNode components, RegexToken closeBracketToken) : RegexBaseCharacterClassNode(RegexKind.CharacterClass, openBracketToken, components, closeBracketToken) 145: base(RegexKind.NegatedCharacterClass, openBracketToken, components, closeBracketToken) 147Debug.Assert(caretToken.Kind == RegexKind.CaretToken); 176: base(RegexKind.CharacterClassRange) 179Debug.Assert(minusToken.Kind == RegexKind.MinusToken); 214: base(RegexKind.CharacterClassSubtraction) 216Debug.Assert(minusToken.Kind == RegexKind.MinusToken); 244protected RegexExpressionNode(RegexKind kind) 255protected RegexPrimaryExpressionNode(RegexKind kind) 267: base(RegexKind.Wildcard) 269Debug.Assert(dotToken.Kind == RegexKind.DotToken); 293protected RegexQuantifierNode(RegexKind kind) 306: base(RegexKind.ZeroOrMoreQuantifier) 309Debug.Assert(asteriskToken.Kind == RegexKind.AsteriskToken); 338: base(RegexKind.OneOrMoreQuantifier) 341Debug.Assert(plusToken.Kind == RegexKind.PlusToken); 370: base(RegexKind.ZeroOrOneQuantifier) 373Debug.Assert(questionToken.Kind == RegexKind.QuestionToken); 404: base(RegexKind.LazyQuantifier) 407Debug.Assert(quantifier.Kind != RegexKind.LazyQuantifier); 408Debug.Assert(questionToken.Kind == RegexKind.QuestionToken); 437RegexKind kind, RegexPrimaryExpressionNode expression, RegexToken openBraceToken, RegexToken firstNumberToken, RegexToken closeBraceToken) 441Debug.Assert(openBraceToken.Kind == RegexKind.OpenBraceToken); 442Debug.Assert(firstNumberToken.Kind == RegexKind.NumberToken); 443Debug.Assert(closeBraceToken.Kind == RegexKind.CloseBraceToken); 460RegexPrimaryExpressionNode expression, RegexToken openBraceToken, RegexToken numberToken, RegexToken closeBraceToken) : RegexNumericQuantifierNode(RegexKind.ExactNumericQuantifier, expression, openBraceToken, numberToken, closeBraceToken) 487: base(RegexKind.OpenRangeNumericQuantifier, expression, openBraceToken, firstNumberToken, closeBraceToken) 489Debug.Assert(commaToken.Kind == RegexKind.CommaToken); 521: base(RegexKind.ClosedRangeNumericQuantifier, expression, openBraceToken, firstNumberToken, closeBraceToken) 523Debug.Assert(commaToken.Kind == RegexKind.CommaToken); 524Debug.Assert(secondNumberToken.Kind == RegexKind.NumberToken); 555public RegexAnchorNode(RegexKind kind, RegexToken anchorToken) 558Debug.Assert(anchorToken.Kind is RegexKind.DollarToken or RegexKind.CaretToken); 583: base(RegexKind.Alternation) 587Debug.Assert(sequenceList.NodesAndTokens[i].Kind == RegexKind.BarToken); 608protected RegexGroupingNode(RegexKind kind, RegexToken openParenToken, RegexToken closeParenToken) 611Debug.Assert(openParenToken.Kind == RegexKind.OpenParenToken); 612Debug.Assert(closeParenToken.Kind == RegexKind.CloseParenToken); 627: base(RegexKind.SimpleGrouping, openParenToken, closeParenToken) 655protected RegexQuestionGroupingNode(RegexKind kind, RegexToken openParenToken, RegexToken questionToken, RegexToken closeParenToken) 658Debug.Assert(questionToken.Kind == RegexKind.QuestionToken); 670protected RegexOptionsGroupingNode(RegexKind kind, RegexToken openParenToken, RegexToken questionToken, RegexToken optionsToken, RegexToken closeParenToken) 683RegexToken openParenToken, RegexToken questionToken, RegexToken optionsToken, RegexToken closeParenToken) : RegexOptionsGroupingNode(RegexKind.SimpleOptionsGrouping, openParenToken, questionToken, optionsToken, closeParenToken) 709: base(RegexKind.NestedOptionsGrouping, openParenToken, questionToken, optionsToken, closeParenToken) 711Debug.Assert(colonToken.Kind == RegexKind.ColonToken); 746: base(RegexKind.NonCapturingGrouping, openParenToken, questionToken, closeParenToken) 748Debug.Assert(colonToken.Kind == RegexKind.ColonToken); 782: base(RegexKind.PositiveLookaheadGrouping, openParenToken, questionToken, closeParenToken) 784Debug.Assert(equalsToken.Kind == RegexKind.EqualsToken); 818: base(RegexKind.NegativeLookaheadGrouping, openParenToken, questionToken, closeParenToken) 820Debug.Assert(exclamationToken.Kind == RegexKind.ExclamationToken); 849RegexKind kind, RegexToken openParenToken, RegexToken questionToken, 853Debug.Assert(lessThanToken.Kind == RegexKind.LessThanToken); 868: base(RegexKind.PositiveLookbehindGrouping, openParenToken, questionToken, lessThanToken, closeParenToken) 870Debug.Assert(equalsToken.Kind == RegexKind.EqualsToken); 905: base(RegexKind.NegativeLookbehindGrouping, openParenToken, questionToken, lessThanToken, closeParenToken) 907Debug.Assert(exclamationToken.Kind == RegexKind.ExclamationToken); 942: base(RegexKind.AtomicGrouping, openParenToken, questionToken, closeParenToken) 944Debug.Assert(greaterThanToken.Kind == RegexKind.GreaterThanToken); 979: base(RegexKind.CaptureGrouping, openParenToken, questionToken, closeParenToken) 1021: base(RegexKind.BalancingGrouping, openParenToken, questionToken, closeParenToken) 1023Debug.Assert(minusToken.Kind == RegexKind.MinusToken); 1064RegexKind kind, RegexToken openParenToken, RegexToken questionToken, 1084: base(RegexKind.ConditionalCaptureGrouping, openParenToken, questionToken, result, closeParenToken) 1086Debug.Assert(innerOpenParenToken.Kind == RegexKind.OpenParenToken); 1087Debug.Assert(innerCloseParenToken.Kind == RegexKind.CloseParenToken); 1127: base(RegexKind.ConditionalExpressionGrouping, openParenToken, questionToken, result, closeParenToken) 1157protected RegexEscapeNode(RegexKind kind, RegexToken backslashToken) : base(kind) 1159Debug.Assert(backslashToken.Kind == RegexKind.BackslashToken); 1171protected RegexTypeEscapeNode(RegexKind kind, RegexToken backslashToken, RegexToken typeToken) 1186: base(RegexKind.SimpleEscape, backslashToken, typeToken) 1188Debug.Assert(typeToken.Kind == RegexKind.TextToken); 1208internal sealed class RegexAnchorEscapeNode(RegexToken backslashToken, RegexToken typeToken) : RegexTypeEscapeNode(RegexKind.AnchorEscape, backslashToken, typeToken) 1227internal sealed class RegexCharacterClassEscapeNode(RegexToken backslashToken, RegexToken typeToken) : RegexTypeEscapeNode(RegexKind.CharacterClassEscape, backslashToken, typeToken) 1246internal sealed class RegexControlEscapeNode(RegexToken backslashToken, RegexToken typeToken, RegexToken controlToken) : RegexTypeEscapeNode(RegexKind.ControlEscape, backslashToken, typeToken) 1268internal sealed class RegexHexEscapeNode(RegexToken backslashToken, RegexToken typeToken, RegexToken hexText) : RegexTypeEscapeNode(RegexKind.HexEscape, backslashToken, typeToken) 1290internal sealed class RegexUnicodeEscapeNode(RegexToken backslashToken, RegexToken typeToken, RegexToken hexText) : RegexTypeEscapeNode(RegexKind.UnicodeEscape, backslashToken, typeToken) 1313RegexToken backslashToken, RegexToken openToken, RegexToken captureToken, RegexToken closeToken) : RegexEscapeNode(RegexKind.CaptureEscape, backslashToken) 1340RegexToken openToken, RegexToken captureToken, RegexToken closeToken) : RegexTypeEscapeNode(RegexKind.KCaptureEscape, backslashToken, typeToken) 1366internal sealed class RegexOctalEscapeNode(RegexToken backslashToken, RegexToken octalText) : RegexEscapeNode(RegexKind.OctalEscape, backslashToken) 1390internal sealed class RegexBackreferenceEscapeNode(RegexToken backslashToken, RegexToken numberToken) : RegexEscapeNode(RegexKind.BackreferenceEscape, backslashToken) 1415: base(RegexKind.CategoryEscape, backslashToken) 1417Debug.Assert(openBraceToken.Kind == RegexKind.OpenBraceToken); 1418Debug.Assert(closeBraceToken.Kind == RegexKind.CloseBraceToken);
EmbeddedLanguages\RegularExpressions\RegexParser.CaptureInfoAnalyzer.cs (7)
20using RegexToken = EmbeddedSyntaxToken<RegexKind>; 85case RegexKind.CaptureGrouping: 90case RegexKind.BalancingGrouping: 95case RegexKind.ConditionalExpressionGrouping: 104case RegexKind.SimpleGrouping: 108case RegexKind.NestedOptionsGrouping: 185if (token.Kind == RegexKind.NumberToken)
EmbeddedLanguages\RegularExpressions\RegexParser.cs (124)
20using RegexAlternatingSequenceList = EmbeddedSeparatedSyntaxNodeList<RegexKind, RegexNode, RegexSequenceNode>; 21using RegexNodeOrToken = EmbeddedSyntaxNodeOrToken<RegexKind, RegexNode>; 22using RegexToken = EmbeddedSyntaxToken<RegexKind>; 169Debug.Assert(_currentToken.Kind == RegexKind.EndOfFile); 267while (_currentToken.Kind == RegexKind.BarToken) 312if (current.Kind != RegexKind.Text) 360RegexKind.TextToken, startTextNode.TextToken.LeadingTrivia, 371if (next.Kind == RegexKind.Text) 397if (_currentToken.Kind == RegexKind.EndOfFile) 402if (_currentToken.Kind == RegexKind.BarToken) 407if (_currentToken.Kind == RegexKind.CloseParenToken) 418if (current.Kind == RegexKind.SimpleOptionsGrouping) 426RegexKind.AsteriskToken => ParseZeroOrMoreQuantifier(current), 427RegexKind.PlusToken => ParseOneOrMoreQuantifier(current), 428RegexKind.QuestionToken => ParseZeroOrOneQuantifier(current), 429RegexKind.OpenBraceToken => TryParseNumericQuantifier(current, _currentToken), 436if (_currentToken.Kind != RegexKind.QuestionToken) 522if (_currentToken.Kind == RegexKind.CommaToken) 554if (_currentToken.Kind != RegexKind.CloseBraceToken) 574RegexKind.DotToken => ParseWildcard(), 575RegexKind.CaretToken => ParseStartAnchor(), 576RegexKind.DollarToken => ParseEndAnchor(), 577RegexKind.BackslashToken => ParseEscape(_currentToken, allowTriviaAfterEnd: true), 578RegexKind.OpenBracketToken => ParseCharacterClass(), 579RegexKind.OpenParenToken => ParseGrouping(inConditionalExpression: false), 580RegexKind.CloseParenToken => ParseUnexpectedCloseParenToken(), 581RegexKind.OpenBraceToken => ParsePossibleUnexpectedNumericQuantifier(lastExpression), 582RegexKind.AsteriskToken or RegexKind.PlusToken or RegexKind.QuestionToken => ParseUnexpectedQuantifier(lastExpression), 592var openBraceToken = _currentToken.With(kind: RegexKind.TextToken); 610var token = _currentToken.With(kind: RegexKind.TextToken).AddDiagnosticIfNone( 626return new RegexTextNode(token.With(kind: RegexKind.TextToken)); 632return new RegexAnchorNode(RegexKind.EndAnchor, ConsumeCurrentToken(allowTrivia: true)); 638return new RegexAnchorNode(RegexKind.StartAnchor, ConsumeCurrentToken(allowTrivia: true)); 657case RegexKind.QuestionToken: 671case RegexKind.CloseParenToken: 676return CreateMissingToken(RegexKind.CloseParenToken).AddDiagnosticIfNone( 704=> token.Kind == RegexKind.EndOfFile 710return token.Kind == RegexKind.EndOfFile 733case RegexKind.LessThanToken: 737case RegexKind.SingleQuoteToken: 742case RegexKind.OpenParenToken: 746case RegexKind.ColonToken: 749case RegexKind.EqualsToken: 752case RegexKind.ExclamationToken: 755case RegexKind.GreaterThanToken: 759if (_currentToken.Kind != RegexKind.CloseParenToken) 791if (capture.Kind == RegexKind.NumberToken) 802if (_currentToken.Kind == RegexKind.CloseParenToken) 814innerCloseParenToken = CreateMissingToken(RegexKind.CloseParenToken); 835if (_currentToken.Kind != RegexKind.CloseParenToken) 864if (_currentToken.Kind != RegexKind.EndOfFile) 917Debug.Assert(_currentToken.Kind == RegexKind.OpenParenToken); 951case RegexKind.EqualsToken: 956case RegexKind.ExclamationToken: 985captureToken = CreateMissingToken(RegexKind.CaptureNameToken); 987if (_currentToken.Kind == RegexKind.MinusToken) 1005if (capture.Kind == RegexKind.NumberToken && (int)capture.Value == 0) 1015if (_currentToken.Kind == RegexKind.MinusToken) 1033if ((openToken.Kind == RegexKind.LessThanToken && _currentToken.Kind == RegexKind.GreaterThanToken) || 1034(openToken.Kind == RegexKind.SingleQuoteToken && _currentToken.Kind == RegexKind.SingleQuoteToken)) 1039if (_currentToken.Kind == RegexKind.EndOfFile) 1056openToken.Kind == RegexKind.LessThanToken 1057? RegexKind.GreaterThanToken : RegexKind.SingleQuoteToken); 1078secondCapture = CreateMissingToken(RegexKind.CaptureNameToken); 1102if (captureToken.Kind == RegexKind.NumberToken) 1151case RegexKind.CloseParenToken: 1158case RegexKind.ColonToken: 1164CreateMissingToken(RegexKind.CloseParenToken).AddDiagnosticIfNone( 1176=> currentToken.Kind == RegexKind.TextToken && currentToken.VirtualChars.Length == 1 && currentToken.VirtualChars[0].Value == ch; 1223Debug.Assert(openBracketToken.Kind == RegexKind.OpenBracketToken); 1224var caretToken = CreateMissingToken(RegexKind.CaretToken); 1225var closeBracketToken = CreateMissingToken(RegexKind.CloseBracketToken); 1229if (_currentToken.Kind == RegexKind.CaretToken) 1242while (_currentToken.Kind != RegexKind.EndOfFile) 1246if (_currentToken.Kind == RegexKind.CloseBracketToken && builder.Count > 0) 1277if (left.Kind is RegexKind.CharacterClassEscape or RegexKind.CategoryEscape || 1286if (_currentToken.Kind == RegexKind.MinusToken && !_lexer.IsAt("]")) 1291if (_currentToken.Kind == RegexKind.OpenBracketToken) 1342case RegexKind.SimpleEscape: 1347case RegexKind.ControlEscape: 1363case RegexKind.OctalEscape: 1367case RegexKind.HexEscape: 1371case RegexKind.UnicodeEscape: 1375case RegexKind.Text: 1379case RegexKind.Sequence: 1470if (_currentToken.Kind == RegexKind.BackslashToken && _lexer.Position < _lexer.Text.Length) 1512backslashToken, ConsumeCurrentToken(allowTrivia: false).With(kind: RegexKind.TextToken)); 1528_currentToken.Kind == RegexKind.MinusToken && 1539ConsumeCurrentToken(allowTrivia: false).With(kind: RegexKind.TextToken)); 1546if (_currentToken.Kind is not RegexKind.CloseBracketToken and not RegexKind.EndOfFile) 1568if (_currentToken.Kind == RegexKind.EndOfFile) 1573return new RegexSimpleEscapeNode(backslashToken, CreateMissingToken(RegexKind.TextToken)); 1614if (_currentToken.Kind == RegexKind.EndOfFile) 1619return new RegexSimpleEscapeNode(backslashToken, CreateMissingToken(RegexKind.TextToken)); 1688RegexKind.NumberToken, [], 1750return new RegexSimpleEscapeNode(backslashToken, typeToken.With(kind: RegexKind.TextToken)); 1769openToken = CreateMissingToken(RegexKind.LessThanToken); 1770capture = CreateMissingToken(RegexKind.CaptureNameToken); 1771closeToken = CreateMissingToken(RegexKind.GreaterThanToken); 1777(_currentToken.Kind == RegexKind.LessThanToken || _currentToken.Kind == RegexKind.SingleQuoteToken)) 1788? CreateMissingToken(RegexKind.CaptureNameToken) 1793closeToken = CreateMissingToken(RegexKind.GreaterThanToken); 1796((openToken.Kind == RegexKind.LessThanToken && _currentToken.Kind == RegexKind.GreaterThanToken) || 1797(openToken.Kind == RegexKind.SingleQuoteToken && _currentToken.Kind == RegexKind.SingleQuoteToken))) 1842var typeToken = ConsumeCurrentToken(allowTrivia: allowTriviaAfterEnd).With(kind: RegexKind.TextToken); 1876if (_currentToken.Kind == RegexKind.EndOfFile) 1881return new RegexControlEscapeNode(backslashToken, typeToken, CreateMissingToken(RegexKind.TextToken)); 1913var controlToken = ConsumeCurrentToken(allowTrivia: allowTriviaAfterEnd).With(kind: RegexKind.TextToken); 1923return new RegexControlEscapeNode(backslashToken, typeToken, CreateMissingToken(RegexKind.TextToken)); 1943typeToken = typeToken.With(kind: RegexKind.TextToken).AddDiagnosticIfNone(new EmbeddedDiagnostic( 1972if (_currentToken.Kind != RegexKind.OpenBraceToken) 1983if (_currentToken.Kind != RegexKind.CloseBraceToken) 2006return new RegexTextNode(token.With(kind: RegexKind.TextToken)); 2012current.Kind == RegexKind.SimpleOptionsGrouping)
EmbeddedLanguages\RegularExpressions\RegexTree.cs (1)
17ImmutableDictionary<int, TextSpan> captureNumbersToSpan) : EmbeddedSyntaxTree<RegexKind, RegexNode, RegexCompilationUnit>(text, root, diagnostics)