203 references to RegexKind
Microsoft.CodeAnalysis.Features (203)
EmbeddedLanguages\RegularExpressions\LanguageServices\RegexBraceMatcher.cs (3)
19
using RegexToken = EmbeddedSyntaxToken<
RegexKind
>;
20
using RegexTrivia = EmbeddedSyntaxTrivia<
RegexKind
>;
79
if (trivia?.Kind !=
RegexKind
.CommentTrivia)
EmbeddedLanguages\RegularExpressions\LanguageServices\RegexClassifier.cs (3)
19
using RegexToken = EmbeddedSyntaxToken<
RegexKind
>;
20
using RegexTrivia = EmbeddedSyntaxTrivia<
RegexKind
>;
97
if (trivia.Kind ==
RegexKind
.CommentTrivia &&
EmbeddedLanguages\RegularExpressions\LanguageServices\RegexDocumentHighlighter.cs (5)
20
using RegexToken = EmbeddedSyntaxToken<
RegexKind
>;
88
if (captureToken.Kind ==
RegexKind
.NumberToken)
128
if (node.Kind is
RegexKind
.BackreferenceEscape or
129
RegexKind
.CaptureEscape or
130
RegexKind
.KCaptureEscape)
EmbeddedLanguages\RegularExpressions\LanguageServices\RegexEmbeddedCompletionProvider.cs (4)
24
using RegexToken = EmbeddedSyntaxToken<
RegexKind
>;
191
case
RegexKind
.BackslashToken:
194
case
RegexKind
.OpenBracketToken:
197
case
RegexKind
.OpenParenToken:
EmbeddedLanguages\RegularExpressions\RegexHelpers.cs (6)
15
using RegexToken = EmbeddedSyntaxToken<
RegexKind
>;
16
using RegexTrivia = EmbeddedSyntaxTrivia<
RegexKind
>;
23
public static RegexToken CreateToken(
RegexKind
kind, ImmutableArray<RegexTrivia> leadingTrivia, VirtualCharSequence virtualChars)
26
public static RegexToken CreateMissingToken(
RegexKind
kind)
29
public static RegexTrivia CreateTrivia(
RegexKind
kind, VirtualCharSequence virtualChars)
32
public static RegexTrivia CreateTrivia(
RegexKind
kind, VirtualCharSequence virtualChars, ImmutableArray<EmbeddedDiagnostic> diagnostics)
EmbeddedLanguages\RegularExpressions\RegexLexer.cs (38)
19
using RegexToken = EmbeddedSyntaxToken<
RegexKind
>;
20
using RegexTrivia = EmbeddedSyntaxTrivia<
RegexKind
>;
35
/// cref="RegexTextNode"/>s in a row (each containing a <see cref="
RegexKind
.TextToken"/> a
62
return CreateToken(
RegexKind
.EndOfFile, trivia, VirtualCharSequence.Empty);
71
private 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,
150
return CreateTrivia(
RegexKind
.CommentTrivia, GetSubPatternToCurrentPos(start));
168
return CreateTrivia(
RegexKind
.CommentTrivia, GetSubPatternToCurrentPos(start), diagnostics);
172
return CreateTrivia(
RegexKind
.CommentTrivia, GetSubPatternToCurrentPos(start));
210
return CreateTrivia(
RegexKind
.WhitespaceTrivia, GetSubPatternToCurrentPos(start));
247
var token = CreateToken(
RegexKind
.EscapeCategoryToken, [], GetSubPatternToCurrentPos(start));
300
var token = CreateToken(
RegexKind
.NumberToken, [], GetSubPatternToCurrentPos(start));
331
var token = CreateToken(
RegexKind
.CaptureNameToken, [], GetSubPatternToCurrentPos(start));
349
: CreateToken(
RegexKind
.OptionsToken, ImmutableArray<RegexTrivia>.Empty, GetSubPatternToCurrentPos(start));
392
RegexKind
.TextToken, [], GetSubPatternToCurrentPos(start));
453
RegexKind
.TextToken, [], GetSubPatternToCurrentPos(start));
EmbeddedLanguages\RegularExpressions\RegexNode.cs (2)
11
internal abstract class RegexNode : EmbeddedSyntaxNode<
RegexKind
, RegexNode>
13
protected RegexNode(
RegexKind
kind) : base(kind)
EmbeddedLanguages\RegularExpressions\RegexNodes.cs (6)
14
using RegexNodeOrToken = EmbeddedSyntaxNodeOrToken<
RegexKind
, RegexNode>;
15
using RegexToken = EmbeddedSyntaxToken<
RegexKind
>;
16
using RegexAlternatingSequenceList = EmbeddedSeparatedSyntaxNodeList<
RegexKind
, RegexNode, RegexSequenceNode>;
21
: base(
RegexKind
.CompilationUnit)
24
Debug.Assert(endOfFileToken.Kind ==
RegexKind
.EndOfFile);
57
internal sealed class RegexSequenceNode(ImmutableArray<RegexExpressionNode> children) : RegexExpressionNode(
RegexKind
.Sequence)
EmbeddedLanguages\RegularExpressions\RegexParser.CaptureInfoAnalyzer.cs (7)
20
using RegexToken = EmbeddedSyntaxToken<
RegexKind
>;
85
case
RegexKind
.CaptureGrouping:
90
case
RegexKind
.BalancingGrouping:
95
case
RegexKind
.ConditionalExpressionGrouping:
104
case
RegexKind
.SimpleGrouping:
108
case
RegexKind
.NestedOptionsGrouping:
185
if (token.Kind ==
RegexKind
.NumberToken)
EmbeddedLanguages\RegularExpressions\RegexParser.cs (128)
21
using RegexAlternatingSequenceList = EmbeddedSeparatedSyntaxNodeList<
RegexKind
, RegexNode, RegexSequenceNode>;
22
using RegexNodeOrToken = EmbeddedSyntaxNodeOrToken<
RegexKind
, RegexNode>;
23
using RegexToken = EmbeddedSyntaxToken<
RegexKind
>;
170
Debug.Assert(_currentToken.Kind ==
RegexKind
.EndOfFile);
268
while (_currentToken.Kind ==
RegexKind
.BarToken)
313
if (current.Kind !=
RegexKind
.Text)
361
RegexKind
.TextToken, startTextNode.TextToken.LeadingTrivia,
372
if (next.Kind ==
RegexKind
.Text)
398
if (_currentToken.Kind ==
RegexKind
.EndOfFile)
403
if (_currentToken.Kind ==
RegexKind
.BarToken)
408
if (_currentToken.Kind ==
RegexKind
.CloseParenToken)
419
if (current.Kind ==
RegexKind
.SimpleOptionsGrouping)
427
RegexKind
.AsteriskToken => ParseZeroOrMoreQuantifier(current),
428
RegexKind
.PlusToken => ParseOneOrMoreQuantifier(current),
429
RegexKind
.QuestionToken => ParseZeroOrOneQuantifier(current),
430
RegexKind
.OpenBraceToken => TryParseNumericQuantifier(current, _currentToken),
437
if (_currentToken.Kind !=
RegexKind
.QuestionToken)
523
if (_currentToken.Kind ==
RegexKind
.CommaToken)
555
if (_currentToken.Kind !=
RegexKind
.CloseBraceToken)
575
RegexKind
.DotToken => ParseWildcard(),
576
RegexKind
.CaretToken => ParseStartAnchor(),
577
RegexKind
.DollarToken => ParseEndAnchor(),
578
RegexKind
.BackslashToken => ParseEscape(_currentToken, allowTriviaAfterEnd: true),
579
RegexKind
.OpenBracketToken => ParseCharacterClass(),
580
RegexKind
.OpenParenToken => ParseGrouping(),
581
RegexKind
.CloseParenToken => ParseUnexpectedCloseParenToken(),
582
RegexKind
.OpenBraceToken => ParsePossibleUnexpectedNumericQuantifier(lastExpression),
583
RegexKind
.AsteriskToken or
RegexKind
.PlusToken or
RegexKind
.QuestionToken => ParseUnexpectedQuantifier(lastExpression),
593
var openBraceToken = _currentToken.With(kind:
RegexKind
.TextToken);
611
var token = _currentToken.With(kind:
RegexKind
.TextToken).AddDiagnosticIfNone(
627
return new RegexTextNode(token.With(kind:
RegexKind
.TextToken));
633
return new RegexAnchorNode(
RegexKind
.EndAnchor, ConsumeCurrentToken(allowTrivia: true));
639
return new RegexAnchorNode(
RegexKind
.StartAnchor, ConsumeCurrentToken(allowTrivia: true));
658
case
RegexKind
.QuestionToken:
672
case
RegexKind
.CloseParenToken:
677
return CreateMissingToken(
RegexKind
.CloseParenToken).AddDiagnosticIfNone(
705
=> token.Kind ==
RegexKind
.EndOfFile
711
return token.Kind ==
RegexKind
.EndOfFile
731
case
RegexKind
.LessThanToken:
735
case
RegexKind
.SingleQuoteToken:
740
case
RegexKind
.OpenParenToken:
744
case
RegexKind
.ColonToken:
747
case
RegexKind
.EqualsToken:
750
case
RegexKind
.ExclamationToken:
753
case
RegexKind
.GreaterThanToken:
757
if (_currentToken.Kind !=
RegexKind
.CloseParenToken)
789
if (capture.Kind ==
RegexKind
.NumberToken)
800
if (_currentToken.Kind ==
RegexKind
.CloseParenToken)
812
innerCloseParenToken = CreateMissingToken(
RegexKind
.CloseParenToken);
833
if (_currentToken.Kind !=
RegexKind
.CloseParenToken)
862
if (_currentToken.Kind !=
RegexKind
.EndOfFile)
915
Debug.Assert(_currentToken.Kind ==
RegexKind
.OpenParenToken);
949
case
RegexKind
.EqualsToken:
954
case
RegexKind
.ExclamationToken:
983
captureToken = CreateMissingToken(
RegexKind
.CaptureNameToken);
985
if (_currentToken.Kind ==
RegexKind
.MinusToken)
1003
if (capture.Kind ==
RegexKind
.NumberToken && (int)capture.Value == 0)
1013
if (_currentToken.Kind ==
RegexKind
.MinusToken)
1031
if ((openToken.Kind ==
RegexKind
.LessThanToken && _currentToken.Kind ==
RegexKind
.GreaterThanToken) ||
1032
(openToken.Kind ==
RegexKind
.SingleQuoteToken && _currentToken.Kind ==
RegexKind
.SingleQuoteToken))
1037
if (_currentToken.Kind ==
RegexKind
.EndOfFile)
1054
openToken.Kind ==
RegexKind
.LessThanToken
1055
?
RegexKind
.GreaterThanToken :
RegexKind
.SingleQuoteToken);
1076
secondCapture = CreateMissingToken(
RegexKind
.CaptureNameToken);
1100
if (captureToken.Kind ==
RegexKind
.NumberToken)
1149
case
RegexKind
.CloseParenToken:
1156
case
RegexKind
.ColonToken:
1162
CreateMissingToken(
RegexKind
.CloseParenToken).AddDiagnosticIfNone(
1174
=> currentToken.Kind ==
RegexKind
.TextToken && currentToken.VirtualChars.Length == 1 && currentToken.VirtualChars[0].Value == ch;
1221
Debug.Assert(openBracketToken.Kind ==
RegexKind
.OpenBracketToken);
1222
var caretToken = CreateMissingToken(
RegexKind
.CaretToken);
1223
var closeBracketToken = CreateMissingToken(
RegexKind
.CloseBracketToken);
1227
if (_currentToken.Kind ==
RegexKind
.CaretToken)
1240
while (_currentToken.Kind !=
RegexKind
.EndOfFile)
1244
if (_currentToken.Kind ==
RegexKind
.CloseBracketToken && builder.Count > 0)
1275
if (left.Kind is
RegexKind
.CharacterClassEscape or
RegexKind
.CategoryEscape ||
1284
if (_currentToken.Kind ==
RegexKind
.MinusToken && !_lexer.IsAt("]"))
1289
if (_currentToken.Kind ==
RegexKind
.OpenBracketToken)
1340
case
RegexKind
.SimpleEscape:
1345
case
RegexKind
.ControlEscape:
1361
case
RegexKind
.OctalEscape:
1365
case
RegexKind
.HexEscape:
1369
case
RegexKind
.UnicodeEscape:
1373
case
RegexKind
.PosixProperty:
1379
case
RegexKind
.Text:
1383
case
RegexKind
.Sequence:
1474
if (_currentToken.Kind ==
RegexKind
.BackslashToken && _lexer.Position < _lexer.Text.Length)
1516
backslashToken, ConsumeCurrentToken(allowTrivia: false).With(kind:
RegexKind
.TextToken));
1532
_currentToken.Kind ==
RegexKind
.MinusToken &&
1544
if (!afterRangeMinus && _currentToken.Kind ==
RegexKind
.OpenBracketToken && _lexer.IsAt(":"))
1555
var token = CreateToken(
RegexKind
.TextToken, [], textChars);
1567
Debug.Assert(_currentToken.Kind ==
RegexKind
.OpenBracketToken);
1573
ConsumeCurrentToken(allowTrivia: false).With(kind:
RegexKind
.TextToken));
1580
if (_currentToken.Kind is not
RegexKind
.CloseBracketToken and not
RegexKind
.EndOfFile)
1602
if (_currentToken.Kind ==
RegexKind
.EndOfFile)
1607
return new RegexSimpleEscapeNode(backslashToken, CreateMissingToken(
RegexKind
.TextToken));
1648
if (_currentToken.Kind ==
RegexKind
.EndOfFile)
1653
return new RegexSimpleEscapeNode(backslashToken, CreateMissingToken(
RegexKind
.TextToken));
1722
RegexKind
.NumberToken, [],
1784
return new RegexSimpleEscapeNode(backslashToken, typeToken.With(kind:
RegexKind
.TextToken));
1803
openToken = CreateMissingToken(
RegexKind
.LessThanToken);
1804
capture = CreateMissingToken(
RegexKind
.CaptureNameToken);
1805
closeToken = CreateMissingToken(
RegexKind
.GreaterThanToken);
1811
(_currentToken.Kind ==
RegexKind
.LessThanToken || _currentToken.Kind ==
RegexKind
.SingleQuoteToken))
1822
? CreateMissingToken(
RegexKind
.CaptureNameToken)
1827
closeToken = CreateMissingToken(
RegexKind
.GreaterThanToken);
1830
((openToken.Kind ==
RegexKind
.LessThanToken && _currentToken.Kind ==
RegexKind
.GreaterThanToken) ||
1831
(openToken.Kind ==
RegexKind
.SingleQuoteToken && _currentToken.Kind ==
RegexKind
.SingleQuoteToken)))
1876
var typeToken = ConsumeCurrentToken(allowTrivia: allowTriviaAfterEnd).With(kind:
RegexKind
.TextToken);
1910
if (_currentToken.Kind ==
RegexKind
.EndOfFile)
1915
return new RegexControlEscapeNode(backslashToken, typeToken, CreateMissingToken(
RegexKind
.TextToken));
1947
var controlToken = ConsumeCurrentToken(allowTrivia: allowTriviaAfterEnd).With(kind:
RegexKind
.TextToken);
1957
return new RegexControlEscapeNode(backslashToken, typeToken, CreateMissingToken(
RegexKind
.TextToken));
1977
typeToken = typeToken.With(kind:
RegexKind
.TextToken).AddDiagnosticIfNone(new EmbeddedDiagnostic(
2006
if (_currentToken.Kind !=
RegexKind
.OpenBraceToken)
2017
if (_currentToken.Kind !=
RegexKind
.CloseBraceToken)
2040
return new RegexTextNode(token.With(kind:
RegexKind
.TextToken));
2046
current.Kind ==
RegexKind
.SimpleOptionsGrouping)
EmbeddedLanguages\RegularExpressions\RegexTree.cs (1)
19
ImmutableDictionary<int, TextSpan> captureNumbersToSpan) : EmbeddedSyntaxTree<
RegexKind
, RegexNode, RegexCompilationUnit>(text, root, diagnostics)