1 write to Parent
Microsoft.CodeAnalysis (1)
Syntax\SyntaxToken.cs (1)
32
Parent
= parent;
2159 references to Parent
Microsoft.AspNetCore.App.Analyzers (15)
Infrastructure\VirtualChars\CSharpVirtualCharService.cs (2)
34
if (token.
Parent
?.Parent is InterpolatedStringExpressionSyntax { StringStartToken.RawKind: (int)SyntaxKind.InterpolatedMultiLineRawStringStartToken })
53
if (IsInDirective(token.
Parent
))
RouteEmbeddedLanguage\FrameworkParametersCompletionProvider.cs (5)
118
var container = TryFindMinimalApiArgument(token.
Parent
) ?? TryFindMvcActionParameter(token.
Parent
);
358
if (token.
Parent
?.Parent is ParameterSyntax parameter)
388
if (token.
Parent
.IsKind(SyntaxKind.PredefinedType))
393
var parameterTypeSymbol = semanticModel.GetSymbolInfo(token.
Parent
!, cancellationToken).GetAnySymbol();
RouteEmbeddedLanguage\Infrastructure\RouteStringSyntaxDetector.cs (5)
65
if (token.
Parent
is not LiteralExpressionSyntax)
158
if (token.
Parent
.IsLiteralExpression() &&
159
token.
Parent
.Parent.IsBinaryExpression() &&
160
token.
Parent
.Parent.RawKind == (int)SyntaxKind.AddExpression)
165
for (var node = token.
Parent
; node != null; node = node.Parent)
RouteEmbeddedLanguage\Infrastructure\RouteUsageDetector.cs (1)
71
if (token.
Parent
is not LiteralExpressionSyntax)
RouteEmbeddedLanguage\Infrastructure\SyntaxNodeExtensions.cs (1)
30
parent = structuredTrivia.ParentTrivia.Token.
Parent
;
RouteEmbeddedLanguage\Infrastructure\SyntaxTokenExtensions.cs (1)
25
=> token.
Parent
?? throw new InvalidOperationException("Token's parent was null");
Microsoft.AspNetCore.App.CodeFixes (2)
Dependencies\ExtensionMethodsCompletionProvider.cs (2)
42
if (token.
Parent
== null)
60
var nearestMemberAccessExpression = FindNearestMemberAccessExpression(token.
Parent
);
Microsoft.AspNetCore.Components.Analyzers (1)
ComponentParametersShouldBePublicCodeFixProvider.cs (1)
38
var declaration = root.FindToken(diagnosticSpan.Start).
Parent
.AncestorsAndSelf().OfType<PropertyDeclarationSyntax>().First();
Microsoft.AspNetCore.Components.SdkAnalyzers (1)
ComponentParametersShouldBePublicCodeFixProvider.cs (1)
38
var declaration = root.FindToken(diagnosticSpan.Start).
Parent
.AncestorsAndSelf().OfType<PropertyDeclarationSyntax>().First();
Microsoft.CodeAnalysis (19)
Syntax\SyntaxNavigator.cs (6)
533
if (current.
Parent
!= null)
548
foreach (var child in current.
Parent
.ChildNodesAndTokens())
577
return GetNextToken(current.
Parent
, predicate, stepInto);
587
if (current.
Parent
!= null)
602
foreach (var child in current.
Parent
.ChildNodesAndTokens().Reverse())
631
return GetPreviousToken(current.
Parent
, predicate, stepInto);
Syntax\SyntaxNode.cs (3)
547
node = ((IStructuredTriviaSyntax)node).ParentTrivia.Token.
Parent
;
825
parent = structuredTrivia.ParentTrivia.Token.
Parent
;
970
.
Parent
Syntax\SyntaxNodeExtensions_Tracking.cs (2)
160
node = ((IStructuredTriviaSyntax)node).ParentTrivia.Token.
Parent
!;
185
node = ((IStructuredTriviaSyntax)node).ParentTrivia.Token.
Parent
!;
Syntax\SyntaxNodeOrToken.cs (1)
775
return new SyntaxNodeOrToken(token.
Parent
, token.Node, token.Position, token.Index);
Syntax\SyntaxToken.cs (5)
226
return
Parent
?.IsPartOfStructuredTrivia() ?? false;
554
return
Parent
== other.
Parent
&&
574
return Hash.Combine(
Parent
, Hash.Combine(Node, Hash.Combine(Position, Index)));
637
public SyntaxTree? SyntaxTree =>
Parent
?.SyntaxTree;
Syntax\SyntaxTokenList.cs (1)
41
_parent = token.
Parent
;
Syntax\SyntaxTrivia.cs (1)
142
return Token.
Parent
?.IsPartOfStructuredTrivia() ?? false;
Microsoft.CodeAnalysis.CodeStyle (23)
src\Analyzers\Core\Analyzers\NewLines\ConsecutiveStatementPlacement\AbstractConsecutiveStatementPlacementDiagnosticAnalyzer.cs (1)
85
var nextTokenContainingStatement = nextToken.
Parent
?.FirstAncestorOrSelf<TExecutableStatementSyntax>();
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SemanticModelExtensions.cs (1)
33
=> semanticModel.GetSymbolInfo(token.
Parent
!, cancellationToken);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SyntaxNodeExtensions.cs (1)
799
parent = structuredTrivia.ParentTrivia.Token.
Parent
;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SyntaxTokenExtensions.cs (12)
19
=> token.
Parent
?.FirstAncestorOrSelf(predicate);
27
return token.
Parent
!= null
28
? token.
Parent
.AncestorsAndSelf().OfType<T>()
34
return token.
Parent
!= null
35
? token.
Parent
.AncestorsAndSelf().Where(predicate)
45
if (token1.
Parent
== null || token2.
Parent
== null)
50
return token1.
Parent
.GetCommonRoot(token2.
Parent
);
55
if (token.
Parent
is not T parentNode)
95
? ((ICompilationUnitSyntax)token.
Parent
!.SyntaxTree!.GetRoot(CancellationToken.None)).EndOfFileToken
165
=> token.
Parent
?? throw new InvalidOperationException("Token's parent was null");
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\BottomUpBaseIndentationFinder.cs (4)
231
var current = token.
Parent
;
238
current = ((IStructuredTriviaSyntax)current).ParentTrivia.Token.
Parent
;
249
var startNode = token.
Parent
;
280
var startNode = token.
Parent
;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Context\FormattingContext.InitialContextFinder.cs (1)
145
var startNode = token.
Parent
;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\TreeData.StructuredTrivia.cs (1)
56
var parent = _trivia.Token.
Parent
;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\CommonFormattingHelpers.cs (2)
279
var parentNode = GetParentThatContainsGivenSpan(token.
Parent
, backwardPosition, forward: false);
310
var parentNode = GetParentThatContainsGivenSpan(token.
Parent
, forwardPosition, forward: true);
Microsoft.CodeAnalysis.CodeStyle.Fixes (7)
src\Analyzers\Core\CodeFixes\ImplementAbstractClass\AbstractImplementAbstractClassCodeFixProvider.cs (1)
38
var classNode = token.
Parent
.GetAncestorOrThis<TClassNode>();
src\Analyzers\Core\CodeFixes\ImplementInterface\AbstractImplementInterfaceCodeFixProvider.cs (1)
43
foreach (var type in token.
Parent
.GetAncestorsOrThis<TTypeSyntax>())
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeRefactorings\AbstractRefactoringHelpersService.cs (2)
275
var leftNode = tokenToLeft.
Parent
;
313
var rightNode = tokenToRightOrIn.
Parent
;
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeRefactorings\CodeRefactoringHelpers.cs (2)
84
var beginningNode = node.FindToken(node.Span.Start).
Parent
;
85
var endNode = node.FindToken(node.Span.End - 1).
Parent
;
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\DocumentExtensions.cs (1)
139
var node = token.
Parent
!.AncestorsAndSelf().First(a => a.FullSpan.Contains(span));
Microsoft.CodeAnalysis.CSharp (145)
Binder\Binder.QueryTranslationState.cs (1)
78
Debug.Assert(identifier.
Parent
is { });
Binder\Binder_AnonymousTypes.cs (1)
91
fieldSyntaxNodes[i] = (nameToken.Kind() == SyntaxKind.IdentifierToken) ? (CSharpSyntaxNode)nameToken.
Parent
! : fieldInitializer;
Binder\BinderFactory.BinderFactoryVisitor.cs (2)
1084
var node = token.
Parent
;
1422
CSharpSyntaxNode curr = (CSharpSyntaxNode)associatedToken.
Parent
;
Compilation\CSharpCompilation.cs (1)
2664
Parent
!.FirstAncestorOrSelf<ExternAliasDirectiveSyntax>();
Compilation\CSharpSemanticModel.cs (5)
441
CSharpSyntaxNode node = (CSharpSyntaxNode)token.
Parent
;
793
var existingConstructorInitializer = this.Root.FindToken(position).
Parent
.AncestorsAndSelf().OfType<ConstructorInitializerSyntax>().FirstOrDefault();
865
var existingConstructorInitializer = this.Root.FindToken(position).
Parent
.AncestorsAndSelf().OfType<PrimaryConstructorBaseTypeSyntax>().FirstOrDefault();
1617
var parentExpr = token.
Parent
as ExpressionSyntax;
1844
var curr = token.
Parent
;
Compilation\MemberSemanticModel.cs (1)
1584
CSharpSyntaxNode node = (CSharpSyntaxNode)token.
Parent
;
Compilation\MethodBodySemanticModel.cs (2)
241
Root.FindToken(position).
Parent
?.AncestorsAndSelf().OfType<ConstructorInitializerSyntax>().FirstOrDefault()?.Parent == Root)
263
if (Root.FindToken(position).
Parent
?.AncestorsAndSelf().OfType<PrimaryConstructorBaseTypeSyntax>().FirstOrDefault() == typeDecl.PrimaryConstructorBaseTypeIfClass)
Compilation\SpeculativeSemanticModelWithMemberModel.cs (2)
59
var attributedNode = model.SyntaxTree.GetRoot().FindToken(position).
Parent
;
139
SyntaxNode? node = Root.FindTokenIncludingCrefAndNameAttributes(position).
Parent
;
Compilation\SyntaxTreeSemanticModel.cs (4)
166
return _binderFactory.GetBinder((CSharpSyntaxNode)token.
Parent
, position).WithAdditionalFlags(GetSemanticModelBinderFlags());
704
var existingConstructorInitializer = this.Root.FindToken(position).
Parent
.AncestorsAndSelf().OfType<ConstructorInitializerSyntax>().FirstOrDefault();
723
var existingConstructorInitializer = this.Root.FindToken(position).
Parent
.AncestorsAndSelf().OfType<PrimaryConstructorBaseTypeSyntax>().FirstOrDefault();
780
CSharpSyntaxNode node = (CSharpSyntaxNode)Root.FindTokenIncludingCrefAndNameAttributes(position).
Parent
;
Parser\Blender.cs (1)
163
for (var parent = token.
Parent
; // for each parent
SymbolDisplay\SymbolDisplayVisitor_Minimal.cs (4)
194
var startNode = token.
Parent
!;
211
startNode ??= token.
Parent
;
259
var identifier = token.
Parent
as IdentifierNameSyntax;
271
token.
Parent
switch
Symbols\RangeVariableSymbol.cs (1)
64
var node = token.
Parent
;
Symbols\Source\ModifierUtils.cs (1)
29
if (readonlyToken.
Parent
is MethodDeclarationSyntax or AccessorDeclarationSyntax or BasePropertyDeclarationSyntax or EventDeclarationSyntax)
Symbols\Source\SourceLocalSymbol.cs (2)
419
return _identifierToken.
Parent
;
428
SyntaxNode node = _identifierToken.
Parent
;
Symbols\Source\SourceMethodSymbolWithAttributes.cs (10)
1082
case {
Parent
: SimpleNameSyntax { Parent: MemberAccessExpressionSyntax { Parent: InvocationExpressionSyntax } memberAccess } rhs } when memberAccess.Name == rhs:
1083
case {
Parent
: SimpleNameSyntax { Parent: MemberBindingExpressionSyntax { Parent: InvocationExpressionSyntax } memberBinding } rhs1 } when memberBinding.Name == rhs1:
1084
case {
Parent
: SimpleNameSyntax { Parent: InvocationExpressionSyntax invocation } simpleName } when invocation.Expression == simpleName:
1087
case {
Parent
: SimpleNameSyntax { Parent: not (MemberAccessExpressionSyntax or MemberBindingExpressionSyntax) } }:
1088
case {
Parent
: SimpleNameSyntax { Parent: MemberAccessExpressionSyntax memberAccess } rhs } when memberAccess.Name == rhs:
1089
case {
Parent
: SimpleNameSyntax { Parent: MemberBindingExpressionSyntax memberBinding } rhs1 } when memberBinding.Name == rhs1:
1295
case {
Parent
: SimpleNameSyntax { Parent: MemberAccessExpressionSyntax { Parent: InvocationExpressionSyntax } memberAccess } rhs } when memberAccess.Name == rhs:
1296
case {
Parent
: SimpleNameSyntax { Parent: InvocationExpressionSyntax invocation } simpleName } when invocation.Expression == simpleName:
1299
case {
Parent
: SimpleNameSyntax { Parent: not MemberAccessExpressionSyntax } }:
1300
case {
Parent
: SimpleNameSyntax { Parent: MemberAccessExpressionSyntax memberAccess } rhs } when memberAccess.Name == rhs:
Symbols\Source\SourceParameterSymbol.cs (1)
55
identifier.
Parent
.GetLocation());
Symbols\Symbol.cs (1)
516
CSharpSyntaxNode node = token.
Parent
.FirstAncestorOrSelf<TNode>();
Syntax\CSharpSyntaxNode.cs (1)
396
CSharpSyntaxNode? curr = (CSharpSyntaxNode?)triviaToken.
Parent
;
Syntax\InternalSyntax\CSharpSyntaxNode.cs (1)
274
var parent = trivia.Token.
Parent
;
Syntax\StructuredTriviaSyntax.cs (1)
25
var parent = trivia.Token.
Parent
;
Syntax\SyntaxNormalizer.cs (102)
202
if (IsAccessorListWithoutAccessorsWithBlockBody(currentToken.
Parent
?.Parent))
207
if (nextToken.
Parent
is InitializerExpressionSyntax or AnonymousObjectCreationExpressionSyntax &&
208
!IsSingleLineInitializerContext(nextToken.
Parent
))
229
if (currentToken.
Parent
is PositionalPatternClauseSyntax)
236
IsInitializerInSingleLineContext(nextToken.
Parent
))
246
return (((currentToken.
Parent
is StatementSyntax) && nextToken.
Parent
!= currentToken.
Parent
)
251
if (currentToken.
Parent
is AttributeListSyntax && currentToken.
Parent
.Parent is not ParameterSyntax)
261
if (currentToken.
Parent
is InitializerExpressionSyntax or AnonymousObjectCreationExpressionSyntax &&
262
!IsSingleLineInitializerContext(nextToken.
Parent
))
266
return currentToken.
Parent
is EnumDeclarationSyntax or SwitchExpressionSyntax ? 1 : 0;
270
if (currentToken.
Parent
is LabeledStatementSyntax || currentToken.
Parent
is SwitchLabelSyntax)
275
case SyntaxKind.SwitchKeyword when currentToken.
Parent
is SwitchExpressionSyntax:
279
if ((nextToken.IsKind(SyntaxKind.FromKeyword) && nextToken.
Parent
.IsKind(SyntaxKind.FromClause)) ||
280
(nextToken.IsKind(SyntaxKind.LetKeyword) && nextToken.
Parent
.IsKind(SyntaxKind.LetClause)) ||
281
(nextToken.IsKind(SyntaxKind.WhereKeyword) && nextToken.
Parent
.IsKind(SyntaxKind.WhereClause)) ||
282
(nextToken.IsKind(SyntaxKind.JoinKeyword) && nextToken.
Parent
.IsKind(SyntaxKind.JoinClause)) ||
283
(nextToken.IsKind(SyntaxKind.JoinKeyword) && nextToken.
Parent
.IsKind(SyntaxKind.JoinIntoClause)) ||
284
(nextToken.IsKind(SyntaxKind.OrderByKeyword) && nextToken.
Parent
.IsKind(SyntaxKind.OrderByClause)) ||
285
(nextToken.IsKind(SyntaxKind.SelectKeyword) && nextToken.
Parent
.IsKind(SyntaxKind.SelectClause)) ||
286
(nextToken.IsKind(SyntaxKind.GroupKeyword) && nextToken.
Parent
.IsKind(SyntaxKind.GroupClause)))
301
return (nextToken.
Parent
is AttributeListSyntax && !(nextToken.
Parent
.Parent is ParameterSyntax)) ? 1 : 0;
303
return currentToken.
Parent
is TypeParameterListSyntax ? 1 : 0;
319
var parent = openBraceToken.
Parent
;
336
var parent = closeBraceToken.
Parent
;
351
var parent = openBraceToken.
Parent
;
367
var currentTokenParent = currentToken.
Parent
;
373
nextToken.
Parent
is MemberAccessExpressionSyntax or BracketedArgumentListSyntax || // Typical cases: `new [] { ... }.Length` or `new [] { ... }[0]`. When in multiline mode still want to keep them on the same line as closing brace
384
nextToken.
Parent
is PropertyDeclarationSyntax nextProperty && IsSingleLineProperty(nextProperty))
400
nextToken.
Parent
.IsKind(SyntaxKind.DoStatement))
417
if (currentToken.
Parent
.IsKind(SyntaxKind.ForStatement))
425
else if (currentToken.
Parent
.IsKind(SyntaxKind.UsingDirective))
427
return nextToken.
Parent
.IsKind(SyntaxKind.UsingDirective) ? 1 : 2;
429
else if (currentToken.
Parent
.IsKind(SyntaxKind.ExternAliasDirective))
431
return nextToken.
Parent
.IsKind(SyntaxKind.ExternAliasDirective) ? 1 : 2;
433
else if (currentToken.
Parent
is AccessorDeclarationSyntax &&
434
IsAccessorListWithoutAccessorsWithBlockBody(currentToken.
Parent
.Parent))
438
else if (currentToken.
Parent
is PropertyDeclarationSyntax property)
448
Debug.Assert(((PropertyDeclarationSyntax)currentToken.
Parent
).SemicolonToken == currentToken);
451
nextToken.
Parent
is PropertyDeclarationSyntax nextProperty &&
470
if (token.
Parent
.IsKind(SyntaxKind.PropertyPatternClause))
472
propPattern = (PropertyPatternClauseSyntax)token.
Parent
;
474
else if (next.
Parent
.IsKind(SyntaxKind.PropertyPatternClause))
476
propPattern = (PropertyPatternClauseSyntax)next.
Parent
;
530
if (token.
Parent
.IsKind(SyntaxKind.PositionalPatternClause))
532
posPattern = (PositionalPatternClauseSyntax)token.
Parent
;
534
else if (next.
Parent
.IsKind(SyntaxKind.PositionalPatternClause))
536
posPattern = (PositionalPatternClauseSyntax)next.
Parent
;
593
var listPattern = token.
Parent
as ListPatternSyntax ?? next.
Parent
as ListPatternSyntax;
616
if (token.
Parent
== null || next.
Parent
== null)
621
if (IsAccessorListWithoutAccessorsWithBlockBody(next.
Parent
) ||
622
IsAccessorListWithoutAccessorsWithBlockBody(next.
Parent
.Parent))
641
if ((token.
Parent
is AssignmentExpressionSyntax && AssignmentTokenNeedsSeparator(token.Kind())) ||
642
(next.
Parent
is AssignmentExpressionSyntax && AssignmentTokenNeedsSeparator(next.Kind())) ||
643
(token.
Parent
is BinaryExpressionSyntax && BinaryTokenNeedsSeparator(token.Kind())) ||
644
(next.
Parent
is BinaryExpressionSyntax && BinaryTokenNeedsSeparator(next.Kind())))
649
if (token.IsKind(SyntaxKind.GreaterThanToken) && token.
Parent
.IsKind(SyntaxKind.TypeArgumentList))
658
token.
Parent
.IsKind(SyntaxKind.FunctionPointerParameterList) &&
659
token.
Parent
.Parent?.Parent is not UsingDirectiveSyntax)
666
!token.
Parent
.IsKind(SyntaxKind.EnumDeclaration))
677
if (next.IsKind(SyntaxKind.SwitchKeyword) && next.
Parent
is SwitchExpressionSyntax)
684
if (token.
Parent
.IsKind(SyntaxKind.ConditionalExpression) || token.
Parent
is TypeSyntax)
686
if (token.
Parent
.Parent?.Kind() is not SyntaxKind.TypeArgumentList and not SyntaxKind.UsingDirective)
695
return !token.
Parent
.IsKind(SyntaxKind.InterpolationFormatClause) &&
696
!token.
Parent
.IsKind(SyntaxKind.XmlPrefix);
701
if (next.
Parent
.IsKind(SyntaxKind.BaseList) ||
702
next.
Parent
.IsKind(SyntaxKind.TypeParameterConstraintClause) ||
703
next.
Parent
is ConstructorInitializerSyntax)
715
if (token.IsKind(SyntaxKind.CloseParenToken) && IsWord(next.Kind()) && token.
Parent
.IsKind(SyntaxKind.TupleType) == true)
721
&& (next.
Parent
.IsKind(SyntaxKind.ConditionalExpression)))
728
return !token.
Parent
.IsKind(SyntaxKind.XmlTextAttribute);
733
return !next.
Parent
.IsKind(SyntaxKind.XmlTextAttribute);
738
if (token.
Parent
.IsKind(SyntaxKind.FunctionPointerType))
747
if (token.IsKind(SyntaxKind.AsteriskToken) && next.
Parent
.IsKind(SyntaxKind.FunctionPointerCallingConvention))
759
if (next.
Parent
.IsKind(SyntaxKind.FunctionPointerParameterList) && next.IsKind(SyntaxKind.LessThanToken))
771
case SyntaxKind.CloseBracketToken when token.
Parent
.IsKind(SyntaxKind.FunctionPointerUnmanagedCallingConventionList):
778
if (token.
Parent
.IsKind(SyntaxKind.FunctionPointerCallingConvention) && next.
Parent
.IsKind(SyntaxKind.FunctionPointerUnmanagedCallingConventionList) &&
785
if (next.
Parent
.IsKind(SyntaxKind.FunctionPointerUnmanagedCallingConventionList) && token.
Parent
.IsKind(SyntaxKind.FunctionPointerUnmanagedCallingConventionList))
818
if (token.IsKind(SyntaxKind.LessThanToken) && token.
Parent
.IsKind(SyntaxKind.FunctionPointerParameterList))
825
if (next.IsKind(SyntaxKind.GreaterThanToken) && next.
Parent
.IsKind(SyntaxKind.FunctionPointerParameterList))
842
if (next.IsKind(SyntaxKind.AsteriskToken) && next.
Parent
is PointerTypeSyntax)
848
if (token.IsKind(SyntaxKind.AsteriskToken) && token.
Parent
is PointerTypeSyntax &&
849
(next.IsKind(SyntaxKind.IdentifierToken) || next.
Parent
.IsKind(SyntaxKind.IndexerDeclaration)))
861
if (IsSingleLineInitializerContext(token.
Parent
))
863
if (next.
Parent
is InitializerExpressionSyntax or AnonymousObjectCreationExpressionSyntax &&
869
if (token.
Parent
is InitializerExpressionSyntax or AnonymousObjectCreationExpressionSyntax &&
875
if (next.
Parent
is InitializerExpressionSyntax or AnonymousObjectCreationExpressionSyntax &&
883
if (next is { RawKind: (int)SyntaxKind.OpenParenToken,
Parent
.Parent: ParenthesizedLambdaExpressionSyntax lambda } &&
896
(!next.IsKind(SyntaxKind.OpenParenToken) || KeywordNeedsSeparatorBeforeOpenParen(token.Kind()) || next.
Parent
.IsKind(SyntaxKind.TupleType)) &&
921
if (token.
Parent
is RelationalPatternSyntax)
957
switch (token.
Parent
.Kind(), next.
Parent
.Kind())
1294
return GetDeclarationDepth(token.
Parent
);
Microsoft.CodeAnalysis.CSharp.CodeStyle (211)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\EmbeddedLanguages\VirtualChars\CSharpVirtualCharService.cs (2)
39
if (token.
Parent
?.Parent is InterpolatedStringExpressionSyntax { StringStartToken.RawKind: (int)SyntaxKind.InterpolatedMultiLineRawStringStartToken })
57
if (IsInDirective(token.
Parent
))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SemanticModelExtensions.cs (3)
27
if (name.
Parent
is ExpressionSyntax expression)
44
if (name.
Parent
is ExpressionSyntax expression)
135
switch (token.
Parent
)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxTokenExtensions.cs (2)
47
token.
Parent
.IsKind(SyntaxKind.ObjectInitializerExpression);
50
=> token.IsKind(SyntaxKind.OpenBraceToken) && token.
Parent
.IsKind(SyntaxKind.AccessorList);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Engine\Trivia\CSharpTriviaFormatter.DocumentationCommentExteriorCommentRewriter.cs (1)
68
var currentParent = trivia.Token.
Parent
;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\FormattingHelpers.cs (46)
77
=> token.IsOpenParenInParameterList() && token.
Parent
.IsParentKind(SyntaxKind.ConversionOperatorDeclaration);
80
=> token.IsOpenParenInParameterList() && token.
Parent
.IsParentKind(SyntaxKind.OperatorDeclaration);
83
=> token.Kind() == SyntaxKind.OpenParenToken && token.
Parent
.IsKind(SyntaxKind.ParameterList);
86
=> token.Kind() == SyntaxKind.CloseParenToken && token.
Parent
.IsKind(SyntaxKind.ParameterList);
103
if (token.
Parent
is (kind: SyntaxKind.ArgumentList or SyntaxKind.AttributeArgumentList))
109
if (token.
Parent
.IsKind(SyntaxKind.PositionalPatternClause) && token.
Parent
.Parent.IsKind(SyntaxKind.RecursivePattern))
112
return token.
Parent
.Parent.GetFirstToken() != token;
119
=> token.Kind() == SyntaxKind.ColonToken && token.
Parent
.IsKind(SyntaxKind.BaseList);
122
=> token.Kind() == SyntaxKind.CommaToken && (token.
Parent
.IsAnyArgumentList() || token.
Parent
?.Kind() is SyntaxKind.ParameterList or SyntaxKind.FunctionPointerParameterList);
125
=> token.Kind() == SyntaxKind.OpenParenToken && token.
Parent
.IsKind(SyntaxKind.ParameterList) && token.
Parent
.Parent.IsKind(SyntaxKind.ParenthesizedLambdaExpression);
151
token.
Parent
is ForStatementSyntax forStatement &&
162
if (token.
Parent
is not StatementSyntax statement ||
178
return token.
Parent
is ExpressionSyntax || token.
Parent
.IsKind(SyntaxKind.PropertyPatternClause);
188
if (token.
Parent
is not BlockSyntax block ||
210
token.
Parent
.IsKind(SyntaxKind.EnumDeclaration);
216
token.
Parent
.IsAnyArgumentList();
221
if (token.
Parent
is not ParenthesizedExpressionSyntax parenthesizedExpression)
231
var parent = token.
Parent
?? throw new ArgumentNullException(nameof(token));
278
token.
Parent
.IsKind(SyntaxKind.EqualsValueClause) &&
279
token.
Parent
.Parent.IsKind(SyntaxKind.PropertyDeclaration);
284
if (token.
Parent
is not StatementSyntax statement)
305
=> token.IsDotInMemberAccess() || (token.Kind() == SyntaxKind.DotToken && token.
Parent
.IsKind(SyntaxKind.QualifiedName));
309
if (token.
Parent
is not MemberAccessExpressionSyntax memberAccess)
321
return token.
Parent
is (kind: SyntaxKind.TypeParameterList or SyntaxKind.TypeArgumentList);
329
((token.
Parent
is InitializerExpressionSyntax) ||
330
(token.
Parent
is AnonymousObjectCreationExpressionSyntax));
334
=> token.Kind() == SyntaxKind.ColonToken && token.
Parent
is CasePatternSwitchLabelSyntax;
337
=> token.Kind() == SyntaxKind.ColonToken && token.
Parent
.IsKind(SyntaxKind.SwitchExpressionArm);
340
=> token.Kind() == SyntaxKind.CommaToken && token.
Parent
.IsKind(SyntaxKind.SwitchExpression);
343
=> token.Kind() == SyntaxKind.CommaToken && token.
Parent
.IsKind(SyntaxKind.PropertyPatternClause);
348
token.
Parent
is LabeledStatementSyntax labeledStatement &&
358
token.
Parent
is LabeledStatementSyntax labeledStatement &&
376
token.
Parent
is FromClauseSyntax fromClause &&
383
token.
Parent
?.Parent is QueryExpressionSyntax queryExpression &&
478
if (token.
Parent
== null)
483
return token.
Parent
.Parent is LabeledStatementSyntax;
517
return token.
Parent
is PrefixUnaryExpressionSyntax;
521
=> currentToken.
Parent
.IsKind(SyntaxKind.Interpolation);
529
currentToken.
Parent
is ParenthesizedVariableDesignationSyntax &&
530
currentToken.
Parent
.Parent is DeclarationExpressionSyntax;
539
currentToken.
Parent
.IsKind(SyntaxKind.TupleExpression);
543
=> token.Kind() == SyntaxKind.CommaToken && token.
Parent
.IsKind(SyntaxKind.CollectionExpression);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\ElasticTriviaFormattingRule.cs (35)
116
currentToken.
Parent
.IsKind(SyntaxKind.TypeParameterConstraintClause))
118
RoslynDebug.AssertNotNull(previousToken.
Parent
);
121
if (previousToken.
Parent
.Ancestors().OfType<TypeParameterConstraintClauseSyntax>().Any())
127
var firstTokenAfterTypeConstraint = currentToken.
Parent
.GetLastToken().GetNextToken();
128
var lastTokenForTypeConstraint = currentToken.
Parent
.GetLastToken().GetNextToken();
131
firstTokenAfterTypeConstraint.
Parent
.IsKind(SyntaxKind.TypeParameterConstraintClause))
143
currentToken.
Parent
.IsParentKind(SyntaxKind.IfStatement))
185
if (previousToken.
Parent
is not FileScopedNamespaceDeclarationSyntax)
294
previousToken.
Parent
is AttributeListSyntax &&
295
currentToken.
Parent
is not AttributeListSyntax)
328
return (((previousToken.
Parent
is StatementSyntax) && currentToken.
Parent
!= previousToken.
Parent
)
334
if (previousToken.
Parent
is AttributeListSyntax parent)
340
if (!currentToken.IsKind(SyntaxKind.EndOfFileToken) && !(currentToken.
Parent
is AttributeListSyntax))
359
return previousToken.
Parent
is EnumDeclarationSyntax ? 1 : 0;
365
if (previousToken.
Parent
is LabeledStatementSyntax or SwitchLabelSyntax)
373
if ((currentToken.Kind() == SyntaxKind.FromKeyword && currentToken.
Parent
.IsKind(SyntaxKind.FromClause)) ||
374
(currentToken.Kind() == SyntaxKind.LetKeyword && currentToken.
Parent
.IsKind(SyntaxKind.LetClause)) ||
375
(currentToken.Kind() == SyntaxKind.WhereKeyword && currentToken.
Parent
.IsKind(SyntaxKind.WhereClause)) ||
376
(currentToken.Kind() == SyntaxKind.JoinKeyword && currentToken.
Parent
.IsKind(SyntaxKind.JoinClause)) ||
377
(currentToken.Kind() == SyntaxKind.JoinKeyword && currentToken.
Parent
.IsKind(SyntaxKind.JoinIntoClause)) ||
378
(currentToken.Kind() == SyntaxKind.OrderByKeyword && currentToken.
Parent
.IsKind(SyntaxKind.OrderByClause)) ||
379
(currentToken.Kind() == SyntaxKind.SelectKeyword && currentToken.
Parent
.IsKind(SyntaxKind.SelectClause)) ||
380
(currentToken.Kind() == SyntaxKind.GroupKeyword && currentToken.
Parent
.IsKind(SyntaxKind.GroupClause)))
396
if (currentToken.
Parent
is AttributeListSyntax parent)
400
previousToken.
Parent
is not AttributeListSyntax)
417
return previousToken.
Parent
is TypeParameterListSyntax ? 1 : 0;
438
nextToken.
Parent
.IsKind(SyntaxKind.DoStatement))
454
if (previousToken.
Parent
is ForStatementSyntax)
462
else if (previousToken.
Parent
is UsingDirectiveSyntax)
464
return currentToken.
Parent
is UsingDirectiveSyntax ? 1 : 2;
466
else if (previousToken.
Parent
is ExternAliasDirectiveSyntax)
468
return currentToken.
Parent
is ExternAliasDirectiveSyntax ? 1 : 2;
470
else if (currentToken.
Parent
is LocalFunctionStatementSyntax)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\NewLineUserSettingFormattingRule.cs (25)
78
RoslynDebug.AssertNotNull(currentToken.
Parent
);
85
&& previousToken.
Parent
!.Parent == currentToken.
Parent
.Parent)
112
if (currentToken.IsKind(SyntaxKind.OpenBraceToken) && currentToken.
Parent
is BaseTypeDeclarationSyntax or NamespaceDeclarationSyntax)
121
if (currentToken.IsKind(SyntaxKind.OpenBraceToken) && currentToken.
Parent
.IsKind(SyntaxKind.AnonymousObjectCreationExpression))
132
if (currentToken.
Parent
.Kind() is SyntaxKind.ObjectInitializerExpression
143
else if (currentToken.
Parent
.IsKind(SyntaxKind.PropertyPatternClause))
153
var isFirstTokenOfSwitchArm = currentToken.
Parent
.IsParentKind(SyntaxKind.RecursivePattern, out RecursivePatternSyntax? recursivePattern)
165
var currentTokenParentParent = currentToken.
Parent
.Parent;
217
if (currentToken.IsKind(SyntaxKind.OpenBraceToken) && currentToken.
Parent
.IsKind(SyntaxKind.SwitchExpression))
226
if (currentToken.IsKind(SyntaxKind.OpenBraceToken) && IsControlBlock(currentToken.
Parent
))
239
RoslynDebug.AssertNotNull(currentToken.
Parent
);
246
if (previousToken.IsKind(SyntaxKind.CommaToken) && previousToken.
Parent
.IsKind(SyntaxKind.ObjectInitializerExpression))
260
if (previousToken.IsKind(SyntaxKind.CommaToken) && previousToken.
Parent
.IsKind(SyntaxKind.AnonymousObjectCreationExpression))
277
|| previousToken.
Parent
!.Parent != currentToken.
Parent
.Parent)
314
if (currentToken.IsKind(SyntaxKind.OpenBraceToken) && currentToken.
Parent
is BaseTypeDeclarationSyntax or NamespaceDeclarationSyntax)
327
if (currentToken.IsKind(SyntaxKind.OpenBraceToken) && currentToken.
Parent
.IsKind(SyntaxKind.AnonymousObjectCreationExpression))
344
currentToken.
Parent
.Kind() is SyntaxKind.ObjectInitializerExpression or SyntaxKind.CollectionInitializerExpression or SyntaxKind.WithInitializerExpression or SyntaxKind.PropertyPatternClause)
361
currentToken.
Parent
.Kind() is SyntaxKind.ArrayInitializerExpression or SyntaxKind.ImplicitArrayCreationExpression)
366
var currentTokenParentParent = currentToken.
Parent
.Parent;
439
if (currentToken.IsKind(SyntaxKind.OpenBraceToken) && currentToken.
Parent
.IsKind(SyntaxKind.SwitchExpression))
452
if (currentToken.IsKind(SyntaxKind.OpenBraceToken) && IsControlBlock(currentToken.
Parent
))
468
&& (previousToken.
Parent
is StatementSyntax && !previousToken.
Parent
.IsKind(SyntaxKind.ForStatement))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\SpacingFormattingRule.cs (29)
45
RoslynDebug.Assert(previousToken.
Parent
!= null && currentToken.
Parent
!= null);
49
var previousParentKind = previousToken.
Parent
.Kind();
50
var currentParentKind = currentToken.
Parent
.Kind();
92
if (previousToken.
Parent
.IsKind(SyntaxKind.OperatorDeclaration) && currentToken.IsOpenParenInParameterListOfAOperationDeclaration())
163
if ((previousToken.
Parent
.Kind() is SyntaxKind.ParenthesizedExpression or SyntaxKind.ParenthesizedPattern && previousKind == SyntaxKind.OpenParenToken) ||
164
(currentToken.
Parent
.Kind() is SyntaxKind.ParenthesizedExpression or SyntaxKind.ParenthesizedPattern && currentKind == SyntaxKind.CloseParenToken))
178
&& IsEmptyForStatement((ForStatementSyntax)previousToken.
Parent
!))
208
if (currentKind == SyntaxKind.OpenBracketToken && currentToken.
Parent
.Kind() is SyntaxKind.ListPattern or SyntaxKind.CollectionExpression)
249
if (previousKind == SyntaxKind.CloseBracketToken && previousToken.
Parent
.IsKind(SyntaxKind.AttributeList))
253
currentToken.
Parent
.IsKind(SyntaxKind.AttributeList))
327
if (currentToken.
Parent
is BinaryExpressionSyntax ||
328
previousToken.
Parent
is BinaryExpressionSyntax ||
329
currentToken.
Parent
is AssignmentExpressionSyntax ||
330
previousToken.
Parent
is AssignmentExpressionSyntax ||
331
currentToken.
Parent
.Kind() is SyntaxKind.AndPattern or SyntaxKind.OrPattern or SyntaxKind.RelationalPattern ||
332
previousToken.
Parent
.Kind() is SyntaxKind.AndPattern or SyntaxKind.OrPattern or SyntaxKind.RelationalPattern)
458
if (previousToken.
Parent
.IsKind(SyntaxKind.NotPattern))
487
if ((currentKind == SyntaxKind.OpenBraceToken && currentToken.
Parent
is InterpolationSyntax) ||
488
(previousKind == SyntaxKind.CloseBraceToken && previousToken.
Parent
is InterpolationSyntax))
494
if (previousKind == SyntaxKind.OpenBraceToken && previousToken.
Parent
is InterpolationSyntax)
500
if (currentKind == SyntaxKind.CloseBraceToken && currentToken.
Parent
is InterpolationSyntax interpolation)
511
if ((previousKind == SyntaxKind.CommaToken && previousToken.
Parent
is InterpolationAlignmentClauseSyntax) ||
512
(currentKind == SyntaxKind.CommaToken && currentToken.
Parent
is InterpolationAlignmentClauseSyntax))
518
if ((previousKind == SyntaxKind.ColonToken && previousToken.
Parent
is InterpolationFormatClauseSyntax) ||
519
(currentKind == SyntaxKind.ColonToken && currentToken.
Parent
is InterpolationFormatClauseSyntax))
539
var rangeExpression = (RangeExpressionSyntax)previousToken.
Parent
!;
550
var rangeExpression = (RangeExpressionSyntax)currentToken.
Parent
!;
606
=> token.
Parent
is (kind: SyntaxKind.ArrayRankSpecifier or SyntaxKind.BracketedArgumentList or SyntaxKind.BracketedParameterList or SyntaxKind.ImplicitArrayCreationExpression or SyntaxKind.ListPattern or SyntaxKind.CollectionExpression);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\StructuredTriviaFormattingRule.cs (4)
16
if (previousToken.
Parent
is StructuredTriviaSyntax || currentToken.
Parent
is StructuredTriviaSyntax)
26
if (previousToken.
Parent
is StructuredTriviaSyntax || currentToken.
Parent
is StructuredTriviaSyntax)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\TokenBasedFormattingRule.cs (29)
170
if (previousToken.Kind() == SyntaxKind.CloseParenToken && previousToken.
Parent
.IsEmbeddedStatementOwnerWithCloseParen())
175
if (previousToken.Kind() == SyntaxKind.DoKeyword && previousToken.
Parent
.IsKind(SyntaxKind.DoStatement))
201
if (previousToken.Kind() == SyntaxKind.CloseBracketToken && previousToken.
Parent
is AttributeListSyntax)
203
var attributeOwner = previousToken.
Parent
?.Parent;
222
if (previousToken.
Parent
is not UsingDirectiveSyntax previousUsing)
229
currentToken.
Parent
is UsingDirectiveSyntax currentUsing &&
269
if (previousToken.Kind() == SyntaxKind.CloseParenToken && previousToken.
Parent
.IsEmbeddedStatementOwnerWithCloseParen())
288
previousToken.
Parent
.IsKind(SyntaxKind.AttributeList) &&
289
previousToken.
Parent
.IsParentKind(SyntaxKind.Parameter))
317
var spaces = previousToken.
Parent
is (kind:
346
if (previousToken.Kind() == SyntaxKind.CommaToken && currentToken.Kind() == SyntaxKind.OpenBracketToken && currentToken.
Parent
is AttributeListSyntax)
352
if (previousToken.Kind() == SyntaxKind.CloseBracketToken && previousToken.
Parent
is AttributeListSyntax)
375
currentToken.
Parent
?.Kind() is not SyntaxKind.CollectionExpression and not SyntaxKind.AttributeList &&
395
if (currentToken.
Parent
is (kind:
409
if (previousToken.
Parent
is CastExpressionSyntax &&
416
if (previousToken.
Parent
is (kind: SyntaxKind.TypeArgumentList or SyntaxKind.TypeParameterList or SyntaxKind.FunctionPointerType))
433
currentToken.
Parent
is (kind: SyntaxKind.TypeArgumentList or SyntaxKind.TypeParameterList))
440
previousToken.
Parent
is PrefixUnaryExpressionSyntax)
447
currentToken.
Parent
is PostfixUnaryExpressionSyntax)
453
if (currentToken.IsKind(SyntaxKind.QuestionToken) && currentToken.
Parent
.IsKind(SyntaxKind.ConditionalAccessExpression))
460
currentToken.
Parent
is (kind: SyntaxKind.NullableType or SyntaxKind.ClassConstraint))
467
previousToken.
Parent
?.IsParentKind(SyntaxKind.ArrayType) == true)
474
currentToken.
Parent
.IsKind(SyntaxKind.SuppressNullableWarningExpression))
480
if (currentToken.Kind() == SyntaxKind.AsteriskToken && currentToken.
Parent
is PointerTypeSyntax)
486
if (previousToken.Kind() == SyntaxKind.AsteriskToken && previousToken.
Parent
is PrefixUnaryExpressionSyntax)
521
&& !previousToken.
Parent
.IsKind(SyntaxKind.SuppressNullableWarningExpression))
527
if (previousToken.Kind() == SyntaxKind.TildeToken && (previousToken.
Parent
is PrefixUnaryExpressionSyntax || previousToken.
Parent
is DestructorDeclarationSyntax))
534
previousToken.
Parent
is PrefixUnaryExpressionSyntax)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Indentation\CSharpSmartTokenFormatter.cs (4)
74
endToken.
Parent
.IsKind(SyntaxKind.Block) &&
75
endToken.
Parent
.Parent?.Kind() is SyntaxKind.TryStatement or SyntaxKind.DoStatement;
96
(token.
Parent
.IsInitializerForArrayOrCollectionCreationExpression() ||
97
token.
Parent
is AnonymousObjectCreationExpressionSyntax))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpSyntaxFacts.cs (16)
102
(token.
Parent
is PrefixUnaryExpressionSyntax || token.
Parent
is PostfixUnaryExpressionSyntax || token.
Parent
is OperatorDeclarationSyntax)) ||
103
(SyntaxFacts.IsBinaryExpression(kind) && (token.
Parent
is BinaryExpressionSyntax or OperatorDeclarationSyntax or RelationalPatternSyntax)) ||
104
(SyntaxFacts.IsAssignmentExpressionOperatorToken(kind) && token.
Parent
is AssignmentExpressionSyntax);
272
=> token.
Parent
is ConstructorInitializerSyntax(SyntaxKind.ThisConstructorInitializer) constructorInit &&
276
=> token.
Parent
is ConstructorInitializerSyntax(SyntaxKind.BaseConstructorInitializer) constructorInit &&
291
return token.
Parent
is QueryClauseSyntax;
295
return token.
Parent
is SelectOrGroupClauseSyntax;
298
return token.
Parent
is OrderingSyntax;
300
return token.
Parent
is (kind: SyntaxKind.JoinIntoClause or SyntaxKind.QueryContinuation);
521
if (token.Kind() == SyntaxKind.CommaToken && token.
Parent
.IsKind(SyntaxKind.OrderByClause))
527
&& token.
Parent
.IsKind(SyntaxKind.CollectionExpression))
715
var node = root.FindToken(position).
Parent
;
998
var node = token.
Parent
;
1415
if (token.Kind() == SyntaxKind.OverrideKeyword && token.
Parent
is MemberDeclarationSyntax member)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\FormattingRangeHelper.cs (15)
42
var (_, closeBrace) = previousToken.
Parent
.GetBracePair();
90
var parent = endToken.
Parent
;
114
var parent = endToken.
Parent
;
171
var parent = endToken.
Parent
;
271
var parent = endToken.
Parent
;
338
RoslynDebug.AssertNotNull(previousToken.
Parent
?.Parent);
339
var labelNode = previousToken.
Parent
.Parent;
349
(previousToken.
Parent
.IsKind(SyntaxKind.Block) ||
350
previousToken.
Parent
is TypeDeclarationSyntax ||
351
previousToken.
Parent
is NamespaceDeclarationSyntax);
410
token.
Parent
is SwitchLabelSyntax switchLabel &&
436
RoslynDebug.AssertNotNull(token.
Parent
);
440
if (token.
Parent
.Kind() is SyntaxKind.Block or
443
return token.
Parent
.Parent as MemberDeclarationSyntax;
447
return token.
Parent
.FirstAncestorOrSelf<MemberDeclarationSyntax>();
Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes (142)
src\Analyzers\CSharp\CodeFixes\ConvertNamespace\ConvertNamespaceTransform.cs (1)
228
if (token.IsKind(SyntaxKind.HashToken) && token.
Parent
!.Kind() is not (SyntaxKind.RegionDirectiveTrivia or SyntaxKind.EndRegionDirectiveTrivia))
src\Analyzers\CSharp\CodeFixes\UseImplicitOrExplicitType\UseExplicitTypeCodeFixProvider.cs (1)
125
varDecl.Variables.Single().Identifier.
Parent
!,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpCodeGenerationHelpers.cs (1)
206
return contextTree?.GetRoot(cancellationToken).FindToken(contextLocation!.SourceSpan.Start).
Parent
;
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\CSharpSyntaxContext.cs (1)
504
return targetToken.
Parent
switch
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTokenExtensions.cs (47)
41
if (token is { RawKind: (int)SyntaxKind.StaticKeyword,
Parent
: UsingDirectiveSyntax })
48
token.GetPreviousToken() is { RawKind: (int)SyntaxKind.StaticKeyword,
Parent
: UsingDirectiveSyntax })
115
case SyntaxKind.OpenBraceToken when token.
Parent
.IsKind(SyntaxKind.Block):
124
if (token.
Parent
.IsKind(SyntaxKind.Block))
126
if (token.
Parent
.Parent is StatementSyntax)
135
if (token.
Parent
.Parent.Kind() is not SyntaxKind.TryStatement and not SyntaxKind.DoStatement)
138
else if (token.
Parent
.Parent?.Kind()
148
if (token.
Parent
.IsKind(SyntaxKind.SwitchStatement))
156
return token.
Parent
is (kind: SyntaxKind.CaseSwitchLabel or SyntaxKind.DefaultSwitchLabel or SyntaxKind.CasePatternSwitchLabel or SyntaxKind.LabeledStatement);
158
case SyntaxKind.DoKeyword when token.
Parent
.IsKind(SyntaxKind.DoStatement):
162
var parent = token.
Parent
;
174
return token.
Parent
.IsKind(SyntaxKind.ElseClause);
177
if (token.
Parent
.IsKind(SyntaxKind.AttributeList))
180
var container = token.
Parent
.Parent;
225
if (token.
Parent
is FileScopedNamespaceDeclarationSyntax namespaceDeclaration && namespaceDeclaration.SemicolonToken == token)
259
if (token.
Parent
.IsKind(SyntaxKind.AttributeList))
261
var container = token.
Parent
.Parent;
274
if (token.
Parent
.IsKind(SyntaxKind.CastExpression))
279
if (token.
Parent
is ParenthesizedExpressionSyntax parenExpr)
334
targetToken.
Parent
.IsKind(SyntaxKind.ParenthesizedExpression))
340
if (targetToken.
Parent
is PrefixUnaryExpressionSyntax prefix)
347
if (targetToken.
Parent
is BinaryExpressionSyntax binary)
396
targetToken.
Parent
.IsKind(SyntaxKind.SwitchStatement))
403
if (targetToken.
Parent
is (kind: SyntaxKind.CaseSwitchLabel or SyntaxKind.DefaultSwitchLabel or SyntaxKind.CasePatternSwitchLabel))
431
targetToken.
Parent
is (kind: SyntaxKind.CrefBracketedParameterList or SyntaxKind.CrefParameterList);
450
targetToken.
Parent
.IsKind(SyntaxKind.NameColon) &&
451
targetToken.
Parent
.Parent.IsKind(SyntaxKind.Argument) &&
452
targetToken.
Parent
.Parent.Parent.IsKind(SyntaxKind.ArgumentList))
454
var owner = targetToken.
Parent
.Parent.Parent.Parent;
468
if (targetToken.
Parent
.IsKind(SyntaxKind.ArgumentList))
470
if (targetToken.
Parent
?.Parent?.Kind()
481
if (targetToken.
Parent
.IsParentKind(SyntaxKind.InvocationExpression) && !targetToken.IsInvocationOfVarExpression())
582
targetToken.
Parent
.IsKind(SyntaxKind.AccessorList))
590
targetToken.
Parent
.IsKind(SyntaxKind.Block) &&
591
targetToken.
Parent
.Parent is AccessorDeclarationSyntax)
598
targetToken.
Parent
is AccessorDeclarationSyntax)
605
targetToken.
Parent
.IsKind(SyntaxKind.AttributeList) &&
606
targetToken.
Parent
.Parent is AccessorDeclarationSyntax)
638
IsGenericInterfaceOrDelegateTypeParameterList(targetToken.
Parent
!))
644
IsGenericInterfaceOrDelegateTypeParameterList(targetToken.
Parent
!))
650
targetToken.
Parent
.IsKind(SyntaxKind.AttributeList) &&
651
targetToken.
Parent
.Parent.IsKind(SyntaxKind.TypeParameter) &&
652
IsGenericInterfaceOrDelegateTypeParameterList(targetToken.
Parent
.Parent.Parent))
662
if (token.Kind() == SyntaxKind.CommaToken && token.
Parent
is BaseArgumentListSyntax)
664
var argumentList = (BaseArgumentListSyntax)token.
Parent
;
688
if (token.
Parent
is not MemberAccessExpressionSyntax memberAccessExpression)
698
=> token.
Parent
is IdentifierNameSyntax typedParent &&
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTreeExtensions.cs (75)
167
if (token.
Parent
is BaseTypeDeclarationSyntax)
178
if (token.
Parent
is MemberDeclarationSyntax &&
179
token.
Parent
.Parent is BaseTypeDeclarationSyntax)
195
if (token.
Parent
is BaseTypeDeclarationSyntax &&
196
token.
Parent
.Parent is BaseTypeDeclarationSyntax)
201
else if (token.
Parent
is AccessorListSyntax)
207
token.
Parent
.IsKind(SyntaxKind.Block) &&
208
token.
Parent
.Parent is MemberDeclarationSyntax)
220
token.
Parent
.IsKind(SyntaxKind.AttributeList))
228
var container = token.
Parent
.Parent?.Parent;
439
if (token.IsKind(SyntaxKind.OpenBraceToken) && token.
Parent
is NamespaceDeclarationSyntax or TypeDeclarationSyntax)
456
if (token.
Parent
is (kind: SyntaxKind.ExternAliasDirective or SyntaxKind.UsingDirective))
460
else if (token.
Parent
is MemberDeclarationSyntax)
478
if (token.
Parent
is BaseTypeDeclarationSyntax)
482
else if (token.
Parent
.IsKind(SyntaxKind.NamespaceDeclaration))
486
else if (token.
Parent
is AccessorListSyntax)
491
token.
Parent
.IsKind(SyntaxKind.Block) &&
492
token.
Parent
.Parent is MemberDeclarationSyntax)
507
token.
Parent
.IsKind(SyntaxKind.AttributeList))
510
if (token.
Parent
.IsParentKind(SyntaxKind.CompilationUnit))
519
var container = token.
Parent
?.Parent?.Parent;
877
token.
Parent
is TypeParameterConstraintClauseSyntax constraintClause)
941
return token.
Parent
.IsKind(SyntaxKind.FunctionPointerParameterList);
947
{
Parent
.RawKind: (int)SyntaxKind.FunctionPointerParameter } => true,
949
{
Parent
: TypeSyntax { Parent.RawKind: (int)SyntaxKind.FunctionPointerParameter } } => true,
955
=> targetToken.
Parent
.IsKind(SyntaxKind.TypeParameterConstraintClause) &&
977
if (token.
Parent
is TypeArgumentListSyntax)
988
if (nameToken.
Parent
is not NameSyntax name)
1158
return token.
Parent
.IsKind(SyntaxKind.BracketedParameterList);
1171
token.
Parent
.IsKind(SyntaxKind.DelegateDeclaration))
1213
var method = tokenOnLeftOfPosition.
Parent
.GetAncestorOrThis<MethodDeclarationSyntax>();
1230
if (token.
Parent
.IsKind(SyntaxKind.ParameterList) &&
1231
token.
Parent
.IsParentKind(SyntaxKind.ParenthesizedLambdaExpression))
1247
if (token.
Parent
is (kind: SyntaxKind.ParenthesizedExpression or SyntaxKind.TupleExpression or SyntaxKind.CastExpression))
1263
parent = token.
Parent
;
1265
else if (token.IsKind(SyntaxKind.ScopedKeyword) && token.
Parent
.IsKind(SyntaxKind.Parameter))
1267
parent = token.
Parent
.Parent;
1269
else if (token.IsKind(SyntaxKind.IdentifierToken) && token.Text == "scoped" && token.
Parent
is IdentifierNameSyntax scopedIdentifierName && scopedIdentifierName.Parent.IsKind(SyntaxKind.Parameter))
1322
if (leftToken.
Parent
is (kind:
1327
var possibleCommaOrParen = FindTokenOnLeftOfNode(leftToken.
Parent
);
1339
var possibleCommaOrParen = FindTokenOnLeftOfNode(leftToken.
Parent
!);
1349
leftToken.
Parent
.IsKind(SyntaxKind.IdentifierName) &&
1350
leftToken.
Parent
.Parent is (kind: SyntaxKind.QualifiedName or SyntaxKind.SimpleMemberAccessExpression))
1352
var possibleCommaOrParen = FindTokenOnLeftOfNode(leftToken.
Parent
.Parent);
1368
if (leftToken.
Parent
is ParenthesizedExpressionSyntax parenthesizedExpression)
1376
if (leftToken.
Parent
.IsKind(SyntaxKind.ParenthesizedPattern))
1391
if (leftToken.Kind() is SyntaxKind.OpenBraceToken or SyntaxKind.CommaToken && leftToken.
Parent
.IsKind(SyntaxKind.SwitchExpression))
1398
if (leftToken.Kind() is SyntaxKind.OpenParenToken or SyntaxKind.CommaToken && leftToken.
Parent
.IsKind(SyntaxKind.PositionalPatternClause))
1405
if (leftToken.Kind() is SyntaxKind.OpenBracketToken or SyntaxKind.CommaToken && leftToken.
Parent
.IsKind(SyntaxKind.ListPattern))
1412
if (leftToken.IsKind(SyntaxKind.DotDotToken) && leftToken.
Parent
.IsKind(SyntaxKind.SlicePattern))
1420
if (leftToken.IsKind(SyntaxKind.ColonToken) && leftToken.
Parent
is (kind: SyntaxKind.NameColon or SyntaxKind.ExpressionColon) &&
1421
leftToken.
Parent
.IsParentKind(SyntaxKind.Subpattern))
1433
return leftToken.
Parent
is BinaryPatternSyntax ||
1434
leftToken.
Parent
is SingleVariableDesignationSyntax { Parent: DeclarationPatternSyntax };
1438
if (leftToken.IsKind(SyntaxKind.NotKeyword) && leftToken.
Parent
.IsKind(SyntaxKind.NotPattern))
1448
leftToken.
Parent
.IsKind(SyntaxKind.RelationalPattern))
1497
originalLeftToken.
Parent
== variableDesignationSyntax)
1543
SyntaxNode? node = leftToken.
Parent
as ExpressionSyntax;
1573
if (possibleCommaOrParen.
Parent
is (kind:
1583
if (possibleCommaOrParen.
Parent
.IsKind(SyntaxKind.ParameterList) &&
1584
possibleCommaOrParen.
Parent
?.Parent is ParenthesizedLambdaExpressionSyntax parenthesizedLambda)
1692
leftToken.
Parent
.IsKind(SyntaxKind.ArgumentList) &&
1693
leftToken.
Parent
?.Parent is InvocationExpressionSyntax invocation)
2049
token.
Parent
.IsKind(SyntaxKind.CastExpression))
2344
previousToken.
Parent
?.Kind() is SyntaxKind.PointerType or SyntaxKind.NullableType)
2346
var type = previousToken.
Parent
as TypeSyntax;
2738
=> token.
Parent
?.Parent is InvocationExpressionSyntax invocation &&
2865
token.
Parent
.IsKind(SyntaxKind.IdentifierName) &&
2866
token.
Parent
.Parent is (kind: SyntaxKind.ObjectInitializerExpression or SyntaxKind.CollectionInitializerExpression))
2873
token.
Parent
.IsKind(SyntaxKind.IdentifierName))
2875
if (token.
Parent
.Parent is ArgumentSyntax { RefOrOutKeyword.RawKind: (int)SyntaxKind.OutKeyword })
2980
token.
Parent
.IsKind(SyntaxKind.CatchDeclaration))
2996
targetToken.
Parent
.IsKind(SyntaxKind.BaseList) &&
2997
targetToken.
Parent
.IsParentKind(SyntaxKind.EnumDeclaration);
3058
targetToken.
Parent
is FunctionPointerTypeSyntax functionPointerType &&
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ITypeSymbolExtensions.cs (1)
145
var namespaceUsings = root.FindToken(position).
Parent
!.GetAncestors<BaseNamespaceDeclarationSyntax>().SelectMany(n => n.Usings);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\SyntaxTreeExtensions.cs (1)
172
return token.
Parent
is GenericNameSyntax genericName && genericName.TypeArgumentList != null &&
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Indentation\CSharpIndentationService.Indenter.cs (14)
124
|| token is { RawKind: (int)SyntaxKind.CloseBraceToken,
Parent
: InterpolationSyntax })
179
(token.IsKind(SyntaxKind.CloseBraceToken) && token.
Parent
.IsKind(SyntaxKind.Interpolation)))
186
if (token.
Parent
is LabeledStatementSyntax || token.IsLastTokenInLabelStatement())
223
token.
Parent
!= null &&
224
(token.
Parent
.Parent is StatementSyntax || token.
Parent
.Parent is ElseClauseSyntax));
226
var embeddedStatementOwner = token.
Parent
.Parent;
251
if (token.
Parent
.IsKind(SyntaxKind.AccessorList) &&
252
token.
Parent
.Parent.IsKind(SyntaxKind.PropertyDeclaration))
270
var nonTerminalNode = token.
Parent
;
283
var nonTerminalNode = token.
Parent
;
307
if (token.
Parent
.IsKind(SyntaxKind.ArgumentList))
309
return GetDefaultIndentationFromToken(indenter, token.
Parent
.GetFirstToken(includeZeroWidth: true));
323
=> token.
Parent
switch
Microsoft.CodeAnalysis.CSharp.EditorFeatures (6)
AutomaticCompletion\AutomaticLineEnderCommandHandler_Helpers.cs (3)
384
&& nextToken.
Parent
!= null
385
&& nextToken.
Parent
.Contains(baseObjectCreationExpressionNode))
387
var objectCreationNodeContainer = nextToken.
Parent
;
EventHookup\EventHookupSessionManager_EventHookupSession.cs (2)
209
if (plusEqualsToken.
Parent
is not AssignmentExpressionSyntax parentToken)
244
if (plusEqualsToken.
Parent
is not AssignmentExpressionSyntax assignmentExpression)
StringCopyPaste\StringCopyPasteHelpers.cs (1)
244
var node = root.FindToken(position).
Parent
;
Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests (1)
TypeInferrer\TypeInferrerTests.cs (1)
75
var currentNode = token.
Parent
;
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (2)
Attributes\AttributeTests.cs (1)
5718
var m = (ExpressionSyntax)cm.SyntaxTrees[0].GetCompilationUnitRoot().FindToken(index).
Parent
.Parent;
FlowAnalysis\RegionAnalysisTests.cs (1)
4428
var node = tok.
Parent
as StatementSyntax;
Microsoft.CodeAnalysis.CSharp.Features (192)
BraceCompletion\BracketBraceCompletionService.cs (1)
49
if (currentToken.IsKind(SyntaxKind.OpenBracketToken) && currentToken.
Parent
.IsKind(SyntaxKind.ListPattern))
BraceCompletion\CurlyBraceCompletionService.cs (6)
48
=> token.IsKind(SyntaxKind.OpenBraceToken) && !token.
Parent
.IsKind(SyntaxKind.Interpolation);
139
if (currentToken.
Parent
is (kind:
150
var currentTokenParentParent = currentToken.
Parent
?.Parent;
165
if (currentToken.
Parent
.IsKind(SyntaxKind.AnonymousObjectCreationExpression))
171
if (IsControlBlock(currentToken.
Parent
))
191
if (currentToken.
Parent
is BaseTypeDeclarationSyntax or NamespaceDeclarationSyntax)
BraceCompletion\InterpolationBraceCompletionService.cs (1)
42
=> token.IsKind(SyntaxKind.OpenBraceToken) && token.
Parent
.IsKind(SyntaxKind.Interpolation);
BraceCompletion\LessAndGreaterThanBraceCompletionService.cs (2)
49
if (token.
Parent
is not BinaryExpressionSyntax(SyntaxKind.LessThanExpression) node || node.OperatorToken != token)
59
if (previousToken.
Parent
is not IdentifierNameSyntax identifier)
BraceCompletion\ParenthesisBraceCompletionService.cs (2)
35
|| token.
Parent
== null)
41
var (openParen, closeParen) = token.
Parent
.GetParentheses();
ChangeSignature\ChangeSignatureFormattingRule.cs (1)
54
if (previousToken.Kind() == SyntaxKind.CommaToken && s_allowableKinds.Contains(previousToken.
Parent
.Kind()))
CodeLens\CSharpCodeLensDisplayInfoService.cs (1)
68
node = structuredTriviaSyntax.ParentTrivia.Token.
Parent
;
CodeRefactorings\EnableNullable\EnableNullableCodeRefactoringProvider.cs (4)
225
if (firstToken.IsKind(SyntaxKind.HashToken) && firstToken.
Parent
.IsKind(SyntaxKind.RegionDirectiveTrivia))
229
var nextToken = firstToken.
Parent
.GetLastToken(includeDirectives: true).GetNextToken(includeDirectives: true);
230
if (nextToken.IsKind(SyntaxKind.HashToken) && nextToken.
Parent
.IsKind(SyntaxKind.EndRegionDirectiveTrivia))
232
firstToken = nextToken.
Parent
.GetLastToken(includeDirectives: true).GetNextToken(includeDirectives: true);
Completion\CompletionProviders\AttributeNamedParameterCompletionProvider.cs (2)
111
if (token.Kind() == SyntaxKind.CommaToken && token.
Parent
is AttributeArgumentListSyntax argumentList)
133
if (token.Kind() == SyntaxKind.CommaToken && token.
Parent
is AttributeArgumentListSyntax argumentList)
Completion\CompletionProviders\AwaitCompletionProvider.cs (1)
61
var parent = leftToken.
Parent
;
Completion\CompletionProviders\CrefCompletionProvider.cs (7)
122
token.
Parent
.IsKind(SyntaxKind.XmlCrefAttribute);
137
if (token.
Parent
?.Kind() is not (SyntaxKind.CrefParameterList or SyntaxKind.CrefBracketedParameterList))
141
token.
Parent
.IsKind(SyntaxKind.CrefParameterList))
147
token.
Parent
.IsKind(SyntaxKind.CrefBracketedParameterList))
161
&& token.
Parent
.IsKind(SyntaxKind.QualifiedCref);
174
return GetQualifiedSymbols((QualifiedCrefSyntax)token.
Parent
!, token, semanticModel, cancellationToken);
187
var typeDeclaration = token.
Parent
?.FirstAncestorOrSelf<TypeDeclarationSyntax>();
Completion\CompletionProviders\CSharpSuggestionModeCompletionProvider.cs (10)
100
if (token.
Parent
is AnonymousObjectCreationExpressionSyntax)
113
if (token.IsKind(SyntaxKind.NewKeyword) && token.
Parent
.IsKind(SyntaxKind.ObjectCreationExpression))
121
if (token.Kind() == SyntaxKind.LessThanToken && token.
Parent
is BinaryExpressionSyntax)
129
if (token.
Parent
is not null and ParameterListSyntax)
131
return token.
Parent
.Parent is not null and ParenthesizedLambdaExpressionSyntax;
139
token.
Parent
is TupleExpressionSyntax tupleExpression &&
142
position = token.
Parent
.SpanStart;
174
if (token.Kind() is SyntaxKind.OpenParenToken or SyntaxKind.CommaToken && token.
Parent
.IsKind(SyntaxKind.ArgumentList)
175
&& token.
Parent
.Parent is InvocationExpressionSyntax invocation
228
token.
Parent
== variableDesignationSyntax)
Completion\CompletionProviders\DeclarationName\DeclarationNameInfo.cs (10)
139
token.
Parent
.IsKind(SyntaxKind.IdentifierName))
141
var argument = token.
Parent
.Parent as ArgumentSyntax // var is child of ArgumentSyntax, eg. Goo(out var $$
142
?? token.
Parent
.Parent?.Parent as ArgumentSyntax; // var is child of DeclarationExpression
237
if (token.IsKind(SyntaxKind.CommaToken) && token.
Parent
!= target)
367
token.
Parent
is ConditionalExpressionSyntax conditionalExpressionSyntax)
419
token.
Parent
.IsKind(SyntaxKind.TypeParameterList))
468
if (token.
Parent
.IsParentKind(SyntaxKind.IsExpression))
477
else if (token.
Parent
.IsParentKind(SyntaxKind.CaseSwitchLabel))
486
else if (token.
Parent
.IsParentKind(SyntaxKind.DeclarationPattern))
505
token.
Parent
.IsKind(SyntaxKind.PredefinedType);
Completion\CompletionProviders\EnumAndCompletionListTagCompletionProvider.cs (2)
298
if (previousToken.
Parent
!= null)
300
var symbol = semanticModel.GetSymbolInfo(previousToken.
Parent
, cancellationToken).Symbol;
Completion\CompletionProviders\ExplicitInterfaceTypeCompletionProvider.cs (1)
77
var potentialTypeNode = targetToken.
Parent
;
Completion\CompletionProviders\ObjectAndWithInitializerCompletionProvider.cs (1)
147
var parent = token.
Parent
?.Parent;
Completion\CompletionProviders\OperatorsAndIndexer\UnnamedSymbolCompletionProvider.cs (2)
86
? dotToken.
Parent
as ExpressionSyntax
87
: (dotToken.
Parent
as RangeExpressionSyntax)?.LeftOperand;
Completion\CompletionProviders\OverrideCompletionProvider.cs (3)
59
if (startToken.
Parent
is TypeSyntax typeSyntax)
85
var parentMember = token.
Parent
;
108
if (token.
Parent
is not AttributeListSyntax)
Completion\CompletionProviders\Scripting\DirectiveCompletionProviderUtilities.cs (1)
22
if (token.Kind() == SyntaxKind.StringLiteralToken && token.
Parent
!.Kind() == directiveKind)
Completion\CompletionProviders\TupleNameCompletionProvider.cs (2)
77
if (token.
Parent
is (kind: SyntaxKind.ParenthesizedExpression or SyntaxKind.TupleExpression or SyntaxKind.CastExpression))
83
if (token.IsKind(SyntaxKind.CommaToken) && token.
Parent
is TupleExpressionSyntax tupleExpr)
Completion\CompletionProviders\XmlDocCommentCompletionProvider.cs (8)
231
if (token.IsKind(SyntaxKind.IdentifierToken) && token.
Parent
.IsKind(SyntaxKind.XmlName))
235
(elementName, attributes) = GetElementNameAndAttributes(token.
Parent
.Parent!);
237
else if (token.
Parent
is XmlAttributeSyntax(
293
if (token.
Parent
.IsKind(SyntaxKind.IdentifierName) &&
294
token.
Parent
?.Parent is XmlNameAttributeSyntax xmlName)
300
token.
Parent
is XmlTextAttributeSyntax xmlText)
305
else if (token.
Parent
.IsKind(SyntaxKind.XmlNameAttribute, out attributeSyntax) ||
306
token.
Parent
.IsKind(SyntaxKind.XmlTextAttribute, out attributeSyntax))
Completion\KeywordRecommenders\AllowsKeywordRecommender.cs (1)
41
token.
Parent
is TypeParameterConstraintClauseSyntax constraintClause)
Completion\KeywordRecommenders\BaseKeywordRecommender.cs (3)
52
token.
Parent
is ConstructorInitializerSyntax &&
53
token.
Parent
.IsParentKind(SyntaxKind.ConstructorDeclaration) &&
54
token.
Parent
.Parent?.Parent is (kind: SyntaxKind.ClassDeclaration or SyntaxKind.RecordDeclaration))
Completion\KeywordRecommenders\ExternKeywordRecommender.cs (3)
91
token.
Parent
.IsKind(SyntaxKind.NamespaceDeclaration))
99
token.
Parent
.IsKind(SyntaxKind.FileScopedNamespaceDeclaration))
107
token.
Parent
.IsKind(SyntaxKind.ExternAliasDirective))
Completion\KeywordRecommenders\FieldKeywordRecommender.cs (1)
46
for (var node = targetToken.
Parent
; node != null; node = node.Parent)
Completion\KeywordRecommenders\InKeywordRecommender.cs (4)
66
if (token.
Parent
is ForEachStatementSyntax statement && token == statement.Identifier)
93
var typeSyntax = token.
Parent
as TypeSyntax;
100
if (token.
Parent
is FromClauseSyntax fromClause)
120
var joinClause = token.
Parent
?.FirstAncestorOrSelf<JoinClauseSyntax>();
Completion\KeywordRecommenders\MethodKeywordRecommender.cs (1)
24
return token.
Parent
is AttributeListSyntax
Completion\KeywordRecommenders\NamespaceKeywordRecommender.cs (10)
105
token.
Parent
.IsKind(SyntaxKind.NamespaceDeclaration))
117
if (token.
Parent
is (kind: SyntaxKind.ExternAliasDirective or SyntaxKind.UsingDirective) &&
118
!token.
Parent
.Parent.IsKind(SyntaxKind.FileScopedNamespaceDeclaration))
128
if (token.
Parent
is TypeDeclarationSyntax &&
129
token.
Parent
.Parent is not TypeDeclarationSyntax)
133
else if (token.
Parent
.IsKind(SyntaxKind.NamespaceDeclaration))
144
if (token.
Parent
.IsKind(SyntaxKind.DelegateDeclaration) &&
145
token.
Parent
.Parent is not TypeDeclarationSyntax)
155
token.
Parent
.IsKind(SyntaxKind.AttributeList) &&
156
token.
Parent
.IsParentKind(SyntaxKind.CompilationUnit))
Completion\KeywordRecommenders\NewKeywordRecommender.cs (1)
102
token.
Parent
is TypeParameterConstraintClauseSyntax constraintClause)
Completion\KeywordRecommenders\ParamKeywordRecommender.cs (1)
29
token.
Parent
.IsKind(SyntaxKind.AttributeList))
Completion\KeywordRecommenders\RefKeywordRecommender.cs (3)
106
token.
Parent
is IdentifierNameSyntax identifier && identifier.Identifier == token &&
207
var parent = token.
Parent
;
216
return token.
Parent
?.Kind() == SyntaxKind.ConditionalExpression;
Completion\KeywordRecommenders\ReturnKeywordRecommender.cs (2)
41
token.
Parent
is AttributeListSyntax &&
42
token.
Parent
.Parent is AccessorDeclarationSyntax;
Completion\KeywordRecommenders\ScopedKeywordRecommender.cs (1)
42
return token.
Parent
is ArgumentSyntax;
Completion\KeywordRecommenders\StructKeywordRecommender.cs (1)
63
token.
Parent
is RefStructConstraintSyntax refStructConstraint && refStructConstraint.RefKeyword == token &&
Completion\KeywordRecommenders\ThisKeywordRecommender.cs (2)
46
token.
Parent
is ConstructorInitializerSyntax &&
47
token.
Parent
.IsParentKind(SyntaxKind.ConstructorDeclaration))
Completion\KeywordRecommenders\TypeVarKeywordRecommender.cs (1)
24
token.
Parent
.IsKind(SyntaxKind.AttributeList))
Completion\KeywordRecommenders\UsingKeywordRecommender.cs (4)
103
if ((token.Kind() == SyntaxKind.OpenBraceToken && token.
Parent
.IsKind(SyntaxKind.NamespaceDeclaration))
104
|| (token.Kind() == SyntaxKind.SemicolonToken && token.
Parent
.IsKind(SyntaxKind.FileScopedNamespaceDeclaration)))
123
if (token.
Parent
is (kind: SyntaxKind.ExternAliasDirective or SyntaxKind.UsingDirective))
152
previousToken.
Parent
is (kind: SyntaxKind.ExternAliasDirective or SyntaxKind.UsingDirective))
Completion\KeywordRecommenders\VoidKeywordRecommender.cs (1)
76
token.
Parent
.IsKind(SyntaxKind.ParenthesizedExpression))
Completion\KeywordRecommenders\WhereKeywordRecommender.cs (5)
58
token.
Parent
.IsKind(SyntaxKind.ParameterList) &&
59
token.
Parent
.IsParentKind(SyntaxKind.DelegateDeclaration))
71
token.
Parent
.IsKind(SyntaxKind.ParameterList))
73
var tokenParent = token.
Parent
;
96
if (token.
Parent
is IdentifierNameSyntax && token.HasMatchingText(SyntaxKind.WhereKeyword))
Completion\KeywordRecommenders\WhileKeywordRecommender.cs (2)
41
token.
Parent
.IsKind(SyntaxKind.Block) &&
42
token.
Parent
.IsParentKind(SyntaxKind.DoStatement))
ConvertToRawString\ConvertRegularStringToRawStringCodeRefactoringProvider.cs (1)
52
if (IsInDirective(token.
Parent
))
Debugging\DataTipInfoGetter.cs (1)
33
if (token.
Parent
is not ExpressionSyntax expression)
DecompiledSource\CSharpDecompiledSourceFormattingRule.cs (4)
35
if (previousToken.
Parent
== null || currentToken.
Parent
== null)
38
var previousStatement = previousToken.
Parent
.FirstAncestorOrSelf<StatementSyntax>();
39
var nextStatement = currentToken.
Parent
.FirstAncestorOrSelf<StatementSyntax>();
EditAndContinue\BreakpointSpans.cs (1)
71
var node = root.FindToken(position).
Parent
;
EditAndContinue\CSharpEditAndContinueAnalyzer.cs (2)
227
node = body.FindToken(position).
Parent
!;
601
=> BreakpointSpans.TryGetClosestBreakpointSpan(token.
Parent
!, token.SpanStart, minLength: token.Span.Length, out span);
ExtractMethod\CSharpSelectionResult.cs (1)
89
for (var current = token.
Parent
; current != null; current = current.Parent)
ExtractMethod\Extensions.cs (2)
152
if (token.
Parent
is not ThrowStatementSyntax throwStatement || throwStatement.Expression != null)
262
if (token1.RawKind != (int)SyntaxKind.SemicolonToken || !(token1.
Parent
is FieldDeclarationSyntax))
GenerateMember\GenerateVariable\CSharpGenerateVariableService.cs (1)
201
var node = identifierToken.
Parent
as IdentifierNameSyntax;
GenerateType\CSharpGenerateTypeService.cs (1)
248
simpleName.Parent == token.
Parent
)
ImplementInterface\AbstractChangeImplementationCodeRefactoringProvider.cs (1)
157
for (var node = token.
Parent
; node != null; node = node.Parent)
IntroduceVariable\CSharpIntroduceVariableService.Rewriter.cs (1)
47
var innerExpression = parenthesizedExpression.OpenParenToken.GetNextToken().
Parent
;
MetadataAsSource\FormattingRule.cs (2)
38
if (previousToken.Kind() == SyntaxKind.SemicolonToken && previousToken.
Parent
.Kind() == SyntaxKind.UsingDirective)
40
previousMember = previousToken.
Parent
;
QuickInfo\CSharpDiagnosticAnalyzerQuickInfoProvider.cs (1)
52
var errorCodeNode = token.
Parent
switch
QuickInfo\CSharpSemanticQuickInfoProvider.cs (8)
40
&& token.
Parent
is (kind: SyntaxKind.ParenthesizedLambdaExpression or SyntaxKind.SimpleLambdaExpression))
43
found = token.
Parent
;
46
else if (token.IsKind(SyntaxKind.DelegateKeyword) && token.
Parent
.IsKind(SyntaxKind.AnonymousMethodExpression))
49
found = token.
Parent
;
60
token.
Parent
?.Parent.IsKind(SyntaxKind.ElementAccessExpression) == true)
62
found = token.
Parent
.Parent;
73
token.
Parent
is MemberAccessExpressionSyntax memberAccess)
84
=> !token.
Parent
.IsKind(SyntaxKind.XmlCrefAttribute);
QuickInfo\CSharpSyntacticQuickInfoProvider.cs (3)
60
if (token.
Parent
is InterpolationSyntax interpolation &&
67
var parent = token.
Parent
!;
140
if (token.
Parent
is DirectiveTriviaSyntax directiveTrivia)
RemoveUnusedVariable\CSharpRemoveUnusedVariableCodeFixProvider.cs (1)
36
=> token.
Parent
is CatchDeclarationSyntax catchDeclaration && catchDeclaration.Identifier == token;
Rename\CSharpRenameIssuesService.cs (2)
42
triggerToken.
Parent
!,
58
var parent = token.
Parent
;
ReplaceMethodWithProperty\CSharpReplaceMethodWithPropertyService.cs (2)
364
if (nameToken.
Parent
is not IdentifierNameSyntax nameNode)
377
newName = newName.WithTriviaFrom(invocation is null ? nameToken.
Parent
: invocation);
SignatureHelp\AttributeSignatureHelpProvider.cs (2)
63
token.
Parent
is AttributeArgumentListSyntax &&
64
token.
Parent
.Parent is AttributeSyntax;
SignatureHelp\ElementAccessExpressionSignatureHelpProvider.cs (16)
117
if (openBracket.
Parent
is BracketedArgumentListSyntax)
128
else if (openBracket.
Parent
is ArrayRankSpecifierSyntax)
157
var newBracketedArgumentList = ParseBracketedArgumentList(openBracket.
Parent
!.ToString());
289
token.
Parent
is BracketedArgumentListSyntax &&
290
token.
Parent
.Parent is ElementAccessExpressionSyntax;
301
Contract.ThrowIfFalse(openBracket.
Parent
is BracketedArgumentListSyntax &&
302
(openBracket.
Parent
.Parent is ElementAccessExpressionSyntax || openBracket.
Parent
.Parent is ElementBindingExpressionSyntax));
303
return SignatureHelpUtilities.GetSignatureHelpSpan((BracketedArgumentListSyntax)openBracket.
Parent
);
338
token.
Parent
is ArrayRankSpecifierSyntax;
343
Contract.ThrowIfFalse(openBracket.
Parent
is ArrayRankSpecifierSyntax && openBracket.
Parent
.Parent is ArrayTypeSyntax);
344
return TextSpan.FromBounds(expression.SpanStart, openBracket.
Parent
.Span.End);
373
token.
Parent
is BracketedArgumentListSyntax &&
374
token.
Parent
.Parent is ElementBindingExpressionSyntax &&
375
token.
Parent
.Parent.Parent is ConditionalAccessExpressionSyntax;
SignatureHelp\GenericNameSignatureHelpProvider.cs (6)
66
token.
Parent
is TypeArgumentListSyntax &&
67
token.
Parent
.Parent is GenericNameSyntax;
86
if (genericIdentifier.
Parent
is not SimpleNameSyntax simpleName)
164
Contract.ThrowIfFalse(lessThanToken.
Parent
is TypeArgumentListSyntax && lessThanToken.
Parent
.Parent is GenericNameSyntax);
165
return SignatureHelpUtilities.GetSignatureHelpSpan(((GenericNameSyntax)lessThanToken.
Parent
.Parent).TypeArgumentList);
SignatureHelp\InitializerExpressionSignatureHelpProvider.cs (1)
51
token.
Parent
is InitializerExpressionSyntax;
SignatureHelp\SignatureHelpUtilities.cs (4)
104
token.
Parent
is ParenthesizedExpressionSyntax parenExpr)
130
if (token.IsKind(SyntaxKind.CommaToken) && token.
Parent
is TupleExpressionSyntax && token.GetAncestor<TSyntaxNode>() != null)
138
token.
Parent
is ArgumentListSyntax &&
139
token.
Parent
.Parent is TSyntaxNode;
SignatureHelp\TupleConstructionSignatureHelpProvider.cs (1)
227
=> token.IsKind(SyntaxKind.OpenParenToken) && token.
Parent
is ParenthesizedExpressionSyntax;
Snippets\CSharpConsoleSnippetProvider.cs (1)
35
if (syntaxContext.TargetToken is { RawKind: (int)SyntaxKind.EqualsGreaterThanToken,
Parent
: LambdaExpressionSyntax lambda })
Snippets\CSharpForEachLoopSnippetProvider.cs (2)
46
if (token is { RawKind: (int)SyntaxKind.AwaitKeyword,
Parent
: ExpressionSyntax { Parent: ExpressionStatementSyntax } } ||
47
token is { RawKind: (int)SyntaxKind.IdentifierToken, ValueText: "await",
Parent
: IdentifierNameSyntax { Parent: ExpressionStatementSyntax } })
SplitStringLiteral\SimpleStringSplitter.cs (1)
36
protected override SyntaxNode GetNodeToReplace() => _token.
Parent
;
SplitStringLiteral\StringSplitter.cs (1)
73
token.
Parent
.IsKind(SyntaxKind.Interpolation) &&
src\Analyzers\CSharp\CodeFixes\ConvertNamespace\ConvertNamespaceTransform.cs (1)
228
if (token.IsKind(SyntaxKind.HashToken) && token.
Parent
!.Kind() is not (SyntaxKind.RegionDirectiveTrivia or SyntaxKind.EndRegionDirectiveTrivia))
src\Analyzers\CSharp\CodeFixes\UseImplicitOrExplicitType\UseExplicitTypeCodeFixProvider.cs (1)
125
varDecl.Variables.Single().Identifier.
Parent
!,
UseAutoProperty\SingleLinePropertyFormattingRule.cs (4)
16
if (currentToken.IsKind(SyntaxKind.OpenBraceToken) && currentToken.
Parent
.IsKind(SyntaxKind.AccessorList))
19
if (previousToken.IsKind(SyntaxKind.OpenBraceToken) && previousToken.
Parent
.IsKind(SyntaxKind.AccessorList))
22
if (currentToken.IsKind(SyntaxKind.CloseBraceToken) && currentToken.
Parent
.IsKind(SyntaxKind.AccessorList))
25
if (previousToken.IsKind(SyntaxKind.SemicolonToken) && currentToken.
Parent
is AccessorDeclarationSyntax)
Wrapping\SeparatedSyntaxList\CSharpArgumentWrapper.cs (1)
100
for (var current = token.
Parent
; current != listSyntax; current = current?.Parent)
Microsoft.CodeAnalysis.CSharp.Features.UnitTests (2)
EditAndContinue\BreakpointSpansTests.cs (1)
77
var declarationNode = root.FindToken(position).
Parent
.FirstAncestorOrSelf<TDeclaration>();
EditAndContinue\CSharpEditAndContinueAnalyzerTests.cs (1)
56
var node = token.
Parent
;
Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests (16)
Semantics\LookupPositionTests.cs (1)
3132
position, token.ToString(), token.
Parent
.ToString(), keyPositionNum, KeyPositionMarker));
Semantics\MethodTypeInferenceTests.cs (4)
1119
var book = (IdentifierNameSyntax)tree.GetRoot().DescendantTokens().Last(t => t.Text == "b").
Parent
;
1160
var author = (IdentifierNameSyntax)tree.GetRoot().DescendantTokens().Last(t => t.Text == "a").
Parent
;
1201
var bookResult = (IdentifierNameSyntax)tree.GetRoot().DescendantTokens().Last(t => t.Text == "bookResult").
Parent
;
1205
var authorResult = (IdentifierNameSyntax)tree.GetRoot().DescendantTokens().Last(t => t.Text == "authorResult").
Parent
;
Semantics\QueryTests.cs (8)
2177
SelectClauseSyntax selectClause = (SelectClauseSyntax)tree.GetCompilationUnitRoot().FindToken(sourceCode.IndexOf("select", StringComparison.Ordinal)).
Parent
;
2207
SelectClauseSyntax selectClause = (SelectClauseSyntax)tree.GetCompilationUnitRoot().FindToken(sourceCode.IndexOf("select w", StringComparison.Ordinal)).
Parent
;
2234
var e = (IdentifierNameSyntax)tree.GetCompilationUnitRoot().FindToken(sourceCode.IndexOf("x+1", StringComparison.Ordinal)).
Parent
;
2240
e = (IdentifierNameSyntax)tree.GetCompilationUnitRoot().FindToken(sourceCode.IndexOf("w+1", StringComparison.Ordinal)).
Parent
;
2272
var queryContinuation = tree.GetRoot().FindToken(sourceCode.IndexOf("into w", StringComparison.Ordinal)).
Parent
;
2325
var joinInto = tree.GetRoot().FindToken(sourceCode.IndexOf("into x8", StringComparison.Ordinal)).
Parent
;
3134
var selectNode = tree.GetCompilationUnitRoot().FindToken(index).
Parent
as SelectClauseSyntax;
3162
var joinNode = tree.GetCompilationUnitRoot().FindToken(index).
Parent
as JoinClauseSyntax;
Semantics\TopLevelStatementsTests.cs (2)
9708
var conversionInTopLevel = speculativeModelInTopLevel.GetConversion(nodeToSpeculate.DescendantTokens().Single(n => n.ValueText == "x").
Parent
);
9713
var conversionOutsideTopLevel = speculativeModelOutsideTopLevel.GetConversion(nodeToSpeculate.DescendantTokens().Single(n => n.ValueText == "x").
Parent
);
Semantics\UnsafeTests.cs (1)
8347
var node = (ExpressionSyntax)nullSyntax.
Parent
;
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (35)
Compilation\GetSemanticInfoTests.cs (5)
4212
var syntax = tree.GetCompilationUnitRoot().FindToken(position).
Parent
.DescendantNodesAndSelf().OfType<OmittedTypeArgumentSyntax>().Single();
4242
var syntax = tree.GetCompilationUnitRoot().FindToken(position).
Parent
.DescendantNodesAndSelf().OfType<OmittedTypeArgumentSyntax>().Single();
4272
var syntax = tree.GetCompilationUnitRoot().FindToken(position).
Parent
.DescendantNodesAndSelf().OfType<GenericNameSyntax>().Single();
4911
var equalsNode = equalsToken.
Parent
;
5914
var expr = tokens.Single(t => t.Kind() == SyntaxKind.TrueKeyword).
Parent
;
Compilation\SemanticModelAPITests.cs (1)
4059
var x = tree.GetRoot().FindToken(match.Index + 4).
Parent
;
Compilation\SemanticModelGetDeclaredSymbolAPITests.cs (17)
429
var node = root.FindToken(tree.GetCompilationUnitRoot().ToFullString().IndexOf("public event D Iter3", StringComparison.Ordinal)).
Parent
as BasePropertyDeclarationSyntax;
3314
var paramNode = tree.GetCompilationUnitRoot().FindToken(tree.GetCompilationUnitRoot().ToFullString().IndexOf("param1", StringComparison.Ordinal)).
Parent
;
3341
var paramNode = root.FindToken(root.ToFullString().IndexOf('x')).
Parent
;
3367
var paramNode = root.FindToken(root.ToFullString().IndexOf('x')).
Parent
;
3408
var foreachNode = tree.GetCompilationUnitRoot().FindToken(tree.GetCompilationUnitRoot().ToFullString().IndexOf("foreach", StringComparison.Ordinal)).
Parent
;
3429
var delegateNode = tree.GetCompilationUnitRoot().FindToken(tree.GetCompilationUnitRoot().ToFullString().IndexOf("delegate", StringComparison.Ordinal)).
Parent
;
3448
var usingNode = tree.GetCompilationUnitRoot().FindToken(tree.GetCompilationUnitRoot().ToFullString().IndexOf("using", StringComparison.Ordinal)).
Parent
;
3477
var foreachNode = tree.GetCompilationUnitRoot().FindToken(tree.GetCompilationUnitRoot().ToFullString().IndexOf("aaa", StringComparison.Ordinal)).
Parent
;
3501
var foreachNode = tree.GetCompilationUnitRoot().FindToken(tree.GetCompilationUnitRoot().ToFullString().IndexOf("aaa", StringComparison.Ordinal)).
Parent
;
3528
var foreachNode1 = tree.GetCompilationUnitRoot().FindToken(tree.GetCompilationUnitRoot().ToFullString().IndexOf("aaa", StringComparison.Ordinal)).
Parent
;
3534
var foreachNode2 = tree.GetCompilationUnitRoot().FindToken(tree.GetCompilationUnitRoot().ToFullString().IndexOf("bbb", StringComparison.Ordinal)).
Parent
;
3565
var catchDeclaration = tree.GetCompilationUnitRoot().FindToken(tree.GetCompilationUnitRoot().ToFullString().IndexOf("aaa", StringComparison.Ordinal)).
Parent
;
3586
var methodDecl = tree.GetCompilationUnitRoot().FindToken(tree.GetCompilationUnitRoot().ToFullString().IndexOf("Goo", StringComparison.Ordinal)).
Parent
;
3611
var methodDecl = tree.GetCompilationUnitRoot().FindToken(tree.GetCompilationUnitRoot().ToFullString().IndexOf("Goo", StringComparison.Ordinal)).
Parent
;
3668
dynamic methodDecl = (MethodDeclarationSyntax)tree.GetCompilationUnitRoot().FindToken(tree.GetCompilationUnitRoot().ToFullString().IndexOf("Main", StringComparison.Ordinal)).
Parent
;
3686
var globalStmt = tree.GetCompilationUnitRoot().FindToken(tree.GetCompilationUnitRoot().ToFullString().IndexOf('/')).
Parent
.AncestorsAndSelf().Single(x => x.IsKind(SyntaxKind.GlobalStatement));
3866
var node = (IdentifierNameSyntax)tree.GetCompilationUnitRoot().DescendantTokens().Where(t => t.ToString() == "Alias").Last().
Parent
;
DeclarationTests.cs (1)
919
for (var node = token.
Parent
; node != null; node = node.Parent)
Symbols\ConversionTests.cs (3)
394
.FindToken(source.IndexOf("ii", StringComparison.Ordinal)).
Parent
;
401
.FindToken(source.IndexOf("jj)", StringComparison.Ordinal)).
Parent
;
407
.FindToken(source.IndexOf("ss)", StringComparison.Ordinal)).
Parent
;
Symbols\ExtensionMethodTests.cs (2)
2727
var node = tree.GetCompilationUnitRoot().FindToken(code.IndexOf("GetHashCode", StringComparison.Ordinal)).
Parent
;
2737
node = tree.GetCompilationUnitRoot().FindToken(code.IndexOf("Cast<T1>", StringComparison.Ordinal)).
Parent
;
Symbols\Source\DeclaringSyntaxNodeTests.cs (6)
140
var node = tree.GetRoot().FindToken(position).
Parent
.FirstAncestorOrSelf<TNode>();
155
var node = tree.GetCompilationUnitRoot().FindToken(position).
Parent
.FirstAncestorOrSelf<TNode>();
263
var declaratorA1 = tree.GetCompilationUnitRoot().FindToken(posA1).
Parent
.FirstAncestorOrSelf<VariableDeclaratorSyntax>();
307
var declaratorQ = tree.GetCompilationUnitRoot().FindToken(posQ).
Parent
.FirstAncestorOrSelf<VariableDeclaratorSyntax>();
314
var declaratorX = tree.GetCompilationUnitRoot().FindToken(posX).
Parent
.FirstAncestorOrSelf<VariableDeclaratorSyntax>();
321
var declaratorZ = tree.GetCompilationUnitRoot().FindToken(posZ).
Parent
.FirstAncestorOrSelf<VariableDeclaratorSyntax>();
Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests (19)
Diagnostics\LocationsTests.cs (1)
458
var expressionDiags = syntaxTree.GetDiagnostics(token.
Parent
.Parent);
LexicalAndXml\SyntaxTokenParserTests.cs (1)
412
Assert.Null(result.Token.
Parent
);
Parsing\ParsingErrorRecoveryTests.cs (1)
7380
var foreachNode = srcTree.GetLastToken().
Parent
;
Syntax\StructuredTriviaTests.cs (1)
85
var foundDocComment = result.
Parent
.Parent.Parent.Parent;
Syntax\SyntaxNodeTests.cs (15)
2479
var b = expr.DescendantTokens().Where(t => t.Text == "b").Select(t => t.
Parent
.FirstAncestorOrSelf<ArgumentSyntax>()).FirstOrDefault();
2494
var b = expr.DescendantTokens().Where(t => t.Text == "b").Select(t => t.
Parent
.FirstAncestorOrSelf<ArgumentSyntax>()).FirstOrDefault();
2510
var b = expr.DescendantTokens().Where(t => t.Text == "b").Select(t => t.
Parent
.FirstAncestorOrSelf<ArgumentSyntax>()).FirstOrDefault();
2527
var b = expr.DescendantTokens().Where(t => t.Text == "b").Select(t => t.
Parent
.FirstAncestorOrSelf<ArgumentSyntax>()).FirstOrDefault();
2548
var b = expr.DescendantTokens().Where(t => t.Text == "b").Select(t => t.
Parent
.FirstAncestorOrSelf<ArgumentSyntax>()).FirstOrDefault();
2567
var b = expr.DescendantTokens().Where(t => t.Text == "b").Select(t => t.
Parent
.FirstAncestorOrSelf<ArgumentSyntax>()).FirstOrDefault();
2583
var b = expr.DescendantTokens().Where(t => t.Text == "b").Select(t => t.
Parent
.FirstAncestorOrSelf<ArgumentSyntax>()).FirstOrDefault();
2599
var b = expr.DescendantTokens().Where(t => t.Text == "b").Select(t => t.
Parent
.FirstAncestorOrSelf<ArgumentSyntax>()).FirstOrDefault();
2615
var b = expr.DescendantTokens().Where(t => t.Text == "b").Select(t => t.
Parent
.FirstAncestorOrSelf<ArgumentSyntax>()).FirstOrDefault();
2635
var b = expr.DescendantTokens().Where(t => t.Text == "b").Select(t => t.
Parent
.FirstAncestorOrSelf<ArgumentSyntax>()).FirstOrDefault();
2652
var n = expr.DescendantTokens().Where(t => t.Text == "a").Select(t => t.
Parent
.FirstAncestorOrSelf<ArgumentSyntax>()).FirstOrDefault();
2666
var n = expr.DescendantTokens().Where(t => t.Text == "a").Select(t => t.
Parent
.FirstAncestorOrSelf<ArgumentSyntax>()).FirstOrDefault();
2680
var n = expr.DescendantTokens().Where(t => t.Text == "c").Select(t => t.
Parent
.FirstAncestorOrSelf<ArgumentSyntax>()).FirstOrDefault();
2694
var b = expr.DescendantTokens().Where(t => t.Text == "b").Select(t => t.
Parent
.FirstAncestorOrSelf<StatementSyntax>()).FirstOrDefault();
2708
var b = expr.DescendantTokens().Where(t => t.Text == "b").Select(t => t.
Parent
.FirstAncestorOrSelf<StatementSyntax>()).FirstOrDefault();
Microsoft.CodeAnalysis.CSharp.Test.Utilities (3)
CompilationTestUtils.cs (1)
516
var node = token.
Parent
;
CSharpTestBase.cs (1)
1754
var node = tree.GetRoot().FindToken(start).
Parent
;
SemanticModelTestBase.cs (1)
141
var nameSyntaxToBind = tree.GetRoot().FindToken(position, findInsideTrivia: true).
Parent
as IdentifierNameSyntax;
Microsoft.CodeAnalysis.CSharp.Workspaces (493)
Classification\ClassificationHelpers.cs (40)
62
=> token.
Parent
is not null &&
64
IsControlStatementKind(token.
Parent
.Kind());
173
return token.
Parent
is InterpolatedStringExpressionSyntax interpolatedString
179
if (token.
Parent
is not InterpolatedStringTextSyntax interpolatedStringText)
194
if (token.
Parent
is BaseTypeDeclarationSyntax typeDeclaration && typeDeclaration.Identifier == token)
198
else if (token.
Parent
is DelegateDeclarationSyntax delegateDecl && delegateDecl.Identifier == token)
202
else if (token.
Parent
is TypeParameterSyntax typeParameter && typeParameter.Identifier == token)
206
else if (token.
Parent
is MethodDeclarationSyntax methodDeclaration && methodDeclaration.Identifier == token)
210
else if (token.
Parent
is ConstructorDeclarationSyntax constructorDeclaration && constructorDeclaration.Identifier == token)
214
else if (token.
Parent
is DestructorDeclarationSyntax destructorDeclaration && destructorDeclaration.Identifier == token)
218
else if (token.
Parent
is LocalFunctionStatementSyntax localFunctionStatement && localFunctionStatement.Identifier == token)
222
else if (token.
Parent
is PropertyDeclarationSyntax propertyDeclaration && propertyDeclaration.Identifier == token)
226
else if (token.
Parent
is EnumMemberDeclarationSyntax enumMemberDeclaration && enumMemberDeclaration.Identifier == token)
230
else if (token.
Parent
is CatchDeclarationSyntax catchDeclaration && catchDeclaration.Identifier == token)
234
else if (token.
Parent
is VariableDeclaratorSyntax variableDeclarator && variableDeclarator.Identifier == token)
245
else if (token.
Parent
is SingleVariableDesignationSyntax singleVariableDesignation && singleVariableDesignation.Identifier == token)
249
else if (token.
Parent
is ParameterSyntax parameterSyntax && parameterSyntax.Identifier == token)
253
else if (token.
Parent
is ForEachStatementSyntax forEachStatementSyntax && forEachStatementSyntax.Identifier == token)
257
else if (token.
Parent
is EventDeclarationSyntax eventDeclarationSyntax && eventDeclarationSyntax.Identifier == token)
265
else if (token.
Parent
is IdentifierNameSyntax identifierNameSyntax && IsNamespaceName(identifierNameSyntax))
269
else if (token.
Parent
is ExternAliasDirectiveSyntax externAliasDirectiveSyntax && externAliasDirectiveSyntax.Identifier == token)
273
else if (token.
Parent
is LabeledStatementSyntax labledStatementSyntax && labledStatementSyntax.Identifier == token)
306
var parentNode = token.
Parent
;
335
=> identifier.
Parent
!.Kind() switch
357
if (token.
Parent
!= null)
359
if (token.
Parent
.Kind() is SyntaxKind.TypeParameterList or
371
if (token.
Parent
!= null)
373
if (token.
Parent
.Kind() != SyntaxKind.ConditionalExpression)
446
if (token.
Parent
is LabeledStatementSyntax statement &&
461
if (token.
Parent
!= null)
469
var fromClause = token.
Parent
.FirstAncestorOrSelf<FromClauseSyntax>();
474
if (token.
Parent
is IdentifierNameSyntax && token.
Parent
?.Parent is ExpressionStatementSyntax)
482
token.
Parent
is IdentifierNameSyntax &&
483
token.
Parent
.Parent is VariableDeclarationSyntax &&
484
!(token.
Parent
.Parent.Parent is FieldDeclarationSyntax) &&
485
!(token.
Parent
.Parent.Parent is EventFieldDeclarationSyntax);
489
return token.
Parent
is IdentifierNameSyntax
490
&& token.
Parent
.Parent is TypeConstraintSyntax
491
&& token.
Parent
.Parent.Parent is TypeParameterConstraintClauseSyntax;
Classification\SyntaxClassification\SyntaxTokenClassifier.cs (2)
62
if (identifier.
Parent
is not IdentifierNameSyntax identifierName)
78
if (identifier.
Parent
.IsParentKind(SyntaxKind.ConditionalAccessExpression))
Classification\Worker_DocumentationComments.cs (2)
161
RoslynDebug.Assert(token.
Parent
is object);
162
switch (token.
Parent
.Kind())
CodeGeneration\CSharpSyntaxGenerator.cs (1)
3075
if (previousToken != default && root.Contains(previousToken.
Parent
))
Rename\CSharpRenameRewriterLanguageService.cs (15)
224
if (newToken.
Parent
.IsKind(SyntaxKind.XmlName))
262
&& IsNameConflictWithProperty("get", token.
Parent
as AccessorDeclarationSyntax);
266
&& IsNameConflictWithProperty("set", token.
Parent
as AccessorDeclarationSyntax);
271
&& IsNameConflictWithProperty("set", token.
Parent
as AccessorDeclarationSyntax);
281
token.
Parent
.IsKind(SyntaxKind.DestructorDeclaration);
404
var isMemberGroupReference = _semanticFactsService.IsInsideNameOfExpression(_semanticModel, token.
Parent
, _cancellationToken);
542
if (token.
Parent
is SimpleNameSyntax &&
544
token.
Parent
.Parent is (kind: SyntaxKind.AliasQualifiedName or SyntaxKind.QualifiedCref or SyntaxKind.QualifiedName))
546
var symbol = _speculativeModel.GetSymbolInfo(token.
Parent
, _cancellationToken).Symbol;
571
var parent = oldToken.
Parent
!;
712
else if (newToken.IsKind(SyntaxKind.IdentifierToken) && newToken.
Parent
.IsKind(SyntaxKind.XmlName) && newToken.ValueText == _originalText)
750
if (token.
Parent
is ExpressionSyntax(SyntaxKind.IdentifierName) expression &&
751
token.
Parent
.IsParentKind(SyntaxKind.InvocationExpression) &&
1184
if (token.
Parent
is TypeSyntax && token.
Parent
.Parent is TypeSyntax)
Simplification\CSharpSimplificationService.cs (2)
80
Contract.ThrowIfNull(token.
Parent
);
86
var rewrittenToken = TryEscapeIdentifierToken(rewriter.VisitToken(token), token.
Parent
).WithAdditionalAnnotations(Simplifier.Annotation);
Simplification\Reducers\CSharpEscapingReducer.cs (1)
51
var parent = token.
Parent
;
Simplification\Simplifiers\AbstractCSharpSimplifier.cs (2)
367
return token.
Parent
;
372
return token.
Parent
;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\EmbeddedLanguages\VirtualChars\CSharpVirtualCharService.cs (2)
39
if (token.
Parent
?.Parent is InterpolatedStringExpressionSyntax { StringStartToken.RawKind: (int)SyntaxKind.InterpolatedMultiLineRawStringStartToken })
57
if (IsInDirective(token.
Parent
))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SemanticModelExtensions.cs (3)
27
if (name.
Parent
is ExpressionSyntax expression)
44
if (name.
Parent
is ExpressionSyntax expression)
135
switch (token.
Parent
)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxTokenExtensions.cs (2)
47
token.
Parent
.IsKind(SyntaxKind.ObjectInitializerExpression);
50
=> token.IsKind(SyntaxKind.OpenBraceToken) && token.
Parent
.IsKind(SyntaxKind.AccessorList);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Engine\Trivia\CSharpTriviaFormatter.DocumentationCommentExteriorCommentRewriter.cs (1)
68
var currentParent = trivia.Token.
Parent
;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\FormattingHelpers.cs (46)
77
=> token.IsOpenParenInParameterList() && token.
Parent
.IsParentKind(SyntaxKind.ConversionOperatorDeclaration);
80
=> token.IsOpenParenInParameterList() && token.
Parent
.IsParentKind(SyntaxKind.OperatorDeclaration);
83
=> token.Kind() == SyntaxKind.OpenParenToken && token.
Parent
.IsKind(SyntaxKind.ParameterList);
86
=> token.Kind() == SyntaxKind.CloseParenToken && token.
Parent
.IsKind(SyntaxKind.ParameterList);
103
if (token.
Parent
is (kind: SyntaxKind.ArgumentList or SyntaxKind.AttributeArgumentList))
109
if (token.
Parent
.IsKind(SyntaxKind.PositionalPatternClause) && token.
Parent
.Parent.IsKind(SyntaxKind.RecursivePattern))
112
return token.
Parent
.Parent.GetFirstToken() != token;
119
=> token.Kind() == SyntaxKind.ColonToken && token.
Parent
.IsKind(SyntaxKind.BaseList);
122
=> token.Kind() == SyntaxKind.CommaToken && (token.
Parent
.IsAnyArgumentList() || token.
Parent
?.Kind() is SyntaxKind.ParameterList or SyntaxKind.FunctionPointerParameterList);
125
=> token.Kind() == SyntaxKind.OpenParenToken && token.
Parent
.IsKind(SyntaxKind.ParameterList) && token.
Parent
.Parent.IsKind(SyntaxKind.ParenthesizedLambdaExpression);
151
token.
Parent
is ForStatementSyntax forStatement &&
162
if (token.
Parent
is not StatementSyntax statement ||
178
return token.
Parent
is ExpressionSyntax || token.
Parent
.IsKind(SyntaxKind.PropertyPatternClause);
188
if (token.
Parent
is not BlockSyntax block ||
210
token.
Parent
.IsKind(SyntaxKind.EnumDeclaration);
216
token.
Parent
.IsAnyArgumentList();
221
if (token.
Parent
is not ParenthesizedExpressionSyntax parenthesizedExpression)
231
var parent = token.
Parent
?? throw new ArgumentNullException(nameof(token));
278
token.
Parent
.IsKind(SyntaxKind.EqualsValueClause) &&
279
token.
Parent
.Parent.IsKind(SyntaxKind.PropertyDeclaration);
284
if (token.
Parent
is not StatementSyntax statement)
305
=> token.IsDotInMemberAccess() || (token.Kind() == SyntaxKind.DotToken && token.
Parent
.IsKind(SyntaxKind.QualifiedName));
309
if (token.
Parent
is not MemberAccessExpressionSyntax memberAccess)
321
return token.
Parent
is (kind: SyntaxKind.TypeParameterList or SyntaxKind.TypeArgumentList);
329
((token.
Parent
is InitializerExpressionSyntax) ||
330
(token.
Parent
is AnonymousObjectCreationExpressionSyntax));
334
=> token.Kind() == SyntaxKind.ColonToken && token.
Parent
is CasePatternSwitchLabelSyntax;
337
=> token.Kind() == SyntaxKind.ColonToken && token.
Parent
.IsKind(SyntaxKind.SwitchExpressionArm);
340
=> token.Kind() == SyntaxKind.CommaToken && token.
Parent
.IsKind(SyntaxKind.SwitchExpression);
343
=> token.Kind() == SyntaxKind.CommaToken && token.
Parent
.IsKind(SyntaxKind.PropertyPatternClause);
348
token.
Parent
is LabeledStatementSyntax labeledStatement &&
358
token.
Parent
is LabeledStatementSyntax labeledStatement &&
376
token.
Parent
is FromClauseSyntax fromClause &&
383
token.
Parent
?.Parent is QueryExpressionSyntax queryExpression &&
478
if (token.
Parent
== null)
483
return token.
Parent
.Parent is LabeledStatementSyntax;
517
return token.
Parent
is PrefixUnaryExpressionSyntax;
521
=> currentToken.
Parent
.IsKind(SyntaxKind.Interpolation);
529
currentToken.
Parent
is ParenthesizedVariableDesignationSyntax &&
530
currentToken.
Parent
.Parent is DeclarationExpressionSyntax;
539
currentToken.
Parent
.IsKind(SyntaxKind.TupleExpression);
543
=> token.Kind() == SyntaxKind.CommaToken && token.
Parent
.IsKind(SyntaxKind.CollectionExpression);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\ElasticTriviaFormattingRule.cs (35)
116
currentToken.
Parent
.IsKind(SyntaxKind.TypeParameterConstraintClause))
118
RoslynDebug.AssertNotNull(previousToken.
Parent
);
121
if (previousToken.
Parent
.Ancestors().OfType<TypeParameterConstraintClauseSyntax>().Any())
127
var firstTokenAfterTypeConstraint = currentToken.
Parent
.GetLastToken().GetNextToken();
128
var lastTokenForTypeConstraint = currentToken.
Parent
.GetLastToken().GetNextToken();
131
firstTokenAfterTypeConstraint.
Parent
.IsKind(SyntaxKind.TypeParameterConstraintClause))
143
currentToken.
Parent
.IsParentKind(SyntaxKind.IfStatement))
185
if (previousToken.
Parent
is not FileScopedNamespaceDeclarationSyntax)
294
previousToken.
Parent
is AttributeListSyntax &&
295
currentToken.
Parent
is not AttributeListSyntax)
328
return (((previousToken.
Parent
is StatementSyntax) && currentToken.
Parent
!= previousToken.
Parent
)
334
if (previousToken.
Parent
is AttributeListSyntax parent)
340
if (!currentToken.IsKind(SyntaxKind.EndOfFileToken) && !(currentToken.
Parent
is AttributeListSyntax))
359
return previousToken.
Parent
is EnumDeclarationSyntax ? 1 : 0;
365
if (previousToken.
Parent
is LabeledStatementSyntax or SwitchLabelSyntax)
373
if ((currentToken.Kind() == SyntaxKind.FromKeyword && currentToken.
Parent
.IsKind(SyntaxKind.FromClause)) ||
374
(currentToken.Kind() == SyntaxKind.LetKeyword && currentToken.
Parent
.IsKind(SyntaxKind.LetClause)) ||
375
(currentToken.Kind() == SyntaxKind.WhereKeyword && currentToken.
Parent
.IsKind(SyntaxKind.WhereClause)) ||
376
(currentToken.Kind() == SyntaxKind.JoinKeyword && currentToken.
Parent
.IsKind(SyntaxKind.JoinClause)) ||
377
(currentToken.Kind() == SyntaxKind.JoinKeyword && currentToken.
Parent
.IsKind(SyntaxKind.JoinIntoClause)) ||
378
(currentToken.Kind() == SyntaxKind.OrderByKeyword && currentToken.
Parent
.IsKind(SyntaxKind.OrderByClause)) ||
379
(currentToken.Kind() == SyntaxKind.SelectKeyword && currentToken.
Parent
.IsKind(SyntaxKind.SelectClause)) ||
380
(currentToken.Kind() == SyntaxKind.GroupKeyword && currentToken.
Parent
.IsKind(SyntaxKind.GroupClause)))
396
if (currentToken.
Parent
is AttributeListSyntax parent)
400
previousToken.
Parent
is not AttributeListSyntax)
417
return previousToken.
Parent
is TypeParameterListSyntax ? 1 : 0;
438
nextToken.
Parent
.IsKind(SyntaxKind.DoStatement))
454
if (previousToken.
Parent
is ForStatementSyntax)
462
else if (previousToken.
Parent
is UsingDirectiveSyntax)
464
return currentToken.
Parent
is UsingDirectiveSyntax ? 1 : 2;
466
else if (previousToken.
Parent
is ExternAliasDirectiveSyntax)
468
return currentToken.
Parent
is ExternAliasDirectiveSyntax ? 1 : 2;
470
else if (currentToken.
Parent
is LocalFunctionStatementSyntax)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\NewLineUserSettingFormattingRule.cs (25)
78
RoslynDebug.AssertNotNull(currentToken.
Parent
);
85
&& previousToken.
Parent
!.Parent == currentToken.
Parent
.Parent)
112
if (currentToken.IsKind(SyntaxKind.OpenBraceToken) && currentToken.
Parent
is BaseTypeDeclarationSyntax or NamespaceDeclarationSyntax)
121
if (currentToken.IsKind(SyntaxKind.OpenBraceToken) && currentToken.
Parent
.IsKind(SyntaxKind.AnonymousObjectCreationExpression))
132
if (currentToken.
Parent
.Kind() is SyntaxKind.ObjectInitializerExpression
143
else if (currentToken.
Parent
.IsKind(SyntaxKind.PropertyPatternClause))
153
var isFirstTokenOfSwitchArm = currentToken.
Parent
.IsParentKind(SyntaxKind.RecursivePattern, out RecursivePatternSyntax? recursivePattern)
165
var currentTokenParentParent = currentToken.
Parent
.Parent;
217
if (currentToken.IsKind(SyntaxKind.OpenBraceToken) && currentToken.
Parent
.IsKind(SyntaxKind.SwitchExpression))
226
if (currentToken.IsKind(SyntaxKind.OpenBraceToken) && IsControlBlock(currentToken.
Parent
))
239
RoslynDebug.AssertNotNull(currentToken.
Parent
);
246
if (previousToken.IsKind(SyntaxKind.CommaToken) && previousToken.
Parent
.IsKind(SyntaxKind.ObjectInitializerExpression))
260
if (previousToken.IsKind(SyntaxKind.CommaToken) && previousToken.
Parent
.IsKind(SyntaxKind.AnonymousObjectCreationExpression))
277
|| previousToken.
Parent
!.Parent != currentToken.
Parent
.Parent)
314
if (currentToken.IsKind(SyntaxKind.OpenBraceToken) && currentToken.
Parent
is BaseTypeDeclarationSyntax or NamespaceDeclarationSyntax)
327
if (currentToken.IsKind(SyntaxKind.OpenBraceToken) && currentToken.
Parent
.IsKind(SyntaxKind.AnonymousObjectCreationExpression))
344
currentToken.
Parent
.Kind() is SyntaxKind.ObjectInitializerExpression or SyntaxKind.CollectionInitializerExpression or SyntaxKind.WithInitializerExpression or SyntaxKind.PropertyPatternClause)
361
currentToken.
Parent
.Kind() is SyntaxKind.ArrayInitializerExpression or SyntaxKind.ImplicitArrayCreationExpression)
366
var currentTokenParentParent = currentToken.
Parent
.Parent;
439
if (currentToken.IsKind(SyntaxKind.OpenBraceToken) && currentToken.
Parent
.IsKind(SyntaxKind.SwitchExpression))
452
if (currentToken.IsKind(SyntaxKind.OpenBraceToken) && IsControlBlock(currentToken.
Parent
))
468
&& (previousToken.
Parent
is StatementSyntax && !previousToken.
Parent
.IsKind(SyntaxKind.ForStatement))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\SpacingFormattingRule.cs (29)
45
RoslynDebug.Assert(previousToken.
Parent
!= null && currentToken.
Parent
!= null);
49
var previousParentKind = previousToken.
Parent
.Kind();
50
var currentParentKind = currentToken.
Parent
.Kind();
92
if (previousToken.
Parent
.IsKind(SyntaxKind.OperatorDeclaration) && currentToken.IsOpenParenInParameterListOfAOperationDeclaration())
163
if ((previousToken.
Parent
.Kind() is SyntaxKind.ParenthesizedExpression or SyntaxKind.ParenthesizedPattern && previousKind == SyntaxKind.OpenParenToken) ||
164
(currentToken.
Parent
.Kind() is SyntaxKind.ParenthesizedExpression or SyntaxKind.ParenthesizedPattern && currentKind == SyntaxKind.CloseParenToken))
178
&& IsEmptyForStatement((ForStatementSyntax)previousToken.
Parent
!))
208
if (currentKind == SyntaxKind.OpenBracketToken && currentToken.
Parent
.Kind() is SyntaxKind.ListPattern or SyntaxKind.CollectionExpression)
249
if (previousKind == SyntaxKind.CloseBracketToken && previousToken.
Parent
.IsKind(SyntaxKind.AttributeList))
253
currentToken.
Parent
.IsKind(SyntaxKind.AttributeList))
327
if (currentToken.
Parent
is BinaryExpressionSyntax ||
328
previousToken.
Parent
is BinaryExpressionSyntax ||
329
currentToken.
Parent
is AssignmentExpressionSyntax ||
330
previousToken.
Parent
is AssignmentExpressionSyntax ||
331
currentToken.
Parent
.Kind() is SyntaxKind.AndPattern or SyntaxKind.OrPattern or SyntaxKind.RelationalPattern ||
332
previousToken.
Parent
.Kind() is SyntaxKind.AndPattern or SyntaxKind.OrPattern or SyntaxKind.RelationalPattern)
458
if (previousToken.
Parent
.IsKind(SyntaxKind.NotPattern))
487
if ((currentKind == SyntaxKind.OpenBraceToken && currentToken.
Parent
is InterpolationSyntax) ||
488
(previousKind == SyntaxKind.CloseBraceToken && previousToken.
Parent
is InterpolationSyntax))
494
if (previousKind == SyntaxKind.OpenBraceToken && previousToken.
Parent
is InterpolationSyntax)
500
if (currentKind == SyntaxKind.CloseBraceToken && currentToken.
Parent
is InterpolationSyntax interpolation)
511
if ((previousKind == SyntaxKind.CommaToken && previousToken.
Parent
is InterpolationAlignmentClauseSyntax) ||
512
(currentKind == SyntaxKind.CommaToken && currentToken.
Parent
is InterpolationAlignmentClauseSyntax))
518
if ((previousKind == SyntaxKind.ColonToken && previousToken.
Parent
is InterpolationFormatClauseSyntax) ||
519
(currentKind == SyntaxKind.ColonToken && currentToken.
Parent
is InterpolationFormatClauseSyntax))
539
var rangeExpression = (RangeExpressionSyntax)previousToken.
Parent
!;
550
var rangeExpression = (RangeExpressionSyntax)currentToken.
Parent
!;
606
=> token.
Parent
is (kind: SyntaxKind.ArrayRankSpecifier or SyntaxKind.BracketedArgumentList or SyntaxKind.BracketedParameterList or SyntaxKind.ImplicitArrayCreationExpression or SyntaxKind.ListPattern or SyntaxKind.CollectionExpression);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\StructuredTriviaFormattingRule.cs (4)
16
if (previousToken.
Parent
is StructuredTriviaSyntax || currentToken.
Parent
is StructuredTriviaSyntax)
26
if (previousToken.
Parent
is StructuredTriviaSyntax || currentToken.
Parent
is StructuredTriviaSyntax)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\TokenBasedFormattingRule.cs (29)
170
if (previousToken.Kind() == SyntaxKind.CloseParenToken && previousToken.
Parent
.IsEmbeddedStatementOwnerWithCloseParen())
175
if (previousToken.Kind() == SyntaxKind.DoKeyword && previousToken.
Parent
.IsKind(SyntaxKind.DoStatement))
201
if (previousToken.Kind() == SyntaxKind.CloseBracketToken && previousToken.
Parent
is AttributeListSyntax)
203
var attributeOwner = previousToken.
Parent
?.Parent;
222
if (previousToken.
Parent
is not UsingDirectiveSyntax previousUsing)
229
currentToken.
Parent
is UsingDirectiveSyntax currentUsing &&
269
if (previousToken.Kind() == SyntaxKind.CloseParenToken && previousToken.
Parent
.IsEmbeddedStatementOwnerWithCloseParen())
288
previousToken.
Parent
.IsKind(SyntaxKind.AttributeList) &&
289
previousToken.
Parent
.IsParentKind(SyntaxKind.Parameter))
317
var spaces = previousToken.
Parent
is (kind:
346
if (previousToken.Kind() == SyntaxKind.CommaToken && currentToken.Kind() == SyntaxKind.OpenBracketToken && currentToken.
Parent
is AttributeListSyntax)
352
if (previousToken.Kind() == SyntaxKind.CloseBracketToken && previousToken.
Parent
is AttributeListSyntax)
375
currentToken.
Parent
?.Kind() is not SyntaxKind.CollectionExpression and not SyntaxKind.AttributeList &&
395
if (currentToken.
Parent
is (kind:
409
if (previousToken.
Parent
is CastExpressionSyntax &&
416
if (previousToken.
Parent
is (kind: SyntaxKind.TypeArgumentList or SyntaxKind.TypeParameterList or SyntaxKind.FunctionPointerType))
433
currentToken.
Parent
is (kind: SyntaxKind.TypeArgumentList or SyntaxKind.TypeParameterList))
440
previousToken.
Parent
is PrefixUnaryExpressionSyntax)
447
currentToken.
Parent
is PostfixUnaryExpressionSyntax)
453
if (currentToken.IsKind(SyntaxKind.QuestionToken) && currentToken.
Parent
.IsKind(SyntaxKind.ConditionalAccessExpression))
460
currentToken.
Parent
is (kind: SyntaxKind.NullableType or SyntaxKind.ClassConstraint))
467
previousToken.
Parent
?.IsParentKind(SyntaxKind.ArrayType) == true)
474
currentToken.
Parent
.IsKind(SyntaxKind.SuppressNullableWarningExpression))
480
if (currentToken.Kind() == SyntaxKind.AsteriskToken && currentToken.
Parent
is PointerTypeSyntax)
486
if (previousToken.Kind() == SyntaxKind.AsteriskToken && previousToken.
Parent
is PrefixUnaryExpressionSyntax)
521
&& !previousToken.
Parent
.IsKind(SyntaxKind.SuppressNullableWarningExpression))
527
if (previousToken.Kind() == SyntaxKind.TildeToken && (previousToken.
Parent
is PrefixUnaryExpressionSyntax || previousToken.
Parent
is DestructorDeclarationSyntax))
534
previousToken.
Parent
is PrefixUnaryExpressionSyntax)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Indentation\CSharpSmartTokenFormatter.cs (4)
74
endToken.
Parent
.IsKind(SyntaxKind.Block) &&
75
endToken.
Parent
.Parent?.Kind() is SyntaxKind.TryStatement or SyntaxKind.DoStatement;
96
(token.
Parent
.IsInitializerForArrayOrCollectionCreationExpression() ||
97
token.
Parent
is AnonymousObjectCreationExpressionSyntax))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpSyntaxFacts.cs (16)
102
(token.
Parent
is PrefixUnaryExpressionSyntax || token.
Parent
is PostfixUnaryExpressionSyntax || token.
Parent
is OperatorDeclarationSyntax)) ||
103
(SyntaxFacts.IsBinaryExpression(kind) && (token.
Parent
is BinaryExpressionSyntax or OperatorDeclarationSyntax or RelationalPatternSyntax)) ||
104
(SyntaxFacts.IsAssignmentExpressionOperatorToken(kind) && token.
Parent
is AssignmentExpressionSyntax);
272
=> token.
Parent
is ConstructorInitializerSyntax(SyntaxKind.ThisConstructorInitializer) constructorInit &&
276
=> token.
Parent
is ConstructorInitializerSyntax(SyntaxKind.BaseConstructorInitializer) constructorInit &&
291
return token.
Parent
is QueryClauseSyntax;
295
return token.
Parent
is SelectOrGroupClauseSyntax;
298
return token.
Parent
is OrderingSyntax;
300
return token.
Parent
is (kind: SyntaxKind.JoinIntoClause or SyntaxKind.QueryContinuation);
521
if (token.Kind() == SyntaxKind.CommaToken && token.
Parent
.IsKind(SyntaxKind.OrderByClause))
527
&& token.
Parent
.IsKind(SyntaxKind.CollectionExpression))
715
var node = root.FindToken(position).
Parent
;
998
var node = token.
Parent
;
1415
if (token.Kind() == SyntaxKind.OverrideKeyword && token.
Parent
is MemberDeclarationSyntax member)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\FormattingRangeHelper.cs (15)
42
var (_, closeBrace) = previousToken.
Parent
.GetBracePair();
90
var parent = endToken.
Parent
;
114
var parent = endToken.
Parent
;
171
var parent = endToken.
Parent
;
271
var parent = endToken.
Parent
;
338
RoslynDebug.AssertNotNull(previousToken.
Parent
?.Parent);
339
var labelNode = previousToken.
Parent
.Parent;
349
(previousToken.
Parent
.IsKind(SyntaxKind.Block) ||
350
previousToken.
Parent
is TypeDeclarationSyntax ||
351
previousToken.
Parent
is NamespaceDeclarationSyntax);
410
token.
Parent
is SwitchLabelSyntax switchLabel &&
436
RoslynDebug.AssertNotNull(token.
Parent
);
440
if (token.
Parent
.Kind() is SyntaxKind.Block or
443
return token.
Parent
.Parent as MemberDeclarationSyntax;
447
return token.
Parent
.FirstAncestorOrSelf<MemberDeclarationSyntax>();
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpCodeGenerationHelpers.cs (1)
206
return contextTree?.GetRoot(cancellationToken).FindToken(contextLocation!.SourceSpan.Start).
Parent
;
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\CSharpSyntaxContext.cs (5)
230
targetToken.
Parent
.IsKind(SyntaxKind.DestructorDeclaration) &&
231
targetToken.
Parent
.Parent is (kind: SyntaxKind.ClassDeclaration or SyntaxKind.RecordDeclaration);
240
var isOnArgumentListBracketOrComma = targetToken.
Parent
is (kind: SyntaxKind.ArgumentList or SyntaxKind.AttributeArgumentList or SyntaxKind.ArrayRankSpecifier);
297
isRightAfterUsingOrImportDirective: targetToken.
Parent
is UsingDirectiveSyntax usingDirective && usingDirective?.GetLastToken() == targetToken,
504
return targetToken.
Parent
switch
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTokenExtensions.cs (47)
41
if (token is { RawKind: (int)SyntaxKind.StaticKeyword,
Parent
: UsingDirectiveSyntax })
48
token.GetPreviousToken() is { RawKind: (int)SyntaxKind.StaticKeyword,
Parent
: UsingDirectiveSyntax })
115
case SyntaxKind.OpenBraceToken when token.
Parent
.IsKind(SyntaxKind.Block):
124
if (token.
Parent
.IsKind(SyntaxKind.Block))
126
if (token.
Parent
.Parent is StatementSyntax)
135
if (token.
Parent
.Parent.Kind() is not SyntaxKind.TryStatement and not SyntaxKind.DoStatement)
138
else if (token.
Parent
.Parent?.Kind()
148
if (token.
Parent
.IsKind(SyntaxKind.SwitchStatement))
156
return token.
Parent
is (kind: SyntaxKind.CaseSwitchLabel or SyntaxKind.DefaultSwitchLabel or SyntaxKind.CasePatternSwitchLabel or SyntaxKind.LabeledStatement);
158
case SyntaxKind.DoKeyword when token.
Parent
.IsKind(SyntaxKind.DoStatement):
162
var parent = token.
Parent
;
174
return token.
Parent
.IsKind(SyntaxKind.ElseClause);
177
if (token.
Parent
.IsKind(SyntaxKind.AttributeList))
180
var container = token.
Parent
.Parent;
225
if (token.
Parent
is FileScopedNamespaceDeclarationSyntax namespaceDeclaration && namespaceDeclaration.SemicolonToken == token)
259
if (token.
Parent
.IsKind(SyntaxKind.AttributeList))
261
var container = token.
Parent
.Parent;
274
if (token.
Parent
.IsKind(SyntaxKind.CastExpression))
279
if (token.
Parent
is ParenthesizedExpressionSyntax parenExpr)
334
targetToken.
Parent
.IsKind(SyntaxKind.ParenthesizedExpression))
340
if (targetToken.
Parent
is PrefixUnaryExpressionSyntax prefix)
347
if (targetToken.
Parent
is BinaryExpressionSyntax binary)
396
targetToken.
Parent
.IsKind(SyntaxKind.SwitchStatement))
403
if (targetToken.
Parent
is (kind: SyntaxKind.CaseSwitchLabel or SyntaxKind.DefaultSwitchLabel or SyntaxKind.CasePatternSwitchLabel))
431
targetToken.
Parent
is (kind: SyntaxKind.CrefBracketedParameterList or SyntaxKind.CrefParameterList);
450
targetToken.
Parent
.IsKind(SyntaxKind.NameColon) &&
451
targetToken.
Parent
.Parent.IsKind(SyntaxKind.Argument) &&
452
targetToken.
Parent
.Parent.Parent.IsKind(SyntaxKind.ArgumentList))
454
var owner = targetToken.
Parent
.Parent.Parent.Parent;
468
if (targetToken.
Parent
.IsKind(SyntaxKind.ArgumentList))
470
if (targetToken.
Parent
?.Parent?.Kind()
481
if (targetToken.
Parent
.IsParentKind(SyntaxKind.InvocationExpression) && !targetToken.IsInvocationOfVarExpression())
582
targetToken.
Parent
.IsKind(SyntaxKind.AccessorList))
590
targetToken.
Parent
.IsKind(SyntaxKind.Block) &&
591
targetToken.
Parent
.Parent is AccessorDeclarationSyntax)
598
targetToken.
Parent
is AccessorDeclarationSyntax)
605
targetToken.
Parent
.IsKind(SyntaxKind.AttributeList) &&
606
targetToken.
Parent
.Parent is AccessorDeclarationSyntax)
638
IsGenericInterfaceOrDelegateTypeParameterList(targetToken.
Parent
!))
644
IsGenericInterfaceOrDelegateTypeParameterList(targetToken.
Parent
!))
650
targetToken.
Parent
.IsKind(SyntaxKind.AttributeList) &&
651
targetToken.
Parent
.Parent.IsKind(SyntaxKind.TypeParameter) &&
652
IsGenericInterfaceOrDelegateTypeParameterList(targetToken.
Parent
.Parent.Parent))
662
if (token.Kind() == SyntaxKind.CommaToken && token.
Parent
is BaseArgumentListSyntax)
664
var argumentList = (BaseArgumentListSyntax)token.
Parent
;
688
if (token.
Parent
is not MemberAccessExpressionSyntax memberAccessExpression)
698
=> token.
Parent
is IdentifierNameSyntax typedParent &&
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTreeExtensions.cs (148)
89
var parent = token.
Parent
;
167
if (token.
Parent
is BaseTypeDeclarationSyntax)
178
if (token.
Parent
is MemberDeclarationSyntax &&
179
token.
Parent
.Parent is BaseTypeDeclarationSyntax)
195
if (token.
Parent
is BaseTypeDeclarationSyntax &&
196
token.
Parent
.Parent is BaseTypeDeclarationSyntax)
201
else if (token.
Parent
is AccessorListSyntax)
207
token.
Parent
.IsKind(SyntaxKind.Block) &&
208
token.
Parent
.Parent is MemberDeclarationSyntax)
220
token.
Parent
.IsKind(SyntaxKind.AttributeList))
228
var container = token.
Parent
.Parent?.Parent;
358
if (token.Kind() == SyntaxKind.CloseBracketToken && token.
Parent
is AttributeListSyntax)
359
return syntaxTree.IsLocalFunctionDeclarationContext(token.
Parent
.SpanStart, validModifiers, cancellationToken);
439
if (token.IsKind(SyntaxKind.OpenBraceToken) && token.
Parent
is NamespaceDeclarationSyntax or TypeDeclarationSyntax)
456
if (token.
Parent
is (kind: SyntaxKind.ExternAliasDirective or SyntaxKind.UsingDirective))
460
else if (token.
Parent
is MemberDeclarationSyntax)
478
if (token.
Parent
is BaseTypeDeclarationSyntax)
482
else if (token.
Parent
.IsKind(SyntaxKind.NamespaceDeclaration))
486
else if (token.
Parent
is AccessorListSyntax)
491
token.
Parent
.IsKind(SyntaxKind.Block) &&
492
token.
Parent
.Parent is MemberDeclarationSyntax)
507
token.
Parent
.IsKind(SyntaxKind.AttributeList))
510
if (token.
Parent
.IsParentKind(SyntaxKind.CompilationUnit))
519
var container = token.
Parent
?.Parent?.Parent;
877
token.
Parent
is TypeParameterConstraintClauseSyntax constraintClause)
895
if (token.IsKind(SyntaxKind.OpenParenToken) && token.
Parent
.IsKind(SyntaxKind.TypeOfExpression))
907
if (token.IsKind(SyntaxKind.OpenParenToken) && token.
Parent
.IsKind(SyntaxKind.DefaultExpression))
920
if (token.IsKind(SyntaxKind.OpenParenToken) && token.
Parent
.IsKind(SyntaxKind.SizeOfExpression))
941
return token.
Parent
.IsKind(SyntaxKind.FunctionPointerParameterList);
947
{
Parent
.RawKind: (int)SyntaxKind.FunctionPointerParameter } => true,
949
{
Parent
: TypeSyntax { Parent.RawKind: (int)SyntaxKind.FunctionPointerParameter } } => true,
955
=> targetToken.
Parent
.IsKind(SyntaxKind.TypeParameterConstraintClause) &&
977
if (token.
Parent
is TypeArgumentListSyntax)
988
if (nameToken.
Parent
is not NameSyntax name)
1064
token.
Parent
is ParameterListSyntax parameterList1 &&
1071
if (token.IsKind(SyntaxKind.LessThanToken) && token.
Parent
.IsKind(SyntaxKind.FunctionPointerParameterList))
1078
token.
Parent
is ParameterListSyntax parameterList2 &&
1088
token.
Parent
is FunctionPointerParameterListSyntax funcPtrParamList)
1097
token.
Parent
.IsKind(SyntaxKind.AttributeList) &&
1098
token.
Parent
.Parent is ParameterSyntax parameter3 &&
1109
parameter4 = token.
Parent
as ParameterSyntax;
1112
else if (token.IsKind(SyntaxKind.IdentifierToken) && token.Text == "scoped" && token.
Parent
is IdentifierNameSyntax scopedIdentifierName)
1158
return token.
Parent
.IsKind(SyntaxKind.BracketedParameterList);
1171
token.
Parent
.IsKind(SyntaxKind.DelegateDeclaration))
1203
token.
Parent
is (kind: SyntaxKind.ParameterList or SyntaxKind.BracketedParameterList))
1213
var method = tokenOnLeftOfPosition.
Parent
.GetAncestorOrThis<MethodDeclarationSyntax>();
1230
if (token.
Parent
.IsKind(SyntaxKind.ParameterList) &&
1231
token.
Parent
.IsParentKind(SyntaxKind.ParenthesizedLambdaExpression))
1247
if (token.
Parent
is (kind: SyntaxKind.ParenthesizedExpression or SyntaxKind.TupleExpression or SyntaxKind.CastExpression))
1263
parent = token.
Parent
;
1265
else if (token.IsKind(SyntaxKind.ScopedKeyword) && token.
Parent
.IsKind(SyntaxKind.Parameter))
1267
parent = token.
Parent
.Parent;
1269
else if (token.IsKind(SyntaxKind.IdentifierToken) && token.Text == "scoped" && token.
Parent
is IdentifierNameSyntax scopedIdentifierName && scopedIdentifierName.Parent.IsKind(SyntaxKind.Parameter))
1322
if (leftToken.
Parent
is (kind:
1327
var possibleCommaOrParen = FindTokenOnLeftOfNode(leftToken.
Parent
);
1339
var possibleCommaOrParen = FindTokenOnLeftOfNode(leftToken.
Parent
!);
1349
leftToken.
Parent
.IsKind(SyntaxKind.IdentifierName) &&
1350
leftToken.
Parent
.Parent is (kind: SyntaxKind.QualifiedName or SyntaxKind.SimpleMemberAccessExpression))
1352
var possibleCommaOrParen = FindTokenOnLeftOfNode(leftToken.
Parent
.Parent);
1368
if (leftToken.
Parent
is ParenthesizedExpressionSyntax parenthesizedExpression)
1376
if (leftToken.
Parent
.IsKind(SyntaxKind.ParenthesizedPattern))
1391
if (leftToken.Kind() is SyntaxKind.OpenBraceToken or SyntaxKind.CommaToken && leftToken.
Parent
.IsKind(SyntaxKind.SwitchExpression))
1398
if (leftToken.Kind() is SyntaxKind.OpenParenToken or SyntaxKind.CommaToken && leftToken.
Parent
.IsKind(SyntaxKind.PositionalPatternClause))
1405
if (leftToken.Kind() is SyntaxKind.OpenBracketToken or SyntaxKind.CommaToken && leftToken.
Parent
.IsKind(SyntaxKind.ListPattern))
1412
if (leftToken.IsKind(SyntaxKind.DotDotToken) && leftToken.
Parent
.IsKind(SyntaxKind.SlicePattern))
1420
if (leftToken.IsKind(SyntaxKind.ColonToken) && leftToken.
Parent
is (kind: SyntaxKind.NameColon or SyntaxKind.ExpressionColon) &&
1421
leftToken.
Parent
.IsParentKind(SyntaxKind.Subpattern))
1433
return leftToken.
Parent
is BinaryPatternSyntax ||
1434
leftToken.
Parent
is SingleVariableDesignationSyntax { Parent: DeclarationPatternSyntax };
1438
if (leftToken.IsKind(SyntaxKind.NotKeyword) && leftToken.
Parent
.IsKind(SyntaxKind.NotPattern))
1448
leftToken.
Parent
.IsKind(SyntaxKind.RelationalPattern))
1497
originalLeftToken.
Parent
== variableDesignationSyntax)
1543
SyntaxNode? node = leftToken.
Parent
as ExpressionSyntax;
1573
if (possibleCommaOrParen.
Parent
is (kind:
1583
if (possibleCommaOrParen.
Parent
.IsKind(SyntaxKind.ParameterList) &&
1584
possibleCommaOrParen.
Parent
?.Parent is ParenthesizedLambdaExpressionSyntax parenthesizedLambda)
1692
leftToken.
Parent
.IsKind(SyntaxKind.ArgumentList) &&
1693
leftToken.
Parent
?.Parent is InvocationExpressionSyntax invocation)
1786
token.
Parent
.IsKind(SyntaxKind.LocalDeclarationStatement))
1797
var parent = token.
Parent
;
1818
token.
Parent
is ArgumentSyntax argument &&
1839
token.
Parent
is LocalDeclarationStatementSyntax)
1865
if (token.IsKind(SyntaxKind.IdentifierToken) && token.Text == "scoped" && token.
Parent
.IsKind(SyntaxKind.IdentifierName) && token.
Parent
.Parent is VariableDeclarationSyntax or ExpressionStatementSyntax or IncompleteMemberSyntax)
1871
if (token.IsKind(SyntaxKind.ScopedKeyword) && token.
Parent
is IncompleteMemberSyntax)
2049
token.
Parent
.IsKind(SyntaxKind.CastExpression))
2069
token.
Parent
.IsKind(SyntaxKind.GotoCaseStatement))
2075
token.
Parent
is EqualsValueClauseSyntax equalsValue)
2110
if (token.
Parent
.IsKind(SyntaxKind.AttributeArgumentList) &&
2118
token.
Parent
.IsKind(SyntaxKind.NameColon) &&
2119
token.
Parent
.IsParentKind(SyntaxKind.AttributeArgument))
2126
token.
Parent
.IsKind(SyntaxKind.NameEquals) &&
2127
token.
Parent
.IsParentKind(SyntaxKind.AttributeArgument))
2208
if (token.
Parent
.IsKind(SyntaxKind.NameEquals) &&
2209
token.
Parent
.IsParentKind(SyntaxKind.UsingDirective))
2250
if (token.
Parent
.IsKind(SyntaxKind.ParenthesizedExpression))
2259
if (token.
Parent
is CastExpressionSyntax castExpression &&
2270
if (token.
Parent
is PrefixUnaryExpressionSyntax prefix)
2283
if (token.
Parent
is AwaitExpressionSyntax awaitExpression)
2307
if (token.
Parent
is BinaryExpressionSyntax binary)
2344
previousToken.
Parent
?.Kind() is SyntaxKind.PointerType or SyntaxKind.NullableType)
2346
var type = previousToken.
Parent
as TypeSyntax;
2367
token.
Parent
.IsKind(SyntaxKind.ArrayRankSpecifier))
2375
token.
Parent
.IsKind(SyntaxKind.RangeExpression) &&
2383
token.
Parent
is ConditionalExpressionSyntax conditionalExpression)
2392
token.
Parent
.IsKind(SyntaxKind.ConditionalExpression))
2402
if (token.
Parent
is (kind: SyntaxKind.TypeOfExpression or SyntaxKind.DefaultExpression or SyntaxKind.SizeOfExpression))
2423
token.
Parent
is (kind: SyntaxKind.ArgumentList or SyntaxKind.BracketedArgumentList or SyntaxKind.TupleExpression))
2434
if (token.
Parent
.IsKind(SyntaxKind.AttributeArgumentList))
2447
if (token.
Parent
.IsKind(SyntaxKind.Argument))
2451
else if (token.
Parent
.IsKind(SyntaxKind.RefExpression))
2455
if (token.
Parent
.IsParentKind(SyntaxKind.ParenthesizedExpression))
2466
token.
Parent
.IsKind(SyntaxKind.NameColon) &&
2467
token.
Parent
.IsParentKind(SyntaxKind.Argument))
2482
if (token.
Parent
is InitializerExpressionSyntax)
2486
if (token.
Parent
.IsKind(SyntaxKind.ObjectInitializerExpression) && token.IsKind(SyntaxKind.OpenBraceToken))
2501
token.
Parent
?.Parent is ObjectCreationExpressionSyntax objectCreation)
2517
token.
Parent
is ForStatementSyntax forStatement)
2528
token.
Parent
is ForStatementSyntax forStatement2 &&
2537
token.
Parent
.IsKind(SyntaxKind.ForStatement))
2548
if (token.
Parent
is (kind:
2561
token.
Parent
.IsKind(SyntaxKind.JoinClause))
2568
token.
Parent
.IsKind(SyntaxKind.WhereClause))
2576
token.
Parent
.IsKind(SyntaxKind.OrderByClause))
2583
token.
Parent
.IsKind(SyntaxKind.SelectClause))
2591
token.
Parent
.IsKind(SyntaxKind.GroupClause))
2624
if (token.IsKind(SyntaxKind.OpenParenToken) && token.
Parent
.IsKind(SyntaxKind.UsingStatement))
2672
if (token.IsKind(SyntaxKind.WhenKeyword) && token.
Parent
.IsKind(SyntaxKind.WhenClause))
2690
token.
Parent
.IsKind(SyntaxKind.AnonymousObjectCreationExpression))
2699
token.
Parent
.IsKind(SyntaxKind.ListPattern))
2708
token.
Parent
.IsKind(SyntaxKind.CollectionExpression))
2717
token.
Parent
.IsKind(SyntaxKind.SpreadElement))
2730
return token.
Parent
is InterpolationSyntax interpolation
2738
=> token.
Parent
?.Parent is InvocationExpressionSyntax invocation &&
2865
token.
Parent
.IsKind(SyntaxKind.IdentifierName) &&
2866
token.
Parent
.Parent is (kind: SyntaxKind.ObjectInitializerExpression or SyntaxKind.CollectionInitializerExpression))
2873
token.
Parent
.IsKind(SyntaxKind.IdentifierName))
2875
if (token.
Parent
.Parent is ArgumentSyntax { RefOrOutKeyword.RawKind: (int)SyntaxKind.OutKeyword })
2980
token.
Parent
.IsKind(SyntaxKind.CatchDeclaration))
2996
targetToken.
Parent
.IsKind(SyntaxKind.BaseList) &&
2997
targetToken.
Parent
.IsParentKind(SyntaxKind.EnumDeclaration);
3012
if (token.
Parent
.IsKind(SyntaxKind.SimpleMemberAccessExpression))
3014
var memberAccess = (MemberAccessExpressionSyntax)token.
Parent
;
3017
else if (token.
Parent
is QualifiedNameSyntax qualifiedName &&
3018
token.
Parent
?.Parent is BinaryExpressionSyntax(SyntaxKind.IsExpression) binaryExpression &&
3024
else if (token.
Parent
is QualifiedNameSyntax qualifiedName1 &&
3025
token.
Parent
?.Parent is DeclarationPatternSyntax declarationExpression &&
3058
targetToken.
Parent
is FunctionPointerTypeSyntax functionPointerType &&
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ITypeSymbolExtensions.cs (1)
145
var namespaceUsings = root.FindToken(position).
Parent
!.GetAncestors<BaseNamespaceDeclarationSyntax>().SelectMany(n => n.Usings);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\SyntaxTreeExtensions.cs (1)
172
return token.
Parent
is GenericNameSyntax genericName && genericName.TypeArgumentList != null &&
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Indentation\CSharpIndentationService.Indenter.cs (14)
124
|| token is { RawKind: (int)SyntaxKind.CloseBraceToken,
Parent
: InterpolationSyntax })
179
(token.IsKind(SyntaxKind.CloseBraceToken) && token.
Parent
.IsKind(SyntaxKind.Interpolation)))
186
if (token.
Parent
is LabeledStatementSyntax || token.IsLastTokenInLabelStatement())
223
token.
Parent
!= null &&
224
(token.
Parent
.Parent is StatementSyntax || token.
Parent
.Parent is ElseClauseSyntax));
226
var embeddedStatementOwner = token.
Parent
.Parent;
251
if (token.
Parent
.IsKind(SyntaxKind.AccessorList) &&
252
token.
Parent
.Parent.IsKind(SyntaxKind.PropertyDeclaration))
270
var nonTerminalNode = token.
Parent
;
283
var nonTerminalNode = token.
Parent
;
307
if (token.
Parent
.IsKind(SyntaxKind.ArgumentList))
309
return GetDefaultIndentationFromToken(indenter, token.
Parent
.GetFirstToken(includeZeroWidth: true));
323
=> token.
Parent
switch
Microsoft.CodeAnalysis.EditorFeatures (2)
DocumentationComments\AbstractXmlTagCompletionCommandHandler.cs (2)
177
while (token.
Parent
is TXmlTextSyntax)
185
if (token.
Parent
is TXmlElementEndTagSyntax endTag &&
Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities (5)
Completion\AbstractCompletionProviderTests.cs (1)
97
var node = (await document.GetSyntaxRootAsync()).FindToken(position).
Parent
;
QuickInfo\AbstractSemanticQuickInfoSourceTests.cs (1)
156
var node = (await document.GetSyntaxRootAsync()).FindToken(position).
Parent
;
SignatureHelp\AbstractSignatureHelpProviderTests.cs (1)
121
var node = (await document.GetSyntaxRootAsync()).FindToken(position).
Parent
;
Structure\AbstractSyntaxNodeStructureProviderTests.cs (1)
27
var node = token.
Parent
.FirstAncestorOrSelf<TSyntaxNode>();
TypeInferrer\TypeInferrerTestBase.cs (1)
29
var node = (await document.GetSyntaxRootAsync()).FindToken(position).
Parent
;
Microsoft.CodeAnalysis.EditorFeatures.UnitTests (2)
CodeGeneration\CodeGenerationTests.cs (2)
909
var symbol = token.
Parent
.AncestorsAndSelf()
920
return token.
Parent
.AncestorsAndSelf().OfType<T>().FirstOrDefault(t => !fullSpanCoverage || t.Span.End >= destSpan.End);
Microsoft.CodeAnalysis.EditorFeatures.Wpf (1)
Peek\PeekHelpers.cs (1)
51
var node = root.FindToken(identifierLocation.SourceSpan.Start).
Parent
;
Microsoft.CodeAnalysis.EditorFeatures2.UnitTests (1)
Diagnostics\AbstractCrossLanguageUserDiagnosticTest.vb (1)
238
Return doc.GetSyntaxRootAsync().Result.FindToken(position).
Parent
Microsoft.CodeAnalysis.Features (52)
AddImport\References\Reference.cs (1)
98
var newContextNode = newRoot.GetAnnotatedTokens(annotation).First().
Parent
;
BraceCompletion\AbstractBraceCompletionService.cs (2)
145
=> token.
Parent
== null || syntaxFacts.IsSkippedTokensTrivia(token.
Parent
);
BraceMatching\AbstractBraceMatcher.cs (1)
29
var parent = token.
Parent
;
CodeLens\CodeLensReferencesService.cs (3)
174
var node = token.
Parent
;
183
node = parentTrivia.Token.
Parent
;
197
node ??= token.
Parent
;
Completion\Providers\AbstractInternalsVisibleToCompletionProvider.cs (1)
91
var node = token.
Parent
;
DocumentHighlighting\AbstractDocumentHighlightsService.cs (2)
317
return syntaxFacts.IsGenericName(token.
Parent
) || syntaxFacts.IsIndexerMemberCref(token.
Parent
)
EditAndContinue\AbstractEditAndContinueAnalyzer.cs (5)
840
var oldEnclosingLambdaBody = FindEnclosingLambdaBody(oldBody.EncompassingAncestor, oldBody.EncompassingAncestor.FindToken(adjustedOldStatementStart).
Parent
!);
1371
newStatementSyntax = newEncompassingAncestor.FindToken(newStatementSyntaxSpan.Start).
Parent
;
1577
var node = root.FindToken(unmappedActiveStatementSpan.Start).
Parent
;
2103
Contract.ThrowIfNull(oldToken.
Parent
);
2104
Contract.ThrowIfNull(newToken.
Parent
);
EmbeddedLanguages\AbstractLanguageDetector.cs (6)
70
if (syntaxFacts.IsLiteralExpression(token.
Parent
) &&
71
syntaxFacts.IsArgument(token.
Parent
.Parent))
73
options = GetOptionsFromSiblingArgument(token.
Parent
.Parent, semanticModel, cancellationToken) ??
102
return syntaxFacts.IsLiteralExpression(token.
Parent
) &&
103
syntaxFacts.IsArgument(token.
Parent
.Parent) &&
104
IsArgumentToWellKnownAPI(token, token.
Parent
.Parent, semanticModel, cancellationToken, out options);
EmbeddedLanguages\DateAndTime\LanguageServices\DateAndTimeLanguageDetector.cs (3)
61
var interpolationFormatClause = token.
Parent
;
134
=> syntaxFacts.IsLiteralExpression(token.
Parent
) &&
135
syntaxFacts.IsArgument(token.
Parent
!.Parent);
EmbeddedLanguages\EmbeddedLanguageDetector.cs (6)
96
if (syntaxFacts.IsLiteralExpression(token.
Parent
) &&
97
syntaxFacts.IsBinaryExpression(token.
Parent
.Parent) &&
98
syntaxFacts.SyntaxKinds.AddExpression == token.
Parent
.Parent.RawKind)
103
for (var node = token.
Parent
; node != null; node = node.Parent)
166
var interpolationFormatClause = token.
Parent
;
287
if (!syntaxFacts.IsLiteralExpression(token.
Parent
))
ExtractMethod\MethodExtractor.Analyzer.cs (2)
629
return tokens.Any(t => semanticFacts.IsWrittenTo(model, t.
Parent
, CancellationToken.None));
926
if (tokens.All(t => !semanticFacts.IsWrittenTo(semanticModel, t.
Parent
, CancellationToken)))
ExtractMethod\MethodExtractor.Analyzer.SymbolMapBuilder.cs (1)
65
_service.IsNameOfNamedArgument(token.
Parent
))
ExtractMethod\MethodExtractor.VariableSymbol.cs (1)
281
var declStatement = identifier.
Parent
.FirstAncestorOrSelf<T>();
GenerateEqualsAndGetHashCodeFromMembers\FormatLargeBinaryExpressionRule.cs (1)
27
if (_syntaxFacts.IsLogicalAndExpression(previousToken.
Parent
))
MoveToNamespace\AbstractMoveToNamespaceService.cs (1)
78
var node = token.
Parent
;
QuickInfo\CommonSemanticQuickInfoProvider.cs (2)
168
if (syntaxFactsService.IsNameOfAttribute(token.
Parent
!))
227
var typeInfo = semanticModel.GetTypeInfo(token.
Parent
!, cancellationToken);
ReplaceDocCommentTextWithTag\AbstractReplaceDocCommentTextWithTagCodeRefactoringProvider.cs (1)
131
for (var node = token.
Parent
; node != null; node = node.Parent)
ReplaceMethodWithProperty\ReplaceMethodWithPropertyCodeRefactoringProvider.cs (6)
251
if (nameToken.
Parent
== null)
260
editor.ReplaceNode(nameToken.
Parent
, nameToken.
Parent
.WithAdditionalAnnotations(
291
if (nameToken.
Parent
== null)
300
editor.ReplaceNode(nameToken.
Parent
, nameToken.
Parent
.WithAdditionalAnnotations(
ReplacePropertyWithMethods\ReplacePropertyWithMethodsCodeRefactoringProvider.cs (1)
264
var parent = nameToken.
Parent
;
Snippets\SnippetProviders\AbstractInlineStatementSnippetProvider.cs (1)
99
var parentNode = targetToken.
Parent
;
SpellCheck\AbstractSpellCheckSpanService.cs (2)
102
token.
Parent
?.RawKind == _syntaxKinds.InterpolatedStringText)
104
AddStringSpans(token, canContainEscapes: !_syntaxFacts.IsVerbatimInterpolatedStringExpression(token.
Parent
.Parent));
SplitOrMergeIfStatements\AbstractSplitIfStatementCodeRefactoringProvider.cs (2)
104
syntaxFacts.GetPartsOfBinaryExpression(token.
Parent
, out var parentLeft, out _, out var parentRight);
107
var right = rootExpression.ReplaceNode(token.
Parent
, parentRight);
src\Analyzers\Core\Analyzers\NewLines\ConsecutiveStatementPlacement\AbstractConsecutiveStatementPlacementDiagnosticAnalyzer.cs (1)
85
var nextTokenContainingStatement = nextToken.
Parent
?.FirstAncestorOrSelf<TExecutableStatementSyntax>();
Microsoft.CodeAnalysis.Features.Test.Utilities (1)
EditAndContinue\EditAndContinueTestVerifier.cs (1)
386
var result = root.FindToken(span.Start).
Parent
!;
Microsoft.CodeAnalysis.Test.Utilities (8)
Diagnostics\DiagnosticDescription.cs (2)
285
if (!_syntaxPredicate(d._location.SourceTree.GetRoot().FindToken(_location.SourceSpan.Start, true).
Parent
))
298
if (!d._syntaxPredicate(_location.SourceTree.GetRoot().FindToken(_location.SourceSpan.Start, true).
Parent
))
Syntax\NodeHelpers.cs (6)
48
return n.GetKind().Contains("Identifier") && n.
Parent
!= null && n.
Parent
.GetKind().Contains("Name");
54
return kind.EndsWith("Keyword", StringComparison.Ordinal) || (kind.Contains("Identifier") && n.
Parent
!= null && !n.
Parent
.GetKind().Contains("Name"));
95
SyntaxNode retVal = node.
Parent
;
120
SyntaxNode retVal = node.Token.
Parent
;
Microsoft.CodeAnalysis.UnitTests (3)
Diagnostics\SuppressMessageTargetSymbolResolverTests.cs (2)
1398
Assert.NotNull(token.
Parent
);
1401
var q = from node in token.
Parent
.AncestorsAndSelf()
Symbols\DocumentationCommentIdTests.cs (1)
179
var node = token.
Parent
;
Microsoft.CodeAnalysis.VisualBasic (69)
Binding\Binder_AnonymousTypes.vb (1)
168
fieldNode = DirectCast(fieldNameToken.
Parent
, VisualBasicSyntaxNode)
Binding\Binder_Query.vb (1)
2156
Debug.Assert(identifier.
Parent
Is rangeVar.Syntax)
Binding\Binder_Utils.vb (1)
1278
Dim containingSyntax = modifierToken.
Parent
Binding\BinderFactory.vb (1)
455
Dim parent = DirectCast(token.
Parent
, VisualBasicSyntaxNode)
Binding\MemberSemanticModel.vb (2)
1274
Return GetEnclosingBinderInternal(memberBinder, binderRoot, DirectCast(trivia.Token.
Parent
, VisualBasicSyntaxNode), position)
1986
node = DirectCast(trivia.Token.
Parent
, VisualBasicSyntaxNode)
Compilation\DocumentationComments\UnprocessedDocumentationCommentFinder.vb (1)
140
Dim parent As VisualBasicSyntaxNode = DirectCast(trivia.Token.
Parent
, VisualBasicSyntaxNode)
Compilation\SemanticModel.vb (5)
625
Dim trivia As StructuredTriviaSyntax = DirectCast(token.
Parent
, VisualBasicSyntaxNode).EnclosingStructuredTrivia
626
If trivia Is Nothing OrElse Not IsInCrefOrNameAttributeInterior(DirectCast(token.
Parent
, VisualBasicSyntaxNode)) Then
644
ElseIf token.
Parent
IsNot Nothing Then
645
Debug.Assert(IsInTree(token.
Parent
))
646
Return DirectCast(token.
Parent
, VisualBasicSyntaxNode)
Symbols\Source\LocalSymbol.vb (7)
537
node = _identifierToken.
Parent
541
node = _identifierToken.
Parent
545
node = _identifierToken.
Parent
558
node = _identifierToken.
Parent
.Parent
562
node = _identifierToken.
Parent
569
node = _identifierToken.
Parent
588
Return ImmutableArray.Create(_identifierToken.
Parent
.GetReference())
Symbols\Source\RangeVariableSymbol.vb (2)
179
Return DirectCast(_identifierToken.
Parent
, VisualBasicSyntaxNode)
194
parent = DirectCast(_identifierToken.
Parent
, VisualBasicSyntaxNode)
Symbols\Source\SourceLabelSymbol.vb (1)
62
Dim parentNode = _labelName.
Parent
Symbols\Source\SourcePropertySymbol.vb (1)
243
DirectCast(identifier.
Parent
, VisualBasicSyntaxNode),
Symbols\Symbol.vb (1)
375
Dim node As VisualBasicSyntaxNode = token.
Parent
.FirstAncestorOrSelf(Of TNode)()
Syntax\StructuredTriviaSyntax.vb (1)
25
Dim parent = DirectCast(trivia.Token.
Parent
, VisualBasicSyntaxNode)
Syntax\SyntaxFactory.vb (1)
1040
Dim node = token.
Parent
Syntax\SyntaxFacts.vb (12)
803
If token.
Parent
Is Nothing Then Throw New ArgumentException("'token' must be parented by a SyntaxNode.")
806
Dim parentKind = token.
Parent
.Kind
815
Return TypeOf token.
Parent
Is BinaryExpressionSyntax
868
Return CType(token.
Parent
, MemberAccessExpressionSyntax).Expression IsNot Nothing OrElse
869
token.
Parent
.Parent.Kind = SyntaxKind.NamedFieldInitializer
889
If CType(token.
Parent
, XmlMemberAccessExpressionSyntax).Base IsNot Nothing Then
952
Return TypeOf token.
Parent
Is QueryClauseSyntax
974
Dim n = TryCast(token.
Parent
.Parent, XmlNodeSyntax)
1042
If token.
Parent
Is Nothing Then Throw New ArgumentException("'token' must be parented by a SyntaxNode.")
1045
Dim parentKind = token.
Parent
.Kind
1100
Return TypeOf token.
Parent
Is QueryClauseSyntax
1108
Dim p As VisualBasicSyntaxNode = TryCast(token.
Parent
, QueryClauseSyntax)
Syntax\SyntaxNormalizer.vb (30)
210
Dim tokenParent = trivia.Token.
Parent
304
(token.
Parent
IsNot Nothing AndAlso token.
Parent
.GetLastToken() = token)
419
If token.
Parent
Is Nothing OrElse nextToken.Kind = SyntaxKind.None Then
423
If nextToken.
Parent
.Kind = SyntaxKind.SingleLineFunctionLambdaExpression Then
433
If TypeOf (token.
Parent
) Is UnaryExpressionSyntax AndAlso
440
If TypeOf (token.
Parent
) Is BinaryExpressionSyntax OrElse
441
TypeOf (nextToken.
Parent
) Is BinaryExpressionSyntax Then
462
If (token.Kind = SyntaxKind.CommaToken AndAlso (nextToken.Kind = SyntaxKind.EmptyToken OrElse token.
Parent
.Kind = SyntaxKind.InterpolationAlignmentClause)) OrElse
470
ElseIf nextToken.Kind = SyntaxKind.DotToken AndAlso nextToken.
Parent
.Kind <> SyntaxKind.NamedFieldInitializer Then
475
If token.
Parent
.Kind = SyntaxKind.LabelStatement Then
479
ElseIf nextToken.
Parent
.Kind = SyntaxKind.InterpolationFormatClause Then
498
If SyntaxFacts.IsRelationalCaseClause(token.
Parent
.Kind()) OrElse
499
SyntaxFacts.IsRelationalCaseClause(nextToken.
Parent
.Kind()) Then
506
token.
Parent
.Kind = SyntaxKind.AttributeList) Then
521
If token.Kind = SyntaxKind.ColonToken AndAlso token.
Parent
.Kind = SyntaxKind.XmlPrefix OrElse
522
nextToken.Kind = SyntaxKind.ColonToken AndAlso nextToken.
Parent
.Kind = SyntaxKind.XmlPrefix Then
549
If token.Kind = SyntaxKind.ColonToken AndAlso token.
Parent
.Kind = SyntaxKind.AttributeTarget OrElse
550
nextToken.Kind = SyntaxKind.ColonToken AndAlso nextToken.
Parent
.Kind = SyntaxKind.AttributeTarget Then
556
(token.
Parent
.Kind = SyntaxKind.XmlAttribute OrElse
557
token.
Parent
.Kind = SyntaxKind.XmlCrefAttribute OrElse
558
token.
Parent
.Kind = SyntaxKind.XmlNameAttribute OrElse
559
token.
Parent
.Kind = SyntaxKind.XmlDeclaration)) OrElse
561
(nextToken.
Parent
.Kind = SyntaxKind.XmlAttribute OrElse
562
nextToken.
Parent
.Kind = SyntaxKind.XmlCrefAttribute OrElse
563
nextToken.
Parent
.Kind = SyntaxKind.XmlNameAttribute OrElse
564
nextToken.
Parent
.Kind = SyntaxKind.XmlDeclaration)) Then
576
If token.Kind = SyntaxKind.AtToken AndAlso token.
Parent
.Kind = SyntaxKind.XmlAttributeAccessExpression Then
592
If token.Kind = SyntaxKind.HashToken AndAlso TypeOf token.
Parent
Is DirectiveTriviaSyntax Then
597
If token.
Parent
.Kind = SyntaxKind.RegionDirectiveTrivia AndAlso
Syntax\VisualBasicSyntaxTree.vb (1)
407
Return InDocumentationComment(token.
Parent
)
Microsoft.CodeAnalysis.VisualBasic.CodeStyle (162)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Extensions\DirectiveSyntaxExtensions.vb (1)
30
node = node.ParentTrivia.Token.
Parent
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Extensions\InvocationExpressionSyntaxExtensions.vb (1)
28
lastExpressionToken.
Parent
.IsKind(SyntaxKind.ArgumentList) Then
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Extensions\ParenthesizedExpressionSyntaxExtensions.vb (9)
14
Dim query = token.
Parent
.FirstAncestorOrSelf(Of QueryExpressionSyntax)()
18
Dim invocationAtLast = token.
Parent
.FirstAncestorOrSelf(Of InvocationExpressionSyntax)()
29
Dim variableDeclarator = token.
Parent
.FirstAncestorOrSelf(Of VariableDeclaratorSyntax)()
35
Dim lambda = token.
Parent
.FirstAncestorOrSelf(Of SingleLineLambdaExpressionSyntax)()
425
Dim lastStatement = lastToken.
Parent
.GetFirstEnclosingStatement()
440
nextToken.
Parent
.IsKind(SyntaxKind.SimpleMemberAccessExpression) Then
512
nextToken.
Parent
.IsKind(SyntaxKind.SimpleMemberAccessExpression)) AndAlso
514
nextToken.
Parent
.IsKind(SyntaxKind.SelectStatement)) AndAlso
517
nextToken.
Parent
.IsKind(SyntaxKind.DictionaryAccessExpression)) Then
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Extensions\SemanticModelExtensions.vb (3)
18
Dim expression = TryCast(name.
Parent
, ExpressionSyntax)
33
Dim expression = TryCast(name.
Parent
, ExpressionSyntax)
73
Dim expression = TryCast(token.
Parent
, ExpressionSyntax)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Extensions\StatementSyntaxExtensions.vb (1)
731
Return nextToken.
Parent
.FirstAncestorOrSelf(Of StatementSyntax)()
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Extensions\SyntaxTokenExtensions.vb (5)
50
Dim expression = TryCast(token.
Parent
, ExpressionSyntax)
58
Return TypeOf token.
Parent
Is SkippedTokensTriviaSyntax
63
Return token.
Parent
.FirstAncestorOrSelf(predicate)
116
Return token.
Parent
IsNot Nothing AndAlso
117
token.
Parent
.AncestorsAndSelf().Any(Function(n) n Is node)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Extensions\SyntaxTreeExtensions.vb (2)
51
Dim current = token.
Parent
361
Dim statement = token.
Parent
.FirstAncestorOrSelf(Of StatementSyntax)()
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Services\SyntaxFacts\VisualBasicSyntaxFacts.vb (17)
118
Return (IsUnaryExpressionOperatorToken(CType(token.Kind, SyntaxKind)) AndAlso (TypeOf token.
Parent
Is UnaryExpressionSyntax OrElse TypeOf token.
Parent
Is OperatorStatementSyntax)) OrElse
119
(IsBinaryExpressionOperatorToken(CType(token.Kind, SyntaxKind)) AndAlso (TypeOf token.
Parent
Is BinaryExpressionSyntax OrElse TypeOf token.
Parent
Is OperatorStatementSyntax))
255
If TypeOf token.
Parent
Is IdentifierNameSyntax AndAlso token.HasMatchingText(SyntaxKind.NewKeyword) Then
256
Dim memberAccess = TryCast(token.
Parent
.Parent, MemberAccessExpressionSyntax)
264
If TypeOf token.
Parent
Is IdentifierNameSyntax AndAlso token.HasMatchingText(SyntaxKind.NewKeyword) Then
265
Dim memberAccess = TryCast(token.
Parent
.Parent, MemberAccessExpressionSyntax)
289
Return TypeOf token.
Parent
Is QueryClauseSyntax
291
Return (TypeOf token.
Parent
Is QueryClauseSyntax) OrElse (token.
Parent
.IsKind(SyntaxKind.GroupAggregation))
293
Return TypeOf token.
Parent
Is JoinConditionSyntax
295
Return TypeOf token.
Parent
Is OrderingSyntax
297
Return TypeOf token.
Parent
Is CollectionRangeVariableSyntax
766
Dim node = root.FindToken(position).
Parent
1083
Dim node = token.
Parent
1551
Dim parent = token.
Parent
src\Workspaces\VisualBasic\Portable\Formatting\DefaultOperationProvider.vb (19)
57
If previousToken.
Parent
Is Nothing Then
69
ElseIf lastTrivia.RawKind = SyntaxKind.LineContinuationTrivia AndAlso previousToken.
Parent
.GetAncestorsOrThis(Of SyntaxNode)().Any(Function(node As SyntaxNode) IsSingleLineIfOrElseClauseSyntax(node)) Then
80
If previousToken.Kind = SyntaxKind.GreaterThanToken AndAlso previousToken.
Parent
IsNot Nothing AndAlso TypeOf previousToken.
Parent
Is AttributeListSyntax Then
84
If previousToken.
Parent
.Parent IsNot Nothing AndAlso TypeOf previousToken.
Parent
.Parent Is ParameterSyntax Then
91
If currentToken.Kind = SyntaxKind.LessThanToken AndAlso currentToken.
Parent
IsNot Nothing AndAlso TypeOf currentToken.
Parent
Is AttributeListSyntax Then
95
currentToken.
Parent
.Parent IsNot Nothing AndAlso TypeOf currentToken.
Parent
.Parent Is ParameterSyntax Then
108
Dim xmlDeclaration = TryCast(previousToken.
Parent
, XmlDeclarationSyntax)
113
If TypeOf previousToken.
Parent
Is XmlNodeSyntax OrElse TypeOf currentToken.
Parent
Is XmlNodeSyntax Then
128
TypeOf currentToken.
Parent
Is ImportsStatementSyntax AndAlso
132
Dim currentImports = DirectCast(currentToken.
Parent
, ImportsStatementSyntax)
182
Dim xmlDeclaration = TryCast(currentToken.
Parent
, XmlDeclarationSyntax)
190
Dim startTag = TryCast(currentToken.
Parent
, XmlElementStartTagSyntax)
198
Dim emptyTag = TryCast(currentToken.
Parent
, XmlEmptyElementSyntax)
211
TypeOf previousToken.
Parent
Is LabelStatementSyntax AndAlso
src\Workspaces\VisualBasic\Portable\Formatting\FormattingHelpers.vb (55)
13
token.
Parent
.Kind = SyntaxKind.AttributeList AndAlso
14
DirectCast(token.
Parent
, AttributeListSyntax).LessThanToken.Equals(token) Then
24
token.
Parent
.Kind = SyntaxKind.AttributeList AndAlso
25
DirectCast(token.
Parent
, AttributeListSyntax).GreaterThanToken.Equals(token) Then
33
If token.
Parent
Is Nothing Then
39
token.
Parent
.Kind = SyntaxKind.XmlString AndAlso
40
(DirectCast(token.
Parent
, XmlStringSyntax).StartQuoteToken.Equals(token) OrElse
41
DirectCast(token.
Parent
, XmlStringSyntax).EndQuoteToken.Equals(token)) Then
49
If token.
Parent
Is Nothing Then
53
If token.
Parent
.Kind = SyntaxKind.XmlString AndAlso
54
Not DirectCast(token.
Parent
, XmlStringSyntax).StartQuoteToken.Equals(token) AndAlso
55
Not DirectCast(token.
Parent
, XmlStringSyntax).EndQuoteToken.Equals(token) Then
87
If token.
Parent
Is Nothing Then
93
token.
Parent
.Kind = SyntaxKind.XmlEmptyElement Then
94
Dim xmlElement = DirectCast(token.
Parent
, XmlEmptyElementSyntax)
104
token.
Parent
.Kind = SyntaxKind.XmlAttributeAccessExpression Then
105
Dim xmlMemberAccess = DirectCast(token.
Parent
, XmlMemberAccessExpressionSyntax)
115
token.
Parent
.Kind = SyntaxKind.XmlPrefix Then
116
Dim xmlElement = DirectCast(token.
Parent
, XmlPrefixSyntax)
126
token.
Parent
.Kind = SyntaxKind.XmlAttribute Then
127
Dim xmlElement = DirectCast(token.
Parent
, XmlAttributeSyntax)
137
token.
Parent
.Kind = SyntaxKind.XmlCrefAttribute Then
138
Dim xmlElement = DirectCast(token.
Parent
, XmlCrefAttributeSyntax)
148
token.
Parent
.Kind = SyntaxKind.XmlNameAttribute Then
149
Dim xmlElement = DirectCast(token.
Parent
, XmlNameAttributeSyntax)
159
token.
Parent
.Kind = SyntaxKind.XmlNamespaceImportsClause Then
160
Dim xmlElement = DirectCast(token.
Parent
, XmlNamespaceImportsClauseSyntax)
170
token.
Parent
.Kind = SyntaxKind.XmlNamespaceImportsClause Then
171
Dim xmlElement = DirectCast(token.
Parent
, XmlNamespaceImportsClauseSyntax)
181
token.
Parent
.Kind = SyntaxKind.XmlBracketedName Then
182
Dim xmlBracketedName = DirectCast(token.
Parent
, XmlBracketedNameSyntax)
192
token.
Parent
.Kind = SyntaxKind.XmlBracketedName Then
193
Dim xmlBracketedName = DirectCast(token.
Parent
, XmlBracketedNameSyntax)
201
If token.
Parent
.Parent Is Nothing Then
207
token.
Parent
.Parent.Kind = SyntaxKind.XmlElement Then
208
Dim xmlElement = DirectCast(token.
Parent
.Parent, XmlElementSyntax)
218
token.
Parent
.Parent.Kind = SyntaxKind.XmlElement Then
219
Dim xmlElement = DirectCast(token.
Parent
.Parent, XmlElementSyntax)
229
If token.Kind = SyntaxKind.GreaterThanToken AndAlso IsGreaterThanInXmlTag(token.
Parent
, token) Then
255
Return TypeOf currentToken.
Parent
Is NullableTypeSyntax OrElse
256
TypeOf currentToken.
Parent
Is ModifiedIdentifierSyntax
264
Return TypeOf previousToken.
Parent
Is AttributeTargetSyntax
273
Dim memberAccess = TryCast(token.
Parent
, MemberAccessExpressionSyntax)
278
If token.
Parent
.Parent Is Nothing Then
283
memberAccess = TryCast(token.
Parent
, MemberAccessExpressionSyntax)
292
Dim argumentList = TryCast(token.
Parent
, ArgumentListSyntax)
301
Dim binaryCondition = TryCast(token.
Parent
, BinaryConditionalExpressionSyntax)
310
Dim ternaryCondition = TryCast(token.
Parent
, TernaryConditionalExpressionSyntax)
319
Dim xmlDeclaration = TryCast(token.
Parent
, XmlDeclarationSyntax)
332
Dim memberAccess = TryCast(token.
Parent
, MemberAccessExpressionSyntax)
337
Dim xmlMemberAccess = TryCast(token.
Parent
, XmlMemberAccessExpressionSyntax)
350
Dim memberAccess = TryCast(token.
Parent
, MemberAccessExpressionSyntax)
359
Dim namedFieldInitializer = TryCast(token.
Parent
, NamedFieldInitializerSyntax)
368
If token.
Parent
.IsKind(SyntaxKind.OperatorStatement) Then
369
Return DirectCast(token.
Parent
, OperatorStatementSyntax).OperatorToken = token
src\Workspaces\VisualBasic\Portable\Formatting\Rules\AdjustSpaceFormattingRule.vb (25)
93
If TypeOf currentToken.
Parent
Is BinaryExpressionSyntax AndAlso DirectCast(currentToken.
Parent
, BinaryExpressionSyntax).Left.IsKind(SyntaxKind.XmlAttributeAccessExpression) OrElse
94
currentToken.
Parent
.IsKind(SyntaxKind.SimpleAssignmentStatement) AndAlso DirectCast(currentToken.
Parent
, AssignmentStatementSyntax).Left.IsKind(SyntaxKind.XmlAttributeAccessExpression) Then
99
If currentToken.
Parent
.IsKind(SyntaxKind.XmlDeclarationOption) Then
173
If currentToken.Kind = SyntaxKind.OpenParenToken AndAlso TypeOf currentToken.
Parent
Is ArrayRankSpecifierSyntax Then
183
If previousToken.Kind = SyntaxKind.CloseParenToken AndAlso TypeOf previousToken.
Parent
Is TypeParameterListSyntax AndAlso
184
currentToken.Kind = SyntaxKind.OpenParenToken AndAlso TypeOf currentToken.
Parent
Is ParameterListSyntax Then
196
previousToken.
Parent
.IsKind(SyntaxKind.ConditionalAccessExpression) Then
202
currentToken.
Parent
.Kind = SyntaxKind.ConditionalAccessExpression Then
210
If previousToken.Kind = SyntaxKind.ColonToken AndAlso TypeOf previousToken.
Parent
Is LabelStatementSyntax Then
223
If previousToken.Kind = SyntaxKind.DollarSignDoubleQuoteToken AndAlso previousToken.
Parent
.IsKind(SyntaxKind.InterpolatedStringExpression) Then
228
If currentToken.Kind = SyntaxKind.DoubleQuoteToken AndAlso currentToken.
Parent
.IsKind(SyntaxKind.InterpolatedStringExpression) Then
233
If (currentToken.Kind = SyntaxKind.OpenBraceToken AndAlso currentToken.
Parent
.IsKind(SyntaxKind.Interpolation)) OrElse
234
(previousToken.Kind = SyntaxKind.CloseBraceToken AndAlso previousToken.
Parent
.IsKind(SyntaxKind.Interpolation)) Then
239
If (previousToken.Kind = SyntaxKind.OpenBraceToken AndAlso previousToken.
Parent
.IsKind(SyntaxKind.Interpolation)) OrElse
240
(currentToken.Kind = SyntaxKind.CloseBraceToken AndAlso currentToken.
Parent
.IsKind(SyntaxKind.Interpolation)) Then
245
If (previousToken.Kind = SyntaxKind.CommaToken AndAlso previousToken.
Parent
.IsKind(SyntaxKind.InterpolationAlignmentClause)) OrElse
246
(currentToken.Kind = SyntaxKind.CommaToken AndAlso currentToken.
Parent
.IsKind(SyntaxKind.InterpolationAlignmentClause)) Then
251
If (previousToken.Kind = SyntaxKind.ColonToken AndAlso previousToken.
Parent
.IsKind(SyntaxKind.InterpolationFormatClause)) OrElse
252
(currentToken.Kind = SyntaxKind.ColonToken AndAlso currentToken.
Parent
.IsKind(SyntaxKind.InterpolationFormatClause)) Then
331
TypeOf previousToken.
Parent
Is UnaryExpressionSyntax Then
347
previousToken.
Parent
Is currentToken.
Parent
Then
352
Dim labelStatement = TryCast(previousToken.
Parent
, LabelStatementSyntax)
src\Workspaces\VisualBasic\Portable\Formatting\Rules\ElasticTriviaFormattingRule.vb (17)
115
currentToken.
Parent
.Kind = SyntaxKind.CollectionInitializer AndAlso
116
currentToken.
Parent
.Parent.Kind = SyntaxKind.ObjectCollectionInitializer Then
142
currentToken.
Parent
.Kind = SyntaxKind.NamedFieldInitializer Then
149
previousToken.
Parent
.Kind = SyntaxKind.CollectionInitializer AndAlso
150
previousToken.
Parent
.Parent.Kind = SyntaxKind.ObjectCollectionInitializer Then
157
previousToken.
Parent
.Kind = SyntaxKind.CollectionInitializer AndAlso
158
previousToken.
Parent
.Parent.Kind = SyntaxKind.ObjectCollectionInitializer Then
165
currentToken.
Parent
.Kind = SyntaxKind.CollectionInitializer AndAlso
166
currentToken.
Parent
.Parent.Kind = SyntaxKind.CollectionInitializer Then
172
If currentToken.
Parent
.Kind = SyntaxKind.ObjectMemberInitializer Then
178
If currentToken.
Parent
.Kind = SyntaxKind.CollectionInitializer AndAlso
179
currentToken.
Parent
.Parent.Kind = SyntaxKind.ObjectCollectionInitializer Then
186
Dim attributeNode = TryCast(previousToken.
Parent
, AttributeListSyntax)
198
TypeOf currentToken.
Parent
Is ParenthesizedExpressionSyntax Then
204
If Not TypeOf currentToken.
Parent
Is EndBlockStatementSyntax Then
215
If TypeOf previousToken.
Parent
Is XmlNodeSyntax Then
237
If Not TypeOf token.
Parent
Is NameSyntax Then
src\Workspaces\VisualBasic\Portable\Formatting\Rules\NodeBasedFormattingRule.vb (3)
200
Dim outerBlock = firstTokenOfInnerBlock.
Parent
213
(ReferenceEquals(outerBlock, firstTokenOfInnerBlock.
Parent
) OrElse
281
If TypeOf previousToken.
Parent
Is XmlElementSyntax Then
src\Workspaces\VisualBasic\Portable\Formatting\Rules\StructuredTriviaFormattingRule.vb (4)
37
If TypeOf previousToken.
Parent
Is StructuredTriviaSyntax OrElse TypeOf currentToken.
Parent
Is StructuredTriviaSyntax Then
41
If TypeOf previousToken.
Parent
Is DirectiveTriviaSyntax OrElse TypeOf currentToken.
Parent
Is DirectiveTriviaSyntax Then
Microsoft.CodeAnalysis.VisualBasic.CodeStyle.Fixes (42)
src\Analyzers\VisualBasic\CodeFixes\UseConditionalExpression\MultiLineConditionalExpressionFormattingRule.vb (1)
33
Return token.
Parent
.HasAnnotation(
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\Extensions\CallStatementSyntaxExtensions.vb (1)
15
nextToken.
Parent
.IsKind(SyntaxKind.PredefinedType)) AndAlso
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\Extensions\ContextQuery\SyntaxTokenExtensions.vb (4)
60
Dim allowsImplicitLineContinuation = token.
Parent
IsNot Nothing AndAlso
105
Return targetToken.
Parent
.IsKind(SyntaxKind.BadDirectiveTrivia)
110
targetToken.GetPreviousToken().
Parent
.IsKind(SyntaxKind.BadDirectiveTrivia)
128
Dim argumentList = TryCast(token.
Parent
, ArgumentListSyntax)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\Extensions\ContextQuery\SyntaxTreeExtensions.vb (23)
125
If targetToken.Kind = SyntaxKind.None OrElse targetToken.
Parent
Is Nothing Then
177
If token.Kind = SyntaxKind.GreaterThanToken AndAlso token.
Parent
.Kind = SyntaxKind.AttributeList Then
248
If targetToken.
Parent
.IsKind(SyntaxKind.ParameterList) AndAlso
255
If targetToken.
Parent
.IsKind(SyntaxKind.Parameter) AndAlso
322
If targetToken.
Parent
.IsKind(SyntaxKind.ArgumentList) AndAlso
323
TypeOf targetToken.
Parent
.Parent Is NewExpressionSyntax Then
325
Dim symbolInfo = semanticModel.GetSymbolInfo(DirectCast(targetToken.
Parent
.Parent, NewExpressionSyntax).Type(), cancellationToken)
443
targetToken.
Parent
.IsKind(SyntaxKind.ParameterList) AndAlso
444
TypeOf targetToken.
Parent
.Parent Is LambdaHeaderSyntax Then
450
targetToken.
Parent
.IsKind(SyntaxKind.ArgumentList, SyntaxKind.CollectionInitializer, SyntaxKind.EraseStatement) Then
470
targetToken.
Parent
.IsKind(SyntaxKind.QualifiedName) AndAlso
471
targetToken.
Parent
.Parent.IsKind(SyntaxKind.Attribute) Then
531
Dim parent = token.
Parent
549
Dim possibleTuple = token.
Parent
672
If targetToken.Kind = SyntaxKind.None OrElse targetToken.
Parent
Is Nothing Then
686
Dim ancestor = targetToken.
Parent
722
If targetToken.
Parent
.FirstAncestorOrSelf(Of AggregateClauseSyntax)() Is Nothing AndAlso
723
targetToken.
Parent
.FirstAncestorOrSelf(Of GroupByClauseSyntax)() Is Nothing AndAlso
724
targetToken.
Parent
.FirstAncestorOrSelf(Of GroupJoinClauseSyntax)() Is Nothing Then
779
Not targetToken.
Parent
.IsKind(SyntaxKind.SimpleMemberAccessExpression) Then
784
Dim memberAccess = DirectCast(targetToken.
Parent
, MemberAccessExpressionSyntax)
1080
Return tokenOnLeftOfPosition.
Parent
.IsKind(SyntaxKind.ParenthesizedExpression,
1085
tokenOnLeftOfPosition.
Parent
.IsKind(SyntaxKind.TupleExpression, SyntaxKind.TupleType)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\Extensions\ContextQuery\VisualBasicSyntaxContext.vb (5)
143
Dim asClause = TryCast(targetToken.
Parent
, AsClauseSyntax)
179
isGenericConstraintContext:=targetToken.
Parent
.IsKind(SyntaxKind.TypeParameterSingleConstraintClause, SyntaxKind.TypeParameterMultipleConstraintClause),
188
isOnArgumentListBracketOrComma:=targetToken.
Parent
.IsKind(SyntaxKind.ArgumentList),
211
Dim collectionRange = TryCast(targetToken.
Parent
, CollectionRangeVariableSyntax)
276
Return TypeOf targetToken.
Parent
Is DirectiveTriviaSyntax
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\Indentation\SpecialFormattingOperation.vb (1)
29
Dim attributeNode = TryCast(previousToken.
Parent
, AttributeListSyntax)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\Indentation\VisualBasicIndentationService.Indenter.vb (6)
159
(containingToken.IsKind(SyntaxKind.CloseBraceToken) AndAlso token.
Parent
.IsKind(SyntaxKind.Interpolation)) Then
192
If Not ContainingStatementHasDiagnostic(lastVisibleTokenOnPreviousLine.
Parent
) Then
205
Dim visibleTokenOnCurrentLineParent = visibleTokenOnCurrentLine.
Parent
313
(TypeOf token.
Parent
Is ParameterListSyntax OrElse
314
TypeOf token.
Parent
Is ArgumentListSyntax OrElse
315
TypeOf token.
Parent
Is TypeParameterListSyntax)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\Indentation\VisualBasicIndentationService.vb (1)
96
Dim startNode = token.
Parent
Microsoft.CodeAnalysis.VisualBasic.EditorFeatures (23)
AutomaticEndConstructCorrection\AutomaticEndConstructCorrector.vb (10)
107
Dim startToken = GetBeginToken(token.
Parent
)
167
If token.
Parent
Is Nothing Then
192
If BeginStatementIsInValidForm(pairToken.
Parent
) Then
200
If token.
Parent
.Parent Is Nothing Then
204
Dim beginNode = token.
Parent
.Parent.TypeSwitch(
220
Dim endBlockStatement = TryCast(token.
Parent
, EndBlockStatementSyntax)
235
If token.
Parent
.Parent Is Nothing Then
239
Return token.
Parent
.Parent.TypeSwitch(
249
Dim pairToken = GetBeginToken(token.
Parent
)
256
If BeginStatementIsInValidForm(token.
Parent
) Then
EndConstructGeneration\EndConstructStatementVisitor_LambdaHeader.vb (1)
26
Dim isNextToXmlEmbeddedExpression = tokenNextToLambda.IsKind(SyntaxKind.PercentGreaterThanToken) AndAlso tokenNextToLambda.
Parent
.IsKind(SyntaxKind.XmlEmbeddedExpression)
EndConstructGeneration\VisualBasicEndConstructGenerationService.vb (2)
306
Dim aligningWhitespace = subjectBuffer.CurrentSnapshot.GetAligningWhitespace(state.TokenToLeft.
Parent
.Span.Start)
321
Return TryCast(token.
Parent
, T)
LineCommit\CommitFormatter.vb (1)
242
Dim node = token.
Parent
Utilities\LineAdjustmentFormattingRule.vb (9)
29
If (current.
Parent
.Kind = SyntaxKind.EndSubStatement AndAlso
30
current.
Parent
.Parent.IsKind(SyntaxKind.ConstructorBlock, SyntaxKind.SubBlock)) OrElse
31
(current.
Parent
.Kind = SyntaxKind.EndFunctionStatement AndAlso
32
current.
Parent
.Parent.Kind = SyntaxKind.FunctionBlock) AndAlso
33
Not DirectCast(current.
Parent
.Parent, MethodBlockSyntax).Statements.Any() Then
40
If currentToken.Kind = SyntaxKind.LessThanToken AndAlso currentToken.
Parent
IsNot Nothing AndAlso TypeOf currentToken.
Parent
Is AttributeListSyntax AndAlso
41
previousToken.Kind = SyntaxKind.GreaterThanToken AndAlso previousToken.
Parent
IsNot Nothing AndAlso TypeOf previousToken.
Parent
Is AttributeListSyntax Then
Microsoft.CodeAnalysis.VisualBasic.Features (86)
BraceCompletion\BracketBraceCompletionService.vb (1)
73
Dim skippedToken = TryCast(token.
Parent
, SkippedTokensTriviaSyntax)
BraceCompletion\InterpolationBraceCompletionService.vb (1)
41
(token.IsKind(SyntaxKind.CloseBraceToken) AndAlso token.
Parent
.IsKind(SyntaxKind.Interpolation))
BraceCompletion\ParenthesisBraceCompletionService.vb (2)
42
Dim skippedTriviaNode = TryCast(token.
Parent
, SkippedTokensTriviaSyntax)
46
If skippedToken.Kind <> SyntaxKind.CloseParenToken OrElse Not TypeOf skippedToken.
Parent
Is BinaryConditionalExpressionSyntax Then
BraceMatching\InterpolatedStringBraceMatcher.vb (2)
33
token.
Parent
.IsKind(SyntaxKind.InterpolatedStringExpression) Then
35
Dim interpolatedString = DirectCast(token.
Parent
, InterpolatedStringExpressionSyntax)
BraceMatching\LessThanGreaterThanBraceMatcher.vb (1)
26
Return tok.
Parent
.Kind <> SyntaxKind.XmlElementStartTag
ChangeSignature\ChangeSignatureFormattingRule.vb (2)
38
(previousToken.
Parent
.IsKind(SyntaxKind.ParameterList) OrElse previousToken.
Parent
.IsKind(SyntaxKind.ArgumentList)) Then
ChangeSignature\VisualBasicChangeSignatureService.vb (3)
104
Dim matchingNode = GetMatchingNode(token.
Parent
, restrictToDeclarations)
130
If token.
Parent
.AncestorsAndSelf().Any(Function(a) a Is objectCreation.Type) Then
727
results.Add(semanticModel.GetDeclaredSymbol(cast.Identifier.
Parent
, cancellationToken))
CodeFixes\GenerateEndConstruct\GenerateEndConstructCodeFixProvider.vb (1)
216
Dim nextNode = endStatement.Parent.GetLastToken().GetNextToken().
Parent
CodeFixes\OverloadBase\OverloadBaseCodeFixProvider.vb (4)
44
If TypeOf token.
Parent
IsNot PropertyStatementSyntax AndAlso TypeOf token.
Parent
IsNot MethodStatementSyntax Then
49
context.RegisterCodeFix(New AddKeywordAction(context.Document, token.
Parent
, VBFeaturesResources.Add_Overloads, SyntaxKind.OverloadsKeyword), context.Diagnostics)
51
context.RegisterCodeFix(New AddKeywordAction(context.Document, token.
Parent
, VBFeaturesResources.Add_Shadows, SyntaxKind.ShadowsKeyword), context.Diagnostics)
CodeLens\VisualBasicDisplayInfoService.vb (1)
57
Return GetDisplayNode(structuredTriviaSyntax.ParentTrivia.Token.
Parent
)
Completion\CompletionProviders\AwaitCompletionProvider.vb (1)
69
Dim memberAccess = TryCast(dotToken.Value.
Parent
, MemberAccessExpressionSyntax)
Completion\CompletionProviders\CrefCompletionProvider.vb (5)
125
token.
Parent
?.FirstAncestorOrSelf(Of XmlCrefAttributeSyntax)() IsNot Nothing
139
If token.
Parent
.IsKind(SyntaxKind.XmlString) AndAlso token.
Parent
.IsParentKind(SyntaxKind.XmlAttribute) Then
140
Dim xmlAttribute = DirectCast(token.
Parent
.Parent, XmlAttributeSyntax)
170
Return GetQualifiedSymbols(DirectCast(token.
Parent
, QualifiedNameSyntax), token, semanticModel, cancellationToken)
Completion\CompletionProviders\ImplementsClauseCompletionProvider.vb (1)
270
Dim parent = token.
Parent
Completion\CompletionProviders\NamedParameterCompletionProvider.vb (1)
198
Dim current = token.
Parent
Completion\CompletionProviders\OverrideCompletionProvider.vb (1)
143
Return overridesToken.Kind = SyntaxKind.OverridesKeyword AndAlso IsOnStartLine(overridesToken.
Parent
.SpanStart, text, startLine)
Completion\CompletionProviders\SymbolCompletionProvider.vb (2)
95
Return token.
Parent
.Kind <> SyntaxKind.SimpleMemberAccessExpression OrElse
96
Not DirectCast(token.
Parent
, MemberAccessExpressionSyntax).Expression.IsKind(SyntaxKind.NumericLiteralExpression)
Completion\CompletionProviders\XmlDocCommentCompletionProvider.vb (5)
197
Dim endTag = TryCast(token.
Parent
, XmlElementEndTagSyntax)
250
If targetToken.IsChildToken(Function(n As XmlNameSyntax) n.LocalName) AndAlso targetToken.
Parent
Is tagNameSyntax Then
256
If targetToken.IsChildToken(Function(n As XmlNameSyntax) n.LocalName) AndAlso targetToken.
Parent
.IsParentKind(SyntaxKind.XmlAttribute) Then
262
If (targetToken.IsChildToken(Function(s As XmlStringSyntax) s.EndQuoteToken) AndAlso targetToken.
Parent
.IsParentKind(SyntaxKind.XmlAttribute)) OrElse
269
If (targetToken.IsChildToken(Function(s As XmlStringSyntax) s.StartQuoteToken) AndAlso targetToken.
Parent
.IsParentKind(SyntaxKind.XmlAttribute)) OrElse
Completion\KeywordRecommenders\Statements\FinallyKeywordRecommender.vb (1)
52
Dim parent = targetToken.
Parent
Debugging\DataTipInfoGetter.vb (2)
25
If token.
Parent
.IsKind(SyntaxKind.ModifiedIdentifier) Then
29
Dim expression = TryCast(token.
Parent
, ExpressionSyntax)
Debugging\ProximityExpressionsGetter.vb (1)
68
Dim parentEndBlock = TryCast(token.
Parent
, EndBlockStatementSyntax)
EditAndContinue\BreakpointSpans.vb (1)
59
Dim node = root.FindToken(position).
Parent
EditAndContinue\VisualBasicEditAndContinueAnalyzer.vb (2)
147
node = body.FindToken(position).
Parent
332
Return BreakpointSpans.TryGetClosestBreakpointSpan(token.
Parent
, token.SpanStart, minLength:=token.Span.Length, span)
EmbeddedLanguages\EmbeddedLanguageUtilities.vb (1)
14
Dim containingStatement = stringLiteral.
Parent
.GetAncestor(Of StatementSyntax)
ExtractMethod\VisualBasicMethodExtractor.TriviaResult.vb (2)
170
Dim singleLineIf = token.
Parent
.GetAncestor(Of SingleLineIfStatementSyntax)()
175
Dim singleLineLambda = token.
Parent
.GetAncestor(Of SingleLineLambdaExpressionSyntax)()
ExtractMethod\VisualBasicMethodExtractor.vb (4)
106
If TypeOf currentToken.
Parent
Is TypeStatementSyntax AndAlso
107
currentToken.
Parent
.GetFirstToken(includeZeroWidth:=True) = currentToken Then
117
token.
Parent
.Kind = SyntaxKind.AttributeList AndAlso
118
DirectCast(token.
Parent
, AttributeListSyntax).LessThanToken.Equals(token) Then
ExtractMethod\VisualBasicSelectionResult.vb (1)
71
Dim current = token.
Parent
GenerateMember\GenerateVariable\VisualBasicGenerateVariableService.vb (1)
102
Dim block = identifierToken.
Parent
.GetContainingMultiLineExecutableBlocks().FirstOrDefault()
GenerateType\VisualBasicGenerateTypeService.vb (1)
153
simpleName.Parent Is token.
Parent
Then
IntroduceVariable\VisualBasicIntroduceVariableService.Rewriter.vb (1)
39
Dim innerExpression = parenthesizedExpression.OpenParenToken.GetNextToken().
Parent
MetadataAsSource\VisualBasicMetadataAsSourceService.vb (2)
94
Dim member1 = token1.
Parent
.FirstAncestorOrSelf(Of DeclarationStatementSyntax)()
95
Dim member2 = token2.
Parent
.FirstAncestorOrSelf(Of DeclarationStatementSyntax)()
QuickInfo\VisualBasicSemanticQuickInfoProvider.vb (7)
59
Dim parent = token.
Parent
132
If token.IsKind(SyntaxKind.SubKeyword, SyntaxKind.FunctionKeyword) AndAlso token.
Parent
.IsKind(SyntaxKind.SubLambdaHeader, SyntaxKind.FunctionLambdaHeader) Then
133
found = token.
Parent
.Parent
143
token.
Parent
?.Parent.IsKind(SyntaxKind.InvocationExpression) = True Then
144
found = token.
Parent
.Parent
154
token.
Parent
.IsKind(SyntaxKind.SimpleMemberAccessExpression) Then
156
found = DirectCast(token.
Parent
, MemberAccessExpressionSyntax).Name.Identifier
ReplaceDocCommentTextWithTag\VisualBasicReplaceDocCommentTextWithTagCodeRefactoringProvider.vb (2)
27
Return token.
Parent
.IsKind(SyntaxKind.XmlAttribute) Or token.
Parent
.IsKind(SyntaxKind.XmlString)
ReplaceMethodWithProperty\VisualBasicReplaceMethodWithPropertyService.vb (2)
141
Dim nameNode = TryCast(nameToken.
Parent
, IdentifierNameSyntax)
170
Dim nameNode = TryCast(nameToken.
Parent
, IdentifierNameSyntax)
SignatureHelp\AttributeSignatureHelpProvider.vb (2)
44
TypeOf token.
Parent
Is ArgumentListSyntax AndAlso
45
TypeOf token.
Parent
.Parent Is AttributeSyntax
SignatureHelp\CollectionInitializerSignatureHelpProvider.vb (1)
41
TypeOf token.
Parent
Is CollectionInitializerSyntax
SignatureHelp\ConditionalExpressionSignatureHelpProvider.vb (2)
24
token.
Parent
.Kind = Kind
38
token.
Parent
.Kind <> Kind)
SignatureHelp\GenericNameSignatureHelpProvider.vb (2)
54
TypeOf token.
Parent
Is TypeArgumentListSyntax AndAlso
55
TypeOf token.
Parent
.Parent Is GenericNameSyntax
SignatureHelp\InvocationExpressionSignatureHelpProvider.vb (2)
55
TypeOf token.
Parent
Is ArgumentListSyntax AndAlso
56
TypeOf token.
Parent
.Parent Is InvocationExpressionSyntax
SignatureHelp\MidAssignmentSignatureHelpProvider.vb (3)
28
token.
Parent
.Kind = SyntaxKind.ArgumentList AndAlso
29
token.
Parent
.IsParentKind(SyntaxKind.MidExpression) AndAlso
30
token.
Parent
.Parent.IsParentKind(SyntaxKind.MidAssignmentStatement)
SignatureHelp\ObjectCreationExpressionSignatureHelpProvider.vb (2)
54
TypeOf token.
Parent
Is ArgumentListSyntax AndAlso
55
TypeOf token.
Parent
.Parent Is ObjectCreationExpressionSyntax
SignatureHelp\RaiseEventStatementSignatureHelpProvider.vb (2)
53
TypeOf token.
Parent
Is ArgumentListSyntax AndAlso
54
TypeOf token.
Parent
.Parent Is RaiseEventStatementSyntax
src\Analyzers\VisualBasic\CodeFixes\UseConditionalExpression\MultiLineConditionalExpressionFormattingRule.vb (1)
33
Return token.
Parent
.HasAnnotation(
Structure\VisualBasicStructureHelpers.vb (2)
214
firstToken.
Parent
.IsKind(SyntaxKind.AttributeList) Then
216
Dim attributeOwner = firstToken.
Parent
.Parent
Wrapping\SeparatedSyntaxList\VisualBasicArgumentWrapper.vb (2)
76
If token.
Parent
.Ancestors().Contains(listSyntax) Then
77
Dim current = token.
Parent
Microsoft.CodeAnalysis.VisualBasic.Features.UnitTests (1)
EditAndContinue\VisualBasicEditAndContinueAnalyzerTests.vb (1)
39
Dim node = tree.GetRoot().FindToken(expected.Key).
Parent
Microsoft.CodeAnalysis.VisualBasic.Semantic.UnitTests (6)
DeclaringSyntaxNodeTests.vb (3)
107
Dim node = token.
Parent
.FirstAncestorOrSelf(Of TNode)()
121
Dim node = token.
Parent
.FirstAncestorOrSelf(Of TNode)()
131
Dim node = tree.GetCompilationUnitRoot().FindToken(position).
Parent
.FirstAncestorOrSelf(Of TNode)()
FlowAnalysis\FlowTestBase.vb (3)
161
Dim parent = token.
Parent
180
Dim startNode = startToken.
Parent
198
Dim endNode = endToken.
Parent
Microsoft.CodeAnalysis.VisualBasic.Symbol.UnitTests (18)
DocumentationComments\DocCommentTests.vb (1)
12091
Dim node = TryCast(token.
Parent
, TNode)
SymbolsTests\AnonymousTypes\AnonymousTypesSemanticsTests.vb (16)
109
Dim declaratorQ = tree.GetRoot().FindToken(posQ).
Parent
.FirstAncestorOrSelf(Of VariableDeclaratorSyntax)()
116
Dim declaratorX = tree.GetRoot().FindToken(posX).
Parent
.FirstAncestorOrSelf(Of VariableDeclaratorSyntax)()
123
Dim declaratorZ = tree.GetRoot().FindToken(posZ).
Parent
.FirstAncestorOrSelf(Of VariableDeclaratorSyntax)()
245
Dim declaratorW = tree.GetRoot().FindToken(posW).
Parent
.FirstAncestorOrSelf(Of VariableDeclaratorSyntax)()
250
Dim declaratorZF = tree.GetRoot().FindToken(posZF).
Parent
.FirstAncestorOrSelf(Of VariableDeclaratorSyntax)()
260
Dim declaratorZL = tree.GetRoot().FindToken(posZL).
Parent
.FirstAncestorOrSelf(Of VariableDeclaratorSyntax)()
316
Dim declaratorT = tree.GetRoot().FindToken(posT).
Parent
.FirstAncestorOrSelf(Of VariableDeclaratorSyntax)()
321
Dim declaratorA = tree.GetRoot().FindToken(posA).
Parent
.FirstAncestorOrSelf(Of VariableDeclaratorSyntax)()
323
tree.GetRoot().FindToken(sub2).
Parent
.Parent.GetLocation,
331
Dim declaratorB = tree.GetRoot().FindToken(posB).
Parent
.FirstAncestorOrSelf(Of VariableDeclaratorSyntax)()
333
tree.GetRoot().FindToken(sub4).
Parent
.Parent.GetLocation,
383
Dim declaratorT = tree.GetRoot().FindToken(posT).
Parent
.FirstAncestorOrSelf(Of VariableDeclaratorSyntax)()
388
Dim declaratorA = tree.GetRoot().FindToken(posA).
Parent
.FirstAncestorOrSelf(Of VariableDeclaratorSyntax)()
390
tree.GetRoot().FindToken(sub1).
Parent
.Parent.GetLocation,
398
Dim declaratorB = tree.GetRoot().FindToken(posB).
Parent
.FirstAncestorOrSelf(Of VariableDeclaratorSyntax)()
401
tree.GetRoot().FindToken(sub2).
Parent
.Parent.GetLocation,
SymbolsTests\Source\BindingsTests.vb (1)
32
Dim node = token.
Parent
Microsoft.CodeAnalysis.VisualBasic.Syntax.UnitTests (6)
Parser\ParseExpression.vb (1)
1161
Dim lambda = DirectCast(subKeyword.
Parent
.Parent, MultiLineLambdaExpressionSyntax)
Syntax\SyntaxFactsTest.vb (4)
1039
If currentToken = currentToken.
Parent
.AncestorsAndSelf.OfType(Of StatementSyntax).First.GetLastToken() OrElse
1083
currentToken <> currentToken.
Parent
.AncestorsAndSelf.OfType(Of StatementSyntax).First.GetLastToken() AndAlso
1148
Dim kindAndParentKind = Tuple.Create(currentToken.Kind(), currentToken.
Parent
.Kind())
1162
"Expected diagnostic when adding line continuation to " & currentToken.Kind.ToString() & " in " & currentToken.
Parent
.ToString() & ".")
TestSyntaxNodes.vb (1)
1817
Dim foundDocComment = result.
Parent
.Parent.Parent.Parent
Microsoft.CodeAnalysis.VisualBasic.Test.Utilities (9)
CompilationTestUtils.vb (6)
510
Dim node = token.
Parent
674
Return FindTokenFromText(tree, textToFind).
Parent
1088
Dim node = CompilationUtils.FindTokenFromText(tree, stringInDecl).
Parent
1102
Dim node = CompilationUtils.FindTokenFromText(tree, stringInDecl).
Parent
1116
Dim node = CompilationUtils.FindTokenFromText(tree, stringInDecl).
Parent
1139
node = tree.GetRoot().FindToken(pos).
Parent
SemanticModelTestBase.vb (3)
17
Dim node = DirectCast(CompilationUtils.FindTokenFromText(tree, textToFind).
Parent
, VisualBasicSyntaxNode)
34
Dim node = token.
Parent
75
Dim node = token.
Parent
Microsoft.CodeAnalysis.VisualBasic.Workspaces (237)
CaseCorrection\VisualBasicCaseCorrectionService.Rewriter.vb (7)
72
If newToken.IsMissing OrElse TypeOf newToken.
Parent
Is ArgumentSyntax OrElse _semanticModel Is Nothing Then
76
If token.
Parent
.IsPartOfStructuredTrivia() Then
77
Dim identifierSyntax = TryCast(token.
Parent
, IdentifierNameSyntax)
93
Dim methodDeclaration = TryCast(token.
Parent
, MethodStatementSyntax)
130
Dim nameColonEquals = TryCast(token.
Parent
?.Parent, NameColonEqualsSyntax)
138
Dim symbol = GetAliasOrAnySymbol(_semanticModel, token.
Parent
, _cancellationToken)
143
Dim expression = TryCast(token.
Parent
, ExpressionSyntax)
Classification\ClassificationHelpers.vb (10)
37
Select Case token.
Parent
.Kind
59
If token.
Parent
Is Nothing Then
64
If token.
Parent
.IsKind(
75
IsControlStatementKind(token.
Parent
.Kind)
178
If TypeOf token.
Parent
Is AttributeListSyntax Then
191
Dim parent = identifier.
Parent
244
Dim parent = identifier.
Parent
273
token.
Parent
.IsKind(SyntaxKind.InterpolatedStringExpression)
308
Select Case identifier.
Parent
.Kind
318
Throw ExceptionUtilities.UnexpectedValue(identifier.
Parent
.Kind)
Classification\Worker.DocumentationCommentClassifier.vb (1)
133
Select Case token.
Parent
.Kind
CodeCleanup\Providers\AddMissingTokensCodeCleanupProvider.vb (3)
572
If TryCast(originalToken.
Parent
, TypeArgumentListSyntax)?.OfKeyword = originalToken Then
574
ElseIf TryCast(originalToken.
Parent
, TypeParameterListSyntax)?.OfKeyword = originalToken Then
576
ElseIf TryCast(originalToken.
Parent
, ContinueStatementSyntax)?.BlockKeyword = originalToken Then
CodeCleanup\Providers\RemoveUnnecessaryLineContinuationCodeCleanupProvider.vb (2)
256
Return TypeOf token.
Parent
Is LabelStatementSyntax
260
Dim node = token.
Parent
CodeCleanup\VisualBasicCodeCleanerService.vb (1)
65
Dim parentMultiLineNode = GetMultiLineContainer(token.
Parent
)
Formatting\DefaultOperationProvider.vb (19)
57
If previousToken.
Parent
Is Nothing Then
69
ElseIf lastTrivia.RawKind = SyntaxKind.LineContinuationTrivia AndAlso previousToken.
Parent
.GetAncestorsOrThis(Of SyntaxNode)().Any(Function(node As SyntaxNode) IsSingleLineIfOrElseClauseSyntax(node)) Then
80
If previousToken.Kind = SyntaxKind.GreaterThanToken AndAlso previousToken.
Parent
IsNot Nothing AndAlso TypeOf previousToken.
Parent
Is AttributeListSyntax Then
84
If previousToken.
Parent
.Parent IsNot Nothing AndAlso TypeOf previousToken.
Parent
.Parent Is ParameterSyntax Then
91
If currentToken.Kind = SyntaxKind.LessThanToken AndAlso currentToken.
Parent
IsNot Nothing AndAlso TypeOf currentToken.
Parent
Is AttributeListSyntax Then
95
currentToken.
Parent
.Parent IsNot Nothing AndAlso TypeOf currentToken.
Parent
.Parent Is ParameterSyntax Then
108
Dim xmlDeclaration = TryCast(previousToken.
Parent
, XmlDeclarationSyntax)
113
If TypeOf previousToken.
Parent
Is XmlNodeSyntax OrElse TypeOf currentToken.
Parent
Is XmlNodeSyntax Then
128
TypeOf currentToken.
Parent
Is ImportsStatementSyntax AndAlso
132
Dim currentImports = DirectCast(currentToken.
Parent
, ImportsStatementSyntax)
182
Dim xmlDeclaration = TryCast(currentToken.
Parent
, XmlDeclarationSyntax)
190
Dim startTag = TryCast(currentToken.
Parent
, XmlElementStartTagSyntax)
198
Dim emptyTag = TryCast(currentToken.
Parent
, XmlEmptyElementSyntax)
211
TypeOf previousToken.
Parent
Is LabelStatementSyntax AndAlso
Formatting\FormattingHelpers.vb (55)
13
token.
Parent
.Kind = SyntaxKind.AttributeList AndAlso
14
DirectCast(token.
Parent
, AttributeListSyntax).LessThanToken.Equals(token) Then
24
token.
Parent
.Kind = SyntaxKind.AttributeList AndAlso
25
DirectCast(token.
Parent
, AttributeListSyntax).GreaterThanToken.Equals(token) Then
33
If token.
Parent
Is Nothing Then
39
token.
Parent
.Kind = SyntaxKind.XmlString AndAlso
40
(DirectCast(token.
Parent
, XmlStringSyntax).StartQuoteToken.Equals(token) OrElse
41
DirectCast(token.
Parent
, XmlStringSyntax).EndQuoteToken.Equals(token)) Then
49
If token.
Parent
Is Nothing Then
53
If token.
Parent
.Kind = SyntaxKind.XmlString AndAlso
54
Not DirectCast(token.
Parent
, XmlStringSyntax).StartQuoteToken.Equals(token) AndAlso
55
Not DirectCast(token.
Parent
, XmlStringSyntax).EndQuoteToken.Equals(token) Then
87
If token.
Parent
Is Nothing Then
93
token.
Parent
.Kind = SyntaxKind.XmlEmptyElement Then
94
Dim xmlElement = DirectCast(token.
Parent
, XmlEmptyElementSyntax)
104
token.
Parent
.Kind = SyntaxKind.XmlAttributeAccessExpression Then
105
Dim xmlMemberAccess = DirectCast(token.
Parent
, XmlMemberAccessExpressionSyntax)
115
token.
Parent
.Kind = SyntaxKind.XmlPrefix Then
116
Dim xmlElement = DirectCast(token.
Parent
, XmlPrefixSyntax)
126
token.
Parent
.Kind = SyntaxKind.XmlAttribute Then
127
Dim xmlElement = DirectCast(token.
Parent
, XmlAttributeSyntax)
137
token.
Parent
.Kind = SyntaxKind.XmlCrefAttribute Then
138
Dim xmlElement = DirectCast(token.
Parent
, XmlCrefAttributeSyntax)
148
token.
Parent
.Kind = SyntaxKind.XmlNameAttribute Then
149
Dim xmlElement = DirectCast(token.
Parent
, XmlNameAttributeSyntax)
159
token.
Parent
.Kind = SyntaxKind.XmlNamespaceImportsClause Then
160
Dim xmlElement = DirectCast(token.
Parent
, XmlNamespaceImportsClauseSyntax)
170
token.
Parent
.Kind = SyntaxKind.XmlNamespaceImportsClause Then
171
Dim xmlElement = DirectCast(token.
Parent
, XmlNamespaceImportsClauseSyntax)
181
token.
Parent
.Kind = SyntaxKind.XmlBracketedName Then
182
Dim xmlBracketedName = DirectCast(token.
Parent
, XmlBracketedNameSyntax)
192
token.
Parent
.Kind = SyntaxKind.XmlBracketedName Then
193
Dim xmlBracketedName = DirectCast(token.
Parent
, XmlBracketedNameSyntax)
201
If token.
Parent
.Parent Is Nothing Then
207
token.
Parent
.Parent.Kind = SyntaxKind.XmlElement Then
208
Dim xmlElement = DirectCast(token.
Parent
.Parent, XmlElementSyntax)
218
token.
Parent
.Parent.Kind = SyntaxKind.XmlElement Then
219
Dim xmlElement = DirectCast(token.
Parent
.Parent, XmlElementSyntax)
229
If token.Kind = SyntaxKind.GreaterThanToken AndAlso IsGreaterThanInXmlTag(token.
Parent
, token) Then
255
Return TypeOf currentToken.
Parent
Is NullableTypeSyntax OrElse
256
TypeOf currentToken.
Parent
Is ModifiedIdentifierSyntax
264
Return TypeOf previousToken.
Parent
Is AttributeTargetSyntax
273
Dim memberAccess = TryCast(token.
Parent
, MemberAccessExpressionSyntax)
278
If token.
Parent
.Parent Is Nothing Then
283
memberAccess = TryCast(token.
Parent
, MemberAccessExpressionSyntax)
292
Dim argumentList = TryCast(token.
Parent
, ArgumentListSyntax)
301
Dim binaryCondition = TryCast(token.
Parent
, BinaryConditionalExpressionSyntax)
310
Dim ternaryCondition = TryCast(token.
Parent
, TernaryConditionalExpressionSyntax)
319
Dim xmlDeclaration = TryCast(token.
Parent
, XmlDeclarationSyntax)
332
Dim memberAccess = TryCast(token.
Parent
, MemberAccessExpressionSyntax)
337
Dim xmlMemberAccess = TryCast(token.
Parent
, XmlMemberAccessExpressionSyntax)
350
Dim memberAccess = TryCast(token.
Parent
, MemberAccessExpressionSyntax)
359
Dim namedFieldInitializer = TryCast(token.
Parent
, NamedFieldInitializerSyntax)
368
If token.
Parent
.IsKind(SyntaxKind.OperatorStatement) Then
369
Return DirectCast(token.
Parent
, OperatorStatementSyntax).OperatorToken = token
Formatting\Rules\AdjustSpaceFormattingRule.vb (25)
93
If TypeOf currentToken.
Parent
Is BinaryExpressionSyntax AndAlso DirectCast(currentToken.
Parent
, BinaryExpressionSyntax).Left.IsKind(SyntaxKind.XmlAttributeAccessExpression) OrElse
94
currentToken.
Parent
.IsKind(SyntaxKind.SimpleAssignmentStatement) AndAlso DirectCast(currentToken.
Parent
, AssignmentStatementSyntax).Left.IsKind(SyntaxKind.XmlAttributeAccessExpression) Then
99
If currentToken.
Parent
.IsKind(SyntaxKind.XmlDeclarationOption) Then
173
If currentToken.Kind = SyntaxKind.OpenParenToken AndAlso TypeOf currentToken.
Parent
Is ArrayRankSpecifierSyntax Then
183
If previousToken.Kind = SyntaxKind.CloseParenToken AndAlso TypeOf previousToken.
Parent
Is TypeParameterListSyntax AndAlso
184
currentToken.Kind = SyntaxKind.OpenParenToken AndAlso TypeOf currentToken.
Parent
Is ParameterListSyntax Then
196
previousToken.
Parent
.IsKind(SyntaxKind.ConditionalAccessExpression) Then
202
currentToken.
Parent
.Kind = SyntaxKind.ConditionalAccessExpression Then
210
If previousToken.Kind = SyntaxKind.ColonToken AndAlso TypeOf previousToken.
Parent
Is LabelStatementSyntax Then
223
If previousToken.Kind = SyntaxKind.DollarSignDoubleQuoteToken AndAlso previousToken.
Parent
.IsKind(SyntaxKind.InterpolatedStringExpression) Then
228
If currentToken.Kind = SyntaxKind.DoubleQuoteToken AndAlso currentToken.
Parent
.IsKind(SyntaxKind.InterpolatedStringExpression) Then
233
If (currentToken.Kind = SyntaxKind.OpenBraceToken AndAlso currentToken.
Parent
.IsKind(SyntaxKind.Interpolation)) OrElse
234
(previousToken.Kind = SyntaxKind.CloseBraceToken AndAlso previousToken.
Parent
.IsKind(SyntaxKind.Interpolation)) Then
239
If (previousToken.Kind = SyntaxKind.OpenBraceToken AndAlso previousToken.
Parent
.IsKind(SyntaxKind.Interpolation)) OrElse
240
(currentToken.Kind = SyntaxKind.CloseBraceToken AndAlso currentToken.
Parent
.IsKind(SyntaxKind.Interpolation)) Then
245
If (previousToken.Kind = SyntaxKind.CommaToken AndAlso previousToken.
Parent
.IsKind(SyntaxKind.InterpolationAlignmentClause)) OrElse
246
(currentToken.Kind = SyntaxKind.CommaToken AndAlso currentToken.
Parent
.IsKind(SyntaxKind.InterpolationAlignmentClause)) Then
251
If (previousToken.Kind = SyntaxKind.ColonToken AndAlso previousToken.
Parent
.IsKind(SyntaxKind.InterpolationFormatClause)) OrElse
252
(currentToken.Kind = SyntaxKind.ColonToken AndAlso currentToken.
Parent
.IsKind(SyntaxKind.InterpolationFormatClause)) Then
331
TypeOf previousToken.
Parent
Is UnaryExpressionSyntax Then
347
previousToken.
Parent
Is currentToken.
Parent
Then
352
Dim labelStatement = TryCast(previousToken.
Parent
, LabelStatementSyntax)
Formatting\Rules\ElasticTriviaFormattingRule.vb (17)
115
currentToken.
Parent
.Kind = SyntaxKind.CollectionInitializer AndAlso
116
currentToken.
Parent
.Parent.Kind = SyntaxKind.ObjectCollectionInitializer Then
142
currentToken.
Parent
.Kind = SyntaxKind.NamedFieldInitializer Then
149
previousToken.
Parent
.Kind = SyntaxKind.CollectionInitializer AndAlso
150
previousToken.
Parent
.Parent.Kind = SyntaxKind.ObjectCollectionInitializer Then
157
previousToken.
Parent
.Kind = SyntaxKind.CollectionInitializer AndAlso
158
previousToken.
Parent
.Parent.Kind = SyntaxKind.ObjectCollectionInitializer Then
165
currentToken.
Parent
.Kind = SyntaxKind.CollectionInitializer AndAlso
166
currentToken.
Parent
.Parent.Kind = SyntaxKind.CollectionInitializer Then
172
If currentToken.
Parent
.Kind = SyntaxKind.ObjectMemberInitializer Then
178
If currentToken.
Parent
.Kind = SyntaxKind.CollectionInitializer AndAlso
179
currentToken.
Parent
.Parent.Kind = SyntaxKind.ObjectCollectionInitializer Then
186
Dim attributeNode = TryCast(previousToken.
Parent
, AttributeListSyntax)
198
TypeOf currentToken.
Parent
Is ParenthesizedExpressionSyntax Then
204
If Not TypeOf currentToken.
Parent
Is EndBlockStatementSyntax Then
215
If TypeOf previousToken.
Parent
Is XmlNodeSyntax Then
237
If Not TypeOf token.
Parent
Is NameSyntax Then
Formatting\Rules\NodeBasedFormattingRule.vb (3)
200
Dim outerBlock = firstTokenOfInnerBlock.
Parent
213
(ReferenceEquals(outerBlock, firstTokenOfInnerBlock.
Parent
) OrElse
281
If TypeOf previousToken.
Parent
Is XmlElementSyntax Then
Formatting\Rules\StructuredTriviaFormattingRule.vb (4)
37
If TypeOf previousToken.
Parent
Is StructuredTriviaSyntax OrElse TypeOf currentToken.
Parent
Is StructuredTriviaSyntax Then
41
If TypeOf previousToken.
Parent
Is DirectiveTriviaSyntax OrElse TypeOf currentToken.
Parent
Is DirectiveTriviaSyntax Then
ObsoleteSymbol\VisualBasicObsoleteSymbolService.vb (1)
26
Dim localDeclaration = TryCast(token.
Parent
, LocalDeclarationStatementSyntax)
Recommendations\VisualBasicRecommendationServiceRunner.vb (2)
436
token.
Parent
?.FirstAncestorOrSelf(Of InheritsStatementSyntax) IsNot Nothing
445
token.
Parent
?.FirstAncestorOrSelf(Of ImplementsStatementSyntax) IsNot Nothing
Rename\VisualBasicRenameRewriterLanguageService.vb (5)
368
Dim isMemberGroupReference = _semanticFactsService.IsInsideNameOfExpression(_semanticModel, token.
Parent
, _cancellationToken)
402
If TypeOf token.
Parent
Is SimpleNameSyntax AndAlso token.Kind <> SyntaxKind.GlobalKeyword AndAlso token.
Parent
.Parent.IsKind(SyntaxKind.QualifiedName, SyntaxKind.QualifiedCrefOperatorReference) Then
403
Dim symbol = Me._speculativeModel.GetSymbolInfo(token.
Parent
, Me._cancellationToken).Symbol
523
Dim parent = oldToken.
Parent
Simplification\Reducers\AbstractVisualBasicReducer.AbstractReductionRewriter.vb (1)
122
Dim parentNode = token.
Parent
Simplification\Reducers\VisualBasicEscapingReducer.vb (1)
46
Dim parent = identifier.
Parent
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Extensions\DirectiveSyntaxExtensions.vb (1)
30
node = node.ParentTrivia.Token.
Parent
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Extensions\InvocationExpressionSyntaxExtensions.vb (1)
28
lastExpressionToken.
Parent
.IsKind(SyntaxKind.ArgumentList) Then
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Extensions\ParenthesizedExpressionSyntaxExtensions.vb (9)
14
Dim query = token.
Parent
.FirstAncestorOrSelf(Of QueryExpressionSyntax)()
18
Dim invocationAtLast = token.
Parent
.FirstAncestorOrSelf(Of InvocationExpressionSyntax)()
29
Dim variableDeclarator = token.
Parent
.FirstAncestorOrSelf(Of VariableDeclaratorSyntax)()
35
Dim lambda = token.
Parent
.FirstAncestorOrSelf(Of SingleLineLambdaExpressionSyntax)()
425
Dim lastStatement = lastToken.
Parent
.GetFirstEnclosingStatement()
440
nextToken.
Parent
.IsKind(SyntaxKind.SimpleMemberAccessExpression) Then
512
nextToken.
Parent
.IsKind(SyntaxKind.SimpleMemberAccessExpression)) AndAlso
514
nextToken.
Parent
.IsKind(SyntaxKind.SelectStatement)) AndAlso
517
nextToken.
Parent
.IsKind(SyntaxKind.DictionaryAccessExpression)) Then
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Extensions\SemanticModelExtensions.vb (3)
18
Dim expression = TryCast(name.
Parent
, ExpressionSyntax)
33
Dim expression = TryCast(name.
Parent
, ExpressionSyntax)
73
Dim expression = TryCast(token.
Parent
, ExpressionSyntax)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Extensions\StatementSyntaxExtensions.vb (1)
731
Return nextToken.
Parent
.FirstAncestorOrSelf(Of StatementSyntax)()
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Extensions\SyntaxTokenExtensions.vb (5)
50
Dim expression = TryCast(token.
Parent
, ExpressionSyntax)
58
Return TypeOf token.
Parent
Is SkippedTokensTriviaSyntax
63
Return token.
Parent
.FirstAncestorOrSelf(predicate)
116
Return token.
Parent
IsNot Nothing AndAlso
117
token.
Parent
.AncestorsAndSelf().Any(Function(n) n Is node)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Extensions\SyntaxTreeExtensions.vb (2)
51
Dim current = token.
Parent
361
Dim statement = token.
Parent
.FirstAncestorOrSelf(Of StatementSyntax)()
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Services\SyntaxFacts\VisualBasicSyntaxFacts.vb (17)
118
Return (IsUnaryExpressionOperatorToken(CType(token.Kind, SyntaxKind)) AndAlso (TypeOf token.
Parent
Is UnaryExpressionSyntax OrElse TypeOf token.
Parent
Is OperatorStatementSyntax)) OrElse
119
(IsBinaryExpressionOperatorToken(CType(token.Kind, SyntaxKind)) AndAlso (TypeOf token.
Parent
Is BinaryExpressionSyntax OrElse TypeOf token.
Parent
Is OperatorStatementSyntax))
255
If TypeOf token.
Parent
Is IdentifierNameSyntax AndAlso token.HasMatchingText(SyntaxKind.NewKeyword) Then
256
Dim memberAccess = TryCast(token.
Parent
.Parent, MemberAccessExpressionSyntax)
264
If TypeOf token.
Parent
Is IdentifierNameSyntax AndAlso token.HasMatchingText(SyntaxKind.NewKeyword) Then
265
Dim memberAccess = TryCast(token.
Parent
.Parent, MemberAccessExpressionSyntax)
289
Return TypeOf token.
Parent
Is QueryClauseSyntax
291
Return (TypeOf token.
Parent
Is QueryClauseSyntax) OrElse (token.
Parent
.IsKind(SyntaxKind.GroupAggregation))
293
Return TypeOf token.
Parent
Is JoinConditionSyntax
295
Return TypeOf token.
Parent
Is OrderingSyntax
297
Return TypeOf token.
Parent
Is CollectionRangeVariableSyntax
766
Dim node = root.FindToken(position).
Parent
1083
Dim node = token.
Parent
1551
Dim parent = token.
Parent
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\Extensions\CallStatementSyntaxExtensions.vb (1)
15
nextToken.
Parent
.IsKind(SyntaxKind.PredefinedType)) AndAlso
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\Extensions\ContextQuery\SyntaxTokenExtensions.vb (4)
60
Dim allowsImplicitLineContinuation = token.
Parent
IsNot Nothing AndAlso
105
Return targetToken.
Parent
.IsKind(SyntaxKind.BadDirectiveTrivia)
110
targetToken.GetPreviousToken().
Parent
.IsKind(SyntaxKind.BadDirectiveTrivia)
128
Dim argumentList = TryCast(token.
Parent
, ArgumentListSyntax)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\Extensions\ContextQuery\SyntaxTreeExtensions.vb (23)
125
If targetToken.Kind = SyntaxKind.None OrElse targetToken.
Parent
Is Nothing Then
177
If token.Kind = SyntaxKind.GreaterThanToken AndAlso token.
Parent
.Kind = SyntaxKind.AttributeList Then
248
If targetToken.
Parent
.IsKind(SyntaxKind.ParameterList) AndAlso
255
If targetToken.
Parent
.IsKind(SyntaxKind.Parameter) AndAlso
322
If targetToken.
Parent
.IsKind(SyntaxKind.ArgumentList) AndAlso
323
TypeOf targetToken.
Parent
.Parent Is NewExpressionSyntax Then
325
Dim symbolInfo = semanticModel.GetSymbolInfo(DirectCast(targetToken.
Parent
.Parent, NewExpressionSyntax).Type(), cancellationToken)
443
targetToken.
Parent
.IsKind(SyntaxKind.ParameterList) AndAlso
444
TypeOf targetToken.
Parent
.Parent Is LambdaHeaderSyntax Then
450
targetToken.
Parent
.IsKind(SyntaxKind.ArgumentList, SyntaxKind.CollectionInitializer, SyntaxKind.EraseStatement) Then
470
targetToken.
Parent
.IsKind(SyntaxKind.QualifiedName) AndAlso
471
targetToken.
Parent
.Parent.IsKind(SyntaxKind.Attribute) Then
531
Dim parent = token.
Parent
549
Dim possibleTuple = token.
Parent
672
If targetToken.Kind = SyntaxKind.None OrElse targetToken.
Parent
Is Nothing Then
686
Dim ancestor = targetToken.
Parent
722
If targetToken.
Parent
.FirstAncestorOrSelf(Of AggregateClauseSyntax)() Is Nothing AndAlso
723
targetToken.
Parent
.FirstAncestorOrSelf(Of GroupByClauseSyntax)() Is Nothing AndAlso
724
targetToken.
Parent
.FirstAncestorOrSelf(Of GroupJoinClauseSyntax)() Is Nothing Then
779
Not targetToken.
Parent
.IsKind(SyntaxKind.SimpleMemberAccessExpression) Then
784
Dim memberAccess = DirectCast(targetToken.
Parent
, MemberAccessExpressionSyntax)
1080
Return tokenOnLeftOfPosition.
Parent
.IsKind(SyntaxKind.ParenthesizedExpression,
1085
tokenOnLeftOfPosition.
Parent
.IsKind(SyntaxKind.TupleExpression, SyntaxKind.TupleType)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\Extensions\ContextQuery\VisualBasicSyntaxContext.vb (5)
143
Dim asClause = TryCast(targetToken.
Parent
, AsClauseSyntax)
179
isGenericConstraintContext:=targetToken.
Parent
.IsKind(SyntaxKind.TypeParameterSingleConstraintClause, SyntaxKind.TypeParameterMultipleConstraintClause),
188
isOnArgumentListBracketOrComma:=targetToken.
Parent
.IsKind(SyntaxKind.ArgumentList),
211
Dim collectionRange = TryCast(targetToken.
Parent
, CollectionRangeVariableSyntax)
276
Return TypeOf targetToken.
Parent
Is DirectiveTriviaSyntax
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\Indentation\SpecialFormattingOperation.vb (1)
29
Dim attributeNode = TryCast(previousToken.
Parent
, AttributeListSyntax)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\Indentation\VisualBasicIndentationService.Indenter.vb (6)
159
(containingToken.IsKind(SyntaxKind.CloseBraceToken) AndAlso token.
Parent
.IsKind(SyntaxKind.Interpolation)) Then
192
If Not ContainingStatementHasDiagnostic(lastVisibleTokenOnPreviousLine.
Parent
) Then
205
Dim visibleTokenOnCurrentLineParent = visibleTokenOnCurrentLine.
Parent
313
(TypeOf token.
Parent
Is ParameterListSyntax OrElse
314
TypeOf token.
Parent
Is ArgumentListSyntax OrElse
315
TypeOf token.
Parent
Is TypeParameterListSyntax)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\Indentation\VisualBasicIndentationService.vb (1)
96
Dim startNode = token.
Parent
Microsoft.CodeAnalysis.VisualBasic.Workspaces.UnitTests (1)
VisualBasicSyntaxFactsServiceTests.vb (1)
544
Dim node = tree.GetRoot().FindToken(position).
Parent
Microsoft.CodeAnalysis.Workspaces (39)
FindSymbols\FindReferences\Finders\AbstractReferenceFinder.cs (2)
46
? token.
Parent
48
parent ??= token.
Parent
!;
FindSymbols\FindReferences\Finders\AbstractReferenceFinder_GlobalSuppressions.cs (1)
184
var attributeArgument = token.
Parent
?.Parent;
FindSymbols\FindReferences\Finders\AbstractTypeParameterSymbolReferenceFinder.cs (4)
50
return syntaxFacts.IsIdentifierName(token.
Parent
) &&
51
syntaxFacts.IsObjectCreationExpression(token.
Parent
.Parent);
61
Contract.ThrowIfNull(token.
Parent
?.Parent);
62
var typeInfo = state.SemanticModel.GetTypeInfo(token.
Parent
.Parent, cancellationToken);
ObsoleteSymbol\AbstractObsoleteSymbolService.cs (2)
173
if (syntaxFacts.IsDeclaration(token.
Parent
))
175
var symbol = semanticModel.GetDeclaredSymbol(token.
Parent
, cancellationToken);
Shared\Extensions\SemanticModelExtensions.cs (2)
93
var tokenParent = token.
Parent
;
97
var usingStatement = token.
Parent
;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SemanticModelExtensions.cs (1)
33
=> semanticModel.GetSymbolInfo(token.
Parent
!, cancellationToken);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SyntaxNodeExtensions.cs (1)
799
parent = structuredTrivia.ParentTrivia.Token.
Parent
;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SyntaxTokenExtensions.cs (12)
19
=> token.
Parent
?.FirstAncestorOrSelf(predicate);
27
return token.
Parent
!= null
28
? token.
Parent
.AncestorsAndSelf().OfType<T>()
34
return token.
Parent
!= null
35
? token.
Parent
.AncestorsAndSelf().Where(predicate)
45
if (token1.
Parent
== null || token2.
Parent
== null)
50
return token1.
Parent
.GetCommonRoot(token2.
Parent
);
55
if (token.
Parent
is not T parentNode)
95
? ((ICompilationUnitSyntax)token.
Parent
!.SyntaxTree!.GetRoot(CancellationToken.None)).EndOfFileToken
165
=> token.
Parent
?? throw new InvalidOperationException("Token's parent was null");
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\BottomUpBaseIndentationFinder.cs (4)
231
var current = token.
Parent
;
238
current = ((IStructuredTriviaSyntax)current).ParentTrivia.Token.
Parent
;
249
var startNode = token.
Parent
;
280
var startNode = token.
Parent
;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Context\FormattingContext.InitialContextFinder.cs (1)
145
var startNode = token.
Parent
;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\TreeData.StructuredTrivia.cs (1)
56
var parent = _trivia.Token.
Parent
;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\CommonFormattingHelpers.cs (2)
279
var parentNode = GetParentThatContainsGivenSpan(token.
Parent
, backwardPosition, forward: false);
310
var parentNode = GetParentThatContainsGivenSpan(token.
Parent
, forwardPosition, forward: true);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeRefactorings\AbstractRefactoringHelpersService.cs (3)
275
var leftNode = tokenToLeft.
Parent
;
313
var rightNode = tokenToRightOrIn.
Parent
;
531
var ancestor = token.
Parent
;
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeRefactorings\CodeRefactoringHelpers.cs (2)
84
var beginningNode = node.FindToken(node.Span.Start).
Parent
;
85
var endNode = node.FindToken(node.Span.End - 1).
Parent
;
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\DocumentExtensions.cs (1)
139
var node = token.
Parent
!.AncestorsAndSelf().First(a => a.FullSpan.Contains(span));
Microsoft.CodeAnalysis.Workspaces.MSBuild.UnitTests (3)
VisualStudioMSBuildWorkspaceTests.cs (3)
62
var type = tree.GetRoot().DescendantTokens().First(t => t.ToString() == "class").
Parent
;
440
var type = tree.GetRoot().DescendantTokens().First(t => t.ToString() == "class").
Parent
;
2848
var type = tree.GetRoot().DescendantTokens().First(t => t.ToString() == "class").
Parent
;
Microsoft.ML.InternalCodeAnalyzer (3)
ContractsCheckNameofFixProvider.cs (2)
44
var nameArg = root.FindToken(diagnosticSpan.Start).
Parent
.FirstAncestorOrSelf<ArgumentSyntax>();
74
.Select(p => p.
Parent
).Where(n => n.IsKind(SyntaxKind.IdentifierName));
NameFixProvider.cs (1)
99
c => RenameAsync(context.Document, token.
Parent
, originalName, renamer, c), diagnostic.Id), diagnostic);
Microsoft.VisualStudio.LanguageServices (2)
Venus\ContainedDocument.cs (2)
832
var current = root.FindToken(visibleTextSpan.Start).
Parent
;
1001
if (syntaxFact.IsSkippedTokensTrivia(token.
Parent
))
Microsoft.VisualStudio.LanguageServices.CSharp (38)
LanguageService\CSharpHelpContextService.cs (36)
161
if (token.
Parent
is TypeArgumentListSyntax)
167
else if (token.
Parent
is NullableTypeSyntax && token.IsKind(SyntaxKind.QuestionToken))
223
token.
Parent
.IsKind(SyntaxKind.SuppressNullableWarningExpression))
242
if (token.IsKind(SyntaxKind.ColonToken) && token.
Parent
is NameColonSyntax)
250
if (token.
Parent
.IsKind(SyntaxKind.EqualsValueClause))
252
if (token.
Parent
.Parent.IsKind(SyntaxKind.Parameter))
257
else if (token.
Parent
.Parent.IsKind(SyntaxKind.PropertyDeclaration))
262
else if (token.
Parent
.Parent.IsKind(SyntaxKind.EnumMemberDeclaration))
267
else if (token.
Parent
.Parent.IsKind(SyntaxKind.VariableDeclarator))
273
else if (token.
Parent
.IsKind(SyntaxKind.NameEquals))
275
if (token.
Parent
.Parent.IsKind(SyntaxKind.AnonymousObjectMemberDeclarator))
280
else if (token.
Parent
.Parent.IsKind(SyntaxKind.UsingDirective))
285
else if (token.
Parent
.Parent.IsKind(SyntaxKind.AttributeArgument))
291
else if (token.
Parent
.IsKind(SyntaxKind.LetClause))
296
else if (token.
Parent
is XmlAttributeSyntax)
314
if (token.
Parent
.IsKind(SyntaxKind.FunctionPointerParameterList))
321
if (token.IsKind(SyntaxKind.QuestionToken) && token.
Parent
is ConditionalExpressionSyntax)
334
token.
Parent
is (kind: SyntaxKind.TypeParameterList or SyntaxKind.TypeArgumentList))
353
if (token.IsKind(SyntaxKind.DefaultKeyword) && token.
Parent
is LineDirectiveTriviaSyntax)
389
if (token.
Parent
.GetAncestorOrThis<MethodDeclarationSyntax>() != null)
394
else if (token.
Parent
.GetAncestorOrThis<TypeDeclarationSyntax>() != null)
403
text = token.
Parent
.GetAncestorOrThis<TypeParameterConstraintClauseSyntax>() != null
416
if (token.
Parent
is IdentifierNameSyntax { Parent: TypeConstraintSyntax { Parent: TypeParameterConstraintClauseSyntax } })
440
case SyntaxKind.UsingKeyword when token.
Parent
is UsingDirectiveSyntax:
445
case SyntaxKind.StaticKeyword when token.
Parent
is UsingDirectiveSyntax:
448
case SyntaxKind.ReturnKeyword when token.
Parent
.IsKind(SyntaxKind.YieldReturnStatement):
449
case SyntaxKind.BreakKeyword when token.
Parent
.IsKind(SyntaxKind.YieldBreakStatement):
459
return CSharpSyntaxFacts.Instance.GetModifiers(token.
Parent
).Any(t => t.IsKind(kind));
482
if (token.
Parent
is DefaultConstraintSyntax)
488
if (token.
Parent
is DefaultSwitchLabelSyntax or GotoStatementSyntax)
495
if (token.IsKind(SyntaxKind.ClassKeyword) && token.
Parent
is ClassOrStructConstraintSyntax)
501
if (token.IsKind(SyntaxKind.StructKeyword) && token.
Parent
is ClassOrStructConstraintSyntax)
507
if (token.IsKind(SyntaxKind.UsingKeyword) && token.
Parent
is UsingStatementSyntax or LocalDeclarationStatementSyntax)
513
if (token.IsKind(SyntaxKind.SwitchKeyword) && token.
Parent
is SwitchExpressionSyntax)
526
token.
Parent
?.Parent is VariableDeclarationSyntax declaration && token.
Parent
== declaration.Type)
Utilities\BlankLineInGeneratedMethodFormattingRule.cs (2)
27
if (currentToken.
Parent
.Kind() == SyntaxKind.Block &&
28
currentToken.
Parent
.Parent.Kind() == SyntaxKind.MethodDeclaration)
Microsoft.VisualStudio.LanguageServices.VisualBasic (2)
Help\VisualBasicHelpContextService.vb (1)
49
visitor.Visit(token.
Parent
)
Help\VisualBasicHelpContextService.Visitor.vb (1)
952
Dim symbol = _semanticModel.GetDeclaredSymbol(token.
Parent
, _cancellationToken)
System.Windows.Forms.Analyzers.CodeFixes.CSharp (1)
System\Windows\Forms\CSharp\CodeFixes\AddDesignerSerializationVisibility\AddDesignerSerializationVisibilityCodeFixProvider.cs (1)
43
.
Parent
!
System.Windows.Forms.Analyzers.CodeFixes.VisualBasic (1)
AddDesignerSerializationVisibility\AddDesignerSerializationVisibilityCodeFixProvider.vb (1)
50
Parent
.AncestorsAndSelf().