150 references to PeekToken
Microsoft.CodeAnalysis.CSharp (150)
Parser\DocumentationCommentParser.cs (1)
1381
else if (CurrentToken.Kind == SyntaxKind.IdentifierToken &&
PeekToken
(1).Kind == SyntaxKind.ColonColonToken)
Parser\LanguageParser.cs (146)
662
if (isGlobal && (this.
PeekToken
(1).Kind == SyntaxKind.OpenParenToken || (!IsScript && IsPossibleTopLevelUsingLocalDeclarationStatement())))
676
if (this.CurrentToken.ContextualKind != SyntaxKind.GlobalKeyword || this.
PeekToken
(1).Kind != SyntaxKind.UsingKeyword)
884
else if (this.
PeekToken
(1).Kind == SyntaxKind.NamespaceKeyword)
921
&& this.
PeekToken
(1) is { Kind: SyntaxKind.IdentifierToken, ContextualKind: SyntaxKind.AliasKeyword }
922
&& this.
PeekToken
(2).Kind == SyntaxKind.IdentifierToken
923
&& this.
PeekToken
(3).Kind == SyntaxKind.SemicolonToken;
1011
if (type.IsMissing && this.
PeekToken
(1).Kind == SyntaxKind.SemicolonToken)
1023
&& IsGlobalAttributeTarget(this.
PeekToken
(1))
1024
&& this.
PeekToken
(2).Kind == SyntaxKind.ColonToken;
1109
=> IsSomeWord(this.CurrentToken.Kind) && this.
PeekToken
(1).Kind == SyntaxKind.ColonToken;
1166
this.
PeekToken
(1).Kind == SyntaxKind.DotToken)
1270
switch (this.
PeekToken
(1).Kind)
1382
var nextToken =
PeekToken
(1);
1413
var next =
PeekToken
(1);
1416
isStructOrRecordKeyword(
PeekToken
(2))))
1500
if (IsNonContextualModifier(
PeekToken
(1)))
1535
(currentTokenKind is SyntaxKind.ExplicitKeyword or SyntaxKind.ImplicitKeyword &&
PeekToken
(1).Kind == SyntaxKind.OperatorKeyword))
1615
var nextToken = this.
PeekToken
(1);
1673
if (this.CurrentToken.ContextualKind == SyntaxKind.GlobalKeyword && this.
PeekToken
(1).Kind == SyntaxKind.UsingKeyword)
1864
this.
PeekToken
(1).ContextualKind == SyntaxKind.RecordKeyword &&
1865
this.
PeekToken
(2).Kind is SyntaxKind.IdentifierToken)
2002
!(kind == SyntaxKind.DelegateKeyword && this.
PeekToken
(1).Kind is SyntaxKind.OpenBraceToken or SyntaxKind.OpenParenToken))
2128
this.
PeekToken
(1).Kind == SyntaxKind.IdentifierToken &&
2129
this.
PeekToken
(2).Kind == SyntaxKind.ColonToken;
2230
return (this.CurrentToken.ContextualKind == SyntaxKind.AllowsKeyword &&
PeekToken
(1).Kind == SyntaxKind.RefKeyword) || this.IsTrueIdentifier();
2271
PeekToken
(1).Kind == SyntaxKind.AsteriskToken
2283
PeekToken
(1).Kind == SyntaxKind.RefKeyword)
2296
if (this.CurrentToken.Kind == SyntaxKind.CommaToken &&
PeekToken
(1).Kind == SyntaxKind.RefKeyword)
2524
if (this.
PeekToken
(1).Kind == SyntaxKind.OpenBraceToken)
2531
if (this.
PeekToken
(1).Kind == SyntaxKind.OpenParenToken)
2538
switch (this.
PeekToken
(1).Kind)
2567
if (this.CurrentToken.Kind == SyntaxKind.IdentifierToken && this.
PeekToken
(1).Kind == SyntaxKind.OpenParenToken)
2904
if (CurrentToken.ContextualKind == SyntaxKind.GlobalKeyword && this.
PeekToken
(1).Kind == SyntaxKind.UsingKeyword)
3016
(this.CurrentToken.Kind is SyntaxKind.SemicolonToken && IsStartOfPropertyBody(this.
PeekToken
(1).Kind)))
3069
if (this.CurrentToken.Kind == SyntaxKind.IdentifierToken && this.
PeekToken
(1).Kind == SyntaxKind.OpenParenToken)
3230
if (this.CurrentToken.ContextualKind == SyntaxKind.GlobalKeyword && this.
PeekToken
(1).Kind == SyntaxKind.UsingKeyword)
3241
var kind = this.
PeekToken
(1).Kind;
3248
IsStartOfPropertyBody(this.
PeekToken
(2).Kind))
3618
else if (this.
PeekToken
(1).Kind is SyntaxKind.CheckedKeyword or SyntaxKind.UncheckedKeyword)
3620
possibleConversion = !SyntaxFacts.IsAnyOverloadableOperator(this.
PeekToken
(2).Kind);
3624
possibleConversion = !SyntaxFacts.IsAnyOverloadableOperator(this.
PeekToken
(1).Kind);
3800
this.
PeekToken
(1).Kind is SyntaxKind.OperatorKeyword)
4211
while (GetModifierExcludingScoped(this.
PeekToken
(peekIndex)) != DeclarationModifiers.None)
4216
var token = this.
PeekToken
(peekIndex);
4712
if (this.CurrentToken.Kind is SyntaxKind.OpenBracketToken && this.
PeekToken
(1).Kind is SyntaxKind.CloseBracketToken)
5060
if (flags.HasFlag(VariableFlags.ForStatement) && this.
PeekToken
(1).Kind != SyntaxKind.SemicolonToken)
5064
if (!IsTrueIdentifier(this.
PeekToken
(1)))
5069
if (this.
PeekToken
(2).Kind is not (SyntaxKind.SemicolonToken or SyntaxKind.EqualsToken or SyntaxKind.CloseParenToken))
5819
if (this.CurrentToken.Kind == SyntaxKind.OpenBracketToken && this.
PeekToken
(1).Kind != SyntaxKind.CloseBracketToken)
5840
if (this.CurrentToken.Kind == SyntaxKind.OpenBracketToken && this.
PeekToken
(1).Kind != SyntaxKind.CloseBracketToken)
5986
case SyntaxKind.GreaterThanToken when ((options & NameOptions.AfterIs) != 0) && this.
PeekToken
(1).Kind != SyntaxKind.GreaterThanToken:
6007
(options & NameOptions.AfterTupleComma) != 0 && this.
PeekToken
(1).Kind is SyntaxKind.CommaToken or SyntaxKind.CloseParenToken ||
6008
(options & NameOptions.FirstElementOfPossibleTupleLiteral) != 0 && this.
PeekToken
(1).Kind == SyntaxKind.CommaToken)
6263
if (this.CurrentToken.Kind is SyntaxKind.IdentifierToken && tokenBreaksTypeArgumentList(this.
PeekToken
(1)))
6273
&& this.
PeekToken
(1).Kind is SyntaxKind.CloseBracketToken)
6357
if (this.CurrentToken.Kind == SyntaxKind.OpenBracketToken && this.
PeekToken
(1).Kind != SyntaxKind.CloseBracketToken)
6401
this.
PeekToken
(1).Kind is SyntaxKind.CommaToken or SyntaxKind.GreaterThanToken)
6428
while (this.
PeekToken
(n).Kind == SyntaxKind.CommaToken)
6431
return this.
PeekToken
(n).Kind == SyntaxKind.GreaterThanToken;
6716
if (this.
PeekToken
(1).Kind == SyntaxKind.ThisKeyword)
6909
isAlias = this.
PeekToken
(1).Kind == SyntaxKind.ColonColonToken;
7100
var peek1 =
PeekToken
(1);
7221
if (this.CurrentToken.Kind == SyntaxKind.VoidKeyword && this.
PeekToken
(1).Kind != SyntaxKind.AsteriskToken)
7396
switch (this.
PeekToken
(1).Kind)
7452
var nextToken =
PeekToken
(1);
7526
switch (this.
PeekToken
(i).Kind)
7774
SyntaxToken peek1 =
PeekToken
(1);
7847
=> CurrentToken.Kind == SyntaxKind.DelegateKeyword &&
PeekToken
(1).Kind == SyntaxKind.AsteriskToken;
7917
|| (this.CurrentToken.ContextualKind is SyntaxKind.SwitchKeyword or SyntaxKind.WithKeyword && this.
PeekToken
(1).Kind is SyntaxKind.OpenBraceToken);
8113
this.
PeekToken
(1).Kind == SyntaxKind.ForEachKeyword)
8119
if (
PeekToken
(2).Kind == SyntaxKind.OpenParenToken)
8146
=>
PeekToken
(1).Kind == SyntaxKind.OpenParenToken ? ParseUsingStatement(attributes) : ParseLocalDeclarationStatement(attributes);
8153
=> CurrentToken.ContextualKind == SyntaxKind.AwaitKeyword &&
PeekToken
(1).Kind == SyntaxKind.UsingKeyword;
8157
return this.
PeekToken
(1).Kind == SyntaxKind.ColonToken && this.IsTrueIdentifier();
8162
return this.
PeekToken
(1).Kind == SyntaxKind.OpenBraceToken;
8168
this.
PeekToken
(1).Kind is SyntaxKind.ReturnKeyword or SyntaxKind.BreakKeyword;
8181
this.
PeekToken
(1).Kind is not SyntaxKind.DotToken // e.g. `int.Parse()` is an expression
8190
Debug.Assert(
PeekToken
(1).Kind != SyntaxKind.OpenParenToken);
8196
Debug.Assert(
PeekToken
(2).Kind != SyntaxKind.OpenParenToken);
8226
bool? typedIdentifier = IsPossibleTypedIdentifierStart(this.CurrentToken, this.
PeekToken
(1), allowThisKeyword: false);
8251
var token1 =
PeekToken
(1);
8255
if (
PeekToken
(2).Kind == SyntaxKind.IdentifierToken &&
8256
PeekToken
(3).Kind == SyntaxKind.IdentifierToken)
8271
var token4Kind =
PeekToken
(4).Kind;
8324
var tk =
PeekToken
(1).Kind;
8534
SyntaxToken nextToken =
PeekToken
(1);
8574
if (SyntaxFacts.IsPredefinedType(
PeekToken
(2).Kind))
8581
if (IsTypeModifierOrTypeKeyword(
PeekToken
(2).Kind))
8591
bool? typedIdentifier = IsPossibleTypedIdentifierStart(nextToken,
PeekToken
(2), allowThisKeyword: true);
9097
if (this.
PeekToken
(1).Kind == SyntaxKind.OpenParenToken)
9224
if (this.
PeekToken
(1).Kind == SyntaxKind.RefKeyword)
9439
if (this.
PeekToken
(1).Kind == SyntaxKind.CommaToken)
9447
if (this.
PeekToken
(1).Kind is SyntaxKind.CommaToken or SyntaxKind.CloseParenToken)
9501
switch (this.
PeekToken
(1).Kind)
9786
(this.CurrentToken.Kind == SyntaxKind.DefaultKeyword && this.
PeekToken
(1).Kind != SyntaxKind.OpenParenToken);
9948
switch (this.
PeekToken
(1).Kind)
10002
bool condition3 = st == ScanTypeFlags.NonGenericTypeOrExpression || this.
PeekToken
(1).Kind == SyntaxKind.EqualsToken;
10023
Debug.Assert(this.IsTrueIdentifier() && this.
PeekToken
(1).Kind == SyntaxKind.ColonToken);
10914
var next =
PeekToken
(1);
11196
&& this.
PeekToken
(1) is { Kind: SyntaxKind.GreaterThanToken or SyntaxKind.GreaterThanEqualsToken } token2
11201
if (this.
PeekToken
(2) is { Kind: SyntaxKind.GreaterThanToken or SyntaxKind.GreaterThanEqualsToken } token3
11228
if (token1Kind == SyntaxKind.SwitchKeyword && this.
PeekToken
(1).Kind == SyntaxKind.OpenBraceToken)
11231
if (token1Kind == SyntaxKind.WithKeyword && this.
PeekToken
(1).Kind == SyntaxKind.OpenBraceToken)
11376
=> IsAtDotDotToken(this.CurrentToken, this.
PeekToken
(1));
11410
if (this.
PeekToken
(1) is not { Kind: SyntaxKind.DotToken } token4 ||
11517
else if (IsCurrentTokenFieldInKeywordContext() &&
PeekToken
(1).Kind != SyntaxKind.ColonColonToken)
11646
if (this.
PeekToken
(1).Kind == SyntaxKind.IdentifierToken)
11678
this.
PeekToken
(1).Kind == SyntaxKind.IdentifierToken &&
11679
this.
PeekToken
(2).ContextualKind == SyntaxKind.IdentifierToken)
11782
while (this.
PeekToken
(tokenIndex).Kind == SyntaxKind.StaticKeyword ||
11783
this.
PeekToken
(tokenIndex).ContextualKind == SyntaxKind.AsyncKeyword)
11788
return this.
PeekToken
(tokenIndex).Kind == SyntaxKind.DelegateKeyword &&
11789
this.
PeekToken
(tokenIndex + 1).Kind != SyntaxKind.AsteriskToken;
11795
var nextToken = this.
PeekToken
(1);
11801
if (nextTokenKind == SyntaxKind.DotToken && !IsAtDotDotToken(nextToken, this.
PeekToken
(2)))
11877
while (this.
PeekToken
(index).Kind == SyntaxKind.ExclamationToken)
11880
return this.
PeekToken
(index).Kind
12028
var nameColon = this.CurrentToken.Kind == SyntaxKind.IdentifierToken && this.
PeekToken
(1).Kind == SyntaxKind.ColonToken
12167
var tk = this.
PeekToken
(curTk++);
12179
return this.
PeekToken
(curTk - 1).Kind == SyntaxKind.CloseParenToken &&
12180
this.
PeekToken
(curTk).Kind == SyntaxKind.EqualsGreaterThanToken;
12184
if (IsTrueIdentifier(this.
PeekToken
(1)))
12190
if (this.
PeekToken
(skipIndex).Kind == SyntaxKind.CloseParenToken
12191
&& this.
PeekToken
(skipIndex + 1).Kind == SyntaxKind.EqualsGreaterThanToken)
12198
if (this.
PeekToken
(1).Kind == SyntaxKind.CloseParenToken
12199
&& this.
PeekToken
(2).Kind == SyntaxKind.EqualsGreaterThanToken)
12207
if (this.
PeekToken
(1).Kind == SyntaxKind.ParamsKeyword)
12216
var token1 = this.
PeekToken
(1);
12224
var token2 = this.
PeekToken
(2);
12309
return this.
PeekToken
(1).Kind == SyntaxKind.EqualsGreaterThanToken;
12481
this.
PeekToken
(1).Kind == SyntaxKind.CloseBracketToken)
12536
var token1 = this.
PeekToken
(1);
12571
this.
PeekToken
(1).Kind == SyntaxKind.StaticKeyword)
12603
this.
PeekToken
(1).Kind == SyntaxKind.EqualsGreaterThanToken)
12640
this.
PeekToken
(1).Kind == SyntaxKind.EqualsGreaterThanToken)
12779
return this.CurrentToken.Kind == SyntaxKind.NewKeyword && this.
PeekToken
(1).Kind == SyntaxKind.OpenBraceToken;
12829
return IsTrueIdentifier() && this.
PeekToken
(1).Kind == SyntaxKind.EqualsToken;
13068
return this.
PeekToken
(1).Kind == SyntaxKind.OpenBracketToken;
13278
switch (this.
PeekToken
(1).Kind)
13358
var identifier = (this.CurrentToken.Kind != SyntaxKind.IdentifierToken && this.
PeekToken
(1).Kind == SyntaxKind.EqualsGreaterThanToken)
13498
var peek1 = this.
PeekToken
(1);
13563
var pk1 = this.
PeekToken
(1).Kind;
13571
var pk2 = this.
PeekToken
(2).Kind;
13679
var type = this.
PeekToken
(1).Kind != SyntaxKind.InKeyword
13684
if (this.
PeekToken
(1).ContextualKind == SyntaxKind.InKeyword &&
13712
type: this.
PeekToken
(1).Kind != SyntaxKind.InKeyword
Parser\LanguageParser_Patterns.cs (2)
85
(this.CurrentToken.ContextualKind != SyntaxKind.NameOfKeyword || this.
PeekToken
(1).Kind != SyntaxKind.OpenParenToken))
394
var tk =
PeekToken
(1).Kind;
Parser\SyntaxParser.cs (1)
178
PeekToken
(offset - _tokenOffset);