300 references to RegexKind
Microsoft.CodeAnalysis.CSharp.EditorFeatures2.UnitTests (4)
EmbeddedLanguages\RegularExpressions\CSharpRegexParserTests.cs (4)
23using RegexToken = EmbeddedSyntaxToken<RegexKind>; 24using RegexTrivia = EmbeddedSyntaxTrivia<RegexKind>; 324case RegexKind.CommentTrivia: 325case RegexKind.WhitespaceTrivia:
Microsoft.CodeAnalysis.Features (296)
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)
23using RegexToken = EmbeddedSyntaxToken<RegexKind>; 194case RegexKind.BackslashToken: 197case RegexKind.OpenBracketToken: 200case 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)
19using RegexToken = EmbeddedSyntaxToken<RegexKind>; 20using RegexTrivia = EmbeddedSyntaxTrivia<RegexKind>; 35/// cref="RegexTextNode"/>s in a row (each containing a <see cref="RegexKind.TextToken"/> a 62return CreateToken(RegexKind.EndOfFile, trivia, VirtualCharSequence.Empty); 71private static RegexKind GetKind(VirtualChar ch) 74'|' => RegexKind.BarToken, 75'*' => RegexKind.AsteriskToken, 76'+' => RegexKind.PlusToken, 77'?' => RegexKind.QuestionToken, 78'{' => RegexKind.OpenBraceToken, 79'}' => RegexKind.CloseBraceToken, 80'\\' => RegexKind.BackslashToken, 81'[' => RegexKind.OpenBracketToken, 82']' => RegexKind.CloseBracketToken, 83'.' => RegexKind.DotToken, 84'^' => RegexKind.CaretToken, 85'$' => RegexKind.DollarToken, 86'(' => RegexKind.OpenParenToken, 87')' => RegexKind.CloseParenToken, 88',' => RegexKind.CommaToken, 89':' => RegexKind.ColonToken, 90'=' => RegexKind.EqualsToken, 91'!' => RegexKind.ExclamationToken, 92'<' => RegexKind.LessThanToken, 93'>' => RegexKind.GreaterThanToken, 94'-' => RegexKind.MinusToken, 95'\'' => RegexKind.SingleQuoteToken, 96_ => RegexKind.TextToken, 150return CreateTrivia(RegexKind.CommentTrivia, GetSubPatternToCurrentPos(start)); 168return CreateTrivia(RegexKind.CommentTrivia, GetSubPatternToCurrentPos(start), diagnostics); 172return CreateTrivia(RegexKind.CommentTrivia, GetSubPatternToCurrentPos(start)); 210return CreateTrivia(RegexKind.WhitespaceTrivia, GetSubPatternToCurrentPos(start)); 247var token = CreateToken(RegexKind.EscapeCategoryToken, ImmutableArray<RegexTrivia>.Empty, GetSubPatternToCurrentPos(start)); 300var token = CreateToken(RegexKind.NumberToken, ImmutableArray<RegexTrivia>.Empty, GetSubPatternToCurrentPos(start)); 331var token = CreateToken(RegexKind.CaptureNameToken, ImmutableArray<RegexTrivia>.Empty, GetSubPatternToCurrentPos(start)); 349: CreateToken(RegexKind.OptionsToken, ImmutableArray<RegexTrivia>.Empty, GetSubPatternToCurrentPos(start)); 392RegexKind.TextToken, ImmutableArray<RegexTrivia>.Empty, GetSubPatternToCurrentPos(start)); 453RegexKind.TextToken, ImmutableArray<RegexTrivia>.Empty, GetSubPatternToCurrentPos(start));
EmbeddedLanguages\RegularExpressions\RegexNode.cs (2)
11internal abstract class RegexNode : EmbeddedSyntaxNode<RegexKind, RegexNode> 13protected RegexNode(RegexKind kind) : base(kind)
EmbeddedLanguages\RegularExpressions\RegexNodes.cs (98)
15using RegexNodeOrToken = EmbeddedSyntaxNodeOrToken<RegexKind, RegexNode>; 16using RegexToken = EmbeddedSyntaxToken<RegexKind>; 17using RegexAlternatingSequenceList = EmbeddedSeparatedSyntaxNodeList<RegexKind, RegexNode, RegexSequenceNode>; 22: base(RegexKind.CompilationUnit) 25Debug.Assert(endOfFileToken.Kind == RegexKind.EndOfFile); 65: base(RegexKind.Sequence) 83: base(RegexKind.Text) 85Debug.Assert(textToken.Kind == RegexKind.TextToken); 110RegexKind kind, RegexToken openBracketToken, RegexSequenceNode components, RegexToken closeBracketToken) 113Debug.Assert(openBracketToken.Kind == RegexKind.OpenBracketToken); 115Debug.Assert(closeBracketToken.Kind == RegexKind.CloseBracketToken); 133: base(RegexKind.CharacterClass, openBracketToken, components, closeBracketToken) 159: base(RegexKind.NegatedCharacterClass, openBracketToken, components, closeBracketToken) 161Debug.Assert(caretToken.Kind == RegexKind.CaretToken); 190: base(RegexKind.CharacterClassRange) 193Debug.Assert(minusToken.Kind == RegexKind.MinusToken); 228: base(RegexKind.CharacterClassSubtraction) 230Debug.Assert(minusToken.Kind == RegexKind.MinusToken); 261: base(RegexKind.PosixProperty) 263Debug.Assert(textToken.Kind == RegexKind.TextToken); 287protected RegexExpressionNode(RegexKind kind) 298protected RegexPrimaryExpressionNode(RegexKind kind) 310: base(RegexKind.Wildcard) 312Debug.Assert(dotToken.Kind == RegexKind.DotToken); 336protected RegexQuantifierNode(RegexKind kind) 349: base(RegexKind.ZeroOrMoreQuantifier) 352Debug.Assert(asteriskToken.Kind == RegexKind.AsteriskToken); 381: base(RegexKind.OneOrMoreQuantifier) 384Debug.Assert(plusToken.Kind == RegexKind.PlusToken); 413: base(RegexKind.ZeroOrOneQuantifier) 416Debug.Assert(questionToken.Kind == RegexKind.QuestionToken); 447: base(RegexKind.LazyQuantifier) 450Debug.Assert(quantifier.Kind != RegexKind.LazyQuantifier); 451Debug.Assert(questionToken.Kind == RegexKind.QuestionToken); 480RegexKind kind, RegexPrimaryExpressionNode expression, RegexToken openBraceToken, RegexToken firstNumberToken, RegexToken closeBraceToken) 484Debug.Assert(openBraceToken.Kind == RegexKind.OpenBraceToken); 485Debug.Assert(firstNumberToken.Kind == RegexKind.NumberToken); 486Debug.Assert(closeBraceToken.Kind == RegexKind.CloseBraceToken); 506: base(RegexKind.ExactNumericQuantifier, expression, openBraceToken, numberToken, closeBraceToken) 535: base(RegexKind.OpenRangeNumericQuantifier, expression, openBraceToken, firstNumberToken, closeBraceToken) 537Debug.Assert(commaToken.Kind == RegexKind.CommaToken); 569: base(RegexKind.ClosedRangeNumericQuantifier, expression, openBraceToken, firstNumberToken, closeBraceToken) 571Debug.Assert(commaToken.Kind == RegexKind.CommaToken); 572Debug.Assert(secondNumberToken.Kind == RegexKind.NumberToken); 603public RegexAnchorNode(RegexKind kind, RegexToken anchorToken) 606Debug.Assert(anchorToken.Kind is RegexKind.DollarToken or RegexKind.CaretToken); 631: base(RegexKind.Alternation) 635Debug.Assert(sequenceList.NodesAndTokens[i].Kind == RegexKind.BarToken); 656protected RegexGroupingNode(RegexKind kind, RegexToken openParenToken, RegexToken closeParenToken) 659Debug.Assert(openParenToken.Kind == RegexKind.OpenParenToken); 660Debug.Assert(closeParenToken.Kind == RegexKind.CloseParenToken); 675: base(RegexKind.SimpleGrouping, openParenToken, closeParenToken) 703protected RegexQuestionGroupingNode(RegexKind kind, RegexToken openParenToken, RegexToken questionToken, RegexToken closeParenToken) 706Debug.Assert(questionToken.Kind == RegexKind.QuestionToken); 718protected RegexOptionsGroupingNode(RegexKind kind, RegexToken openParenToken, RegexToken questionToken, RegexToken optionsToken, RegexToken closeParenToken) 734: base(RegexKind.SimpleOptionsGrouping, openParenToken, questionToken, optionsToken, closeParenToken) 762: base(RegexKind.NestedOptionsGrouping, openParenToken, questionToken, optionsToken, closeParenToken) 764Debug.Assert(colonToken.Kind == RegexKind.ColonToken); 799: base(RegexKind.NonCapturingGrouping, openParenToken, questionToken, closeParenToken) 801Debug.Assert(colonToken.Kind == RegexKind.ColonToken); 835: base(RegexKind.PositiveLookaheadGrouping, openParenToken, questionToken, closeParenToken) 837Debug.Assert(equalsToken.Kind == RegexKind.EqualsToken); 871: base(RegexKind.NegativeLookaheadGrouping, openParenToken, questionToken, closeParenToken) 873Debug.Assert(exclamationToken.Kind == RegexKind.ExclamationToken); 902RegexKind kind, RegexToken openParenToken, RegexToken questionToken, 906Debug.Assert(lessThanToken.Kind == RegexKind.LessThanToken); 921: base(RegexKind.PositiveLookbehindGrouping, openParenToken, questionToken, lessThanToken, closeParenToken) 923Debug.Assert(equalsToken.Kind == RegexKind.EqualsToken); 958: base(RegexKind.NegativeLookbehindGrouping, openParenToken, questionToken, lessThanToken, closeParenToken) 960Debug.Assert(exclamationToken.Kind == RegexKind.ExclamationToken); 995: base(RegexKind.AtomicGrouping, openParenToken, questionToken, closeParenToken) 997Debug.Assert(greaterThanToken.Kind == RegexKind.GreaterThanToken); 1032: base(RegexKind.CaptureGrouping, openParenToken, questionToken, closeParenToken) 1074: base(RegexKind.BalancingGrouping, openParenToken, questionToken, closeParenToken) 1076Debug.Assert(minusToken.Kind == RegexKind.MinusToken); 1117RegexKind kind, RegexToken openParenToken, RegexToken questionToken, 1137: base(RegexKind.ConditionalCaptureGrouping, openParenToken, questionToken, result, closeParenToken) 1139Debug.Assert(innerOpenParenToken.Kind == RegexKind.OpenParenToken); 1140Debug.Assert(innerCloseParenToken.Kind == RegexKind.CloseParenToken); 1178: base(RegexKind.ConditionalExpressionGrouping, openParenToken, questionToken, result, closeParenToken) 1208protected RegexEscapeNode(RegexKind kind, RegexToken backslashToken) : base(kind) 1210Debug.Assert(backslashToken.Kind == RegexKind.BackslashToken); 1222protected RegexTypeEscapeNode(RegexKind kind, RegexToken backslashToken, RegexToken typeToken) 1237: base(RegexKind.SimpleEscape, backslashToken, typeToken) 1239Debug.Assert(typeToken.Kind == RegexKind.TextToken); 1262: base(RegexKind.AnchorEscape, backslashToken, typeToken) 1286: base(RegexKind.CharacterClassEscape, backslashToken, typeToken) 1310: base(RegexKind.ControlEscape, backslashToken, typeToken) 1338: base(RegexKind.HexEscape, backslashToken, typeToken) 1366: base(RegexKind.UnicodeEscape, backslashToken, typeToken) 1395: base(RegexKind.CaptureEscape, backslashToken) 1430: base(RegexKind.KCaptureEscape, backslashToken, typeToken) 1464: base(RegexKind.OctalEscape, backslashToken) 1494: base(RegexKind.BackreferenceEscape, backslashToken) 1522: base(RegexKind.CategoryEscape, backslashToken) 1524Debug.Assert(openBraceToken.Kind == RegexKind.OpenBraceToken); 1525Debug.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 (129)
21using RegexAlternatingSequenceList = EmbeddedSeparatedSyntaxNodeList<RegexKind, RegexNode, RegexSequenceNode>; 22using RegexNodeOrToken = EmbeddedSyntaxNodeOrToken<RegexKind, RegexNode>; 23using RegexToken = EmbeddedSyntaxToken<RegexKind>; 24using RegexTrivia = EmbeddedSyntaxTrivia<RegexKind>; 171Debug.Assert(_currentToken.Kind == RegexKind.EndOfFile); 269while (_currentToken.Kind == RegexKind.BarToken) 314if (current.Kind != RegexKind.Text) 362RegexKind.TextToken, startTextNode.TextToken.LeadingTrivia, 373if (next.Kind == RegexKind.Text) 399if (_currentToken.Kind == RegexKind.EndOfFile) 404if (_currentToken.Kind == RegexKind.BarToken) 409if (_currentToken.Kind == RegexKind.CloseParenToken) 420if (current.Kind == RegexKind.SimpleOptionsGrouping) 428RegexKind.AsteriskToken => ParseZeroOrMoreQuantifier(current), 429RegexKind.PlusToken => ParseOneOrMoreQuantifier(current), 430RegexKind.QuestionToken => ParseZeroOrOneQuantifier(current), 431RegexKind.OpenBraceToken => TryParseNumericQuantifier(current, _currentToken), 438if (_currentToken.Kind != RegexKind.QuestionToken) 524if (_currentToken.Kind == RegexKind.CommaToken) 556if (_currentToken.Kind != RegexKind.CloseBraceToken) 576RegexKind.DotToken => ParseWildcard(), 577RegexKind.CaretToken => ParseStartAnchor(), 578RegexKind.DollarToken => ParseEndAnchor(), 579RegexKind.BackslashToken => ParseEscape(_currentToken, allowTriviaAfterEnd: true), 580RegexKind.OpenBracketToken => ParseCharacterClass(), 581RegexKind.OpenParenToken => ParseGrouping(), 582RegexKind.CloseParenToken => ParseUnexpectedCloseParenToken(), 583RegexKind.OpenBraceToken => ParsePossibleUnexpectedNumericQuantifier(lastExpression), 584RegexKind.AsteriskToken or RegexKind.PlusToken or RegexKind.QuestionToken => ParseUnexpectedQuantifier(lastExpression), 594var openBraceToken = _currentToken.With(kind: RegexKind.TextToken); 612var token = _currentToken.With(kind: RegexKind.TextToken).AddDiagnosticIfNone( 628return new RegexTextNode(token.With(kind: RegexKind.TextToken)); 634return new RegexAnchorNode(RegexKind.EndAnchor, ConsumeCurrentToken(allowTrivia: true)); 640return new RegexAnchorNode(RegexKind.StartAnchor, ConsumeCurrentToken(allowTrivia: true)); 659case RegexKind.QuestionToken: 673case RegexKind.CloseParenToken: 678return CreateMissingToken(RegexKind.CloseParenToken).AddDiagnosticIfNone( 706=> token.Kind == RegexKind.EndOfFile 712return token.Kind == RegexKind.EndOfFile 732case RegexKind.LessThanToken: 736case RegexKind.SingleQuoteToken: 741case RegexKind.OpenParenToken: 745case RegexKind.ColonToken: 748case RegexKind.EqualsToken: 751case RegexKind.ExclamationToken: 754case RegexKind.GreaterThanToken: 758if (_currentToken.Kind != RegexKind.CloseParenToken) 790if (capture.Kind == RegexKind.NumberToken) 801if (_currentToken.Kind == RegexKind.CloseParenToken) 813innerCloseParenToken = CreateMissingToken(RegexKind.CloseParenToken); 834if (_currentToken.Kind != RegexKind.CloseParenToken) 863if (_currentToken.Kind != RegexKind.EndOfFile) 916Debug.Assert(_currentToken.Kind == RegexKind.OpenParenToken); 950case RegexKind.EqualsToken: 955case RegexKind.ExclamationToken: 984captureToken = CreateMissingToken(RegexKind.CaptureNameToken); 986if (_currentToken.Kind == RegexKind.MinusToken) 1004if (capture.Kind == RegexKind.NumberToken && (int)capture.Value == 0) 1014if (_currentToken.Kind == RegexKind.MinusToken) 1032if ((openToken.Kind == RegexKind.LessThanToken && _currentToken.Kind == RegexKind.GreaterThanToken) || 1033(openToken.Kind == RegexKind.SingleQuoteToken && _currentToken.Kind == RegexKind.SingleQuoteToken)) 1038if (_currentToken.Kind == RegexKind.EndOfFile) 1055openToken.Kind == RegexKind.LessThanToken 1056? RegexKind.GreaterThanToken : RegexKind.SingleQuoteToken); 1077secondCapture = CreateMissingToken(RegexKind.CaptureNameToken); 1101if (captureToken.Kind == RegexKind.NumberToken) 1150case RegexKind.CloseParenToken: 1157case RegexKind.ColonToken: 1163CreateMissingToken(RegexKind.CloseParenToken).AddDiagnosticIfNone( 1175=> currentToken.Kind == RegexKind.TextToken && currentToken.VirtualChars.Length == 1 && currentToken.VirtualChars[0].Value == ch; 1222Debug.Assert(openBracketToken.Kind == RegexKind.OpenBracketToken); 1223var caretToken = CreateMissingToken(RegexKind.CaretToken); 1224var closeBracketToken = CreateMissingToken(RegexKind.CloseBracketToken); 1228if (_currentToken.Kind == RegexKind.CaretToken) 1241while (_currentToken.Kind != RegexKind.EndOfFile) 1245if (_currentToken.Kind == RegexKind.CloseBracketToken && builder.Count > 0) 1276if (left.Kind == RegexKind.CharacterClassEscape || 1277left.Kind == 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.PosixProperty: 1381case RegexKind.Text: 1385case RegexKind.Sequence: 1476if (_currentToken.Kind == RegexKind.BackslashToken && _lexer.Position < _lexer.Text.Length) 1518backslashToken, ConsumeCurrentToken(allowTrivia: false).With(kind: RegexKind.TextToken)); 1534_currentToken.Kind == RegexKind.MinusToken && 1546if (!afterRangeMinus && _currentToken.Kind == RegexKind.OpenBracketToken && _lexer.IsAt(":")) 1557var token = CreateToken(RegexKind.TextToken, ImmutableArray<RegexTrivia>.Empty, textChars); 1569Debug.Assert(_currentToken.Kind == RegexKind.OpenBracketToken); 1575ConsumeCurrentToken(allowTrivia: false).With(kind: RegexKind.TextToken)); 1582if (_currentToken.Kind is not RegexKind.CloseBracketToken and not RegexKind.EndOfFile) 1604if (_currentToken.Kind == RegexKind.EndOfFile) 1609return new RegexSimpleEscapeNode(backslashToken, CreateMissingToken(RegexKind.TextToken)); 1650if (_currentToken.Kind == RegexKind.EndOfFile) 1655return new RegexSimpleEscapeNode(backslashToken, CreateMissingToken(RegexKind.TextToken)); 1724RegexKind.NumberToken, ImmutableArray<RegexTrivia>.Empty, 1786return new RegexSimpleEscapeNode(backslashToken, typeToken.With(kind: RegexKind.TextToken)); 1805openToken = CreateMissingToken(RegexKind.LessThanToken); 1806capture = CreateMissingToken(RegexKind.CaptureNameToken); 1807closeToken = CreateMissingToken(RegexKind.GreaterThanToken); 1813(_currentToken.Kind == RegexKind.LessThanToken || _currentToken.Kind == RegexKind.SingleQuoteToken)) 1824? CreateMissingToken(RegexKind.CaptureNameToken) 1829closeToken = CreateMissingToken(RegexKind.GreaterThanToken); 1832((openToken.Kind == RegexKind.LessThanToken && _currentToken.Kind == RegexKind.GreaterThanToken) || 1833(openToken.Kind == RegexKind.SingleQuoteToken && _currentToken.Kind == RegexKind.SingleQuoteToken))) 1878var typeToken = ConsumeCurrentToken(allowTrivia: allowTriviaAfterEnd).With(kind: RegexKind.TextToken); 1912if (_currentToken.Kind == RegexKind.EndOfFile) 1917return new RegexControlEscapeNode(backslashToken, typeToken, CreateMissingToken(RegexKind.TextToken)); 1949var controlToken = ConsumeCurrentToken(allowTrivia: allowTriviaAfterEnd).With(kind: RegexKind.TextToken); 1959return new RegexControlEscapeNode(backslashToken, typeToken, CreateMissingToken(RegexKind.TextToken)); 1979typeToken = typeToken.With(kind: RegexKind.TextToken).AddDiagnosticIfNone(new EmbeddedDiagnostic( 2008if (_currentToken.Kind != RegexKind.OpenBraceToken) 2019if (_currentToken.Kind != RegexKind.CloseBraceToken) 2042return new RegexTextNode(token.With(kind: RegexKind.TextToken)); 2048current.Kind == RegexKind.SimpleOptionsGrouping)
EmbeddedLanguages\RegularExpressions\RegexTree.cs (1)
14internal sealed class RegexTree : EmbeddedSyntaxTree<RegexKind, RegexNode, RegexCompilationUnit>