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