5217 references to Parent
ILLink.CodeFixProvider (3)
BaseAttributeCodeFixProvider.cs (3)
95 SyntaxNode? parentNode = node.Parent; 112 parentNode = parentNode.Parent; 120 parentNode = parentNode.Parent;
Microsoft.Analyzers.Extra (8)
CallAnalysis\Fixers\LegacyLoggingFixer.cs (5)
331var ns = cl.Parent as BaseNamespaceDeclarationSyntax; 334if (cl.Parent is not CompilationUnitSyntax) 346ns = ns.Parent as BaseNamespaceDeclarationSyntax; 522if (invocationExpression.Parent!.IsKind(SyntaxKind.ConditionalAccessExpression)) 524invocationExpression = (ExpressionSyntax)invocationExpression.Parent;
Utilities\SyntaxNodeExtensions.cs (3)
26var n = node.Parent; 29n = n.Parent; 118currentNode = currentNode.Parent;
Microsoft.Analyzers.Local (2)
CallAnalysis\Throws.cs (1)
49if (throwExpression.Parent is BinaryExpressionSyntax binaryExpression)
InternalReferencedInPublicDocAnalyzer.cs (1)
91node = node.Parent as MemberDeclarationSyntax;
Microsoft.AspNetCore.App.Analyzers (47)
Infrastructure\VirtualChars\CSharpVirtualCharService.cs (1)
34if (token.Parent?.Parent is InterpolatedStringExpressionSyntax { StringStartToken.RawKind: (int)SyntaxKind.InterpolatedMultiLineRawStringStartToken })
RouteEmbeddedLanguage\FrameworkParametersCompletionProvider.cs (7)
149if (container.Parent.IsKind(SyntaxKind.Argument)) 331current = current.Parent; 342if (current.Parent?.IsKind(SyntaxKind.Argument) ?? false) 344if (current.Parent?.Parent?.IsKind(SyntaxKind.ArgumentList) ?? false) 350current = current.Parent; 358if (token.Parent?.Parent is ParameterSyntax parameter)
RouteEmbeddedLanguage\Infrastructure\RouteStringSyntaxDetector.cs (20)
83if (container.Parent.IsKind(SyntaxKind.Argument)) 85if (IsArgumentWithMatchingStringSyntaxAttribute(semanticModel, container.Parent, cancellationToken, out identifier)) 90else if (container.Parent.IsKind(SyntaxKind.AttributeArgument)) 92if (IsArgumentToAttributeParameterWithMatchingStringSyntaxAttribute(semanticModel, container.Parent, cancellationToken, out identifier)) 111if (container.Parent?.IsKind(SyntaxKind.EqualsValueClause) ?? false) 113if (container.Parent.Parent?.IsKind(SyntaxKind.VariableDeclarator) ?? false) 115var variableDeclarator = container.Parent.Parent; 125else if (IsEqualsValueOfPropertyDeclaration(container.Parent)) 127var property = container.Parent.GetRequiredParent(); 159token.Parent.Parent.IsBinaryExpression() && 160token.Parent.Parent.RawKind == (int)SyntaxKind.AddExpression) 165for (var node = token.Parent; node != null; node = node.Parent) 234=> node?.Parent is PropertyDeclarationSyntax propertyDeclaration && propertyDeclaration.Initializer == node; 390if (argument.Parent is not BaseArgumentListSyntax argumentList || 391argumentList.Parent is null) 397var symbolInfo = semanticModel.GetSymbolInfo(argumentList.Parent, cancellationToken); 472if (argument.Parent is not AttributeArgumentListSyntax argumentList) 476if (argumentList.Parent is not AttributeSyntax invocableExpression)
RouteEmbeddedLanguage\Infrastructure\RouteUsageDetector.cs (11)
82if (container.Parent.IsKind(SyntaxKind.Argument)) 109else if (container.Parent.IsKind(SyntaxKind.AttributeArgument)) 193var argument = container.Parent; 194if (argument?.Parent is not AttributeArgumentListSyntax argumentList) 199if (argumentList.Parent is not AttributeSyntax attribute) 204if (attribute.Parent is not AttributeListSyntax attributeList) 209return attributeList.Parent; 234var argument = container.Parent; 235if (argument?.Parent is not BaseArgumentListSyntax argumentList || 236argumentList.Parent is null) 243var symbols = GetBestOrAllSymbols(semanticModel.GetSymbolInfo(argumentList.Parent, cancellationToken));
RouteEmbeddedLanguage\Infrastructure\SyntaxNodeExtensions.cs (6)
21=> node.Parent ?? throw new InvalidOperationException("Node's parent was null"); 25var parent = node.Parent; 46while (node?.Parent?.RawKind == (int)SyntaxKind.ParenthesizedExpression) 48node = node.Parent; 58Parent: BaseObjectCreationExpressionSyntax or ArrayCreationExpressionSyntax or ImplicitArrayCreationExpressionSyntax 61creationExpression = node.Parent;
RouteEmbeddedLanguage\Infrastructure\SyntaxTokenExtensions.cs (1)
16if (node.Parent.IsAnyInitializerExpression(out var instance))
WebApplicationBuilder\PublicPartialProgramClassAnalyzer.cs (1)
37&& classDeclaration.Parent is CompilationUnitSyntax parentNode
Microsoft.AspNetCore.App.CodeFixes (5)
Dependencies\AddPackageFixer.cs (2)
61if (node.Parent is not MemberAccessExpressionSyntax) 66var symbol = semanticModel.GetSymbolInfo(((MemberAccessExpressionSyntax)node.Parent).Expression).Symbol;
Dependencies\ExtensionMethodsCompletionProvider.cs (1)
95current = current?.Parent;
Kestrel\ListenOnIPv6AnyFixer.cs (2)
47if (argumentSyntax.Parent?.Parent is not InvocationExpressionSyntax { ArgumentList.Arguments.Count: > 1 } invocationExpressionSyntax)
Microsoft.AspNetCore.SignalR.Client.SourceGenerator (13)
HubClientProxyGenerator.Parser.cs (7)
27Parent: 29Parent: MethodDeclarationSyntax 31Parent: ClassDeclarationSyntax 47return (MethodDeclarationSyntax)attributeSyntax.Parent.Parent; 217if (!IsExtensionClassSignatureValid((ClassDeclarationSyntax)methodDeclarationSyntax.Parent)) 255&& memberAccess.Parent.ChildNodes().FirstOrDefault(x => x is ArgumentListSyntax) is
HubServerProxyGenerator.Parser.cs (6)
27Parent: 29Parent: MethodDeclarationSyntax 31Parent: ClassDeclarationSyntax 47return (MethodDeclarationSyntax)attributeSyntax.Parent.Parent; 206if (!IsExtensionClassSignatureValid((ClassDeclarationSyntax)methodDeclarationSyntax.Parent))
Microsoft.CodeAnalysis (25)
DiagnosticAnalyzer\AnalyzerDriver.cs (1)
1269node = node.Parent)
DiagnosticAnalyzer\SuppressMessageAttributeState.cs (1)
168node = node.Parent)
Syntax\SeparatedSyntaxList.cs (1)
154return new SyntaxToken(node.Parent, green, node.GetChildPosition(index), _list.index + index);
Syntax\SyntaxList.cs (1)
27protected override SyntaxTree SyntaxTreeCore => this.Parent!.SyntaxTree;
Syntax\SyntaxNavigator.cs (6)
435while (node.Parent != null) 440foreach (var child in node.Parent.ChildNodesAndTokens()) 469node = node.Parent; 485while (node.Parent != null) 490foreach (var child in node.Parent.ChildNodesAndTokens().Reverse()) 519node = node.Parent;
Syntax\SyntaxNode.cs (9)
221Interlocked.CompareExchange(ref element, green.CreateRed(this.Parent, this.GetChildPosition(slot)), null); 243Interlocked.CompareExchange(ref element, green.CreateRed(this.Parent, this.GetChildPosition(1)), null); 266var newNode = greenChild.CreateRed(this.Parent, GetChildPosition(index)); 387for (SyntaxNode? node = this; node != null; node = node.Parent) 541if (node.Parent != null) 543node = node.Parent; 801return this.Parent? 819var parent = node.Parent; 981var parent = node.Parent;
Syntax\SyntaxNodeExtensions_Tracking.cs (4)
149while (node.Parent != null) 151node = node.Parent; 175if (node.Parent != null) 177node = node.Parent;
Syntax\SyntaxNodeOrToken.cs (1)
126public SyntaxNode? Parent => _token != null ? _nodeOrParent : _nodeOrParent?.Parent;
Syntax\SyntaxNodeOrTokenList.cs (1)
118internal SyntaxNode? Parent => _node?.Parent;
Microsoft.CodeAnalysis.CodeStyle (45)
src\Analyzers\Core\Analyzers\ConvertTypeofToNameof\AbstractConvertTypeOfToNameOfDiagnosticAnalyzer.cs (1)
42var parent = node.Parent;
src\Analyzers\Core\Analyzers\RemoveUnnecessaryParentheses\AbstractRemoveUnnecessaryParenthesesDiagnosticAnalyzer.cs (1)
73var parentKind = parenthesizedExpression.Parent?.RawKind;
src\Analyzers\Core\Analyzers\UseAutoProperty\AbstractUseAutoPropertyAnalyzer.cs (2)
324fieldDeclaration = variableDeclarator?.Parent?.Parent as TFieldDeclaration;
src\Analyzers\Core\Analyzers\UseCollectionInitializer\UseCollectionInitializerHelpers.cs (1)
69containingBlockOrCompilationUnit = containingBlockOrCompilationUnit.Parent!;
src\Analyzers\Core\Analyzers\UseIsNullCheck\AbstractUseIsNullForReferenceEqualsDiagnosticAnalyzer.cs (1)
134var negated = syntaxFacts.IsLogicalNotExpression(invocation.Parent);
src\Analyzers\Core\Analyzers\UseNullPropagation\AbstractUseNullPropagationDiagnosticAnalyzer_IfStatement.cs (1)
77if (whenPartMatch.Parent is TMemberAccessExpressionSyntax memberAccess)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SyntaxNodeExtensions.cs (6)
24=> node.Parent ?? throw new InvalidOperationException("Node's parent was null"); 34var current = node.Parent; 47var current = node.Parent; 62var current = node.Parent; 131if (node?.Parent is not T parentNode) 794var parent = node.Parent;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\BottomUpBaseIndentationFinder.cs (4)
242current = current.Parent; 261currentNode = currentNode.Parent; 272currentNode = currentNode.Parent; 295currentNode = currentNode.Parent;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Context\FormattingContext.InitialContextFinder.cs (2)
101node = node.Parent; 164currentIndentationNode = currentIndentationNode.Parent;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\FormattingExtensions.cs (4)
24if (node.Parent == null) 29if (node.Parent.Span != node.Span) 31return node.Parent; 34return GetParentWithBiggerSpan(node.Parent);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\BlockFacts\IBlockFactsExtensions.cs (3)
15for (var current = node; current is not null; current = current.Parent) 17if (blockFacts.IsStatementContainer(current.Parent)) 18return current.Parent;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\SelectedMembers\AbstractSelectedMembers.cs (2)
69.Where(m => m.Parent is TTypeDeclarationSyntax) 82var containingType = (TTypeDeclarationSyntax)firstMember.Parent;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\SyntaxFacts\ISyntaxFactsExtensions.cs (10)
300while (syntaxFacts.IsParenthesizedExpression(node?.Parent)) 301node = node.Parent; 612var parent = node?.Parent; 621var parent = node?.Parent; 631var parent = node?.Parent; 641if (!syntaxFacts.IsAttribute(node?.Parent)) 644syntaxFacts.GetPartsOfAttribute(node.Parent, out var name, out _); 650var parent = node?.Parent; 660var parent = node?.Parent; 670var parent = node?.Parent;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\AbstractSpeculationAnalyzer.cs (6)
543RoslynDebug.AssertNotNull(currentOriginalNode.Parent); 544RoslynDebug.AssertNotNull(currentReplacedNode.Parent); 548currentOriginalNode = currentOriginalNode.Parent; 549currentReplacedNode = currentReplacedNode.Parent; 573Debug.Assert(previousOriginalNode == null || previousOriginalNode.Parent == currentOriginalNode); 574Debug.Assert(previousReplacedNode == null || previousReplacedNode.Parent == currentReplacedNode);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\CommonFormattingHelpers.cs (1)
341node = node.Parent;
Microsoft.CodeAnalysis.CodeStyle.Fixes (42)
src\Analyzers\Core\CodeFixes\AddAnonymousTypeMemberName\AbstractAddAnonymousTypeMemberNameCodeFixProvider.cs (3)
64if (node.Parent is not TAnonymousObjectMemberDeclaratorSyntax declarator) 75if (declarator.Parent is not TAnonymousObjectInitializer) 126var anonymousType = current.Parent;
src\Analyzers\Core\CodeFixes\AddExplicitCast\AbstractAddExplicitCastCodeFixProvider.cs (3)
129if (syntaxFacts.IsParenthesizedExpression(currentTarget.Parent)) 131return (currentTarget.Parent, currentTarget.Parent.ReplaceNode(currentTarget, currentReplacement).WithAdditionalAnnotations(Simplifier.Annotation));
src\Analyzers\Core\CodeFixes\AddParameter\AbstractAddParameterCodeFixProvider.cs (1)
73for (var node = initialNode; node != null; node = node.Parent)
src\Analyzers\Core\CodeFixes\GenerateVariable\AbstractGenerateVariableService.State.cs (1)
439if (syntaxKinds.AddressOfExpression == SimpleNameOrMemberAccessExpressionOpt.Parent?.RawKind)
src\Analyzers\Core\CodeFixes\NamingStyle\NamingStyleCodeFixProvider.cs (1)
67node = node.Parent;
src\Analyzers\Core\CodeFixes\RemoveUnusedParametersAndValues\AbstractRemoveUnusedValuesCodeFixProvider.cs (15)
173!syntaxFacts.IsExpressionStatement(node.Parent)) 182else if (syntaxFacts.IsDeclarationPattern(node.Parent) || 183syntaxFacts.IsRecursivePattern(node.Parent) || 184syntaxFacts.IsListPattern(node.Parent)) 482if (declaredLocal == null && node.Parent is TCatchStatementSyntax) 484declaredLocal = semanticModel.GetDeclaredSymbol(node.Parent, cancellationToken) as ILocalSymbol; 519if (node.Parent is TStatementSyntax) 522nodesToRemove.Add(node.Parent); 524else if (node.Parent is TExpressionSyntax && node.Parent.Parent is TExpressionStatementSyntax) 527nodesToRemove.Add(node.Parent.Parent); 695n => n.Parent is TSwitchCaseBlockSyntax || 696blockFacts.IsExecutableBlock(n.Parent) &&
src\Analyzers\Core\CodeFixes\SimplifyInterpolation\AbstractSimplifyInterpolationCodeFixProvider.cs (1)
63interpolationSyntax.Parent is TInterpolatedStringExpressionSyntax interpolatedString)
src\Analyzers\Core\CodeFixes\UseCompoundAssignment\AbstractUseCompoundAssignmentCodeFixProvider.cs (1)
103if (syntaxFacts.IsSimpleAssignmentStatement(currentAssignment.Parent))
src\Analyzers\Core\CodeFixes\UseConditionalExpression\AbstractUseConditionalExpressionCodeFixProvider.cs (2)
165while (sourceSyntax is { Parent.RawKind: var kind } && kind == suppressKind) 166sourceSyntax = sourceSyntax.Parent;
src\Analyzers\Core\CodeFixes\UseNullPropagation\AbstractUseNullPropagationCodeFixProvider.cs (5)
184var isElseIf = syntaxFacts.IsElseClause(ifStatement.Parent); 199TryGetBlock(whenTrueStatement.Parent, out var block)) 217nodeToBeReplaced = ifStatement.Parent!; 240if (syntaxFacts.IsSimpleMemberAccessExpression(match.Parent)) 242var memberAccess = match.Parent;
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeRefactorings\AbstractRefactoringHelpersService.cs (7)
284leftNode = leftNode?.Parent; 323rightNode = rightNode?.Parent; 378selectionNode = selectionNode.Parent; 409if (syntaxFacts.IsLocalDeclarationStatement(node) || syntaxFacts.IsLocalDeclarationStatement(node.Parent)) 411var localDeclarationStatement = syntaxFacts.IsLocalDeclarationStatement(node) ? node : node.Parent!; 471if (syntaxFacts.IsExpressionStatement(node.Parent)) 473yield return node.Parent;
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\SyntaxEditorExtensions.cs (2)
206n.Parent == null, 214n.Parent == null,
Microsoft.CodeAnalysis.CSharp (136)
Binder\Binder.IdentifierUsedAsValueFinder.cs (2)
123Debug.Assert(targetNode.Parent is not null); 124targetNode = targetNode.Parent;
Binder\Binder_Expressions.cs (6)
4577SyntaxNode equalsValueClause = node.Parent; 4584SyntaxNode variableDeclarator = equalsValueClause.Parent; 4591SyntaxNode variableDeclaration = variableDeclarator.Parent; 4598variableDeclaration.Parent.IsKind(SyntaxKind.LocalDeclarationStatement) || 4599variableDeclaration.Parent.IsKind(SyntaxKind.ForStatement); 9135if (expr.Syntax.Parent is ConditionalAccessExpressionSyntax conditional &&
Binder\Binder_QueryErrors.cs (1)
33for (SyntaxNode node = queryClause; ; node = node.Parent)
Binder\Binder_Statements.cs (2)
3375if (syntax.Parent is QueryClauseSyntax || syntax.Parent is SelectOrGroupClauseSyntax)
Binder\Binder_Symbols.cs (2)
2312node = node.Parent; 2612var code = (where.Parent is QueryClauseSyntax) ? ErrorCode.ERR_TypeVarNotFoundRangeVariable : ErrorCode.ERR_TypeVarNotFound;
Binder\Binder_TupleOperators.cs (1)
318Location location = ((BoundTupleExpression)(useRight ? right : left)).Arguments[i].Syntax.Parent.Location;
Binder\BinderFactory.BinderFactoryVisitor.cs (3)
87return VisitCore(parent.Parent); 1091if (node.IsKind(SyntaxKind.UsingDirective) && node.Parent == containingNode) 1096node = node.Parent;
Binder\BinderFactory.cs (2)
116if ((!InScript || node.Kind() != SyntaxKind.CompilationUnit) && node.Parent != null) 118node = node.Parent;
Compilation\CSharpSemanticModel.cs (1)
3975parentSyntax == boundNode.Syntax.Parent &&
Compilation\SpeculativeSemanticModelWithMemberModel.cs (2)
154attributeOrParameter.Parent is null || 160MemberSemanticModel containing = GetEnclosingMemberModel(attributeOrParameter.Parent);
Compilation\SyntaxTreeSemanticModel.cs (8)
374var variableDecl = type.ModifyingScopedOrRefTypeOrSelf().Parent as VariableDeclarationSyntax; 991for (SyntaxNode curr = node; curr != null; curr = curr.Parent) 2415return (node) => node.Kind() != SyntaxKind.GlobalStatement || node.Parent != unit; 2420return (node) => node.Parent != unit || node.Kind() == SyntaxKind.GlobalStatement; 2442if (node.Parent == typeDeclaration) 2446else if (node.Parent is BaseListSyntax baseList) 2450else if (node.Parent is PrimaryConstructorBaseTypeSyntax baseType && baseType == typeDeclaration.PrimaryConstructorBaseTypeIfClass) 2478if (node.Parent == typeDeclaration)
FlowAnalysis\UnassignedAddressTakenVariablesWalker.cs (2)
54if (node.Parent.Kind() == SyntaxKind.AddressOfExpression) 56_result.Add((PrefixUnaryExpressionSyntax)node.Parent);
Lowering\AsyncRewriter\AsyncExceptionHandlerRewriter.cs (1)
549var tryStatementSyntax = (TryStatementSyntax)node.Syntax.Parent;
Lowering\ClosureConversion\ClosureConversion.cs (2)
1767var curSyntax = lambdaSyntax.Parent; 1782curSyntax = curSyntax.Parent;
Lowering\Instrumentation\CodeCoverageInstrumenter.cs (3)
417Debug.Assert(returnStatement.ExpressionOpt.Syntax.Parent != null); 419SyntaxKind parentKind = returnStatement.ExpressionOpt.Syntax.Parent.Kind(); 571SyntaxNode? parent = body.Parent;
Lowering\Instrumentation\DebugInfoInjector.cs (5)
141Debug.Assert(syntax is { Parent: { Parent: { } } }); 142var grandparent = syntax.Parent.Parent; 199SyntaxNode? parent = original.Syntax.Parent;
Lowering\LocalRewriter\LocalRewriter_FixedStatement.cs (6)
83SyntaxNode? node = boundFixed.Syntax.Parent; 135Debug.Assert(node.Parent is TryStatementSyntax); 136if (((TryStatementSyntax)node.Parent).Finally != null) 143node = node.Parent; 145node = node.Parent; 153node = node.Parent;
Lowering\LocalRewriter\LocalRewriter_PatternSwitchStatement.cs (1)
45SyntaxNode? section = d.Syntax.Parent;
Operations\CSharpOperationFactory.cs (3)
2124Debug.Assert(node.Parent != null); 2125varStatement = node.Parent; 2127varDeclaration = node.Parent;
Operations\CSharpOperationFactory_Methods.cs (3)
40(SyntaxNode syntax, bool isImplicit) = expression.Syntax is { Parent: ArgumentSyntax or AttributeArgumentSyntax } ? (expression.Syntax.Parent, expression.WasCompilerGenerated) : (value.Syntax, true); 464var assignmentSyntax = value.Syntax?.Parent ?? syntax;
Parser\Blender.cs (1)
165parent = parent.Parent)
Parser\Blender.Cursor.cs (3)
111if (node.Parent == null) 116var children = node.Parent.ChildNodesAndTokens(); 149var redToken = new CodeAnalysis.SyntaxToken(node.Parent, greenToken, node.Position, _indexInParent);
src\Compilers\CSharp\CSharpAnalyzerDriver\CSharpDeclarationComputer.cs (1)
201if (node.Parent is BasePropertyDeclarationSyntax parentProperty)
SymbolDisplay\SymbolDisplayVisitor_Minimal.cs (4)
204startNode = startNode.Parent!.Parent!; 208startNode = startNode.Parent; 232startNode = startNode.Parent;
Symbols\Source\SourceLocalSymbol.cs (6)
171nodeToBind.Kind() == SyntaxKind.ArgumentList && (nodeToBind.Parent is ConstructorInitializerSyntax || nodeToBind.Parent is PrimaryConstructorBaseTypeSyntax) || 745nodeToBind.Kind() == SyntaxKind.ArgumentList && (nodeToBind.Parent is ConstructorInitializerSyntax || nodeToBind.Parent is PrimaryConstructorBaseTypeSyntax) || 776switch (_nodeToBind.Parent) 785throw ExceptionUtilities.UnexpectedValue(_nodeToBind.Parent);
Symbols\Tuples\TupleTypeSymbol.cs (1)
300diagnostics.Add(ErrorCode.WRN_TupleLiteralNameMismatch, literal.Arguments[i].Syntax.Parent!.Location, sourceName, destination);
Syntax\CSharpSyntaxNode.cs (1)
129return (CSharpSyntaxNode?)base.Parent;
Syntax\LambdaUtilities.cs (15)
40return !node.Parent.IsKind(SyntaxKind.QueryExpression); 53Debug.Assert(lambdaBody.Parent is object); 54var lambda = lambdaBody.Parent; 60lambda = lambda.Parent; 73Debug.Assert(oldBody.Parent is object); 103var oldJoin = (JoinClauseSyntax)oldBody.Parent; 109var oldGroup = (GroupClauseSyntax)oldBody.Parent; 141var parent = node?.Parent; 298if (node.Parent.IsKind(SyntaxKind.QueryExpression)) 440if (node.Parent != null) 442switch (node.Parent.Kind()) 448SeparatedSyntaxList<ExpressionSyntax> incrementors = ((ForStatementSyntax)node.Parent).Incrementors; 466if (node is ExpressionSyntax && node.Parent != null && node.Parent.Parent == null)
Syntax\SyntaxFacts.cs (13)
24var p = node.Parent as AliasQualifiedNameSyntax; 30var parent = node.Parent; 47var p = node.Parent as AttributeSyntax; 283var parent1 = node.Parent; 289var parent2 = parent1.Parent; 300var parent3 = parent2.Parent; 316var parent4 = parent3.Parent; 345var current = node.Parent; 348while (current != null && (current.IsKind(ParenthesizedExpression) || current.IsKind(CastExpression))) current = current.Parent; 350current = current.Parent; 352current = current.Parent; 354current = current.Parent; 455parent = node.ModifyingScopedOrRefTypeOrSelf().Parent as DeclarationExpressionSyntax;
Syntax\SyntaxNodeExtensions.cs (10)
150if (node.Parent.IsKind(SyntaxKind.CastExpression)) 152node = node.Parent; 155while (node.Parent.IsKind(SyntaxKind.ConditionalExpression)) 157node = node.Parent; 160SyntaxNode? parentNode = node.Parent; 172SyntaxNode? variableDeclarator = parentNode.Parent; 175variableDeclarator.Parent.IsKind(SyntaxKind.VariableDeclaration); 180return parentNode.Parent.IsKind(SyntaxKind.ExpressionStatement); 301SyntaxNode? parentNode = syntax.Parent; 306parentNode = parentNode.Parent;
Syntax\SyntaxNodeRemover.cs (4)
326Debug.Assert(node.Parent is object); 346this.AddDirectives(node.Parent, GetRemovedSpan(span, fullSpan)); 366Debug.Assert(node.Parent is object); 380this.AddDirectives(node.Parent, GetRemovedSpan(span, fullSpan));
Syntax\SyntaxNormalizer.cs (21)
202if (IsAccessorListWithoutAccessorsWithBlockBody(currentToken.Parent?.Parent)) 251if (currentToken.Parent is AttributeListSyntax && currentToken.Parent.Parent is not ParameterSyntax) 301return (nextToken.Parent is AttributeListSyntax && !(nextToken.Parent.Parent is ParameterSyntax)) ? 1 : 0; 370currentTokenParent?.Parent is AnonymousFunctionExpressionSyntax || 383if (currentTokenParent?.Parent is PropertyDeclarationSyntax property && IsSingleLineProperty(property) && 434IsAccessorListWithoutAccessorsWithBlockBody(currentToken.Parent.Parent)) 622IsAccessorListWithoutAccessorsWithBlockBody(next.Parent.Parent)) 659token.Parent.Parent?.Parent is not UsingDirectiveSyntax) 686if (token.Parent.Parent?.Kind() is not SyntaxKind.TypeArgumentList and not SyntaxKind.UsingDirective) 883if (next is { RawKind: (int)SyntaxKind.OpenParenToken, Parent.Parent: ParenthesizedLambdaExpressionSyntax lambda } && 1319else if (node.Parent != null) 1321if (node.Parent.IsKind(SyntaxKind.CompilationUnit)) 1326int parentDepth = GetDeclarationDepth(node.Parent); 1328if (node.Parent.Kind() is SyntaxKind.GlobalStatement or SyntaxKind.FileScopedNamespaceDeclaration) 1333if (node.IsKind(SyntaxKind.IfStatement) && node.Parent.IsKind(SyntaxKind.ElseClause)) 1338if (node.Parent is BlockSyntax) 1343if (node is { Parent: InitializerExpressionSyntax or AnonymousObjectMemberDeclaratorSyntax } || 1346if (!IsSingleLineInitializerContext(node.Parent)) 1408var currentParent = node.Parent; 1425currentParent = currentParent.Parent;
Microsoft.CodeAnalysis.CSharp.CodeStyle (434)
src\Analyzers\CSharp\Analyzers\AddAccessibilityModifiers\CSharpAddAccessibilityModifiers.cs (1)
59if (member.Parent is InterfaceDeclarationSyntax)
src\Analyzers\CSharp\Analyzers\AddRequiredParentheses\CSharpAddRequiredExpressionParenthesesDiagnosticAnalyzer.cs (4)
79=> binaryLike.Parent is ConstantPatternSyntax 80? binaryLike.Parent.Parent as ExpressionSyntax 81: binaryLike.Parent as ExpressionSyntax;
src\Analyzers\CSharp\Analyzers\AddRequiredParentheses\CSharpAddRequiredPatternParenthesesDiagnosticAnalyzer.cs (1)
43=> binaryLike.Parent as PatternSyntax;
src\Analyzers\CSharp\Analyzers\ConvertProgram\ConvertProgramAnalysis_TopLevelStatements.cs (1)
61methodDeclaration.Parent is not TypeDeclarationSyntax containingTypeDeclaration ||
src\Analyzers\CSharp\Analyzers\ConvertSwitchStatementToExpression\ConvertSwitchStatementToExpressionDiagnosticAnalyzer.Analyzer.cs (1)
65if (declaration.Parent == node.Parent && declarator.Initializer is null)
src\Analyzers\CSharp\Analyzers\ConvertTypeofToNameof\CSharpConvertTypeOfToNameOfDiagnosticAnalyzer.cs (1)
37return node is TypeOfExpressionSyntax { Parent: MemberAccessExpressionSyntax } typeofExpression &&
src\Analyzers\CSharp\Analyzers\InlineDeclaration\CSharpInlineDeclarationDiagnosticAnalyzer.cs (9)
97if (argumentNode.Parent is not ArgumentListSyntax argumentList) 102var invocationOrCreation = argumentList.Parent; 145var localDeclaration = localDeclarator.Parent as VariableDeclarationSyntax; 146if (localDeclaration?.Parent is not LocalDeclarationStatementSyntax localStatement) 179var enclosingBlockOfLocalStatement = GetEnclosingPseudoBlock(localStatement.Parent); 259return parent.Parent as CompilationUnitSyntax; 306for (var current = argumentExpression; current != null; current = current.Parent) 308if (current.Parent is LambdaExpressionSyntax lambda && 348? current.Parent
src\Analyzers\CSharp\Analyzers\NamingStyle\CSharpNamingStyleDiagnosticAnalyzer.cs (2)
33Parent: ParameterListSyntax 35Parent: RecordDeclarationSyntax
src\Analyzers\CSharp\Analyzers\NewLines\ArrowExpressionClausePlacement\ArrowExpressionClausePlacementDiagnosticAnalyzer.cs (1)
68if (arrowExpressionClause.Parent is AccessorDeclarationSyntax)
src\Analyzers\CSharp\Analyzers\NewLines\EmbeddedStatementPlacement\EmbeddedStatementPlacementDiagnosticAnalyzer.cs (2)
87var parent = statement.Parent; 110var blockParent = parent.Parent;
src\Analyzers\CSharp\Analyzers\QualifyMemberAccess\CSharpQualifyMemberAccessDiagnosticAnalyzer.cs (2)
44if (node.Parent is AssignmentExpressionSyntax { Parent: InitializerExpressionSyntax(SyntaxKind.ObjectInitializerExpression), Left: var left } &&
src\Analyzers\CSharp\Analyzers\RemoveUnnecessaryDiscardDesignation\CSharpRemoveUnnecessaryDiscardDesignationDiagnosticAnalyzer.cs (3)
55if (discard.Parent is DeclarationPatternSyntax declarationPattern) 59if (declarationPattern.Parent is not IsPatternExpressionSyntax) 81else if (discard.Parent is RecursivePatternSyntax recursivePattern)
src\Analyzers\CSharp\Analyzers\RemoveUnnecessaryLambdaExpression\CSharpRemoveUnnecessaryLambdaExpressionDiagnosticAnalyzer.cs (2)
256node1 = node1.Parent; 257node2 = node2.Parent;
src\Analyzers\CSharp\Analyzers\RemoveUnnecessaryNullableDirective\NullableImpactingSpanWalker.cs (4)
66if (node?.Parent is QualifiedNameSyntax qualifiedName 85if (node?.Parent is BaseNamespaceDeclarationSyntax) 91if (node.IsParentKind(SyntaxKind.NameEquals) && node.Parent.IsParentKind(SyntaxKind.UsingDirective)) 105while (node.Parent is QualifiedNameSyntax qualifiedName
src\Analyzers\CSharp\Analyzers\RemoveUnnecessaryParentheses\CSharpRemoveUnnecessaryExpressionParenthesesDiagnosticAnalyzer.cs (2)
55switch (parenthesizedExpression.Parent) 80case ConstantPatternSyntax constantPattern when constantPattern.Parent is IsPatternExpressionSyntax isPatternExpression:
src\Analyzers\CSharp\Analyzers\RemoveUnnecessaryParentheses\CSharpRemoveUnnecessaryPatternParenthesesDiagnosticAnalyzer.cs (2)
51if (parenthesizedPattern.Parent is not PatternSyntax) 60if (parenthesizedPattern.Parent is not BinaryPatternSyntax parentPattern)
src\Analyzers\CSharp\Analyzers\RemoveUnreachableCode\RemoveUnreachableCodeHelpers.cs (2)
18switch (firstUnreachableStatement.Parent) 29if (globalStatement.Parent is not CompilationUnitSyntax compilationUnit)
src\Analyzers\CSharp\Analyzers\RemoveUnusedMembers\CSharpRemoveUnusedMembersDiagnosticAnalyzer.cs (2)
41=> variableDeclarator.Parent is VariableDeclarationSyntax 43Parent: FieldDeclarationSyntax { Declaration.Variables.Count: 0 } or
src\Analyzers\CSharp\Analyzers\RemoveUnusedParametersAndValues\CSharpRemoveUnusedParametersAndValuesDiagnosticAnalyzer.cs (2)
69var statementAncestor = unusedSymbolWriteOperation.Syntax.FirstAncestorOrSelf<StatementSyntax>()?.Parent; 103if (unusedDefinition.Syntax.Parent is ForEachStatementSyntax forEachStatement &&
src\Analyzers\CSharp\Analyzers\SimplifyInterpolation\CSharpSimplifyInterpolationHelpers.cs (1)
22ConditionalExpressionSyntax { Parent: ParenthesizedExpressionSyntax parent } => parent,
src\Analyzers\CSharp\Analyzers\SimplifyPropertyPattern\SimplifyPropertyPatternHelpers.cs (1)
26Parent: PropertyPatternClauseSyntax,
src\Analyzers\CSharp\Analyzers\UseCollectionExpression\CSharpUseCollectionExpressionForArrayDiagnosticAnalyzer.cs (4)
150var isConcreteOrImplicitArrayCreation = initializer.Parent is ArrayCreationExpressionSyntax or ImplicitArrayCreationExpressionSyntax; 153if (!isConcreteOrImplicitArrayCreation && initializer.Parent is not EqualsValueClauseSyntax) 175var matches = initializer.Parent switch 189Debug.Assert(initializer.Parent is EqualsValueClauseSyntax);
src\Analyzers\CSharp\Analyzers\UseCollectionExpression\CSharpUseCollectionExpressionForBuilderDiagnosticAnalyzer.cs (6)
137if (invocationExpression.Parent is not EqualsValueClauseSyntax { Parent: VariableDeclaratorSyntax { Parent: VariableDeclarationSyntax { Parent: LocalDeclarationStatementSyntax localDeclarationStatement } } declarator }) 217identifierName.Parent is MemberAccessExpressionSyntax(SyntaxKind.SimpleMemberAccessExpression) memberAccess && 219memberAccess.Parent is InvocationExpressionSyntax { ArgumentList.Arguments.Count: 0 } invocationExpression &&
src\Analyzers\CSharp\Analyzers\UseCollectionExpression\CSharpUseCollectionExpressionForEmptyDiagnosticAnalyzer.cs (1)
42: memberAccess.Parent is InvocationExpressionSyntax invocation && IsCollectionEmptyAccess(semanticModel, invocation, cancellationToken)
src\Analyzers\CSharp\Analyzers\UseCollectionExpression\CSharpUseCollectionExpressionForFluentDiagnosticAnalyzer.cs (3)
80if (memberAccess.Parent is not InvocationExpressionSyntax invocation) 88if (invocation.Parent is MemberAccessExpressionSyntax { Parent: InvocationExpressionSyntax parentInvocation } parentMemberAccess &&
src\Analyzers\CSharp\Analyzers\UseCollectionExpression\UseCollectionExpressionHelpers.cs (17)
104if (topMostExpression.Parent is CastExpressionSyntax castExpression && castExpression.Type is IdentifierNameSyntax) 439if (locallyScopedExpression.Parent is ExpressionStatementSyntax) 444if (locallyScopedExpression.Parent is ReturnStatementSyntax or ArrowExpressionClauseSyntax) 447if (locallyScopedExpression.Parent is ArgumentSyntax argument) 457if (locallyScopedExpression.Parent is MemberAccessExpressionSyntax memberAccess && 460if (memberAccess.Parent is InvocationExpressionSyntax invocationExpression) 482if (locallyScopedExpression.Parent is ElementAccessExpressionSyntax elementAccess) 496if (locallyScopedExpression.Parent is EqualsValueClauseSyntax { Parent: VariableDeclaratorSyntax declarator }) 505if (locallyScopedExpression.Parent is AssignmentExpressionSyntax assignment && 585if (argument.Parent is not BaseArgumentListSyntax { Parent: ExpressionSyntax parentInvocation } argumentList) 659Contract.ThrowIfFalse(originalInitializer.Parent 783if (expression.WalkUpParentheses().Parent is not EqualsValueClauseSyntax 785Parent: VariableDeclaratorSyntax 788Parent.Parent: LocalDeclarationStatementSyntax localDeclarationStatement
src\Analyzers\CSharp\Analyzers\UseConditionalExpression\CSharpUseConditionalExpressionForReturnDiagnosticAnalyzer.cs (1)
39if (block.Syntax.Parent is UnsafeStatementSyntax or CheckedStatementSyntax)
src\Analyzers\CSharp\Analyzers\UseDeconstruction\CSharpUseDeconstructionDiagnosticAnalyzer.cs (3)
103if (variableDeclaration is not { Parent: LocalDeclarationStatementSyntax localDeclaration, Variables: [{ Initializer.Value: { } initializerValue } declarator] }) 110var searchScope = localDeclaration.Parent is GlobalStatementSyntax globalStatement 259if (identifierName.Parent is not MemberAccessExpressionSyntax memberAccess)
src\Analyzers\CSharp\Analyzers\UseImplicitObjectCreation\CSharpUseImplicitObjectCreationDiagnosticAnalyzer.cs (16)
86if (objectCreation.Parent is EqualsValueClauseSyntax 88Parent: VariableDeclaratorSyntax { Parent: VariableDeclarationSyntax { Type.IsVar: false } variableDeclaration } 101else if (objectCreation.Parent.IsKind(SyntaxKind.ArrowExpressionClause)) 103typeNode = objectCreation.Parent.Parent switch 110AccessorDeclarationSyntax(SyntaxKind.GetAccessorDeclaration) { Parent: AccessorListSyntax { Parent: BasePropertyDeclarationSyntax baseProperty } } => baseProperty.Type, 114else if (objectCreation.Parent is InitializerExpressionSyntax { Parent: ObjectCreationExpressionSyntax { Type: var collectionType } }) 123else if (objectCreation.Parent is InitializerExpressionSyntax(kind: SyntaxKind.ArrayInitializerExpression) 125Parent: EqualsValueClauseSyntax { Parent: VariableDeclaratorSyntax { Parent: VariableDeclarationSyntax arrayVariableDeclaration } } 130else if (objectCreation.Parent is InitializerExpressionSyntax { Parent: ArrayCreationExpressionSyntax { Type: var arrayCreationType } })
src\Analyzers\CSharp\Analyzers\UseInferredMemberName\CSharpUseInferredMemberNameDiagnosticAnalyzer.cs (2)
39if (nameColon.Parent is not ArgumentSyntax argument) 68if (nameEquals.Parent is not AnonymousObjectMemberDeclaratorSyntax anonCtor)
src\Analyzers\CSharp\Analyzers\UseLocalFunction\CSharpUseLocalFunctionDiagnosticAnalyzer.cs (12)
93if (localDeclaration.Parent is not BlockSyntax block) 216Parent: EqualsValueClauseSyntax 218Parent: VariableDeclaratorSyntax 220Parent: VariableDeclarationSyntax 222Parent: LocalDeclarationStatementSyntax declaration, 267if (nodeToCheck.Parent is BinaryExpressionSyntax) 274if (nodeToCheck.Parent is InvocationExpressionSyntax invocationExpression) 278else if (nodeToCheck.Parent is MemberAccessExpressionSyntax memberAccessExpression) 280if (memberAccessExpression.Parent is InvocationExpressionSyntax explicitInvocationExpression && 353if (anonymousFunction?.Parent is AssignmentExpressionSyntax(SyntaxKind.SimpleAssignmentExpression) assignment && 354assignment.Parent is ExpressionStatementSyntax expressionStatement && 355expressionStatement.Parent is BlockSyntax block)
src\Analyzers\CSharp\Analyzers\UseNameofInNullableAttribute\CSharpUseNameofInNullableAttributeDiagnosticAnalyzer.cs (4)
119var attributeList = attribute.Parent as AttributeListSyntax; 120var container = attributeList?.Parent; 124var parameterList = container.Parent as BaseParameterListSyntax; 125container = parameterList?.Parent;
src\Analyzers\CSharp\Analyzers\UsePatternCombinators\CSharpUsePatternCombinatorsDiagnosticAnalyzer.cs (1)
126return node.WalkUpParentheses().Parent switch
src\Analyzers\CSharp\Analyzers\UsePatternMatching\CSharpAsAndNullCheckDiagnosticAnalyzer.Analyzer.cs (1)
328if (statement.Parent is BlockSyntax block)
src\Analyzers\CSharp\Analyzers\UsePatternMatching\CSharpAsAndNullCheckDiagnosticAnalyzer.cs (2)
112var enclosingBlock = localStatement.Parent; 241if (identifierName.Parent is AssignmentExpressionSyntax assignmentExpression &&
src\Analyzers\CSharp\Analyzers\UsePatternMatching\CSharpIsAndCastCheckDiagnosticAnalyzer.cs (3)
96var ifStatementScope = ifStatement.Parent.IsKind(SyntaxKind.Block) 97? ifStatement.Parent 174if (!isExpression.Parent.IsKind(SyntaxKind.IfStatement, out ifStatement))
src\Analyzers\CSharp\Analyzers\UsePatternMatching\UsePatternMatchingHelpers.cs (5)
29if (asExpression.Parent is not ParenthesizedExpressionSyntax 32Parent: ConditionalAccessExpressionSyntax parentConditionalAccess 54if (conditionalAccessExpression.Parent is BinaryExpressionSyntax(SyntaxKind.EqualsExpression) parentBinaryExpression1 && 63else if (conditionalAccessExpression.Parent is 81else if (conditionalAccessExpression.Parent is IsPatternExpressionSyntax parentIsPatternExpression)
src\Analyzers\CSharp\Analyzers\UsePrimaryConstructor\CSharpUsePrimaryConstructorDiagnosticAnalyzer.cs (3)
125else if (nodeToRemove is VariableDeclaratorSyntax { Parent: VariableDeclarationSyntax { Parent: FieldDeclarationSyntax field } }) 315if (primaryConstructorDeclaration.Parent is not TypeDeclarationSyntax)
src\Analyzers\CSharp\Analyzers\UseSystemThreadingLock\CSharpUseSystemThreadingLockDiagnosticAnalyzer.cs (2)
118if (variableDeclarator.Parent is not VariableDeclarationSyntax { Parent: FieldDeclarationSyntax, Variables.Count: 1 })
src\Analyzers\CSharp\Analyzers\UseUtf8StringLiteral\UseUtf8StringLiteralDiagnosticAnalyzer.cs (2)
105else if (elements is [{ Syntax.Parent: ArgumentSyntax }, ..]) 110else if (elements is [{ Syntax.Parent: (kind: SyntaxKind.CollectionInitializerExpression) }, ..])
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\EmbeddedLanguages\VirtualChars\CSharpVirtualCharService.cs (1)
39if (token.Parent?.Parent is InterpolatedStringExpressionSyntax { StringStartToken.RawKind: (int)SyntaxKind.InterpolatedMultiLineRawStringStartToken })
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\ArgumentSyntaxExtensions.cs (3)
45if (argument.Parent is not BaseArgumentListSyntax argumentList || 46argumentList.Parent is null) 52var symbolInfo = semanticModel.GetSymbolInfo(argumentList.Parent, cancellationToken);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\AttributeArgumentSyntaxExtensions.cs (2)
33if (argument.Parent is not AttributeArgumentListSyntax argumentList) 36if (argumentList.Parent is not AttributeSyntax invocableExpression)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\DefaultExpressionSyntaxExtensions.cs (4)
40if (defaultExpression?.Parent is EqualsValueClauseSyntax equalsValueClause) 70equalsValueClause.Parent?.Parent is VariableDeclarationSyntax declaration) 74else if (equalsValueClause?.Parent is ParameterSyntax parameter)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\DirectiveSyntaxExtensions.cs (2)
21while (node.Parent != null || node is StructuredTriviaSyntax) 23node = node.Parent ?? node.ParentTrivia.Token.GetRequiredParent();
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\ExpressionSyntaxExtensions.cs (54)
23while (expression?.Parent is ParenthesizedExpressionSyntax parentExpr) 46=> expression.IsParentKind(SyntaxKind.NameMemberCref) && expression.Parent.IsParentKind(SyntaxKind.QualifiedCref); 49=> expression?.Parent is MemberAccessExpressionSyntax(SyntaxKind.SimpleMemberAccessExpression) memberAccess && memberAccess.Name == expression; 56return expression == (expression.Parent as MemberAccessExpressionSyntax)?.Name || 61=> expression?.Parent is MemberBindingExpressionSyntax memberBinding && 65=> expression?.Parent is QualifiedNameSyntax qualifiedName && qualifiedName.Right == expression; 68=> expression?.Parent is AliasQualifiedNameSyntax aliasName && aliasName.Name == expression; 99=> (expression?.Parent) is MemberAccessExpressionSyntax(SyntaxKind.SimpleMemberAccessExpression) memberAccess && 104(expression.Parent is MemberAccessExpressionSyntax memberAccess && memberAccess.Expression == expression); 107=> (expression?.Parent) is QualifiedNameSyntax qualifiedName && qualifiedName.Left == expression; 113=> expression?.Parent is InvocationExpressionSyntax invocation && 198=> expression?.Parent is ArgumentSyntax { RefOrOutKeyword: SyntaxToken(SyntaxKind.OutKeyword) } argument && 210while (expression?.Parent is ParenthesizedExpressionSyntax or PostfixUnaryExpressionSyntax(SyntaxKind.SuppressNullableWarningExpression)) 211expression = (ExpressionSyntax)expression.Parent; 213if (expression?.Parent is RefExpressionSyntax or 216refParent = expression.Parent; 225=> expression?.Parent is ArgumentSyntax { RefKindKeyword: SyntaxToken(SyntaxKind.InKeyword) }; 249if (expression.Parent != null) 283var parent = expr.Parent; 292if (parent.Parent?.Kind() == SyntaxKind.TupleExpression) 294expr = (TupleExpressionSyntax)parent.Parent; 338if (refParent.Parent is EqualsValueClauseSyntax { Parent: VariableDeclaratorSyntax { Parent: VariableDeclarationSyntax { Type: { } variableDeclarationType } } }) 356if (expression.Parent.IsKind(SyntaxKind.AddressOfExpression)) 367if (expression.Parent is MemberAccessExpressionSyntax { Parent: InvocationExpressionSyntax } memberAccess && 385if (expression.Parent is ArgumentSyntax) 400var nameEquals = expression?.Parent as NameEqualsSyntax; 406if (expression?.Parent is SyntaxNode parent) 422=> expression is IdentifierNameSyntax { Parent: NameColonSyntax }; 518return expression is { Parent.RawKind: not (int)SyntaxKind.ConditionalAccessExpression }; 521if (expression.Parent == null) 524switch (expression.Parent.Kind()) 554var parentConditionalAccessExpression = (ConditionalAccessExpressionSyntax)expression.Parent; 556!parentConditionalAccessExpression.Parent.IsKind(SyntaxKind.ConditionalAccessExpression); 561var isOrAsExpression = (BinaryExpressionSyntax)expression.Parent; 597if (expression.Parent is PrefixUnaryExpressionSyntax) 607while (topExpression.Parent is TypeSyntax typeSyntax) 621if (expression.Parent is PostfixUnaryExpressionSyntax or 640if ((expression.IsParentKind(SyntaxKind.NameEquals) && expression.Parent.IsParentKind(SyntaxKind.AttributeArgument)) || 650=> expression is { Parent: ArgumentSyntax { Parent: ArgumentListSyntax { Parent: InvocationExpressionSyntax invocation } } } && 902=> expression?.Parent is MemberAccessExpressionSyntax; 913var parent = topExpression.Parent; 945if (argument.Parent is TupleExpressionSyntax tupleExpression) 974for (SyntaxNode? current = returnStatement; current != null; current = current.Parent) 989if (equalsValue.Parent is VariableDeclaratorSyntax { Parent: VariableDeclarationSyntax { Type.IsVar: true } }) 1059if (initializerExpression.Parent is ArrayCreationExpressionSyntax arrayCreation) 1063if (initializerExpression.Parent is ImplicitArrayCreationExpressionSyntax) 1075if (initializerExpression.Parent is EqualsValueClauseSyntax equalsValue) 1079if (initializerExpression.Parent is StackAllocArrayCreationExpressionSyntax or ImplicitStackAllocArrayCreationExpressionSyntax)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\ParenthesizedExpressionSyntaxExtensions.cs (22)
29var nodeParent = node.Parent; 41? nodeParent.Parent as ExpressionSyntax 72if (nodeParent is EqualsValueClauseSyntax { Parent: VariableDeclaratorSyntax { Parent: VariableDeclarationSyntax varDecl } }) 326if (node.Parent is not ConstantPatternSyntax { Parent: IsPatternExpressionSyntax }) 506if (node?.Parent is CastExpressionSyntax castExpression) 564if (node.Parent is BinaryExpressionSyntax binaryExpression && 566(binaryExpression.IsParentKind(SyntaxKind.Argument) || binaryExpression.Parent is InitializerExpressionSyntax)) 618if (node.Parent is ArgumentSyntax argument) 620if (argument.Parent is ArgumentListSyntax argumentList) 629else if (node.Parent is InitializerExpressionSyntax initializer) 653if (node.Parent is ArgumentSyntax argument) 655if (argument.Parent is ArgumentListSyntax argumentList) 664else if (node.Parent is InitializerExpressionSyntax initializer) 702if (pattern is DiscardPatternSyntax && node.Parent is IsPatternExpressionSyntax) 717if (node.Parent is ParenthesizedPatternSyntax) 721if (node.Parent is IsPatternExpressionSyntax) 725if (node.Parent is SwitchExpressionArmSyntax) 729if (node.Parent is SubpatternSyntax) 733if (node.Parent is CasePatternSwitchLabelSyntax) 739return node.Parent is PatternSyntax patternParent &&
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SemanticModelExtensions.cs (29)
207if (type.Parent is BaseTypeSyntax baseType && 208baseType.Parent is BaseListSyntax baseList && 216else if (baseList.Types[0] == type.Parent) 225if (type?.Parent is VariableDeclarationSyntax variableDeclaration && 234type.Parent.IsParentKind(SyntaxKind.EqualsValueClause) && 235type.Parent.Parent.IsParentKind(SyntaxKind.VariableDeclarator) && 236type.Parent.Parent.Parent.IsParentKind(SyntaxKind.VariableDeclaration, out variableDeclaration) && 252if (type.Parent.Kind() 261type.Parent, cancellationToken).DeclaredAccessibility; 274if (type.IsParentKind(SyntaxKind.Parameter) && type.Parent.IsParentKind(SyntaxKind.ParameterList)) 276if (type.Parent.Parent.Parent?.Kind() 283type.Parent.Parent.Parent, cancellationToken).DeclaredAccessibility; 286if (type.Parent.Parent.IsParentKind(SyntaxKind.ConstructorDeclaration)) 288var symbol = semanticModel.GetDeclaredSymbol(type.Parent.Parent.Parent, cancellationToken); 381if (current.Parent is ForEachStatementSyntax foreachStatement && 388if (current.Parent is AnonymousObjectMemberDeclaratorSyntax { NameEquals: { } nameEquals } anonymousObjectMemberDeclarator && 433if (topExpression?.Parent is ArgumentSyntax argument) 440if (argument.Parent is BaseArgumentListSyntax argumentList) 443if (semanticModel.GetSymbolInfo(argumentList.Parent, cancellationToken).Symbol is IMethodSymbol member && index < member.Parameters.Length)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SimpleNameSyntaxExtensions.cs (6)
19return ((MemberAccessExpressionSyntax)name.Parent).Expression; 27return ((QualifiedNameSyntax)name.Parent).Left; 31return ((QualifiedCrefSyntax)name.Parent.Parent).Container; 52if (simpleName?.Parent is InvocationExpressionSyntax invocation && 59if (simpleName?.Parent is ElementAccessExpressionSyntax elementAccess &&
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\StatementSyntaxExtensions.cs (4)
40if (first.Parent.IsKind(SyntaxKind.GlobalStatement)) 41return second.Parent.IsKind(SyntaxKind.GlobalStatement); 43return first.Parent == second.Parent;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxNodeExtensions.cs (23)
43=> CodeAnalysis.CSharpExtensions.IsKind(node?.Parent, kind); 50result = (TNode)node.Parent!; 184if ((current?.Parent is MemberAccessExpressionSyntax(SyntaxKind.SimpleMemberAccessExpression) memberAccess && memberAccess.Name == current) || 185(current?.Parent is MemberBindingExpressionSyntax memberBinding && memberBinding.Name == current)) 187current = current.Parent; 201current.Parent is not ConditionalAccessExpressionSyntax) 203current = current.Parent; 233if (current?.Parent is ConditionalAccessExpressionSyntax conditional1 && 239if (current?.Parent is ConditionalAccessExpressionSyntax conditional2 && 259while (current?.Parent is ConditionalAccessExpressionSyntax conditional && 286=> node?.Parent is AssignmentExpressionSyntax(SyntaxKind.SimpleAssignmentExpression) assignment && 290=> node?.Parent is AssignmentExpressionSyntax assignment && assignment.Left == node; 293=> node?.Parent is AssignmentExpressionSyntax assignment && assignment.Right == node; 297return node?.Parent != null && 298node.Parent.IsCompoundAssignExpression() && 299((AssignmentExpressionSyntax)node.Parent).Left == node; 335for (var current = node; current != null; current = current.Parent) 358return !current.Parent.IsKind(SyntaxKind.CompilationUnit); 674=> node?.Parent is EqualsValueClauseSyntax { Parent: VariableDeclaratorSyntax } equalsValue && 690current = current.Parent; 792for (var current = node; current != null; current = current.Parent) 841for (var current = node; current != null; current = current.Parent)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\VariableDeclaratorExtensions.cs (1)
15if (declarator.Parent is VariableDeclarationSyntax variableDeclaration)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Engine\Trivia\CSharpTriviaFormatter.DocumentationCommentExteriorCommentRewriter.cs (1)
86currentParent = currentParent.Parent;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\FormattingHelpers.cs (14)
109if (token.Parent.IsKind(SyntaxKind.PositionalPatternClause) && token.Parent.Parent.IsKind(SyntaxKind.RecursivePattern)) 112return token.Parent.Parent.GetFirstToken() != token; 125=> token.Kind() == SyntaxKind.OpenParenToken && token.Parent.IsKind(SyntaxKind.ParameterList) && token.Parent.Parent.IsKind(SyntaxKind.ParenthesizedLambdaExpression); 134return node.Parent?.Kind() is SyntaxKind.SimpleLambdaExpression or SyntaxKind.ParenthesizedLambdaExpression; 203&& statementOrElse.Parent != null 204&& statementOrElse.Parent.IsEmbeddedStatementOwner(); 279token.Parent.Parent.IsKind(SyntaxKind.PropertyDeclaration); 383token.Parent?.Parent is QueryExpressionSyntax queryExpression && 391var parent = initializer.Parent; 415return anonymousObjectInitializer.Parent is AnonymousObjectCreationExpressionSyntax; 427var parent = initializer.Parent; 447var parent = anonymousObjectInitializer.Parent; 483return token.Parent.Parent is LabeledStatementSyntax; 530currentToken.Parent.Parent is DeclarationExpressionSyntax;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\AnchorIndentationFormattingRule.cs (2)
35if (block.Parent is null or BlockSyntax) 43block.Parent.GetFirstToken(includeZeroWidth: true),
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\BaseFormattingRule.cs (2)
179RoslynDebug.AssertNotNull(node.Parent); 182firstTokenOfNode = node.Parent.GetFirstToken(includeZeroWidth: true);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\ElasticTriviaFormattingRule.cs (1)
406if (parent.Parent is ParameterSyntax)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\IndentBlockFormattingRule.cs (9)
67if (node is TypeParameterConstraintClauseSyntax { Parent: { } declaringNode }) 108RoslynDebug.AssertNotNull(node.Parent); 109var switchStatement = (SwitchStatementSyntax)node.Parent; 188if (propertyPatternClause.Parent is RecursivePatternSyntax { Parent: { } recursivePatternParent }) 233if (node.IsKind(SyntaxKind.ArrayInitializerExpression) && node.Parent != null && node.Parent.IsKind(SyntaxKind.ArrayCreationExpression)) 257if (node.Parent is SwitchExpressionArmSyntax arm && arm.Pattern == node) 267if (node.Parent != null && node.Kind() is SyntaxKind.ListPattern or SyntaxKind.CollectionExpression)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\NewLineUserSettingFormattingRule.cs (7)
49var parentKind = node.Parent?.Kind(); 85&& previousToken.Parent!.Parent == currentToken.Parent.Parent) 165var currentTokenParentParent = currentToken.Parent.Parent; 277|| previousToken.Parent!.Parent != currentToken.Parent.Parent) 366var currentTokenParentParent = currentToken.Parent.Parent;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\SuppressFormattingRule.cs (3)
133var constructorDeclarationNode = constructorInitializerNode.Parent as ConstructorDeclarationSyntax; 386if (initializer?.Parent != null) 388AddInitializerSuppressOperations(list, initializer.Parent, initializer.Expressions);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\TokenBasedFormattingRule.cs (3)
211var attributeOwner = previousToken.Parent?.Parent; 240RoslynDebug.AssertNotNull(currentUsing.Parent); 242var usings = GetUsings(currentUsing.Parent);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\WrappingFormattingRule.cs (1)
150firstTokenOfNode = node.Parent!.GetFirstToken(includeZeroWidth: true);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Indentation\CSharpSmartTokenFormatter.cs (1)
75endToken.Parent.Parent?.Kind() is SyntaxKind.TryStatement or SyntaxKind.DoStatement;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SemanticFacts\CSharpSemanticFacts.cs (1)
340case IdentifierNameSyntax { Parent: PrimaryConstructorBaseTypeSyntax baseType }:
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpAccessibilityFacts.cs (6)
242if (vd.Variables.Count == 1 && vd.Parent == null) 255var vd = declaration.Parent as VariableDeclarationSyntax; 287if (declaration.Parent is not AttributeListSyntax parentList || parentList.Attributes.Count > 1) 323=> node?.Parent.IsKind(SyntaxKind.FieldDeclaration) ?? false; 326=> node?.Parent.IsKind(SyntaxKind.EventFieldDeclaration) ?? false; 329=> node?.Parent.IsKind(SyntaxKind.LocalDeclarationStatement) ?? false;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpBlockFacts.cs (2)
29=> statement.Parent switch 33GlobalStatementSyntax globalStatement => globalStatement.Parent,
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpSyntaxFacts.cs (30)
165=> node?.Parent is MemberAccessExpressionSyntax memberAccess && memberAccess.Name == node; 196=> node?.Parent is UsingDirectiveSyntax usingDirective && 246if (firstStatement.Parent == secondStatement.Parent) 249if (IsGlobalStatement(firstStatement.Parent) 250&& IsGlobalStatement(secondStatement.Parent) 251&& firstStatement.Parent.Parent == secondStatement.Parent.Parent) 265return node.Parent is BaseMethodDeclarationSyntax or 536if (semanticModel != null && token.Parent is BracketedArgumentListSyntax { Parent: ElementAccessExpressionSyntax elementAccessExpression }) 645node.Parent.IsParentKind(SyntaxKind.Subpattern); 657if (identifier.Parent.IsParentKind(SyntaxKind.WithInitializerExpression)) 659var withInitializer = identifier.Parent.GetRequiredParent(); 663else if (identifier.Parent.IsParentKind(SyntaxKind.ObjectInitializerExpression)) 665var objectInitializer = identifier.Parent.GetRequiredParent(); 686Parent: BaseObjectCreationExpressionSyntax or ArrayCreationExpressionSyntax or ImplicitArrayCreationExpressionSyntax 689creationExpression = node.Parent; 735node = node.Parent; 782var parent = node.GetAncestor<TypeDeclarationSyntax>() ?? node.Parent; 1009var parent = node.Parent; 1182=> node?.Parent?.Kind() is SyntaxKind.PostIncrementExpression or SyntaxKind.PreIncrementExpression; 1185=> node?.Parent?.Kind() is SyntaxKind.PostDecrementExpression or SyntaxKind.PreDecrementExpression; 1246node.Parent is AttributeListSyntax attributeList && 1275return node.Parent?.Parent?.Kind() is SyntaxKind.FieldDeclaration or SyntaxKind.EventFieldDeclaration; 1359=> node?.Parent is ForEachStatementSyntax foreachStatement && foreachStatement.Expression == node; 1402=> ((VariableDeclarationSyntax)((VariableDeclaratorSyntax)node).Parent!).Type; 1408=> node?.Parent is PropertyDeclarationSyntax propertyDeclaration && propertyDeclaration.Initializer == node;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Simplification\CSharpInferredMemberNameSimplifier.cs (3)
16if (node.NameColon == null || !node.Parent.IsKind(SyntaxKind.TupleExpression)) 26if (RemovalCausesAmbiguity(((TupleExpressionSyntax)node.Parent).Arguments, node)) 47if (RemovalCausesAmbiguity(((AnonymousObjectCreationExpressionSyntax)node.Parent!).Initializers, node))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Simplification\Simplifiers\CastSimplifier.cs (30)
125if (leftOrRightChild.Parent is BinaryExpressionSyntax(SyntaxKind.EqualsExpression or SyntaxKind.NotEqualsExpression) binary) 159if (castExpression.WalkUpParentheses().Parent is PrefixUnaryExpressionSyntax(SyntaxKind.BitwiseNotExpression) parent && 160parent.WalkUpParentheses().Parent is CastExpressionSyntax parentCast) 192if (isDefaultLiteralCast && castNode.WalkUpParentheses().Parent is PatternSyntax or CaseSwitchLabelSyntax) 364if (rewrittenConversion.IsExplicit && castNode.WalkUpParentheses().Parent is not InterpolationSyntax) 451if (castNode.WalkUpParentheses().Parent is MemberAccessExpressionSyntax memberAccessExpression) 484if (castNode.WalkUpParentheses().Parent is InvocationExpressionSyntax invocationExpression) 503if (castNode.WalkUpParentheses().Parent is BinaryExpressionSyntax(SyntaxKind.IsExpression) isExpression && 713if (castNode.WalkUpParentheses().Parent is not MemberAccessExpressionSyntax { Parent: InvocationExpressionSyntax } memberAccessExpression) 832if (parent.Parent is not ConditionalExpressionSyntax originalConditionalExpression) 1008if (parent.Parent is ConditionalExpressionSyntax conditionalExpression) 1078if (castNode.Parent is AssignmentExpressionSyntax assignmentExpression && 1085else if (castNode.Parent is InitializerExpressionSyntax(SyntaxKind.ArrayInitializerExpression) arrayInitializer) 1091else if (castNode.Parent is EqualsValueClauseSyntax equalsValue && 1093equalsValue.Parent is VariableDeclaratorSyntax variableDeclarator) 1117for (SyntaxNode? current = expression; current != null; current = current.Parent) 1132for (SyntaxNode? currentOld = castNode.WalkUpParentheses().Parent, currentNew = rewrittenExpression.WalkUpParentheses().Parent; 1134currentOld = currentOld.Parent, currentNew = currentNew.Parent) 1188for (SyntaxNode? currentOld = castNode.WalkUpParentheses().Parent, currentNew = rewrittenExpression.WalkUpParentheses().Parent; 1190currentOld = currentOld.Parent, currentNew = currentNew.Parent) 1218for (SyntaxNode? currentOld = castNode.WalkUpParentheses().Parent, currentNew = rewrittenExpression.WalkUpParentheses().Parent; 1220currentOld = currentOld.Parent, currentNew = currentNew.Parent) 1494if (castNode.WalkUpParentheses().Parent is InterpolationSyntax)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\FormattingRangeHelper.cs (9)
187var containerOfList = parent.Parent; 203var parentOfParent = parent.Parent; 337RoslynDebug.AssertNotNull(previousToken.Parent?.Parent); 338var labelNode = previousToken.Parent.Parent; 381RoslynDebug.AssertNotNull(node.Parent); 383node = node.Parent; 390node = node.Parent; 400node = node.Parent; 442return token.Parent.Parent as MemberDeclarationSyntax;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\SpeculationAnalyzer.cs (6)
297Debug.Assert(previousOriginalNode == null || previousOriginalNode.Parent == currentOriginalNode); 298Debug.Assert(previousReplacedNode == null || previousReplacedNode.Parent == currentReplacedNode); 441var oldSwitchStatement = (SwitchStatementSyntax)originalCaseSwitchLabel.Parent.Parent; 442var newSwitchStatement = (SwitchStatementSyntax)newCaseSwitchLabel.Parent.Parent;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\TypeStyle\CSharpTypeStyleHelper.cs (2)
106var isSupportedParentKind = variableDeclaration.Parent is (kind: 122switch (declaration.Parent)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\TypeStyle\CSharpUseExplicitTypeHelper.cs (6)
72if (typeName.Parent is DeclarationExpressionSyntax declExpression && 85if (typeName.Parent is VariableDeclarationSyntax variableDeclaration && 86typeName.Parent.Parent is (kind: SyntaxKind.LocalDeclarationStatement or SyntaxKind.ForStatement or SyntaxKind.UsingStatement)) 99if ((variableDeclaration.Parent as LocalDeclarationStatementSyntax)?.IsConst == true) 104else if (typeName.Parent is ForEachStatementSyntax foreachStatement &&
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\TypeStyle\CSharpUseImplicitTypeHelper.cs (10)
112if (typeName.Parent is VariableDeclarationSyntax variableDeclaration && 113typeName.Parent.Parent is (kind: 119if (variableDeclaration.Parent is LocalDeclarationStatementSyntax { IsConst: true }) 146else if (typeName.Parent is ForEachStatementSyntax foreachStatement && 155else if (typeName.Parent is DeclarationExpressionSyntax declarationExpression && 217if (declarationExpression.Parent is not ArgumentSyntax 219Parent: ArgumentListSyntax { Parent: InvocationExpressionSyntax invocationExpression } 293if (n.Parent is MemberAccessExpressionSyntax memberAccessParent && memberAccessParent.Expression == n)
Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes (271)
src\Analyzers\CSharp\CodeFixes\AddExplicitCast\ArgumentFixer.cs (1)
31var newInvocation = newArgumentList.Parent!;
src\Analyzers\CSharp\CodeFixes\AddExplicitCast\AttributeArgumentFixer.cs (1)
31var newAttribute = (AttributeSyntax)newArgumentList.Parent!;
src\Analyzers\CSharp\CodeFixes\AddExplicitCast\CSharpAddExplicitCastCodeFixProvider.cs (4)
71&& targetArgument.Parent is ArgumentListSyntax argumentList 72&& argumentList.Parent is SyntaxNode invocationNode) 79&& targetAttributeArgument.Parent is AttributeArgumentListSyntax attributeArgumentList 80&& attributeArgumentList.Parent is AttributeSyntax attributeNode)
src\Analyzers\CSharp\CodeFixes\AddInheritdoc\AddInheritdocCodeFixProvider.cs (2)
76if (node is VariableDeclaratorSyntax { Parent.Parent: EventFieldDeclarationSyntax eventField })
src\Analyzers\CSharp\CodeFixes\AssignOutParameters\AbstractAssignOutParametersCodeFixProvider.cs (5)
68return location.Parent is BlockSyntax 69|| location.Parent is SwitchSectionSyntax 70|| location.Parent.IsEmbeddedStatementOwner(); 75return location.Parent is ArrowExpressionClauseSyntax or LambdaExpressionSyntax; 83for (var current = node; current != null; current = current.Parent)
src\Analyzers\CSharp\CodeFixes\AssignOutParameters\AssignOutParametersAtStartCodeFixProvider.cs (2)
40statement.Parent is BlockSyntax block && 42block.Parent == container)
src\Analyzers\CSharp\CodeFixes\ConvertNamespace\ConvertNamespaceTransform.cs (1)
138if (stringLiteral.GetRequiredParent() is not InterpolatedStringTextSyntax { Parent: InterpolatedStringExpressionSyntax { StringStartToken: (kind: SyntaxKind.InterpolatedMultiLineRawStringStartToken) } interpolatedString })
src\Analyzers\CSharp\CodeFixes\ConvertSwitchStatementToExpression\ConvertSwitchStatementToExpressionCodeFixProvider.cs (2)
99if (declaratorToRemoveNode.Parent is VariableDeclarationSyntax { Parent: LocalDeclarationStatementSyntax declStatement, Variables.Count: 1 })
src\Analyzers\CSharp\CodeFixes\ConvertToRecord\ConvertToRecordEngine.cs (2)
184(expression.Parent as AssignmentExpressionSyntax)?.Parent as ExpressionStatementSyntax)
src\Analyzers\CSharp\CodeFixes\FixIncorrectConstraint\CSharpFixIncorrectConstraintCodeFixProvider.cs (1)
41if (constraint.Parent is not TypeParameterConstraintClauseSyntax)
src\Analyzers\CSharp\CodeFixes\GenerateConstructor\CSharpGenerateConstructorService.cs (4)
89? (NameSyntax)simpleName.Parent 92if (fullName.Parent is ObjectCreationExpressionSyntax objectCreationExpression) 121? (NameSyntax)simpleName.Parent 124if (fullName.Parent is AttributeSyntax attribute)
src\Analyzers\CSharp\CodeFixes\GenerateDefaultConstructors\CSharpGenerateDefaultConstructorsService.cs (2)
44if (node is { Parent: BaseTypeSyntax { Parent: BaseListSyntax { Types: [var firstType, ..] } baseList } }) 46if (baseList.Parent is TypeDeclarationSyntax(SyntaxKind.ClassDeclaration or SyntaxKind.RecordDeclaration) parentTypeDecl &&
src\Analyzers\CSharp\CodeFixes\GenerateEnumMember\CSharpGenerateEnumMemberService.cs (2)
33simpleNameOrMemberAccessExpression = identifierName.Parent is MemberAccessExpressionSyntax memberAccess && memberAccess.Name == identifierName 40if (simpleNameOrMemberAccessExpression.Parent.Kind()
src\Analyzers\CSharp\CodeFixes\GenerateParameterizedMember\CSharpGenerateConversionService.cs (2)
31(node.Parent is AssignmentExpressionSyntax || node.Parent is EqualsValueClauseSyntax) &&
src\Analyzers\CSharp\CodeFixes\GenerateParameterizedMember\CSharpGenerateMethodService.cs (4)
89var memberAccess = simpleName?.Parent as MemberAccessExpressionSyntax; 90var conditionalMemberAccess = simpleName?.Parent?.Parent?.Parent as ConditionalAccessExpressionSyntax;
src\Analyzers\CSharp\CodeFixes\ImplementInterface\CSharpImplementInterfaceCodeFixProvider.cs (2)
29=> type.Parent is BaseTypeSyntax { Parent: BaseListSyntax } baseTypeParent && baseTypeParent.Type == type;
src\Analyzers\CSharp\CodeFixes\ImplementInterface\CSharpImplementInterfaceService.cs (7)
47if (node is TypeSyntax interfaceNode && interfaceNode.Parent is BaseTypeSyntax baseType && 51if (interfaceNode.Parent.Parent?.Parent.Kind() is 64classOrStructDecl = interfaceNode.Parent.Parent.Parent as TypeDeclarationSyntax;
src\Analyzers\CSharp\CodeFixes\InlineDeclaration\CSharpInlineDeclarationCodeFixProvider.cs (4)
108var declaration = (VariableDeclarationSyntax)declarator.Parent; 117var localDeclarationStatement = (LocalDeclarationStatementSyntax)declaration.Parent; 118var block = CSharpInlineDeclarationDiagnosticAnalyzer.GetEnclosingPseudoBlock(localDeclarationStatement.Parent); 175editor.RemoveNode(localDeclarationStatement.Parent is GlobalStatementSyntax globalStatement
src\Analyzers\CSharp\CodeFixes\InvokeDelegateWithConditionalAccess\InvokeDelegateWithConditionalAccessCodeFixProvider.cs (1)
99if (ifStatement.Parent.IsKind(SyntaxKind.ElseClause) &&
src\Analyzers\CSharp\CodeFixes\Iterator\CSharpChangeToIEnumerableCodeFixProvider.cs (4)
87var oldAccessor = node.Parent?.Parent as PropertyDeclarationSyntax; 93var oldIndexer = node.Parent?.Parent as IndexerDeclarationSyntax;
src\Analyzers\CSharp\CodeFixes\MakeLocalFunctionStatic\MakeLocalFunctionStaticCodeFixHelper.cs (1)
74if (identifierNode.Parent is InvocationExpressionSyntax invocation)
src\Analyzers\CSharp\CodeFixes\MakeMemberRequired\CSharpMakeMemberRequiredCodeFixProvider.cs (4)
50if (node is not (PropertyDeclarationSyntax or VariableDeclaratorSyntax { Parent.Parent: FieldDeclarationSyntax })) 125if (memberDeclarator is VariableDeclaratorSyntax { Parent.Parent: FieldDeclarationSyntax fieldDeclaration })
src\Analyzers\CSharp\CodeFixes\MakeMemberStatic\CSharpMakeMemberStaticCodeFixProvider.cs (4)
31if (node.IsKind(SyntaxKind.VariableDeclarator) && node.Parent is VariableDeclarationSyntax { Parent: FieldDeclarationSyntax or EventFieldDeclarationSyntax }) 33memberDeclaration = node.Parent.Parent;
src\Analyzers\CSharp\CodeFixes\MakeStatementAsynchronous\CSharpMakeStatementAsynchronousCodeFixProvider.cs (2)
98if (node.Parent is (kind: 103return node.Parent;
src\Analyzers\CSharp\CodeFixes\MakeStructMemberReadOnly\CSharpMakeStructMemberReadOnlyCodeFixProvider.cs (2)
53else if (declaration is AccessorDeclarationSyntax { Parent: AccessorListSyntax { Parent: BasePropertyDeclarationSyntax property } accessorList } accessor)
src\Analyzers\CSharp\CodeFixes\Nullable\CSharpDeclareAsNullableCodeFixProvider.cs (20)
60if (node.Parent is ArgumentSyntax) 64if (node.Parent is AssignmentExpressionSyntax) 117if (node.Parent is (kind: SyntaxKind.ReturnStatement or SyntaxKind.YieldReturnStatement)) 162if (node.Parent?.Parent?.Parent is VariableDeclarationSyntax variableDeclaration) 171if (node.Parent is AssignmentExpressionSyntax assignment) 177if (syntax is VariableDeclaratorSyntax { Parent: VariableDeclarationSyntax { Variables.Count: 1 } declaration }) 188if (syntax is VariableDeclaratorSyntax { Parent: VariableDeclarationSyntax { Variables.Count: 1 } declaration }) 213if (node.Parent is ArgumentSyntax argument && argument.Parent?.Parent is InvocationExpressionSyntax invocation) 240if (node.Parent?.Parent is PropertyDeclarationSyntax propertyDeclaration) 250if (node is VariableDeclaratorSyntax { Parent: VariableDeclarationSyntax { Parent: FieldDeclarationSyntax, Variables.Count: 1 } declarationSyntax }) 254if (node.Parent?.Parent is ParameterSyntax optionalParameter) 262node.Parent?.Parent is MethodDeclarationSyntax arrowMethod)
src\Analyzers\CSharp\CodeFixes\RemoveUnnecessaryDiscardDesignation\CSharpRemoveUnnecessaryDiscardDesignationCodeFixProvider.cs (1)
46if (declarationPattern.Parent is IsPatternExpressionSyntax isPattern)
src\Analyzers\CSharp\CodeFixes\RemoveUnreachableCode\CSharpRemoveUnreachableCodeCodeFixProvider.cs (1)
82if (statement.Parent?.Kind()
src\Analyzers\CSharp\CodeFixes\RemoveUnusedParametersAndValues\CSharpRemoveUnusedValuesCodeFixProvider.cs (4)
43=> declarator.Parent?.Parent as LocalDeclarationStatementSyntax; 57variableDeclarator.Parent is VariableDeclarationSyntax parent) 213if (originalCompoundAssignment.Parent.IsKind(SyntaxKind.ExpressionStatement))
src\Analyzers\CSharp\CodeFixes\UseCollectionExpression\CSharpCollectionExpressionRewriter.cs (3)
547Contract.ThrowIfNull(expression.Parent); 591for (var current = node; current != null; current = current.Parent) 814Contract.ThrowIfNull(expression.Parent);
src\Analyzers\CSharp\CodeFixes\UseCollectionInitializer\CSharpUseCollectionInitializerCodeFixProvider_CollectionInitializer.cs (1)
99Contract.ThrowIfNull(expression.Parent);
src\Analyzers\CSharp\CodeFixes\UseCompoundAssignment\CSharpUseCompoundAssignmentCodeFixProvider.cs (1)
52if (currentAssignment.Parent is ForStatementSyntax forStatement &&
src\Analyzers\CSharp\CodeFixes\UseConditionalExpression\CSharpUseConditionalExpressionForAssignmentCodeFixProvider.cs (1)
47if (ifStatement.Parent is ElseClauseSyntax &&
src\Analyzers\CSharp\CodeFixes\UseConditionalExpression\CSharpUseConditionalExpressionForReturnCodeFixProvider.cs (1)
34if (ifStatement.Parent is ElseClauseSyntax &&
src\Analyzers\CSharp\CodeFixes\UseDeconstruction\CSharpUseDeconstructionCodeFixProvider.cs (2)
74var variableDeclaration = (VariableDeclarationSyntax)variableDeclarator.Parent; 81variableDeclaration.Parent,
src\Analyzers\CSharp\CodeFixes\UseImplicitOrExplicitType\UseExplicitTypeCodeFixProvider.cs (4)
58var declarationContext = node.Parent; 62declarationContext = declarationContext.Parent; 92RoslynDebug.AssertNotNull(typeSyntax.Parent); 94var tupleTypeSymbol = GetConvertedType(semanticModel, typeSyntax.Parent, cancellationToken);
src\Analyzers\CSharp\CodeFixes\UseIndexOrRangeOperator\CSharpUseRangeOperatorCodeFixProvider.cs (1)
228while (expr?.Parent is CheckedExpressionSyntax parent)
src\Analyzers\CSharp\CodeFixes\UseNullPropagation\CSharpUseNullPropagationCodeFixProvider.cs (1)
49var elseClauseSyntax = (ElseClauseSyntax)ifStatement.Parent!;
src\Analyzers\CSharp\CodeFixes\UsePatternMatching\CSharpAsAndNullCheckCodeFixProvider.cs (4)
75if (statement.Parent is BlockSyntax or SwitchSectionSyntax) 77statementParentScopes.Add(statement.Parent); 110if (declarator.Parent is VariableDeclarationSyntax declaration && 111declaration.Parent is LocalDeclarationStatementSyntax localDeclaration &&
src\Analyzers\CSharp\CodeFixes\UsePrimaryConstructor\CSharpUsePrimaryConstructorCodeFixProvider.cs (2)
285if (nameSyntax.Parent is QualifiedNameSyntax qualifiedNameSyntax) 294else if (nameSyntax.Parent is MemberAccessExpressionSyntax memberAccessExpression)
src\Analyzers\CSharp\CodeFixes\UseSystemThreadingLock\CSharpUseSystemThreadingLockCodeFixProvider.cs (4)
90if (variableDeclarator.Parent is not VariableDeclarationSyntax { Parent: FieldDeclarationSyntax } variableDeclaration) 141if (expression.Parent is MemberAccessExpressionSyntax memberAccess && 147if (expression.Parent is not AssignmentExpressionSyntax assignment ||
src\Analyzers\CSharp\CodeFixes\UseThrowExpression\UseThrowExpressionCodeFixProvider.cs (1)
63if (throwStatementExpression.Parent is ThrowStatementSyntax throwStatement &&
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpCodeGenerationHelpers.cs (3)
280&& reusableSyntaxNode.Parent is VariableDeclarationSyntax variableDeclarationNode 281&& reusableSyntaxNode.Parent.Parent is FieldDeclarationSyntax fieldDeclarationNode)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpDeclarationComparer.cs (5)
345for (var node = parent; node != null; node = node.Parent) 388var xAccessibility = GetAccessibilityPrecedence(xModifiers, x.Parent ?? y.Parent); 389var yAccessibility = GetAccessibilityPrecedence(yModifiers, y.Parent ?? x.Parent);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeRefactorings\CSharpRefactoringHelpersService.cs (2)
97var declaration = declarator.Parent; 98if (declaration?.Parent is LocalDeclarationStatementSyntax localDeclarationStatement)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\CSharpSyntaxContext.cs (3)
393token.Parent.Parent is ParameterSyntax { Parent: ParameterListSyntax { Parent: RecordDeclarationSyntax record } }) 506FromClauseSyntax { Parent: QueryExpressionSyntax queryExpression } fromClause => queryExpression.FromClause == fromClause,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTokenExtensions.cs (20)
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() 180var container = token.Parent.Parent; 261var container = token.Parent.Parent; 262if (container is IncompleteMemberSyntax && container.Parent is CompilationUnitSyntax) 451targetToken.Parent.Parent.IsKind(SyntaxKind.Argument) && 452targetToken.Parent.Parent.Parent.IsKind(SyntaxKind.ArgumentList)) 454var owner = targetToken.Parent.Parent.Parent.Parent; 470if (targetToken.Parent?.Parent?.Kind() 591targetToken.Parent.Parent is AccessorDeclarationSyntax) 606targetToken.Parent.Parent is AccessorDeclarationSyntax) 618if (node?.Parent is TypeDeclarationSyntax(SyntaxKind.InterfaceDeclaration) typeDecl) 620else if (node?.Parent is DelegateDeclarationSyntax delegateDecl) 651targetToken.Parent.Parent.IsKind(SyntaxKind.TypeParameter) && 652IsGenericInterfaceOrDelegateTypeParameterList(targetToken.Parent.Parent.Parent))
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTreeExtensions.cs (48)
99parent = attributeList.Parent; 179token.Parent.Parent is BaseTypeDeclarationSyntax) 196token.Parent.Parent is BaseTypeDeclarationSyntax) 208token.Parent.Parent is MemberDeclarationSyntax) 228var container = token.Parent.Parent?.Parent; 492token.Parent.Parent is MemberDeclarationSyntax) 519var container = token.Parent?.Parent?.Parent; 778token.Parent is BaseListSyntax { Parent: not EnumDeclarationSyntax }) 949{ Parent: TypeSyntax { Parent.RawKind: (int)SyntaxKind.FunctionPointerParameter } } => true, 1008name.Parent?.Parent is ConditionalExpressionSyntax conditional && 1010conditional.Parent.IsParentKind(SyntaxKind.GlobalStatement)) 1099parameter3.Parent is ParameterListSyntax parameterList3 && 1114parameter4 = scopedIdentifierName.Parent as ParameterSyntax; 1118if (parameter4 is { Parent: ParameterListSyntax parameterList4 } && 1128=> parameterList.Parent switch 1267parent = token.Parent.Parent; 1269else if (token.IsKind(SyntaxKind.IdentifierToken) && token.Text == "scoped" && token.Parent is IdentifierNameSyntax scopedIdentifierName && scopedIdentifierName.Parent.IsKind(SyntaxKind.Parameter)) 1271parent = scopedIdentifierName.Parent.Parent; 1350leftToken.Parent.Parent is (kind: SyntaxKind.QualifiedName or SyntaxKind.SimpleMemberAccessExpression)) 1352var possibleCommaOrParen = FindTokenOnLeftOfNode(leftToken.Parent.Parent); 1434leftToken.Parent is SingleVariableDesignationSyntax { Parent: DeclarationPatternSyntax }; 1556if (node is CaseSwitchLabelSyntax { Parent: SwitchSectionSyntax }) 1584possibleCommaOrParen.Parent?.Parent is ParenthesizedLambdaExpressionSyntax parenthesizedLambda) 1652if (outer.Parent is ForEachStatementSyntax @foreach) 1673if (node.Parent.IsKind(SyntaxKind.ParenthesizedExpression)) 1675node = node.Parent; 1679if (node.Parent.IsKind(SyntaxKind.Argument) && node.Parent.Parent.IsKind(SyntaxKind.TupleExpression)) 1681node = node.Parent.Parent; 1693leftToken.Parent?.Parent is InvocationExpressionSyntax invocation) 2078equalsValue.Parent.IsParentKind(SyntaxKind.VariableDeclaration)) 2348type.Parent?.Parent is LocalDeclarationStatementSyntax declStatement) 2738=> token.Parent?.Parent is InvocationExpressionSyntax invocation && 2855nameExpr = (ExpressionSyntax)nameExpr.Parent!; 2866token.Parent.Parent is (kind: SyntaxKind.ObjectInitializerExpression or SyntaxKind.CollectionInitializerExpression)) 2875if (token.Parent.Parent is ArgumentSyntax { RefOrOutKeyword.RawKind: (int)SyntaxKind.OutKeyword }) 2911if (name.Parent != null) 2913switch (name.Parent.Kind()) 2916return ((QualifiedNameSyntax)name.Parent).Right == name; 2918return ((AliasQualifiedNameSyntax)name.Parent).Name == name; 2920return ((MemberAccessExpressionSyntax)name.Parent).Name == name;
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\NameSyntaxExtensions.cs (1)
54if (nameSyntax.Parent?.Kind()
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Indentation\CSharpIndentationService.cs (3)
133!argument.Parent.IsKind(SyntaxKind.ThisConstructorInitializer) && 196RoslynDebug.AssertNotNull(node.Parent); 199var baseToken = node.Parent.GetFirstToken(includeZeroWidth: true);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Indentation\CSharpIndentationService.Indenter.cs (9)
224(token.Parent.Parent is StatementSyntax || token.Parent.Parent is ElseClauseSyntax)); 226var embeddedStatementOwner = token.Parent.Parent; 229RoslynDebug.AssertNotNull(embeddedStatementOwner.Parent); 230embeddedStatementOwner = embeddedStatementOwner.Parent; 252token.Parent.Parent.IsKind(SyntaxKind.PropertyDeclaration)) 404if (queryExpressionClause.Parent is not QueryBodySyntax queryBody) 427RoslynDebug.AssertNotNull(queryBody.Parent); 428return indenter.GetIndentationOfToken(queryBody.Parent.GetFirstToken(includeZeroWidth: true));
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpReplaceDiscardDeclarationsWithAssignmentsService.cs (2)
102declarationPattern.Parent is IsPatternExpressionSyntax isPatternExpression) 210if (_localDeclarationStatement.Parent is BlockSyntax or SwitchSectionSyntax)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpSemanticFactsService.cs (1)
48if (SyntaxFacts.IsParameterList(container) && SyntaxFacts.IsLocalFunctionStatement(container.Parent))
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpTypeInferenceService.TypeInferrer.cs (54)
134var parent = node.Parent; 277if (argument is { Parent.Parent: ConstructorInitializerSyntax initializer }) 283if (argument is { Parent.Parent: InvocationExpressionSyntax invocation }) 289if (argument is { Parent.Parent: BaseObjectCreationExpressionSyntax creation }) 300if (argument is { Parent.Parent: PrimaryConstructorBaseTypeSyntax primaryConstructorBaseType }) 307if (argument is { Parent.Parent: ElementAccessExpressionSyntax elementAccess }) 318if (argument is { Parent: TupleExpressionSyntax tupleExpression }) 323if (argument.Parent.IsParentKind(SyntaxKind.ImplicitElementAccess) && 324argument.Parent.Parent.IsParentKind(SyntaxKind.SimpleAssignmentExpression) && 325argument.Parent.Parent.Parent.IsParentKind(SyntaxKind.ObjectInitializerExpression) && 326argument.Parent.Parent.Parent.Parent?.Parent is BaseObjectCreationExpressionSyntax objectCreation) 377if (argument.Parent != null) 379if (argument.Parent.Parent is AttributeSyntax attribute) 517switch (argumentList.Parent) 547if (attributeArgumentList.Parent is AttributeSyntax attribute) 743var argumentCount = argumentOpt?.Parent is BaseArgumentListSyntax baseArgumentList ? baseArgumentList.Arguments.Count : -1; 896if (bracketedArgumentList.Parent is ElementAccessExpressionSyntax elementAccess) 1214if (equalsValue?.Parent is VariableDeclaratorSyntax varDecl) 1217if (equalsValue?.Parent is PropertyDeclarationSyntax propertyDecl) 1221SemanticModel.GetDeclaredSymbol(equalsValue.Parent, CancellationToken) is IParameterSymbol parameter) 1356if (initializerExpression?.Parent is ImplicitArrayCreationExpressionSyntax implicitArray) 1384else if (initializerExpression?.Parent is EqualsValueClauseSyntax equalsValueClause) 1394else if (initializerExpression?.Parent is ArrayCreationExpressionSyntax arrayCreation) 1404else if (initializerExpression?.Parent is ObjectCreationExpressionSyntax objectCreation) 1428var assignExpression = (AssignmentExpressionSyntax)initializerExpression.Parent; 1497if (singleVariableDesignation.Parent is DeclarationPatternSyntax declarationPattern) 1635if (memberDeclarator.NameEquals != null && memberDeclarator.Parent is AnonymousObjectCreationExpressionSyntax) 1641var types = InferTypes((AnonymousObjectCreationExpressionSyntax)memberDeclarator.Parent); 1660return nameColon.Parent switch 1676return expressionColon.Parent switch 1728memberAccessExpression?.Parent is InvocationExpressionSyntax invocation && 1729memberAccessExpression.Parent.IsParentKind(SyntaxKind.AwaitExpression)) 1851if (nameColon.Parent is SubpatternSyntax subpattern) 1861if (expressionColon.Parent is SubpatternSyntax subpattern) 1878if (nameEquals.Parent is AttributeArgumentSyntax attributeArgumentSyntax) 2036=> InferTypeInMethodLikeDeclaration(arrowClause.Parent); 2072if (arm.Parent is SwitchExpressionSyntax switchExpression) 2120var switchStatement = (SwitchStatementSyntax)switchLabel.Parent.Parent; 2186variableDeclarator.Parent is not VariableDeclarationSyntax variableDeclaration) 2254var inferredFutureUsage = InferTypeBasedOnLaterUsage(symbol, afterNode: left.Parent);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\InitializeParameter\InitializeParameterHelpers.cs (1)
121if (node is IdentifierNameSyntax { Parent: not NameColonSyntax } identifierName &&
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Utilities\CSharpSimplificationHelpers.cs (1)
33var parent = parentOfToken.Parent;
Microsoft.CodeAnalysis.CSharp.EditorFeatures (17)
AutomaticCompletion\AutomaticLineEnderCommandHandler.cs (1)
302=> n is ArrowExpressionClauseSyntax ? n.Parent : n;
AutomaticCompletion\AutomaticLineEnderCommandHandler_Helpers.cs (8)
246if (ifStatementNode.Else == null && ifStatementNode.Parent is BlockSyntax) 314if (elseClauseNode.Parent is IfStatementSyntax { Parent: BlockSyntax }) 321elseClauseNode.Parent!, 565var parent = accessorDeclarationNode.Parent; 566var parentOfParent = parent?.Parent; 801&& accessorDeclarationNode.Parent != null 802&& accessorDeclarationNode.Parent.IsParentKind(SyntaxKind.PropertyDeclaration)
CompleteStatement\CompleteStatementCommandHandler.cs (7)
124Parent: EqualsValueClauseSyntax 126Parent: VariableDeclaratorSyntax 128Parent: VariableDeclarationSyntax 130Parent: FieldDeclarationSyntax or LocalDeclarationStatementSyntax 268currentNode = currentNode.Parent; 584for (var node = currentNode.Parent; node is not null; node = node.Parent)
StringCopyPaste\StringCopyPasteHelpers.cs (1)
245for (var current = node; current != null; current = current.Parent)
Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests (6)
Formatting\CodeCleanupTests.TestFixers.cs (2)
37Assumes.NotNull(node?.Parent); 38var newRoot = root.RemoveNode(node.Parent, SyntaxRemoveOptions.KeepNoTrivia);
RefactoringHelpers\RefactoringHelpersTests.cs (3)
1302await TestMissingAsync<ArgumentSyntax>(testText, n => n.Parent is TupleExpressionSyntax); 1336await TestAsync<ArgumentSyntax>(testText, n => n.Parent is TupleExpressionSyntax); 1784await TestAsync<ArgumentSyntax>(testText, predicate: n => n.Parent is TupleExpressionSyntax);
TypeInferrer\TypeInferrerTests.cs (1)
83currentNode = currentNode.Parent;
Microsoft.CodeAnalysis.CSharp.Emit.UnitTests (97)
CodeGen\CodeGenDeconstructTests.cs (61)
1511Assert.Equal("(x, y) = new C(1)", tuple1.Parent.ToString()); 1516Assert.Equal("(x, y) = new C(2)", tuple2.Parent.ToString()); 1564Assert.Equal("(x, y) = new C()", tuple.Parent.ToString()); 3630return (decl.Parent as DeclarationExpressionSyntax)?.Type; 3757var x34Var = (DeclarationExpressionSyntax)x3.Parent.Parent; 3851var x12Var = (DeclarationExpressionSyntax)x1.Parent.Parent; 4036var x12Var = (DeclarationExpressionSyntax)x1.Parent.Parent; 4144var x12Var = (DeclarationExpressionSyntax)x1.Parent.Parent; 4227var x12Var = (DeclarationExpressionSyntax)x1.Parent.Parent; 4338var x12Var = (DeclarationExpressionSyntax)x1.Parent.Parent; 4459var x23Var = (DeclarationExpressionSyntax)x2.Parent.Parent; 4605var x23Var = (DeclarationExpressionSyntax)x2.Parent.Parent; 5192var x23Var = (DeclarationExpressionSyntax)x2.Parent.Parent; 5739var x123Var = (DeclarationExpressionSyntax)x1.Parent.Parent; 5781var x123Var = (DeclarationExpressionSyntax)x1.Parent.Parent; 5911var declaration1 = (DeclarationExpressionSyntax)discard1.Parent; 5919var declaration2 = (DeclarationExpressionSyntax)discard2.Parent; 5925var declaration3 = (DeclarationExpressionSyntax)discard3.Parent.Parent; 6255Assert.Equal("(_, var x)", discard.Parent.Parent.ToString()); 6309var tuple1 = (TupleExpressionSyntax)discard1.Parent.Parent; 6339var tuple1 = (DeclarationExpressionSyntax)discard1.Parent.Parent; 6368Assert.Equal("(_, x)", discard.Parent.Parent.ToString()); 6398var declaration1 = (DeclarationExpressionSyntax)discard1.Parent.Parent; 6404Assert.Equal("(_, (var y, int z))", discard2.Parent.Parent.ToString()); 6444var tuple = (TupleExpressionSyntax)refs.ElementAt(0).Parent.Parent; 6861var declaration1 = (DeclarationExpressionSyntax)discard1.Parent; 6867var declaration2 = (DeclarationExpressionSyntax)discard2.Parent; 6872var tuple = (TupleExpressionSyntax)declaration1.Parent.Parent; 6933var nestedDeclaration = (DeclarationExpressionSyntax)discard2.Parent.Parent; 6940var tuple = (TupleExpressionSyntax)discard2.Parent.Parent.Parent.Parent; 6979var declaration1 = (DeclarationExpressionSyntax)discard1.Parent; 6988var declaration2 = (DeclarationExpressionSyntax)discard2.Parent; 6994Assert.Equal("_", discard3.Parent.ToString()); 7007var nestedDeclaration = (DeclarationExpressionSyntax)discard4.Parent.Parent; 8651Assert.Equal("((short, short))((int, int))(1L, 2L)", node.Parent.ToString()); 8653compilation.VerifyOperationTree(node.Parent, expectedOperationTree:
CodeGen\CodeGenTupleTest.cs (32)
8352Assert.Equal("(System.Int16 c, System.String d)?", model.GetTypeInfo(node.Parent).Type.ToTestDisplayString()); 8353Assert.Equal("(System.Int16 a, System.String b)?", model.GetTypeInfo(node.Parent).ConvertedType.ToTestDisplayString()); 8354Assert.Equal(Conversion.Identity, model.GetConversion(node.Parent)); 8457Assert.Equal("(System.Int16 c, System.String d)", model.GetTypeInfo(node.Parent).Type.ToTestDisplayString()); 8458Assert.Equal("(System.Int16 a, System.String b)?", model.GetTypeInfo(node.Parent).ConvertedType.ToTestDisplayString()); 8459Assert.Equal(ConversionKind.ImplicitNullable, model.GetConversion(node.Parent).Kind); 8484var node = nodes.OfType<ParenthesizedExpressionSyntax>().Single().Parent; 8518var node = nodes.OfType<ParenthesizedExpressionSyntax>().Single().Parent; 8601Assert.Equal("(System.Int32 c, System.String d)?", model.GetTypeInfo(node.Parent).Type.ToTestDisplayString()); 8602Assert.Equal("(System.Int32 a, System.String b)?", model.GetTypeInfo(node.Parent).ConvertedType.ToTestDisplayString()); 8603Assert.Equal(Conversion.Identity, model.GetConversion(node.Parent)); 8636Assert.Equal("(System.Int32 c, System.String d)", model.GetTypeInfo(node.Parent).Type.ToTestDisplayString()); 8637Assert.Equal("(System.Int32 a, System.String b)?", model.GetTypeInfo(node.Parent).ConvertedType.ToTestDisplayString()); 8638Assert.Equal(ConversionKind.ImplicitNullable, model.GetConversion(node.Parent).Kind); 8779Assert.Equal("(System.Int16 c, System.String d)", model.GetTypeInfo(node.Parent).Type.ToTestDisplayString()); 8780Assert.Equal("(System.Int16 a, System.String b)", model.GetTypeInfo(node.Parent).ConvertedType.ToTestDisplayString()); 8781Assert.Equal(Conversion.Identity, model.GetConversion(node.Parent)); 8852Assert.Equal("(System.Int16 c, System.String d)", model.GetTypeInfo(node.Parent).Type.ToTestDisplayString()); 8853Assert.Equal("(System.Int16 a, System.String b)", model.GetTypeInfo(node.Parent).ConvertedType.ToTestDisplayString()); 8854Assert.Equal(Conversion.Identity, model.GetConversion(node.Parent)); 8962Assert.Equal("(System.Int16 c, System.String d)", model.GetTypeInfo(node.Parent).Type.ToTestDisplayString()); 8963Assert.Equal("(System.Int16 a, System.String b)", model.GetTypeInfo(node.Parent).ConvertedType.ToTestDisplayString()); 8964Assert.Equal(Conversion.Identity, model.GetConversion(node.Parent)); 13975var nameofArg = ((InvocationExpressionSyntax)nameofNode.Parent).ArgumentList.Arguments.Single().Expression; 24184Assert.Equal("tuple.elem2 = 23", nodes[0].Parent.Parent.ToString()); 24187Assert.Equal("elem2 = 10", nodes[1].Parent.ToString()); 24190Assert.Equal("(tuple.elem2)", nodes[2].Parent.Parent.Parent.ToString()); 24193Assert.Equal("(elem2)", nodes[3].Parent.Parent.ToString());
CodeGen\ObjectAndCollectionInitializerTests.cs (4)
1110var (graph, symbol) = ControlFlowGraphVerifier.GetControlFlowGraph(node.Parent.Parent, model); 3592var (graph, symbol) = ControlFlowGraphVerifier.GetControlFlowGraph(node.Parent.Parent, model);
Microsoft.CodeAnalysis.CSharp.Emit2.UnitTests (35)
CodeGen\IndexAndRangeTests.cs (34)
129var (graph, symbol) = ControlFlowGraphVerifier.GetControlFlowGraph(node.Parent.Parent, model); 335var (graph, symbol) = ControlFlowGraphVerifier.GetControlFlowGraph(node.Parent.Parent, model); 422var (graph, symbol) = ControlFlowGraphVerifier.GetControlFlowGraph(node.Parent.Parent, model); 509var (graph, symbol) = ControlFlowGraphVerifier.GetControlFlowGraph(node.Parent.Parent, model); 693var (graph, symbol) = ControlFlowGraphVerifier.GetControlFlowGraph(node.Parent.Parent, model); 1618var (graph, symbol) = ControlFlowGraphVerifier.GetControlFlowGraph(node.Parent.Parent, model); 1811var (graph, symbol) = ControlFlowGraphVerifier.GetControlFlowGraph(node.Parent.Parent, model); 2347var (graph, symbol) = ControlFlowGraphVerifier.GetControlFlowGraph(node.Parent.Parent, model); 2681var (graph, symbol) = ControlFlowGraphVerifier.GetControlFlowGraph(node.Parent.Parent, model); 2844var (graph, symbol) = ControlFlowGraphVerifier.GetControlFlowGraph(node.Parent.Parent, model); 3022var (graph, symbol) = ControlFlowGraphVerifier.GetControlFlowGraph(node.Parent.Parent, model); 3136var (graph, symbol) = ControlFlowGraphVerifier.GetControlFlowGraph(node.Parent.Parent, model); 3357var (graph, symbol) = ControlFlowGraphVerifier.GetControlFlowGraph(node.Parent.Parent, model); 3644var (graph, symbol) = ControlFlowGraphVerifier.GetControlFlowGraph(node.Parent.Parent, model); 3734var (graph, symbol) = ControlFlowGraphVerifier.GetControlFlowGraph(node.Parent.Parent, model); 3820var (graph, symbol) = ControlFlowGraphVerifier.GetControlFlowGraph(node.Parent.Parent, model); 3893var (graph, symbol) = ControlFlowGraphVerifier.GetControlFlowGraph(node.Parent.Parent, model);
Emit\EditAndContinue\EditAndContinueTestBase.cs (1)
133node = node.Parent;
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (261)
Attributes\AttributeTests.cs (1)
5718var m = (ExpressionSyntax)cm.SyntaxTrees[0].GetCompilationUnitRoot().FindToken(index).Parent.Parent;
Diagnostics\DiagnosticAnalyzerTests.cs (1)
808switch (CSharpExtensions.Kind(context.Node.Parent))
FieldKeywordTests.cs (2)
10496Assert.Equal("return field;", expr.Parent.ToString()); 10530Assert.Equal("return field;", expr.Parent.ToString());
FlowAnalysis\FlowTestBase.cs (2)
206if (firstStatement != null && stmt.Span.End <= end && stmt.Parent == firstStatement.Parent)
Semantics\InlineArrayTests.cs (42)
2360Assert.Equal("b[c]", c.Parent.Parent.Parent.ToString()); 2395Assert.Equal("b[c]", c.Parent.Parent.Parent.ToString()); 2429Assert.Equal("b[c]", c.Parent.Parent.Parent.ToString()); 2509Assert.Equal("x.F[0]", f.Parent.Parent.ToString()); 2520var access = f.Parent.Parent; 6034Assert.Equal("x.F[^10]", f.Parent.Parent.ToString()); 6200Assert.Equal("x.F[..5]", f.Parent.Parent.ToString()); 6211var access = f.Parent.Parent; 8835var m3 = tree.GetRoot().DescendantNodes().OfType<IdentifierNameSyntax>().Where(m => m.Identifier.ValueText == "M3").Single().Parent; 8836Assert.Equal("M3()[0]", m3.Parent.ToString()); 8847var access = m3.Parent; 9204Assert.Equal("M3()[..]", m3.Parent.Parent.ToString()); 9206var typeInfo = model.GetTypeInfo(m3.Parent); 9211var symbolInfo = model.GetSymbolInfo(m3.Parent); 10548Assert.Equal("c.F[0]", f.Parent.Parent.ToString()); 10559var access = f.Parent.Parent; 11292Assert.Equal("c.F[..5]", f.Parent.Parent.ToString()); 11303var access = f.Parent.Parent; 15210Assert.Equal("=> x.F", f[^2].Parent.Parent.ToString()); 15217Assert.Equal("=> x.F", f[^1].Parent.Parent.ToString()); 16495var m3 = tree.GetRoot().DescendantNodes().OfType<IdentifierNameSyntax>().Where(m => m.Identifier.ValueText == "M3").First().Parent; 18593var forEachInfo = model.GetForEachStatementInfo((ForEachStatementSyntax)f.Parent); 18919var forEachInfo = model.GetForEachStatementInfo((ForEachStatementSyntax)f.Parent); 19256var forEachInfo = model.GetForEachStatementInfo((ForEachStatementSyntax)collection.Parent);
Semantics\OutVarTests.cs (40)
916Assert.Null(model.GetDeclaredSymbol((ArgumentSyntax)x2Ref.Parent)); 1090var dataFlowParent = decl.Parent.Parent.Parent as ExpressionSyntax; 1094if (isExecutableCode || !(decl.Parent.Parent.Parent is VariableDeclaratorSyntax)) 1096Assert.IsAssignableFrom<ConstructorInitializerSyntax>(decl.Parent.Parent.Parent); 1183var parent1 = ((VariableDeclarationSyntax)((VariableDeclaratorSyntax)parent).Parent).Parent; 1224switch (reference.Parent.Kind()) 1227if (((ArgumentSyntax)reference.Parent).RefOrOutKeyword.Kind() != SyntaxKind.OutKeyword) 1244if (((AssignmentExpressionSyntax)reference.Parent).Left != reference) 1290((methodDeclParent = containingReturnOrThrow.Parent.Parent as MethodDeclarationSyntax) == null || 1333switch (reference.Parent.Kind()) 1336if (((ArgumentSyntax)reference.Parent).RefOrOutKeyword.Kind() != SyntaxKind.None) 1353if (((AssignmentExpressionSyntax)reference.Parent).Left == reference) 1413Assert.Null(model.GetDeclaredSymbol((ArgumentSyntax)x2Ref.Parent)); 1648Assert.Null(model.GetDeclaredSymbol((ArgumentSyntax)x2Ref.Parent)); 18814var constructorDeclaration = (ConstructorDeclarationSyntax)context.Node.Parent; 20052Assert.Equal("System.Console.WriteLine(y)", yRef[2].Parent.Parent.Parent.ToString()); 32756var inFieldDeclaratorArgumentlist = declarator != null && declarator.Parent.Parent.Kind() != SyntaxKind.LocalDeclarationStatement && 32787var dataFlowParent = (ExpressionSyntax)decl.Parent.Parent.Parent; 32982var declaration1 = (DeclarationExpressionSyntax)discard1.Parent; 32991var declaration2 = (DeclarationExpressionSyntax)discard2.Parent; 33066var declaration1 = (DeclarationExpressionSyntax)discard1.Parent; 33082var declaration2 = (DeclarationExpressionSyntax)discard2.Parent; 33138var declaration1 = (DeclarationExpressionSyntax)discard1.Parent; 33180var declaration1 = (DeclarationExpressionSyntax)discard1.Parent; 33196var declaration2 = (DeclarationExpressionSyntax)discard2.Parent; 33244var declaration1 = (DeclarationExpressionSyntax)discard1.Parent; 33260var declaration2 = (DeclarationExpressionSyntax)discard2.Parent;
Semantics\ParamsCollectionTests.cs (2)
12555VerifyFlowGraph(comp, node.Parent.Parent, """
Semantics\PatternMatchingTestBase.cs (9)
37return tree.GetRoot().DescendantNodes().OfType<SingleVariableDesignationSyntax>().Where(p => p.Parent.Kind() == SyntaxKind.DeclarationPattern || p.Parent.Kind() == SyntaxKind.VarPattern); 99switch (designation.Parent) 151switch (designation.Parent) 266switch (designation.Parent) 292var inFieldDeclaratorArgumentlist = declarator != null && declarator.Parent.Parent.Kind() != SyntaxKind.LocalDeclarationStatement && 386if (designation.Parent is DeclarationPatternSyntax decl) 407else if (designation.Parent is VarPatternSyntax varp)
Semantics\PatternMatchingTests.cs (4)
4293var declaration1 = (DeclarationPatternSyntax)discard1.Parent; 4301var declaration2 = (VarPatternSyntax)discard2.Parent; 4307var declaration3 = (DeclarationPatternSyntax)discard3.Parent; 4314var declaration4 = (VarPatternSyntax)discard4.Parent;
Semantics\PatternMatchingTests_Global.cs (4)
6323Assert.True(x1Decl.Parent is VarPatternSyntax); 6352Assert.True(x1Decl.Parent is VarPatternSyntax); 6376var x1 = (DeclarationPatternSyntax)x1Decl.Parent; 6399var x1 = (DeclarationPatternSyntax)x1Decl.Parent;
Semantics\PatternMatchingTests_ListPatterns.cs (7)
3651typeInfo = model.GetTypeInfo(designation.Parent); 3688Assert.Equal(syntax, clause.Parent.Parent.ToString()); 3690var typeInfo = model.GetTypeInfo(clause.Parent); // inner {} pattern 3733typeInfo = model.GetTypeInfo(itemDesignation.Parent); 3748typeInfo = model.GetTypeInfo(sliceDesignation.Parent); 4421typeInfo = model.GetTypeInfo(designation.Parent);
Semantics\PatternMatchingTests2.cs (8)
2944checkType((CastExpressionSyntax)expr.Parent.Parent, "C", "C", ConversionKind.Identity); 2951checkType((CastExpressionSyntax)expr.Parent.Parent, "D", "D", ConversionKind.Identity); 2958checkType((CastExpressionSyntax)expr.Parent.Parent, "D", "D", ConversionKind.Identity); 2965checkType((CastExpressionSyntax)expr.Parent.Parent, "D", "D", ConversionKind.Identity);
Semantics\PrimaryConstructorTests.cs (70)
1008Assert.Equal("= X", x.Parent.ToString()); 1073Assert.Equal("Base(X, Y)", x.Parent.Parent.Parent.ToString()); 1128Assert.Null(model.GetOperation(baseWithargs.Parent)); 1129Assert.Same(operation.Parent.Parent, model.GetOperation(baseWithargs.Parent.Parent)); 1130Assert.Equal(SyntaxKind.ClassDeclaration, baseWithargs.Parent.Parent.Kind()); 1229model.VerifyOperationTree(baseWithargs.Parent, 1301Assert.Equal("Test(X, out var y)", x.Parent.Parent.Parent.ToString()); 1312Assert.Equal("y", y.Parent.ToString()); 1313Assert.Equal("(Test(X, out var y), y)", y.Parent.Parent.ToString()); 1314Assert.Equal("Base(Test(X, out var y), y)", y.Parent.Parent.Parent.ToString()); 1325Assert.Equal("(Test(X, out var y), y)", test.Parent.Parent.Parent.ToString()); 1366Assert.Equal("Base(X, Y)", x.Parent.Parent.Parent.ToString()); 1412Assert.Equal("Base(X, Y)", x.Parent.Parent.Parent.ToString()); 1472Assert.Equal("Base(X, Y)", x.Parent.Parent.Parent.ToString()); 1530Assert.Equal("Base(X, Y)", x.Parent.Parent.Parent.ToString()); 1541Assert.Equal("Base(X, Y)", x.Parent.Parent.Parent.ToString()); 1619Assert.Equal("Base(X, Y)", x.Parent.Parent.Parent.ToString()); 1630Assert.Equal("Base(X, Y)", x.Parent.Parent.Parent.ToString()); 1815Assert.Equal("Base(X)", x.Parent.Parent.Parent.ToString()); 1855Assert.Equal("Base(X)", x.Parent.Parent.Parent.ToString()); 1898Assert.Equal("Base(X)", x.Parent.Parent.Parent.ToString()); 1968Assert.Equal("Base(X, Y)", x.Parent.Parent.Parent.ToString()); 2176var otherBasePosition = ((BaseListSyntax)baseWithargs.Parent).Types[1].SpanStart; 2328var otherBasePosition = ((BaseListSyntax)baseWithargs.Parent).Types[1].SpanStart; 2426Assert.Equal("Base(X)", x.Parent.Parent.Parent.ToString()); 2642Assert.Equal("= X + 1", x.Parent.Parent.ToString()); 2680Assert.Equal("= X + 1", x.Parent.Parent.ToString()); 2717Assert.Equal("= X + 1", x.Parent.Parent.ToString()); 2753Assert.Equal("() => X + 1", x.Parent.Parent.ToString()); 3914switch (identifier.Parent.ToString()) 3922Assert.Equal(SyntaxKind.SimpleBaseType, identifier.Parent.Kind());
Semantics\RecordTests.cs (69)
21190Assert.Equal("Base(X, Y)", x.Parent!.Parent!.Parent!.ToString()); 21246Assert.Null(model.GetOperation(baseWithargs.Parent)); 21247Assert.Same(operation.Parent.Parent, model.GetOperation(baseWithargs.Parent.Parent)); 21248Assert.Equal(SyntaxKind.RecordDeclaration, baseWithargs.Parent.Parent.Kind()); 21348model.VerifyOperationTree(baseWithargs.Parent, 21420Assert.Equal("Test(X, out var y)", x.Parent!.Parent!.Parent!.ToString()); 21431Assert.Equal("y", y.Parent!.ToString()); 21432Assert.Equal("(Test(X, out var y), y)", y.Parent!.Parent!.ToString()); 21433Assert.Equal("Base(Test(X, out var y), y)", y.Parent!.Parent!.Parent!.ToString()); 21444Assert.Equal("(Test(X, out var y), y)", test.Parent!.Parent!.Parent!.ToString()); 21485Assert.Equal("Base(X, Y)", x.Parent!.Parent!.Parent!.ToString()); 21531Assert.Equal("Base(X, Y)", x.Parent!.Parent!.Parent!.ToString()); 21591Assert.Equal("Base(X, Y)", x.Parent!.Parent!.Parent!.ToString()); 21649Assert.Equal("Base(X, Y)", x.Parent!.Parent!.Parent!.ToString()); 21660Assert.Equal("Base(X, Y)", x.Parent!.Parent!.Parent!.ToString()); 21738Assert.Equal("Base(X, Y)", x.Parent!.Parent!.Parent!.ToString()); 21749Assert.Equal("Base(X, Y)", x.Parent!.Parent!.Parent!.ToString()); 21934Assert.Equal("Base(X)", x.Parent!.Parent!.Parent!.ToString()); 21971Assert.Equal("Base(X)", x.Parent!.Parent!.Parent!.ToString()); 22011Assert.Equal("Base(X)", x.Parent!.Parent!.Parent!.ToString()); 22046Assert.Equal("Base(X)", x.Parent!.Parent!.Parent!.ToString()); 22125Assert.Equal("Base(X, Y)", x.Parent!.Parent!.Parent!.ToString()); 22333var otherBasePosition = ((BaseListSyntax)baseWithargs.Parent!).Types[1].SpanStart; 22485var otherBasePosition = ((BaseListSyntax)baseWithargs.Parent!).Types[1].SpanStart; 24689Assert.Equal("= X + 1", x.Parent!.Parent!.ToString()); 24724Assert.Equal("= X + 1", x.Parent!.Parent!.ToString()); 24758Assert.Equal("= X + 1", x.Parent!.Parent!.ToString()); 24793Assert.Equal("() => X + 1", x.Parent!.Parent!.ToString()); 26395switch (identifier.Parent!.ToString()) 26403Assert.Equal(SyntaxKind.SimpleBaseType, identifier.Parent.Kind());
Microsoft.CodeAnalysis.CSharp.Features (710)
AddImport\CSharpAddImportFeatureService.cs (10)
64else if (node.Parent.IsKind(SyntaxKind.CollectionInitializerExpression)) 83var memberAccessName = (node.Parent as MemberAccessExpressionSyntax)?.Name; 84var conditionalAccessName = (((node.Parent as ConditionalAccessExpressionSyntax)?.WhenNotNull as InvocationExpressionSyntax)?.Expression as MemberBindingExpressionSyntax)?.Name; 115if (nameNode?.Parent?.Kind() is not SyntaxKind.SimpleMemberAccessExpression and not SyntaxKind.MemberBindingExpression) 118var memberAccess = nameNode.Parent as MemberAccessExpressionSyntax; 119var memberBinding = nameNode.Parent as MemberBindingExpressionSyntax; 120if (memberAccess?.Parent?.Kind() is SyntaxKind.SimpleMemberAccessExpression or SyntaxKind.ElementAccessExpression || 121memberBinding?.Parent?.Kind() is SyntaxKind.SimpleMemberAccessExpression or SyntaxKind.ElementAccessExpression) 159node.AncestorsAndSelf().Any(n => n is QueryExpressionSyntax && !(n.Parent is QueryContinuationSyntax)); 633if (node.Parent.IsKind(SyntaxKind.CollectionInitializerExpression))
BraceCompletion\CurlyBraceCompletionService.cs (2)
150var currentTokenParentParent = currentToken.Parent?.Parent; 206var parentKind = node?.Parent?.Kind();
ChangeSignature\ChangeSignatureFormattingRule.cs (2)
40if (node.Parent != null) 42var baseToken = node.Parent.GetFirstToken();
ChangeSignature\CSharpChangeSignatureService.cs (1)
199for (var current = node; current != null; current = current.Parent)
CodeFixes\Suppression\CSharpSuppressionCodeFixProvider.cs (1)
216return attributeSyntax.Parent is AttributeListSyntax attributeList && attributeList.Attributes.Count == 1;
CodeLens\CSharpCodeLensDisplayInfoService.cs (8)
54node = node.Parent; 59node = node.Parent; 96if (node.Parent.IsKind(SyntaxKind.AccessorList) && 97node.Parent.Parent.IsKind(SyntaxKind.IndexerDeclaration)) 99return GetDisplayName(semanticModel, node.Parent.Parent); 186scopeNode = scopeNode.Parent;
CodeRefactorings\ConvertLocalFunctionToMethod\CSharpConvertLocalFunctionToMethodCodeRefactoringProvider.cs (1)
186if (node.Parent is InvocationExpressionSyntax invocation)
CodeRefactorings\InlineMethod\CSharpInlineMethodRefactoringProvider.cs (1)
108return syntaxNode.Parent switch
CodeRefactorings\InlineTemporary\InlineTemporaryCodeRefactoringProvider.cs (18)
54variableDeclaration.Parent is not LocalDeclarationStatementSyntax localDeclarationStatement) 268var variableDeclaration = (VariableDeclarationSyntax)variableDeclarator.Parent; 269var localDeclaration = (LocalDeclarationStatementSyntax)variableDeclaration.Parent; 270var scope = localDeclaration.Parent; 273scope = scope.Parent; 276scope = parentExpressions.LastOrDefault()?.Parent ?? scope; 279scope = scope.Parent; 297var localDeclaration = (LocalDeclarationStatementSyntax)variableDeclaration.Parent; 311var variableDeclaration = (VariableDeclarationSyntax)variableDeclarator.Parent; 317var localDeclaration = (LocalDeclarationStatementSyntax)variableDeclaration.Parent; 346if (newLocalDeclaration?.Parent is LabeledStatementSyntax labeledStatement) 353if (newLocalDeclaration?.Parent is GlobalStatementSyntax globalStatement) 381var isVar = ((VariableDeclarationSyntax)variableDeclarator.Parent).Type.IsVar; 436var parent = node.Parent; 438parent = parent.Parent; 442parent = parent.Parent; 447else if (parent?.Parent is AssignmentExpressionSyntax(SyntaxKind.SimpleAssignmentExpression) assignment) 452parent = parent.Parent;
CodeRefactorings\InlineTemporary\InlineTemporaryCodeRefactoringProvider.ReferenceRewriter.cs (1)
79if (node.Parent is TupleExpressionSyntax tupleExpression &&
CodeRefactorings\SyncNamespace\CSharpChangeNamespaceService.cs (6)
138RoslynDebug.Assert(nameRef.Parent is object); 139oldNode = nameRef.Parent; 155RoslynDebug.Assert(nameRef.Parent is object); 156oldNode = nameRef.Parent; 169else if (nameRef.Parent is NameMemberCrefSyntax crefName && crefName.Parent is QualifiedCrefSyntax qualifiedCref)
CodeRefactorings\UseRecursivePatterns\UseRecursivePatternsCodeRefactoringProvider.cs (9)
78WhenClauseSyntax { Parent: CasePatternSwitchLabelSyntax switchLabel } whenClause => CombineWhenClauseCondition(switchLabel.Pattern, whenClause.Condition, model), 79WhenClauseSyntax { Parent: SwitchExpressionArmSyntax switchArm } whenClause => CombineWhenClauseCondition(switchArm.Pattern, whenClause.Condition, model), 89WhenClauseSyntax { Parent: CasePatternSwitchLabelSyntax } => true, 90WhenClauseSyntax { Parent: SwitchExpressionArmSyntax } => true, 105if (leftTarget.Parent is IsPatternExpressionSyntax isPatternExpression && 276ExpressionSyntax constant => originalReceiver.Parent switch 318if (designation is not { Parent: PatternSyntax(not SyntaxKind.ListPattern) containingPattern }) 453var leftIsNullCheck = IsNullCheck(leftTarget.Parent); 454var rightIsNullCheck = IsNullCheck(rightTarget.Parent);
Completion\CompletionProviders\AwaitCompletionProvider.cs (1)
107if (parent is NameSyntax { Parent: LocalFunctionStatementSyntax localFunction } name &&
Completion\CompletionProviders\CSharpSuggestionModeCompletionProvider.cs (2)
127return token.Parent.Parent is not null and ParenthesizedLambdaExpressionSyntax; 171&& token.Parent.Parent is InvocationExpressionSyntax invocation
Completion\CompletionProviders\DeclarationName\DeclarationNameInfo.cs (4)
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 474parent is TypeArgumentListSyntax { Parent: GenericNameSyntax genericName })
Completion\CompletionProviders\DeclarationName\DeclarationNameRecommender.cs (2)
289if (parameterSyntax is not { Type: { } parameterType, Parent.Parent: BaseMethodDeclarationSyntax baseMethod })
Completion\CompletionProviders\ExplicitInterfaceMemberCompletionProvider.cs (1)
94ancestor = ancestor.Parent;
Completion\CompletionProviders\ExplicitInterfaceTypeCompletionProvider.cs (2)
74potentialTypeNode = typeArgumentList.Parent; 80if (typeNode.Parent is TypeSyntax parentType && parentType.Span.End < position)
Completion\CompletionProviders\NamedParameterCompletionProvider.cs (3)
82var parameterLists = GetParameterLists(semanticModel, position, argumentList.Parent!, cancellationToken); 234var baseList = baseType.Parent; 235if (baseList?.Parent is not BaseTypeDeclarationSyntax typeDeclaration)
Completion\CompletionProviders\ObjectAndWithInitializerCompletionProvider.cs (1)
142var parent = token.Parent?.Parent;
Completion\CompletionProviders\PropertySubPatternCompletionProvider.cs (7)
59var propertyPatternType = semanticModel.GetTypeInfo((PatternSyntax)propertyPatternClause.Parent!, cancellationToken).ConvertedType; 182return token.Parent is PropertyPatternClauseSyntax { Parent: PatternSyntax } propertyPatternClause 200while (memberAccess.Parent.IsKind(SyntaxKind.SimpleMemberAccessExpression)) 202memberAccess = (MemberAccessExpressionSyntax)memberAccess.Parent; 205if (memberAccess is { Parent.Parent: SubpatternSyntax { Parent: PropertyPatternClauseSyntax found } })
Completion\CompletionProviders\XmlDocCommentCompletionProvider.cs (3)
235(elementName, attributes) = GetElementNameAndAttributes(token.Parent.Parent!); 249(elementName, attributes) = GetElementNameAndAttributes(attributeSyntax.Parent!); 294token.Parent?.Parent is XmlNameAttributeSyntax xmlName)
Completion\KeywordRecommenders\AssemblyKeywordRecommender.cs (2)
36case BaseTypeDeclarationSyntax baseType when baseType.Parent is CompilationUnitSyntax: 40case IncompleteMemberSyntax incompleteMember when incompleteMember.Parent is CompilationUnitSyntax:
Completion\KeywordRecommenders\BaseKeywordRecommender.cs (2)
54token.Parent.Parent?.Parent is (kind: SyntaxKind.ClassDeclaration or SyntaxKind.RecordDeclaration))
Completion\KeywordRecommenders\FieldKeywordRecommender.cs (4)
46for (var node = targetToken.Parent; node != null; node = node.Parent) 48if (node is ArrowExpressionClauseSyntax { Parent: PropertyDeclarationSyntax }) 51if (node is AccessorDeclarationSyntax { Parent: AccessorListSyntax { Parent: PropertyDeclarationSyntax } })
Completion\KeywordRecommenders\MethodKeywordRecommender.cs (1)
26Parent: PropertyDeclarationSyntax
Completion\KeywordRecommenders\NamespaceKeywordRecommender.cs (3)
118!token.Parent.Parent.IsKind(SyntaxKind.FileScopedNamespaceDeclaration)) 129token.Parent.Parent is not TypeDeclarationSyntax) 145token.Parent.Parent is not TypeDeclarationSyntax)
Completion\KeywordRecommenders\RefKeywordRecommender.cs (3)
107identifier.Parent is TypeConstraintSyntax typeConstraint && typeConstraint.Type == identifier && 108typeConstraint.Parent is TypeParameterConstraintClauseSyntax constraintClause) 209|| parent?.Parent?.Kind() == SyntaxKind.VariableDeclarator;
Completion\KeywordRecommenders\ReturnKeywordRecommender.cs (1)
42token.Parent.Parent is AccessorDeclarationSyntax;
Completion\KeywordRecommenders\StructKeywordRecommender.cs (2)
64refStructConstraint.Parent is AllowsConstraintClauseSyntax allowsClause && 65allowsClause.Parent is TypeParameterConstraintClauseSyntax)
Completion\KeywordRecommenders\WhereKeywordRecommender.cs (1)
81else if (tokenParent.Parent is LocalFunctionStatementSyntax { TypeParameterList.Parameters.Count: > 0 })
ConvertIfToSwitch\CSharpConvertIfToSwitchCodeRefactoringProvider.cs (1)
39if (syntaxToRemove is (IfStatementSyntax or BlockSyntax) and { Parent: ElseClauseSyntax elseClause } &&
ConvertLinq\ConvertForEachToLinqQuery\CSharpConvertForEachToLinqQueryProvider.cs (1)
293block.Parent == memberDeclarationSyntax)
ConvertLinq\CSharpConvertLinqQueryToForEachProvider.cs (5)
213var identifier = ((QueryBodySyntax)selectClause.Parent).Continuation.Identifier; 264currentNode = currentNode.Parent; 280if (memberAccessExpression.Parent is InvocationExpressionSyntax invocationExpression) 472((VariableDeclarationSyntax)variableDeclarator.Parent).Type, 947node = node.Parent;
ConvertPrimaryToRegularConstructor\ConvertPrimaryToRegularConstructorCodeRefactoringProvider.cs (4)
222if (initializer.Parent is not PropertyDeclarationSyntax and not VariableDeclaratorSyntax { Parent: VariableDeclarationSyntax { Parent: FieldDeclarationSyntax } }) 268if (initializer.Parent is PropertyDeclarationSyntax propertyDeclaration) 277else if (initializer.Parent is VariableDeclaratorSyntax)
ConvertProgram\ConvertProgramTransform_TopLevelStatements.cs (4)
32var typeDeclaration = (TypeDeclarationSyntax?)methodDeclaration.Parent; 43if (typeDeclaration.Parent is not BaseNamespaceDeclarationSyntax namespaceDeclaration) 109var namespaceDeclaration = typeDeclaration.Parent as BaseNamespaceDeclarationSyntax; 223typeDeclaration.Parent is NamespaceDeclarationSyntax namespaceDeclaration)
ConvertToRawString\ConvertInterpolatedStringToRawStringCodeRefactoringProvider.cs (1)
277for (var current = node; current != null; current = current.Parent)
Debugging\CSharpProximityExpressionsService.Worker.cs (12)
81if (block != null && block?.Parent is CatchClauseSyntax catchClause && 91? (BlockSyntax)_parentStatement.Parent 98=> _parentStatement.Parent is BlockSyntax parentBlockOpt && parentBlockOpt.Statements.FirstOrDefault() == _parentStatement; 114if (block != null && block.Parent is MemberDeclarationSyntax memberDeclaration) 120&& _parentStatement.Parent is GlobalStatementSyntax { Parent: CompilationUnitSyntax compilationUnit } globalStatement 134block.Parent is AccessorDeclarationSyntax && 135block.Parent.Parent is AccessorListSyntax && 136block.Parent.Parent.Parent is IndexerDeclarationSyntax indexerDeclaration)
Debugging\CSharpProximityExpressionsService_ExpressionTermCollector.cs (1)
189memberAccessExpression.Parent?.Kind() is not SyntaxKind.SimpleMemberAccessExpression and not SyntaxKind.PointerMemberAccessExpression)
Diagnostics\Analyzers\CSharpUnboundIdentifiersDiagnosticAnalyzer.cs (1)
29=> node.Parent is InvocationExpressionSyntax invocation && invocation.IsNameOfInvocation();
DocumentationComments\CSharpDocumentationCommentSnippetService.cs (2)
186for (SyntaxNode? current = exceptionType; current != null; current = current?.Parent) 188if (current is not BlockSyntax { Parent: TryStatementSyntax tryStatement } block ||
EditAndContinue\BreakpointSpans.cs (7)
102node = node.Parent; 555if (switchLabel.Parent is not SwitchSectionSyntax switchSection || switchSection.Statements.Count == 0) 773=> declaration.Parent!.Kind() switch 837var variableDeclaration = (VariableDeclarationSyntax)variableDeclarator.Parent!; 857var variableDeclaration = (VariableDeclarationSyntax)variableDeclarator.Parent!; 941if (expression == null || expression.Parent == null) 946var parent = expression.Parent;
EditAndContinue\CSharpEditAndContinueAnalyzer.cs (89)
134if (current is { Parent.Parent: RecordDeclarationSyntax }) 144Debug.Assert(current.Parent.IsKind(SyntaxKind.VariableDeclaration)); 146switch (current.Parent.Parent!.Kind()) 154current = current.Parent; 159if (current.Parent is (kind: SyntaxKind.PropertyDeclaration or SyntaxKind.IndexerDeclaration)) 168Debug.Assert(current.Parent.IsKind(SyntaxKind.CompilationUnit)); 169declarations = new(current.Parent); 173current = current.Parent; 322node = node.Parent!; 325partnerStatement = partnerStatement.Parent; 399ParameterListSyntax parameters => parameters.Parent!, 415current = current.Parent; 432AccessorDeclarationSyntax { Parent.Parent: IndexerDeclarationSyntax { ParameterList: var list } } => list, 433ArrowExpressionClauseSyntax { Parent: { } memberDecl } => GetDeclarationParameterList(memberDecl), 444(oldBody.Parent.IsKind(SyntaxKind.LocalFunctionStatement) && newBody.Parent.IsKind(SyntaxKind.LocalFunctionStatement))) 465var parent = body.Parent!; 468return parent.IsKind(SyntaxKind.ArrowExpressionClause) && parent.Parent.IsKind(SyntaxKind.LocalFunctionStatement) ? parent.Parent : parent; 666case SyntaxKind.ParameterList when node.Parent is TypeDeclarationSyntax typeDeclaration: 702var parent = statement.Parent; 794if (oldStatement.Parent is UsingStatementSyntax oldUsing) 796return newStatement.Parent is UsingStatementSyntax newUsing && 937=> node is CompilationUnitSyntax ? null : node.Parent!.FirstAncestorOrSelf<BaseTypeDeclarationSyntax>(); 943=> declaration.Parent is TypeDeclarationSyntax { ParameterList: var parameterList } && parameterList == declaration; 1026Contract.ThrowIfNull(declaration.Parent); 1027var recordType = (INamedTypeSymbol?)model.GetDeclaredSymbol(declaration.Parent, cancellationToken); 1029return recordType.InstanceConstructors.Single(ctor => ctor.DeclaringSyntaxReferences is [var syntaxRef] && syntaxRef.GetSyntax(cancellationToken) == declaration.Parent); 1124if (oldNode is ParameterSyntax { Parent.Parent: RecordDeclarationSyntax } || 1125newNode is ParameterSyntax { Parent.Parent: RecordDeclarationSyntax }) 1321Debug.Assert(node.Parent.IsKind(SyntaxKind.AccessorList)); 1323if (HasEdit(editMap, node.Parent, editKind) && !HasEdit(editMap, node.Parent.Parent, editKind)) 1422Contract.ThrowIfNull(node.Parent); 1423node = node.Parent; 1449if (declaration is BaseParameterListSyntax and not { Parent: TypeDeclarationSyntax }) 1451declaration = declaration.Parent; 1457=> node is TypeParameterSyntax ? node.Parent!.Parent! : node!.Parent!; 1676return TryGetDiagnosticSpanImpl(node.Parent!, editKind); 1739return TryGetDiagnosticSpanImpl(node.Parent!, editKind); 1758return TryGetDiagnosticSpanImpl(node.Parent!, editKind); 1882return TryGetDiagnosticSpanImpl(queryBody.Clauses.FirstOrDefault() ?? queryBody.Parent!, editKind); 2055return TryGetDisplayNameImpl(node.Parent!, editKind); 2086if (node.Parent!.Parent!.IsKind(SyntaxKind.PropertyDeclaration)) 2092RoslynDebug.Assert(node.Parent.Parent.IsKind(SyntaxKind.IndexerDeclaration)); 2098if (node.Parent!.Parent!.IsKind(SyntaxKind.PropertyDeclaration)) 2104RoslynDebug.Assert(node.Parent.Parent.IsKind(SyntaxKind.IndexerDeclaration)); 2113return node.Parent!.Kind() switch 2131return node.Parent is TypeDeclarationSyntax ? FeaturesResources.constructor : null; 2274RoslynDebug.Assert(((LocalDeclarationStatementSyntax)node.Parent!.Parent!).AwaitKeyword.IsKind(SyntaxKind.AwaitKeyword)); 2418if (node.IsParentKind(SyntaxKind.CompilationUnit) || node.Parent.IsParentKind(SyntaxKind.CompilationUnit)) 2444if (oldNode.IsParentKind(SyntaxKind.CompilationUnit) || oldNode.Parent.IsParentKind(SyntaxKind.CompilationUnit)) 2467if (newNode.IsParentKind(SyntaxKind.CompilationUnit) || newNode.Parent.IsParentKind(SyntaxKind.CompilationUnit)) 2602RoslynDebug.Assert(current.Parent is object); 2603RoslynDebug.Assert(current.Parent.Kind() == SyntaxKind.TryStatement); 2604current = current.Parent; 2622Debug.Assert(current.Parent != null); 2623current = current.Parent; 2707tryStatement = (TryStatementSyntax)node.Parent!; 2748RoslynDebug.Assert(node.Parent is object); 2749switch (node.Parent.Kind()) 2768node = node.Parent; 2802return awaitExpression.Parent!.Parent!.Parent == containingStatementPart; 2807return awaitExpression.Parent!.Parent!.Parent!.Parent == containingStatementPart; 2875if (oldActiveStatement.Parent!.Parent!.Parent is not SwitchStatementSyntax oldSwitch) 2881var newSwitch = (SwitchStatementSyntax)newActiveStatement.Parent!.Parent!.Parent!; 2971node = node.Parent;
EditAndContinue\SyntaxComparer.cs (26)
245if (node != null && node.Parent.IsKind(SyntaxKind.ForStatement) && node is ExpressionSyntax) 467if (node == null || node.Parent.IsKind(SyntaxKind.QueryExpression)) 633if (node?.Parent is (kind: SyntaxKind.PropertyDeclaration or SyntaxKind.IndexerDeclaration)) 677if (node is { Parent: { } parent } && parent.IsParentKind(SyntaxKind.CompilationUnit)) 1038if (leftBlock.Parent == null || 1039rightBlock.Parent == null || 1040leftBlock.Parent.IsKind(SyntaxKind.ConstructorDeclaration) || 1041rightBlock.Parent.IsKind(SyntaxKind.ConstructorDeclaration)) 1047if (GetLabel(leftBlock.Parent) != GetLabel(rightBlock.Parent)) 1053switch (leftBlock.Parent.Kind()) 1070distance = GetDistance(leftBlock.Parent, rightBlock.Parent); 1074var leftCatch = (CatchClauseSyntax)leftBlock.Parent; 1075var rightCatch = (CatchClauseSyntax)rightBlock.Parent; 1079var leftTry = (TryStatementSyntax)leftCatch.Parent!; 1080var rightTry = (TryStatementSyntax)rightCatch.Parent!; 1088distance = GetDistance(leftBlock.Parent, rightBlock.Parent); 1109throw ExceptionUtilities.UnexpectedValue(leftBlock.Parent.Kind()); 1118if (leftNode.Parent != null && 1119rightNode.Parent != null && 1120GetLabel(leftNode.Parent) == GetLabel(rightNode.Parent)) 1122parentDistance = ComputeDistance(leftNode.Parent, rightNode.Parent);
EditAndContinue\SyntaxUtilities.cs (14)
39ArrowExpressionClauseSyntax { Parent: (kind: SyntaxKind.PropertyDeclaration) or (kind: SyntaxKind.IndexerDeclaration) } arrowExpression 40=> new PropertyOrIndexerWithExplicitBodyDeclarationBody((BasePropertyDeclarationSyntax)arrowExpression.Parent!), 55VariableDeclaratorSyntax { Parent.Parent: BaseFieldDeclarationSyntax fieldDeclaration, Initializer: { } } variableDeclarator 59ParameterListSyntax { Parent: TypeDeclarationSyntax typeDeclaration } 69ParameterSyntax { Parent.Parent: RecordDeclarationSyntax } parameterSyntax when symbol is not IParameterSymbol 107if (syntax is ExpressionSyntax { Parent: ArrowExpressionClauseSyntax }) 113if (syntax is ExpressionSyntax { Parent.Parent: VariableDeclaratorSyntax }) 119if (syntax is ExpressionSyntax { Parent.Parent: PropertyDeclarationSyntax }) 217Contract.ThrowIfNull(declaration.Parent); 218declaration = declaration.Parent;
EncapsulateField\CSharpEncapsulateFieldService.cs (5)
65var declaration = root.GetAnnotatedNodes<SyntaxNode>(tempAnnotation).First().Parent as VariableDeclarationSyntax; 69var fieldSyntax = declaration.Parent as FieldDeclarationSyntax; 91declaration = declarator.Parent as VariableDeclarationSyntax; 115declaration = declarator.Parent as VariableDeclarationSyntax; 154=> field.Parent is TypeDeclarationSyntax;
ExtractMethod\CSharpMethodExtractor.Analyzer.cs (3)
71Parent: VariableDeclarationSyntax 73Parent: LocalDeclarationStatementSyntax 75Parent: BlockSyntax { Statements: [.., var lastBlockStatement] },
ExtractMethod\CSharpMethodExtractor.cs (3)
102return globalStatement.Parent; 134return globalStatement.Parent; 140return globalStatement.Parent;
ExtractMethod\CSharpMethodExtractor.CSharpCodeGenerator.CallSiteContainerRewriter.cs (6)
50Contract.ThrowIfFalse(_firstStatementOrFieldToReplace.Parent == _lastStatementOrFieldToReplace.Parent 57private SyntaxNode ContainerOfStatementsOrFieldToReplace => _firstStatementOrFieldToReplace.Parent; 327var firstMemberIndex = newMembers.FindIndex(s => s == (global ? _firstStatementOrFieldToReplace.Parent : _firstStatementOrFieldToReplace)); 330var lastMemberIndex = newMembers.FindIndex(s => s == (global ? _lastStatementOrFieldToReplace.Parent : _lastStatementOrFieldToReplace)); 419if (node != ContainerOfStatementsOrFieldToReplace.Parent)
ExtractMethod\CSharpMethodExtractor.CSharpCodeGenerator.cs (2)
128Contract.ThrowIfFalse(firstStatementToRemove.Parent == lastStatementToRemove.Parent
ExtractMethod\CSharpMethodExtractor.CSharpCodeGenerator.ExpressionCodeGenerator.cs (8)
45if (expression.Parent != null && 46expression.Parent.Kind() == SyntaxKind.EqualsValueClause && 47expression.Parent.Parent != null && 48expression.Parent.Parent.Kind() == SyntaxKind.VariableDeclarator) 50var name = ((VariableDeclaratorSyntax)expression.Parent.Parent).Identifier.ValueText;
ExtractMethod\CSharpMethodExtractor.CSharpCodeGenerator.MultipleStatementsCodeGenerator.cs (1)
74GlobalStatementSyntax globalStatement => ((CompilationUnitSyntax)globalStatement.Parent).Members.OfType<GlobalStatementSyntax>().Select(globalStatement => globalStatement.Statement),
ExtractMethod\CSharpSelectionResult.cs (6)
88for (var current = token.Parent; current != null; current = current.Parent) 127var container = firstStatement.Parent; 129return container.Parent; 201Contract.ThrowIfFalse(last.Parent.IsParentKind(SyntaxKind.CompilationUnit)); 202return last.Parent.Parent;
ExtractMethod\CSharpSelectionResult.ExpressionResult.cs (1)
73if (node.Parent is CastExpressionSyntax castExpression)
ExtractMethod\CSharpSelectionResult.StatementResult.cs (5)
73if (access.Parent == null || access.Parent.Parent == null) 76return semanticModel.GetDeclaredSymbol(access.Parent.Parent) switch
ExtractMethod\CSharpSelectionValidator.cs (1)
519if (body.Parent is not MethodDeclarationSyntax method)
ExtractMethod\CSharpSelectionValidator.Validator.cs (1)
31return block.Parent is BlockSyntax or
ExtractMethod\Extensions.cs (7)
23for (var current = node; current is object; current = current.Parent) 25if (current.Parent != null && 26current.Parent.IsStatementContainerNode()) 36=> (StatementSyntax)((node.Parent is LabeledStatementSyntax) ? node.Parent : node); 252=> node is InitializerExpressionSyntax && node.Parent is EqualsValueClauseSyntax; 255=> node is ExpressionSyntax && node.Parent is CastExpressionSyntax;
FullyQualify\CSharpFullyQualifyService.cs (1)
59simpleName.Parent is UsingDirectiveSyntax { Alias: null, StaticKeyword.RawKind: 0 } usingDirective)
GenerateMember\GenerateVariable\CSharpGenerateVariableService.cs (8)
96var memberAccess = identifierName.Parent as MemberAccessExpressionSyntax; 97var conditionalMemberAccess = identifierName.Parent.Parent as ConditionalAccessExpressionSyntax; 184if (expression.Parent is (kind: SyntaxKind.NameColon or SyntaxKind.ExpressionColon) && 185expression.Parent.IsParentKind(SyntaxKind.Subpattern)) 202if (node.IsLeftSideOfAssignExpression() && node.Parent.IsParentKind(SyntaxKind.ExpressionStatement)) 204var assignExpression = (AssignmentExpressionSyntax)node.Parent; 205var expressionStatement = (StatementSyntax)assignExpression.Parent;
GenerateType\CSharpGenerateTypeService.cs (35)
49expression.Parent.IsParentKind(SyntaxKind.ArrayCreationExpression); 57if (expression is TypeSyntax typeSyntax && expression.Parent is TypeArgumentListSyntax typeArgumentList) 59var symbolInfo = semanticModel.GetSymbolInfo(typeArgumentList.Parent, cancellationToken); 87if (expression is TypeSyntax { Parent: BaseTypeSyntax { Parent: BaseListSyntax baseList } baseType } && 91if (baseList.Types[0] != expression.Parent) 96return baseList.Parent.Kind() is 102if (expression is TypeSyntax { Parent: TypeConstraintSyntax { Parent: TypeParameterConstraintClauseSyntax constraintClause } typeConstraint }) 145nameOrMemberAccessExpression = generateTypeServiceStateOptions.NameOrMemberAccessExpression = (ExpressionSyntax)simpleName.Parent; 166if (nameOrMemberAccessExpression.Parent is BaseTypeSyntax baseType && 167nameOrMemberAccessExpression.Parent.IsParentKind(SyntaxKind.BaseList) && 169nameOrMemberAccessExpression.Parent.Parent.IsParentKind(SyntaxKind.EnumDeclaration)) 224simpleName.Parent == token.Parent) 247if (simpleName.Parent is QualifiedNameSyntax parent) 279if (simpleName.Parent is not null and not QualifiedNameSyntax) 292if (nameOrMemberAccessExpression.Parent is not null and QualifiedNameSyntax) 311if ((nameOrMemberAccessExpression.IsKind(SyntaxKind.SimpleMemberAccessExpression) || (nameOrMemberAccessExpression.Parent != null && nameOrMemberAccessExpression.IsParentKind(SyntaxKind.SimpleMemberAccessExpression))) 323outerMostMemberAccessExpression = (ExpressionSyntax)nameOrMemberAccessExpression.Parent; 350if (nameOrMemberAccessExpression.Parent is ObjectCreationExpressionSyntax objectCreationExpressionOpt) 379if (nameOrMemberAccessExpression.Parent is VariableDeclarationSyntax 390if (nameOrMemberAccessExpression.Parent is VariableDeclarationSyntax variableDeclaration) 398if (nameOrMemberAccessExpression.Parent is CastExpressionSyntax { Expression: not null } castExpression) 643if (expression.Parent is BaseTypeSyntax { Parent: BaseListSyntax baseList }) 645if (baseList.Parent.Kind() is SyntaxKind.InterfaceDeclaration or SyntaxKind.StructDeclaration or SyntaxKind.RecordStructDeclaration) 670node.Parent != null && 671node.Parent is TypeDeclarationSyntax) 673if (node.Parent is TypeDeclarationSyntax typeDecl) 683node.Parent != null && 684node.Parent is TypeDeclarationSyntax) 694node = node.Parent; 765if (propertyName.Parent is AssignmentExpressionSyntax parentAssignment) 771if (propertyName.Parent is IsPatternExpressionSyntax isPatternExpression)
GoToDefinition\CSharpGoToDefinitionSymbolService.cs (3)
102node = node.Parent; 118node = node.Parent; 133node = node.Parent;
Highlighting\KeywordHighlighters\IfStatementHighlighter.cs (1)
33if (ifStatement.Parent.Kind() != SyntaxKind.ElseClause)
ImplementInterface\AbstractChangeImplementationCodeRefactoringProvider.cs (1)
156for (var node = token.Parent; node != null; node = node.Parent)
InitializeParameter\CSharpInitializeMemberFromPrimaryConstructorParameterCodeRefactoringProvider.cs (1)
47if (selectedParameter.Parent is not ParameterListSyntax { Parent: TypeDeclarationSyntax(kind: SyntaxKind.ClassDeclaration or SyntaxKind.StructDeclaration) typeDeclaration })
InlineHints\CSharpInlineTypeHintsService.cs (4)
52else if (node is SingleVariableDesignationSyntax { Parent: not DeclarationPatternSyntax and not DeclarationExpressionSyntax } variableDesignation) 58return node.Parent is VarPatternSyntax varPattern 81return parameterNode.Parent?.Parent?.Kind() is SyntaxKind.ParenthesizedLambdaExpression
IntroduceParameter\CSharpIntroduceParameterCodeRefactoringProvider.cs (2)
35return variableDecl.Parent?.Parent as LocalDeclarationStatementSyntax;
IntroduceUsingStatement\CSharpIntroduceUsingStatementCodeRefactoringProvider.cs (1)
100if (declarationStatement.Parent is SwitchSectionSyntax ||
IntroduceVariable\CSharpIntroduceVariableService.cs (1)
65for (SyntaxNode node = expression; node != null; node = node.Parent)
IntroduceVariable\CSharpIntroduceVariableService.Rewriter.cs (1)
65node.Parent is TupleExpressionSyntax)
IntroduceVariable\CSharpIntroduceVariableService_IntroduceLocal.cs (5)
72var method = document.SemanticModel.GetDeclaredSymbol(arrowExpression.Parent, cancellationToken) as IMethodSymbol; 224var oldParentingNode = oldBody.Parent; 379if (!IsBlockLike(statement.Parent)) 391innermostCommonBlock = statement.Parent; 416if (statement is IfStatementSyntax { Parent: ElseClauseSyntax })
InvertIf\CSharpInvertIfCodeRefactoringProvider.cs (1)
37=> ifNode?.Parent is (kind: SyntaxKind.Block or SyntaxKind.SwitchSection);
QuickInfo\CSharpDiagnosticAnalyzerQuickInfoProvider.cs (3)
58{ Parent: PragmaWarningDirectiveTriviaSyntax } node => node, 100Parent: AttributeArgumentListSyntax 103Parent: AttributeSyntax
QuickInfo\CSharpSemanticQuickInfoProvider.cs (2)
60token.Parent?.Parent.IsKind(SyntaxKind.ElementAccessExpression) == true) 62found = token.Parent.Parent;
QuickInfo\CSharpSyntacticQuickInfoProvider.cs (2)
88spanStart = parent.Parent!.SpanStart; 98&& node.Parent?.Kind() is SyntaxKind.Block or SyntaxKind.SwitchSection or SyntaxKind.GlobalStatement;
RemoveUnusedVariable\CSharpRemoveUnusedVariableCodeFixProvider.cs (5)
40node = node.Parent; 43var parent = node.Parent; 65RemoveNode(editor, node.IsParentKind(SyntaxKind.GlobalStatement) ? node.Parent : node, blockFacts); 77if (node.Parent?.Parent is not LocalDeclarationStatementSyntax localDeclaration)
Rename\CSharpRenameIssuesService.cs (2)
62if (parent?.Parent is VariableDeclarationSyntax varDecl) 66else if (parent?.Parent is FieldDeclarationSyntax fieldDecl)
ReplaceMethodWithProperty\CSharpReplaceMethodWithPropertyService.cs (1)
399if (nameNode.IsAnyMemberAccessExpressionName() && nameNode.Parent == invocationExpression)
ReplacePropertyWithMethods\CSharpReplacePropertyWithMethodsService.cs (1)
298=> identifierName.Parent as NameMemberCrefSyntax;
SignatureHelp\AttributeSignatureHelpProvider.cs (1)
64token.Parent.Parent is AttributeSyntax;
SignatureHelp\ElementAccessExpressionSignatureHelpProvider.cs (9)
119if (expression.Parent is ConditionalAccessExpressionSyntax conditional) 158if (expression.Parent is ConditionalAccessExpressionSyntax) 290token.Parent.Parent is ElementAccessExpressionSyntax; 302(openBracket.Parent.Parent is ElementAccessExpressionSyntax || openBracket.Parent.Parent is ElementBindingExpressionSyntax)); 343Contract.ThrowIfFalse(openBracket.Parent is ArrayRankSpecifierSyntax && openBracket.Parent.Parent is ArrayTypeSyntax); 374token.Parent.Parent is ElementBindingExpressionSyntax && 375token.Parent.Parent.Parent is ConditionalAccessExpressionSyntax;
SignatureHelp\GenericNameSignatureHelpProvider.cs (3)
67token.Parent.Parent is GenericNameSyntax; 164Contract.ThrowIfFalse(lessThanToken.Parent is TypeArgumentListSyntax && lessThanToken.Parent.Parent is GenericNameSyntax); 165return SignatureHelpUtilities.GetSignatureHelpSpan(((GenericNameSyntax)lessThanToken.Parent.Parent).TypeArgumentList);
SignatureHelp\PrimaryConstructorBaseTypeSignatureHelpProvider.cs (2)
77var baseList = baseTypeSyntax.Parent as BaseListSyntax; 78var namedTypeSyntax = baseList?.Parent as BaseTypeDeclarationSyntax;
SignatureHelp\SignatureHelpUtilities.cs (1)
139token.Parent.Parent is TSyntaxNode;
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 } })
SplitOrMergeIfStatements\CSharpIfLikeStatementGenerator.cs (8)
33if (expression.Parent is IfStatementSyntax ifStatement && ifStatement.Condition == expression) 45if (node is IfStatementSyntax && node.Parent is ElseClauseSyntax) 47parentIfOrElseIf = (IfStatementSyntax)node.Parent.Parent; 78while (ifStatement.Parent is ElseClauseSyntax elseClause) 80ifStatement = (IfStatementSyntax)elseClause.Parent; 158editor.ReplaceNode(elseIfClause.Parent.Parent, (currentNode, _) =>
src\Analyzers\CSharp\Analyzers\AddAccessibilityModifiers\CSharpAddAccessibilityModifiers.cs (1)
59if (member.Parent is InterfaceDeclarationSyntax)
src\Analyzers\CSharp\Analyzers\AddRequiredParentheses\CSharpAddRequiredExpressionParenthesesDiagnosticAnalyzer.cs (4)
79=> binaryLike.Parent is ConstantPatternSyntax 80? binaryLike.Parent.Parent as ExpressionSyntax 81: binaryLike.Parent as ExpressionSyntax;
src\Analyzers\CSharp\Analyzers\AddRequiredParentheses\CSharpAddRequiredPatternParenthesesDiagnosticAnalyzer.cs (1)
43=> binaryLike.Parent as PatternSyntax;
src\Analyzers\CSharp\Analyzers\ConvertProgram\ConvertProgramAnalysis_TopLevelStatements.cs (1)
61methodDeclaration.Parent is not TypeDeclarationSyntax containingTypeDeclaration ||
src\Analyzers\CSharp\Analyzers\ConvertSwitchStatementToExpression\ConvertSwitchStatementToExpressionDiagnosticAnalyzer.Analyzer.cs (1)
65if (declaration.Parent == node.Parent && declarator.Initializer is null)
src\Analyzers\CSharp\Analyzers\ConvertTypeofToNameof\CSharpConvertTypeOfToNameOfDiagnosticAnalyzer.cs (1)
37return node is TypeOfExpressionSyntax { Parent: MemberAccessExpressionSyntax } typeofExpression &&
src\Analyzers\CSharp\Analyzers\InlineDeclaration\CSharpInlineDeclarationDiagnosticAnalyzer.cs (9)
97if (argumentNode.Parent is not ArgumentListSyntax argumentList) 102var invocationOrCreation = argumentList.Parent; 145var localDeclaration = localDeclarator.Parent as VariableDeclarationSyntax; 146if (localDeclaration?.Parent is not LocalDeclarationStatementSyntax localStatement) 179var enclosingBlockOfLocalStatement = GetEnclosingPseudoBlock(localStatement.Parent); 259return parent.Parent as CompilationUnitSyntax; 306for (var current = argumentExpression; current != null; current = current.Parent) 308if (current.Parent is LambdaExpressionSyntax lambda && 348? current.Parent
src\Analyzers\CSharp\Analyzers\NamingStyle\CSharpNamingStyleDiagnosticAnalyzer.cs (2)
33Parent: ParameterListSyntax 35Parent: RecordDeclarationSyntax
src\Analyzers\CSharp\Analyzers\NewLines\ArrowExpressionClausePlacement\ArrowExpressionClausePlacementDiagnosticAnalyzer.cs (1)
68if (arrowExpressionClause.Parent is AccessorDeclarationSyntax)
src\Analyzers\CSharp\Analyzers\NewLines\EmbeddedStatementPlacement\EmbeddedStatementPlacementDiagnosticAnalyzer.cs (2)
87var parent = statement.Parent; 110var blockParent = parent.Parent;
src\Analyzers\CSharp\Analyzers\QualifyMemberAccess\CSharpQualifyMemberAccessDiagnosticAnalyzer.cs (2)
44if (node.Parent is AssignmentExpressionSyntax { Parent: InitializerExpressionSyntax(SyntaxKind.ObjectInitializerExpression), Left: var left } &&
src\Analyzers\CSharp\Analyzers\RemoveUnnecessaryDiscardDesignation\CSharpRemoveUnnecessaryDiscardDesignationDiagnosticAnalyzer.cs (3)
55if (discard.Parent is DeclarationPatternSyntax declarationPattern) 59if (declarationPattern.Parent is not IsPatternExpressionSyntax) 81else if (discard.Parent is RecursivePatternSyntax recursivePattern)
src\Analyzers\CSharp\Analyzers\RemoveUnnecessaryLambdaExpression\CSharpRemoveUnnecessaryLambdaExpressionDiagnosticAnalyzer.cs (2)
256node1 = node1.Parent; 257node2 = node2.Parent;
src\Analyzers\CSharp\Analyzers\RemoveUnnecessaryNullableDirective\NullableImpactingSpanWalker.cs (4)
66if (node?.Parent is QualifiedNameSyntax qualifiedName 85if (node?.Parent is BaseNamespaceDeclarationSyntax) 91if (node.IsParentKind(SyntaxKind.NameEquals) && node.Parent.IsParentKind(SyntaxKind.UsingDirective)) 105while (node.Parent is QualifiedNameSyntax qualifiedName
src\Analyzers\CSharp\Analyzers\RemoveUnnecessaryParentheses\CSharpRemoveUnnecessaryExpressionParenthesesDiagnosticAnalyzer.cs (2)
55switch (parenthesizedExpression.Parent) 80case ConstantPatternSyntax constantPattern when constantPattern.Parent is IsPatternExpressionSyntax isPatternExpression:
src\Analyzers\CSharp\Analyzers\RemoveUnnecessaryParentheses\CSharpRemoveUnnecessaryPatternParenthesesDiagnosticAnalyzer.cs (2)
51if (parenthesizedPattern.Parent is not PatternSyntax) 60if (parenthesizedPattern.Parent is not BinaryPatternSyntax parentPattern)
src\Analyzers\CSharp\Analyzers\RemoveUnreachableCode\RemoveUnreachableCodeHelpers.cs (2)
18switch (firstUnreachableStatement.Parent) 29if (globalStatement.Parent is not CompilationUnitSyntax compilationUnit)
src\Analyzers\CSharp\Analyzers\RemoveUnusedMembers\CSharpRemoveUnusedMembersDiagnosticAnalyzer.cs (2)
41=> variableDeclarator.Parent is VariableDeclarationSyntax 43Parent: FieldDeclarationSyntax { Declaration.Variables.Count: 0 } or
src\Analyzers\CSharp\Analyzers\RemoveUnusedParametersAndValues\CSharpRemoveUnusedParametersAndValuesDiagnosticAnalyzer.cs (2)
69var statementAncestor = unusedSymbolWriteOperation.Syntax.FirstAncestorOrSelf<StatementSyntax>()?.Parent; 103if (unusedDefinition.Syntax.Parent is ForEachStatementSyntax forEachStatement &&
src\Analyzers\CSharp\Analyzers\SimplifyInterpolation\CSharpSimplifyInterpolationHelpers.cs (1)
22ConditionalExpressionSyntax { Parent: ParenthesizedExpressionSyntax parent } => parent,
src\Analyzers\CSharp\Analyzers\SimplifyPropertyPattern\SimplifyPropertyPatternHelpers.cs (1)
26Parent: PropertyPatternClauseSyntax,
src\Analyzers\CSharp\Analyzers\UseCollectionExpression\CSharpUseCollectionExpressionForArrayDiagnosticAnalyzer.cs (4)
150var isConcreteOrImplicitArrayCreation = initializer.Parent is ArrayCreationExpressionSyntax or ImplicitArrayCreationExpressionSyntax; 153if (!isConcreteOrImplicitArrayCreation && initializer.Parent is not EqualsValueClauseSyntax) 175var matches = initializer.Parent switch 189Debug.Assert(initializer.Parent is EqualsValueClauseSyntax);
src\Analyzers\CSharp\Analyzers\UseCollectionExpression\CSharpUseCollectionExpressionForBuilderDiagnosticAnalyzer.cs (6)
137if (invocationExpression.Parent is not EqualsValueClauseSyntax { Parent: VariableDeclaratorSyntax { Parent: VariableDeclarationSyntax { Parent: LocalDeclarationStatementSyntax localDeclarationStatement } } declarator }) 217identifierName.Parent is MemberAccessExpressionSyntax(SyntaxKind.SimpleMemberAccessExpression) memberAccess && 219memberAccess.Parent is InvocationExpressionSyntax { ArgumentList.Arguments.Count: 0 } invocationExpression &&
src\Analyzers\CSharp\Analyzers\UseCollectionExpression\CSharpUseCollectionExpressionForEmptyDiagnosticAnalyzer.cs (1)
42: memberAccess.Parent is InvocationExpressionSyntax invocation && IsCollectionEmptyAccess(semanticModel, invocation, cancellationToken)
src\Analyzers\CSharp\Analyzers\UseCollectionExpression\CSharpUseCollectionExpressionForFluentDiagnosticAnalyzer.cs (3)
80if (memberAccess.Parent is not InvocationExpressionSyntax invocation) 88if (invocation.Parent is MemberAccessExpressionSyntax { Parent: InvocationExpressionSyntax parentInvocation } parentMemberAccess &&
src\Analyzers\CSharp\Analyzers\UseCollectionExpression\UseCollectionExpressionHelpers.cs (8)
460if (memberAccess.Parent is InvocationExpressionSyntax invocationExpression) 496if (locallyScopedExpression.Parent is EqualsValueClauseSyntax { Parent: VariableDeclaratorSyntax declarator }) 585if (argument.Parent is not BaseArgumentListSyntax { Parent: ExpressionSyntax parentInvocation } argumentList) 659Contract.ThrowIfFalse(originalInitializer.Parent 785Parent: VariableDeclaratorSyntax 788Parent.Parent: LocalDeclarationStatementSyntax localDeclarationStatement
src\Analyzers\CSharp\Analyzers\UseConditionalExpression\CSharpUseConditionalExpressionForReturnDiagnosticAnalyzer.cs (1)
39if (block.Syntax.Parent is UnsafeStatementSyntax or CheckedStatementSyntax)
src\Analyzers\CSharp\Analyzers\UseDeconstruction\CSharpUseDeconstructionDiagnosticAnalyzer.cs (3)
103if (variableDeclaration is not { Parent: LocalDeclarationStatementSyntax localDeclaration, Variables: [{ Initializer.Value: { } initializerValue } declarator] }) 110var searchScope = localDeclaration.Parent is GlobalStatementSyntax globalStatement 259if (identifierName.Parent is not MemberAccessExpressionSyntax memberAccess)
src\Analyzers\CSharp\Analyzers\UseImplicitObjectCreation\CSharpUseImplicitObjectCreationDiagnosticAnalyzer.cs (16)
86if (objectCreation.Parent is EqualsValueClauseSyntax 88Parent: VariableDeclaratorSyntax { Parent: VariableDeclarationSyntax { Type.IsVar: false } variableDeclaration } 101else if (objectCreation.Parent.IsKind(SyntaxKind.ArrowExpressionClause)) 103typeNode = objectCreation.Parent.Parent switch 110AccessorDeclarationSyntax(SyntaxKind.GetAccessorDeclaration) { Parent: AccessorListSyntax { Parent: BasePropertyDeclarationSyntax baseProperty } } => baseProperty.Type, 114else if (objectCreation.Parent is InitializerExpressionSyntax { Parent: ObjectCreationExpressionSyntax { Type: var collectionType } }) 123else if (objectCreation.Parent is InitializerExpressionSyntax(kind: SyntaxKind.ArrayInitializerExpression) 125Parent: EqualsValueClauseSyntax { Parent: VariableDeclaratorSyntax { Parent: VariableDeclarationSyntax arrayVariableDeclaration } } 130else if (objectCreation.Parent is InitializerExpressionSyntax { Parent: ArrayCreationExpressionSyntax { Type: var arrayCreationType } })
src\Analyzers\CSharp\Analyzers\UseInferredMemberName\CSharpUseInferredMemberNameDiagnosticAnalyzer.cs (2)
39if (nameColon.Parent is not ArgumentSyntax argument) 68if (nameEquals.Parent is not AnonymousObjectMemberDeclaratorSyntax anonCtor)
src\Analyzers\CSharp\Analyzers\UseLocalFunction\CSharpUseLocalFunctionDiagnosticAnalyzer.cs (9)
93if (localDeclaration.Parent is not BlockSyntax block) 216Parent: EqualsValueClauseSyntax 218Parent: VariableDeclaratorSyntax 220Parent: VariableDeclarationSyntax 222Parent: LocalDeclarationStatementSyntax declaration, 280if (memberAccessExpression.Parent is InvocationExpressionSyntax explicitInvocationExpression && 353if (anonymousFunction?.Parent is AssignmentExpressionSyntax(SyntaxKind.SimpleAssignmentExpression) assignment && 354assignment.Parent is ExpressionStatementSyntax expressionStatement && 355expressionStatement.Parent is BlockSyntax block)
src\Analyzers\CSharp\Analyzers\UseNameofInNullableAttribute\CSharpUseNameofInNullableAttributeDiagnosticAnalyzer.cs (4)
119var attributeList = attribute.Parent as AttributeListSyntax; 120var container = attributeList?.Parent; 124var parameterList = container.Parent as BaseParameterListSyntax; 125container = parameterList?.Parent;
src\Analyzers\CSharp\Analyzers\UsePatternMatching\CSharpAsAndNullCheckDiagnosticAnalyzer.Analyzer.cs (1)
328if (statement.Parent is BlockSyntax block)
src\Analyzers\CSharp\Analyzers\UsePatternMatching\CSharpAsAndNullCheckDiagnosticAnalyzer.cs (2)
112var enclosingBlock = localStatement.Parent; 241if (identifierName.Parent is AssignmentExpressionSyntax assignmentExpression &&
src\Analyzers\CSharp\Analyzers\UsePatternMatching\CSharpIsAndCastCheckDiagnosticAnalyzer.cs (3)
96var ifStatementScope = ifStatement.Parent.IsKind(SyntaxKind.Block) 97? ifStatement.Parent 174if (!isExpression.Parent.IsKind(SyntaxKind.IfStatement, out ifStatement))
src\Analyzers\CSharp\Analyzers\UsePatternMatching\UsePatternMatchingHelpers.cs (5)
29if (asExpression.Parent is not ParenthesizedExpressionSyntax 32Parent: ConditionalAccessExpressionSyntax parentConditionalAccess 54if (conditionalAccessExpression.Parent is BinaryExpressionSyntax(SyntaxKind.EqualsExpression) parentBinaryExpression1 && 63else if (conditionalAccessExpression.Parent is 81else if (conditionalAccessExpression.Parent is IsPatternExpressionSyntax parentIsPatternExpression)
src\Analyzers\CSharp\Analyzers\UsePrimaryConstructor\CSharpUsePrimaryConstructorDiagnosticAnalyzer.cs (3)
125else if (nodeToRemove is VariableDeclaratorSyntax { Parent: VariableDeclarationSyntax { Parent: FieldDeclarationSyntax field } }) 315if (primaryConstructorDeclaration.Parent is not TypeDeclarationSyntax)
src\Analyzers\CSharp\Analyzers\UseSystemThreadingLock\CSharpUseSystemThreadingLockDiagnosticAnalyzer.cs (2)
118if (variableDeclarator.Parent is not VariableDeclarationSyntax { Parent: FieldDeclarationSyntax, Variables.Count: 1 })
src\Analyzers\CSharp\Analyzers\UseUtf8StringLiteral\UseUtf8StringLiteralDiagnosticAnalyzer.cs (2)
105else if (elements is [{ Syntax.Parent: ArgumentSyntax }, ..]) 110else if (elements is [{ Syntax.Parent: (kind: SyntaxKind.CollectionInitializerExpression) }, ..])
src\Analyzers\CSharp\CodeFixes\AddExplicitCast\ArgumentFixer.cs (1)
31var newInvocation = newArgumentList.Parent!;
src\Analyzers\CSharp\CodeFixes\AddExplicitCast\AttributeArgumentFixer.cs (1)
31var newAttribute = (AttributeSyntax)newArgumentList.Parent!;
src\Analyzers\CSharp\CodeFixes\AddExplicitCast\CSharpAddExplicitCastCodeFixProvider.cs (4)
71&& targetArgument.Parent is ArgumentListSyntax argumentList 72&& argumentList.Parent is SyntaxNode invocationNode) 79&& targetAttributeArgument.Parent is AttributeArgumentListSyntax attributeArgumentList 80&& attributeArgumentList.Parent is AttributeSyntax attributeNode)
src\Analyzers\CSharp\CodeFixes\AddInheritdoc\AddInheritdocCodeFixProvider.cs (2)
76if (node is VariableDeclaratorSyntax { Parent.Parent: EventFieldDeclarationSyntax eventField })
src\Analyzers\CSharp\CodeFixes\AssignOutParameters\AbstractAssignOutParametersCodeFixProvider.cs (5)
68return location.Parent is BlockSyntax 69|| location.Parent is SwitchSectionSyntax 70|| location.Parent.IsEmbeddedStatementOwner(); 75return location.Parent is ArrowExpressionClauseSyntax or LambdaExpressionSyntax; 83for (var current = node; current != null; current = current.Parent)
src\Analyzers\CSharp\CodeFixes\AssignOutParameters\AssignOutParametersAtStartCodeFixProvider.cs (2)
40statement.Parent is BlockSyntax block && 42block.Parent == container)
src\Analyzers\CSharp\CodeFixes\ConvertNamespace\ConvertNamespaceTransform.cs (1)
138if (stringLiteral.GetRequiredParent() is not InterpolatedStringTextSyntax { Parent: InterpolatedStringExpressionSyntax { StringStartToken: (kind: SyntaxKind.InterpolatedMultiLineRawStringStartToken) } interpolatedString })
src\Analyzers\CSharp\CodeFixes\ConvertSwitchStatementToExpression\ConvertSwitchStatementToExpressionCodeFixProvider.cs (2)
99if (declaratorToRemoveNode.Parent is VariableDeclarationSyntax { Parent: LocalDeclarationStatementSyntax declStatement, Variables.Count: 1 })
src\Analyzers\CSharp\CodeFixes\ConvertToRecord\ConvertToRecordEngine.cs (2)
184(expression.Parent as AssignmentExpressionSyntax)?.Parent as ExpressionStatementSyntax)
src\Analyzers\CSharp\CodeFixes\FixIncorrectConstraint\CSharpFixIncorrectConstraintCodeFixProvider.cs (1)
41if (constraint.Parent is not TypeParameterConstraintClauseSyntax)
src\Analyzers\CSharp\CodeFixes\GenerateConstructor\CSharpGenerateConstructorService.cs (4)
89? (NameSyntax)simpleName.Parent 92if (fullName.Parent is ObjectCreationExpressionSyntax objectCreationExpression) 121? (NameSyntax)simpleName.Parent 124if (fullName.Parent is AttributeSyntax attribute)
src\Analyzers\CSharp\CodeFixes\GenerateDefaultConstructors\CSharpGenerateDefaultConstructorsService.cs (2)
44if (node is { Parent: BaseTypeSyntax { Parent: BaseListSyntax { Types: [var firstType, ..] } baseList } }) 46if (baseList.Parent is TypeDeclarationSyntax(SyntaxKind.ClassDeclaration or SyntaxKind.RecordDeclaration) parentTypeDecl &&
src\Analyzers\CSharp\CodeFixes\GenerateEnumMember\CSharpGenerateEnumMemberService.cs (2)
33simpleNameOrMemberAccessExpression = identifierName.Parent is MemberAccessExpressionSyntax memberAccess && memberAccess.Name == identifierName 40if (simpleNameOrMemberAccessExpression.Parent.Kind()
src\Analyzers\CSharp\CodeFixes\GenerateParameterizedMember\CSharpGenerateConversionService.cs (2)
31(node.Parent is AssignmentExpressionSyntax || node.Parent is EqualsValueClauseSyntax) &&
src\Analyzers\CSharp\CodeFixes\GenerateParameterizedMember\CSharpGenerateMethodService.cs (4)
89var memberAccess = simpleName?.Parent as MemberAccessExpressionSyntax; 90var conditionalMemberAccess = simpleName?.Parent?.Parent?.Parent as ConditionalAccessExpressionSyntax;
src\Analyzers\CSharp\CodeFixes\ImplementInterface\CSharpImplementInterfaceCodeFixProvider.cs (2)
29=> type.Parent is BaseTypeSyntax { Parent: BaseListSyntax } baseTypeParent && baseTypeParent.Type == type;
src\Analyzers\CSharp\CodeFixes\ImplementInterface\CSharpImplementInterfaceService.cs (7)
47if (node is TypeSyntax interfaceNode && interfaceNode.Parent is BaseTypeSyntax baseType && 51if (interfaceNode.Parent.Parent?.Parent.Kind() is 64classOrStructDecl = interfaceNode.Parent.Parent.Parent as TypeDeclarationSyntax;
src\Analyzers\CSharp\CodeFixes\InlineDeclaration\CSharpInlineDeclarationCodeFixProvider.cs (4)
108var declaration = (VariableDeclarationSyntax)declarator.Parent; 117var localDeclarationStatement = (LocalDeclarationStatementSyntax)declaration.Parent; 118var block = CSharpInlineDeclarationDiagnosticAnalyzer.GetEnclosingPseudoBlock(localDeclarationStatement.Parent); 175editor.RemoveNode(localDeclarationStatement.Parent is GlobalStatementSyntax globalStatement
src\Analyzers\CSharp\CodeFixes\InvokeDelegateWithConditionalAccess\InvokeDelegateWithConditionalAccessCodeFixProvider.cs (1)
99if (ifStatement.Parent.IsKind(SyntaxKind.ElseClause) &&
src\Analyzers\CSharp\CodeFixes\Iterator\CSharpChangeToIEnumerableCodeFixProvider.cs (4)
87var oldAccessor = node.Parent?.Parent as PropertyDeclarationSyntax; 93var oldIndexer = node.Parent?.Parent as IndexerDeclarationSyntax;
src\Analyzers\CSharp\CodeFixes\MakeLocalFunctionStatic\MakeLocalFunctionStaticCodeFixHelper.cs (1)
74if (identifierNode.Parent is InvocationExpressionSyntax invocation)
src\Analyzers\CSharp\CodeFixes\MakeMemberRequired\CSharpMakeMemberRequiredCodeFixProvider.cs (4)
50if (node is not (PropertyDeclarationSyntax or VariableDeclaratorSyntax { Parent.Parent: FieldDeclarationSyntax })) 125if (memberDeclarator is VariableDeclaratorSyntax { Parent.Parent: FieldDeclarationSyntax fieldDeclaration })
src\Analyzers\CSharp\CodeFixes\MakeMemberStatic\CSharpMakeMemberStaticCodeFixProvider.cs (4)
31if (node.IsKind(SyntaxKind.VariableDeclarator) && node.Parent is VariableDeclarationSyntax { Parent: FieldDeclarationSyntax or EventFieldDeclarationSyntax }) 33memberDeclaration = node.Parent.Parent;
src\Analyzers\CSharp\CodeFixes\MakeStatementAsynchronous\CSharpMakeStatementAsynchronousCodeFixProvider.cs (2)
98if (node.Parent is (kind: 103return node.Parent;
src\Analyzers\CSharp\CodeFixes\MakeStructMemberReadOnly\CSharpMakeStructMemberReadOnlyCodeFixProvider.cs (2)
53else if (declaration is AccessorDeclarationSyntax { Parent: AccessorListSyntax { Parent: BasePropertyDeclarationSyntax property } accessorList } accessor)
src\Analyzers\CSharp\CodeFixes\Nullable\CSharpDeclareAsNullableCodeFixProvider.cs (20)
60if (node.Parent is ArgumentSyntax) 64if (node.Parent is AssignmentExpressionSyntax) 117if (node.Parent is (kind: SyntaxKind.ReturnStatement or SyntaxKind.YieldReturnStatement)) 162if (node.Parent?.Parent?.Parent is VariableDeclarationSyntax variableDeclaration) 171if (node.Parent is AssignmentExpressionSyntax assignment) 177if (syntax is VariableDeclaratorSyntax { Parent: VariableDeclarationSyntax { Variables.Count: 1 } declaration }) 188if (syntax is VariableDeclaratorSyntax { Parent: VariableDeclarationSyntax { Variables.Count: 1 } declaration }) 213if (node.Parent is ArgumentSyntax argument && argument.Parent?.Parent is InvocationExpressionSyntax invocation) 240if (node.Parent?.Parent is PropertyDeclarationSyntax propertyDeclaration) 250if (node is VariableDeclaratorSyntax { Parent: VariableDeclarationSyntax { Parent: FieldDeclarationSyntax, Variables.Count: 1 } declarationSyntax }) 254if (node.Parent?.Parent is ParameterSyntax optionalParameter) 262node.Parent?.Parent is MethodDeclarationSyntax arrowMethod)
src\Analyzers\CSharp\CodeFixes\RemoveUnnecessaryDiscardDesignation\CSharpRemoveUnnecessaryDiscardDesignationCodeFixProvider.cs (1)
46if (declarationPattern.Parent is IsPatternExpressionSyntax isPattern)
src\Analyzers\CSharp\CodeFixes\RemoveUnreachableCode\CSharpRemoveUnreachableCodeCodeFixProvider.cs (1)
82if (statement.Parent?.Kind()
src\Analyzers\CSharp\CodeFixes\RemoveUnusedParametersAndValues\CSharpRemoveUnusedValuesCodeFixProvider.cs (4)
43=> declarator.Parent?.Parent as LocalDeclarationStatementSyntax; 57variableDeclarator.Parent is VariableDeclarationSyntax parent) 213if (originalCompoundAssignment.Parent.IsKind(SyntaxKind.ExpressionStatement))
src\Analyzers\CSharp\CodeFixes\UseCollectionExpression\CSharpCollectionExpressionRewriter.cs (3)
547Contract.ThrowIfNull(expression.Parent); 591for (var current = node; current != null; current = current.Parent) 814Contract.ThrowIfNull(expression.Parent);
src\Analyzers\CSharp\CodeFixes\UseCollectionInitializer\CSharpUseCollectionInitializerCodeFixProvider_CollectionInitializer.cs (1)
99Contract.ThrowIfNull(expression.Parent);
src\Analyzers\CSharp\CodeFixes\UseCompoundAssignment\CSharpUseCompoundAssignmentCodeFixProvider.cs (1)
52if (currentAssignment.Parent is ForStatementSyntax forStatement &&
src\Analyzers\CSharp\CodeFixes\UseConditionalExpression\CSharpUseConditionalExpressionForAssignmentCodeFixProvider.cs (1)
47if (ifStatement.Parent is ElseClauseSyntax &&
src\Analyzers\CSharp\CodeFixes\UseConditionalExpression\CSharpUseConditionalExpressionForReturnCodeFixProvider.cs (1)
34if (ifStatement.Parent is ElseClauseSyntax &&
src\Analyzers\CSharp\CodeFixes\UseDeconstruction\CSharpUseDeconstructionCodeFixProvider.cs (2)
74var variableDeclaration = (VariableDeclarationSyntax)variableDeclarator.Parent; 81variableDeclaration.Parent,
src\Analyzers\CSharp\CodeFixes\UseImplicitOrExplicitType\UseExplicitTypeCodeFixProvider.cs (4)
58var declarationContext = node.Parent; 62declarationContext = declarationContext.Parent; 92RoslynDebug.AssertNotNull(typeSyntax.Parent); 94var tupleTypeSymbol = GetConvertedType(semanticModel, typeSyntax.Parent, cancellationToken);
src\Analyzers\CSharp\CodeFixes\UseIndexOrRangeOperator\CSharpUseRangeOperatorCodeFixProvider.cs (1)
228while (expr?.Parent is CheckedExpressionSyntax parent)
src\Analyzers\CSharp\CodeFixes\UseNullPropagation\CSharpUseNullPropagationCodeFixProvider.cs (1)
49var elseClauseSyntax = (ElseClauseSyntax)ifStatement.Parent!;
src\Analyzers\CSharp\CodeFixes\UsePatternMatching\CSharpAsAndNullCheckCodeFixProvider.cs (4)
75if (statement.Parent is BlockSyntax or SwitchSectionSyntax) 77statementParentScopes.Add(statement.Parent); 110if (declarator.Parent is VariableDeclarationSyntax declaration && 111declaration.Parent is LocalDeclarationStatementSyntax localDeclaration &&
src\Analyzers\CSharp\CodeFixes\UsePrimaryConstructor\CSharpUsePrimaryConstructorCodeFixProvider.cs (2)
285if (nameSyntax.Parent is QualifiedNameSyntax qualifiedNameSyntax) 294else if (nameSyntax.Parent is MemberAccessExpressionSyntax memberAccessExpression)
src\Analyzers\CSharp\CodeFixes\UseSystemThreadingLock\CSharpUseSystemThreadingLockCodeFixProvider.cs (4)
90if (variableDeclarator.Parent is not VariableDeclarationSyntax { Parent: FieldDeclarationSyntax } variableDeclaration) 141if (expression.Parent is MemberAccessExpressionSyntax memberAccess && 147if (expression.Parent is not AssignmentExpressionSyntax assignment ||
src\Analyzers\CSharp\CodeFixes\UseThrowExpression\UseThrowExpressionCodeFixProvider.cs (1)
63if (throwStatementExpression.Parent is ThrowStatementSyntax throwStatement &&
src\Compilers\CSharp\CSharpAnalyzerDriver\CSharpDeclarationComputer.cs (1)
201if (node.Parent is BasePropertyDeclarationSyntax parentProperty)
src\Compilers\CSharp\Portable\Syntax\LambdaUtilities.cs (21)
40return !node.Parent.IsKind(SyntaxKind.QueryExpression); 53Debug.Assert(lambdaBody.Parent is object); 54var lambda = lambdaBody.Parent; 60lambda = lambda.Parent; 73Debug.Assert(oldBody.Parent is object); 103var oldJoin = (JoinClauseSyntax)oldBody.Parent; 109var oldGroup = (GroupClauseSyntax)oldBody.Parent; 141var parent = node?.Parent; 161return arrowExpressionClause.Expression == node && arrowExpressionClause.Parent is LocalFunctionStatementSyntax; 165return fromClause.Expression == node && fromClause.Parent is QueryBodySyntax; 228Debug.Assert(selectOrGroupClause.Parent!.Parent is object); 229var containingQueryOrContinuation = selectOrGroupClause.Parent.Parent; 298if (node.Parent.IsKind(SyntaxKind.QueryExpression)) 440if (node.Parent != null) 442switch (node.Parent.Kind()) 448SeparatedSyntaxList<ExpressionSyntax> incrementors = ((ForStatementSyntax)node.Parent).Incrementors; 466if (node is ExpressionSyntax && node.Parent != null && node.Parent.Parent == null)
src\Compilers\CSharp\Portable\Syntax\SyntaxBindingUtilities.cs (4)
17or VariableDeclaratorSyntax { Parent.Parent: UsingStatementSyntax { AwaitKeyword.RawKind: not 0 } or LocalDeclarationStatementSyntax { AwaitKeyword.RawKind: not 0 } } 21=> node is VariableDeclaratorSyntax { Parent.Parent: UsingStatementSyntax { } or LocalDeclarationStatementSyntax { UsingKeyword.RawKind: not 0 } }
Structure\Providers\ArrowExpressionClauseStructureProvider.cs (2)
27textSpan: TextSpan.FromBounds(previousToken.Span.End, node.Parent.Span.End), 28hintSpan: node.Parent.Span,
Structure\Providers\BlockSyntaxStructureProvider.cs (2)
39if (parent is IfStatementSyntax { Parent: not ElseClauseSyntax } ifStatement) 176if (node.Parent.IsKind(SyntaxKind.IfStatement))
Structure\Providers\CollectionExpressionStructureProvider.cs (2)
22if (node.Parent?.Parent is CollectionExpressionSyntax)
Structure\Providers\InitializerExpressionStructureProvider.cs (2)
24if (node.Parent is InitializerExpressionSyntax) 65hintSpan: node.Parent.Span,
UseAutoProperty\UseAutoPropertyRewriter.cs (2)
45if (node.Parent is AssignmentExpressionSyntax 47Parent: InitializerExpressionSyntax { RawKind: (int)SyntaxKind.ObjectInitializerExpression }
UseExpressionBody\UseExpressionBodyCodeRefactoringProvider.cs (2)
152for (var current = node; current != null; current = current.Parent) 178? declaration.Parent
UseNamedArguments\CSharpUseNamedArgumentsCodeRefactoringProvider.cs (2)
30=> argument.Parent?.Parent;
UsePatternMatching\CSharpIsAndCastCheckWithoutNameDiagnosticAnalyzer.cs (1)
254for (SyntaxNode? current = isExpression; current != null; current = current.Parent)
Wrapping\SeparatedSyntaxList\CSharpArgumentWrapper.cs (1)
100for (var current = token.Parent; current != listSyntax; current = current?.Parent)
Microsoft.CodeAnalysis.CSharp.Features.UnitTests (1)
EditAndContinue\CSharpEditAndContinueAnalyzerTests.cs (1)
59node = node.Parent;
Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests (291)
Semantics\BindingTests.cs (22)
2726.First(x => x.Parent.IsKind(SyntaxKind.SimpleMemberAccessExpression) && x.Identifier.ValueText.Equals("M0")); 2728Assert.Equal("A.B<string>.M0", identifierNameM0.Parent.ToString()); 2738.First(x => x.Parent.IsKind(SyntaxKind.SimpleMemberAccessExpression) && x.Identifier.ValueText.Equals("M1")); 2740Assert.Equal("A.B<string>.M1", identifierNameM1.Parent.ToString()); 2786Assert.Equal("(MyDelegate<int>)MyMethod", identifiers[0].Parent.ToString()); 2789Assert.Equal("(MyDelegate<long>)MyMethod", identifiers[1].Parent.ToString()); 2792Assert.Equal("(MyDelegate<float>)MyMethod", identifiers[2].Parent.ToString()); 2795Assert.Equal("(MyDelegate<double>)MyMethod", identifiers[3].Parent.ToString()); 2837.First(x => x.Parent.IsKind(SyntaxKind.SimpleMemberAccessExpression) && x.Identifier.ValueText.Equals("M0")); 2839Assert.Equal("b.M0", identifierNameM0.Parent.ToString()); 2849.First(x => x.Parent.IsKind(SyntaxKind.SimpleMemberAccessExpression) && x.Identifier.ValueText.Equals("M1")); 2851Assert.Equal("b.M1", identifierNameM1.Parent.ToString()); 3037var node1 = tree.GetRoot().DescendantNodes().Where(n => n.IsKind(SyntaxKind.IdentifierName) && ((IdentifierNameSyntax)n).Identifier.ValueText == "Use").Single().Parent; 3051var node = tree.GetRoot().DescendantNodes().Where(n => n.IsKind(SyntaxKind.IdentifierName) && ((IdentifierNameSyntax)n).Identifier.ValueText == "AuthenticateAsync").Single().Parent; 3117var node1 = tree.GetRoot().DescendantNodes().Where(n => n.IsKind(SyntaxKind.IdentifierName) && ((IdentifierNameSyntax)n).Identifier.ValueText == "Use").Single().Parent; 3131var node = tree.GetRoot().DescendantNodes().Where(n => n.IsKind(SyntaxKind.IdentifierName) && ((IdentifierNameSyntax)n).Identifier.ValueText == "AuthenticateAsync").Single().Parent; 3190var node1 = tree.GetRoot().DescendantNodes().Where(n => n.IsKind(SyntaxKind.IdentifierName) && ((IdentifierNameSyntax)n).Identifier.ValueText == "Use").Single().Parent; 3205var node = tree.GetRoot().DescendantNodes().Where(n => n.IsKind(SyntaxKind.IdentifierName) && ((IdentifierNameSyntax)n).Identifier.ValueText == "AuthenticateAsync").Single().Parent; 3275var node1 = tree.GetRoot().DescendantNodes().Where(n => n.IsKind(SyntaxKind.IdentifierName) && ((IdentifierNameSyntax)n).Identifier.ValueText == "Use").Single().Parent; 3290var node = tree.GetRoot().DescendantNodes().Where(n => n.IsKind(SyntaxKind.IdentifierName) && ((IdentifierNameSyntax)n).Identifier.ValueText == "AuthenticateAsync").Single().Parent; 3380var node1 = tree.GetRoot().DescendantNodes().Where(n => n.IsKind(SyntaxKind.IdentifierName) && ((IdentifierNameSyntax)n).Identifier.ValueText == "MathMin").Single().Parent; 3732var node1 = tree.GetRoot().DescendantNodes().Where(n => n.IsKind(SyntaxKind.IdentifierName) && ((IdentifierNameSyntax)n).Identifier.ValueText == "E").Single().Parent;
Semantics\ColorColorTests.cs (17)
597var parentExpr = (ExpressionSyntax)expr.Parent; 644var parentExpr = (ExpressionSyntax)expr.Parent; 1073var parentExpr = (ExpressionSyntax)expr.Parent; 1119var parentExpr = (ExpressionSyntax)expr.Parent; 1165var parentExpr = (ExpressionSyntax)expr.Parent; 1210var parentExpr = (ExpressionSyntax)expr.Parent; 1254var parentExpr = (ExpressionSyntax)expr.Parent; 1288var parentExpr = (ExpressionSyntax)expr.Parent; 1851var parentExpr = (ExpressionSyntax)expr.Parent; 1892var node2 = tree.GetRoot().DescendantNodes().OfType<IdentifierNameSyntax>().Where(n => n.Identifier.Text == "E" && (n.Parent is EqualsValueClauseSyntax)).Single(); 1894Assert.Equal("= E", node2.Parent.ToString()); 1949var node2 = tree.GetRoot().DescendantNodes().OfType<IdentifierNameSyntax>().Where(n => n.Identifier.Text == "E" && (n.Parent is EqualsValueClauseSyntax)).Single(); 1951Assert.Equal("= E", node2.Parent.ToString()); 2006var node2 = tree.GetRoot().DescendantNodes().OfType<IdentifierNameSyntax>().Where(n => n.Identifier.Text == "E" && (n.Parent is EqualsValueClauseSyntax)).Single(); 2008Assert.Equal("= E", node2.Parent.ToString()); 2055var node2 = tree.GetRoot().DescendantNodes().OfType<IdentifierNameSyntax>().Where(n => n.Identifier.Text == "E" && (n.Parent is EqualsValueClauseSyntax)).Single(); 2057Assert.Equal("= E", node2.Parent.ToString());
Semantics\ConditionalOperatorTests.cs (4)
1347var access = (ConditionalAccessExpressionSyntax)memberBinding.Parent!; 1401var invocation = (InvocationExpressionSyntax)memberBinding.Parent!; 1402var access = (ConditionalAccessExpressionSyntax)invocation.Parent!; 1448var access = (ConditionalAccessExpressionSyntax)memberBinding.Parent!;
Semantics\DeconstructionTests.cs (5)
5997var argument = (ArgumentSyntax)mainCall.Parent; 6040var argument = (ArgumentSyntax)mainCall.Parent; 6080var argument = (ArgumentSyntax)mainCall.Parent; 6122var argument = (ArgumentSyntax)two.Parent; 6162var argument = (ArgumentSyntax)mainCall.Parent;
Semantics\DynamicTests.cs (68)
6690var assignment = (AssignmentExpressionSyntax)elementAccess.Parent; 6799var assignment = (AssignmentExpressionSyntax)elementAccess.Parent; 6909var assignment = (AssignmentExpressionSyntax)elementAccess.Parent; 7006var assignment = (AssignmentExpressionSyntax)elementAccess.Parent; 7078var assignment = (AssignmentExpressionSyntax)elementAccess.Parent; 7181var assignment = (AssignmentExpressionSyntax)elementAccess.Parent; 7294var assignment = (AssignmentExpressionSyntax)elementAccess.Parent; 7410var assignment = (AssignmentExpressionSyntax)elementAccess.Parent; 7523var assignment = (AssignmentExpressionSyntax)elementAccess.Parent; 7600var assignment = (AssignmentExpressionSyntax)elementAccess.Parent; 7705var assignment = (PostfixUnaryExpressionSyntax)elementAccess.Parent; 7811var assignment = (PostfixUnaryExpressionSyntax)elementAccess.Parent; 7915var assignment = (PostfixUnaryExpressionSyntax)elementAccess.Parent; 7986var assignment = (PrefixUnaryExpressionSyntax)elementAccess.Parent; 8092var assignment = (PrefixUnaryExpressionSyntax)elementAccess.Parent; 8197var assignment = (PrefixUnaryExpressionSyntax)elementAccess.Parent; 8302var assignment = (AssignmentExpressionSyntax)elementAccess.Parent; 8411var assignment = (AssignmentExpressionSyntax)elementAccess.Parent; 8520var assignment = (AssignmentExpressionSyntax)elementAccess.Parent; 8630var assignment = (AssignmentExpressionSyntax)elementAccess.Parent; 8739var assignment = (AssignmentExpressionSyntax)elementAccess.Parent; 8808var assignment = (AssignmentExpressionSyntax)elementAccess.Parent; 8880var assignment = (AssignmentExpressionSyntax)elementAccess.Parent; 8936var assignment = (AssignmentExpressionSyntax)elementAccess.Parent; 9026var assignment = (AssignmentExpressionSyntax)elementAccess.Parent; 9117var assignment = (AssignmentExpressionSyntax)elementAccess.Parent; 9207var assignment = (AssignmentExpressionSyntax)elementAccess.Parent; 9263var assignment = (AssignmentExpressionSyntax)elementAccess.Parent; 9324var assignment = (AssignmentExpressionSyntax)elementAccess.Parent; 9445var assignment = (AssignmentExpressionSyntax)elementAccess.Parent; 9565var assignment = (AssignmentExpressionSyntax)elementAccess.Parent; 9679var assignment = (AssignmentExpressionSyntax)elementAccess.Parent; 9790var assignment = (AssignmentExpressionSyntax)elementAccess.Parent; 9901var assignment = (AssignmentExpressionSyntax)elementAccess.Parent; 10032var left = (TupleExpressionSyntax)elementAccess.Parent.Parent; 10037var assignment = (AssignmentExpressionSyntax)left.Parent; 10160var left = (TupleExpressionSyntax)elementAccess.Parent.Parent; 10165var assignment = (AssignmentExpressionSyntax)left.Parent; 10288var left = (TupleExpressionSyntax)elementAccess.Parent.Parent; 10293var assignment = (AssignmentExpressionSyntax)left.Parent; 10442var left = (TupleExpressionSyntax)elementAccess.Parent.Parent; 10447var assignment = (AssignmentExpressionSyntax)left.Parent; 10576var left = (TupleExpressionSyntax)elementAccess.Parent.Parent; 10581var assignment = (AssignmentExpressionSyntax)left.Parent; 10724var left = (TupleExpressionSyntax)elementAccess.Parent.Parent; 10729var assignment = (AssignmentExpressionSyntax)left.Parent; 10994var left = (TupleExpressionSyntax)elementAccess.Parent.Parent; 10999var assignment = (AssignmentExpressionSyntax)left.Parent; 11112var left = (TupleExpressionSyntax)elementAccess.Parent.Parent; 11117left = (TupleExpressionSyntax)left.Parent.Parent; 11122var assignment = (AssignmentExpressionSyntax)left.Parent; 11196var left = (TupleExpressionSyntax)elementAccess.Parent.Parent; 11201left = (TupleExpressionSyntax)left.Parent.Parent; 11206var assignment = (AssignmentExpressionSyntax)left.Parent; 11274var left = (TupleExpressionSyntax)elementAccess.Parent.Parent; 11279var assignment = (AssignmentExpressionSyntax)left.Parent;
Semantics\FunctionPointerTests.cs (4)
3221FunctionPointerUtilities.VerifyFunctionPointerSemanticInfo(model, invocations[2].Parent!.Parent!, 3227VerifyOperationTreeForNode(comp, model, invocations[2].Parent!.Parent!, expectedOperationTree: @"
Semantics\ImplicitObjectCreationTests.cs (8)
3218Assert.Equal("(o, new())", first.Parent.Parent.ToString()); 3222Assert.Equal("(new(), o)", second.Parent.Parent.ToString()); 3226Assert.Equal("(c, new())", third.Parent.Parent.ToString()); 3230Assert.Equal("(new(), c)", fourth.Parent.Parent.ToString());
Semantics\LambdaTests.cs (4)
1515Assert.Equal("a.", node.Parent.ToString().Trim()); 1550Assert.Equal("a.", node.Parent.ToString().Trim()); 1584Assert.Equal("a.", node.Parent.ToString().Trim()); 1616Assert.Equal("a.", node.Parent.ToString().Trim());
Semantics\MethodTypeInferenceTests.cs (1)
844var declaration = (DeclarationExpressionSyntax)discard.Parent;
Semantics\NonTrailingNamedArgumentsTests.cs (2)
52Assert.Equal("a: 1", firstNamedArgA.Parent.ToString()); 64Assert.Equal("a: 4", secondNamedArgA.Parent.ToString());
Semantics\NullableReferenceTypesTests.cs (1)
65901Assert.Equal("object?", object2.Parent.ToString());
Semantics\ObjectAndCollectionInitializerTests.cs (2)
4238var assignment = (AssignmentExpressionSyntax)elementAccess.Parent; 4292var assignment = (AssignmentExpressionSyntax)propertyAccess.Parent;
Semantics\QueryTests.cs (1)
2246var e2 = e.Parent as ExpressionSyntax; // w+1
Semantics\RecordStructTests.cs (8)
2595Assert.Equal("= X + 1", x.Parent!.Parent!.ToString()); 2630Assert.Equal("= X + 1", x.Parent!.Parent!.ToString()); 2664Assert.Equal("= X + 1", x.Parent!.Parent!.ToString()); 2699Assert.Equal("() => X + 1", x.Parent!.Parent!.ToString());
Semantics\RefEscapingTests.cs (8)
5786Assert.Equal(@"(global, s) = (local, """")", tuple2.Parent.ToString()); 5792Assert.Equal(@"(global, s) = (local, null)", tuple3.Parent.ToString()); 5798Assert.Equal(@"(c, s) = (local, """")", tuple6.Parent.ToString()); 5804Assert.Equal("(c, s) = (local, null)", tuple7.Parent.ToString()); 5886Assert.Equal(@"(global, s) = (local, """")", tuple2.Parent.ToString()); 5892Assert.Equal(@"(global, s) = (local, null)", tuple3.Parent.ToString()); 5898Assert.Equal(@"(c, s) = (local, """")", tuple6.Parent.ToString()); 5904Assert.Equal("(c, s) = (local, null)", tuple7.Parent.ToString());
Semantics\RefFieldTests.cs (26)
12073var type = ((VariableDeclarationSyntax)decl.Parent).Type; 12141var type = ((VariableDeclarationSyntax)decl.Parent).Type; 12207var type = ((VariableDeclarationSyntax)decl.Parent).Type; 12396var type = ((DeclarationExpressionSyntax)decl.Parent).Type; 12428var type = ((DeclarationExpressionSyntax)decl.Parent).Type; 12580var type = ((DeclarationExpressionSyntax)decl.Parent).Type; 12608var type = ((DeclarationExpressionSyntax)decl.Parent).Type; 12807var type = ((DeclarationExpressionSyntax)decl.Parent).Type; 12841var type = ((DeclarationExpressionSyntax)decl.Parent).Type; 12987var type = ((DeclarationExpressionSyntax)decl.Parent).Type; 13015var type = ((DeclarationExpressionSyntax)decl.Parent).Type; 13453var type = ((VariableDeclarationSyntax)decl.Parent).Type; 13517var type = ((VariableDeclarationSyntax)decl.Parent).Type; 13594var type = ((DeclarationExpressionSyntax)decl.Parent).Type; 13664var type = ((DeclarationExpressionSyntax)decl.Parent).Type; 14361var type = ((VariableDeclarationSyntax)decls[0].Parent).Type; 14403var type = ((VariableDeclarationSyntax)decls[0].Parent).Type; 14855var type = ((DeclarationExpressionSyntax)decl.Parent).Type; 14883var type = ((DeclarationExpressionSyntax)decl.Parent).Type; 27619var type = ((VariableDeclarationSyntax)decl.Parent).Type; 27709var type = ((VariableDeclarationSyntax)decl.Parent).Type; 27980var type = ((VariableDeclarationSyntax)decl.Parent).Type; 28040var type = ((VariableDeclarationSyntax)decl.Parent).Type; 28262var type = ((VariableDeclarationSyntax)decls[0].Parent).Type; 28310var type = ((VariableDeclarationSyntax)decls[0].Parent).Type; 29395var symbol = model.GetDeclaredSymbol(fieldInitializerSyntax.Parent);
Semantics\TargetTypedDefaultTests.cs (9)
1632Assert.Equal("s += default", defaultLiteral.Parent.ToString()); 2415Assert.Equal("(o, default)", first.Parent.Parent.ToString()); 2420Assert.Equal("(default, o)", second.Parent.Parent.ToString()); 2425Assert.Equal("(s, default)", third.Parent.Parent.ToString()); 2430Assert.Equal("(default, s)", fourth.Parent.Parent.ToString());
Semantics\TopLevelStatementsTests.cs (99)
200var operation1 = model1.GetOperation(localRef.Parent); 328var operation1 = model1.GetOperation(localRef.Parent); 1709Assert.Equal("System.Console.WriteLine(Test)", nameRef.Parent.Parent.Parent.ToString()); 1717Assert.Equal("using alias1 = Test;", nameRef.Parent.ToString()); 1733Assert.Equal(": Test", nameRef.Parent.Parent.ToString()); 1739Assert.Equal("System.Console.WriteLine(Test)", nameRef.Parent.Parent.Parent.ToString()); 1744Assert.Equal("using alias2 = Test;", nameRef.Parent.ToString()); 1749Assert.Equal(": Test", nameRef.Parent.Parent.ToString()); 1755Assert.Equal("System.Console.WriteLine(Test)", nameRef.Parent.Parent.Parent.ToString()); 1885Assert.Equal("using alias1 = Test;", nameRef.Parent.ToString()); 1901Assert.Equal(": Test", nameRef.Parent.Parent.ToString()); 1907Assert.Equal("System.Console.WriteLine(Test)", nameRef.Parent.Parent.Parent.ToString()); 1912Assert.Equal("using alias2 = Test;", nameRef.Parent.ToString()); 1917Assert.Equal(": Test", nameRef.Parent.Parent.ToString()); 1923Assert.Equal("System.Console.WriteLine(Test)", nameRef.Parent.Parent.Parent.ToString()); 2103Assert.Equal("using alias1 = Test;", nameRef.Parent.ToString()); 2116Assert.Equal(": Test", nameRef.Parent.Parent.ToString()); 2121Assert.Equal("System.Console.WriteLine(Test())", nameRef.Parent.Parent.Parent.Parent.ToString()); 2126Assert.Equal("using alias2 = Test;", nameRef.Parent.ToString()); 2131Assert.Equal(": Test", nameRef.Parent.Parent.ToString()); 2136Assert.Equal("System.Console.WriteLine(Test())", nameRef.Parent.Parent.Parent.Parent.ToString()); 2269Assert.Equal("using alias1 = Test;", nameRef.Parent.ToString()); 2282Assert.Equal(": Test", nameRef.Parent.Parent.ToString()); 2287Assert.Equal("System.Console.WriteLine(Test())", nameRef.Parent.Parent.Parent.Parent.ToString()); 2292Assert.Equal("using alias2 = Test;", nameRef.Parent.ToString()); 2297Assert.Equal(": Test", nameRef.Parent.Parent.ToString()); 2302Assert.Equal("System.Console.WriteLine(Test())", nameRef.Parent.Parent.Parent.Parent.ToString()); 2449Assert.Equal("using alias1 = Test;", nameRef.Parent.ToString()); 2464Assert.Equal("goto Test;", nameRef.Parent.ToString()); 2479Assert.Equal(": Test", nameRef.Parent.Parent.ToString()); 2484Assert.Equal("goto Test;", nameRef.Parent.ToString()); 2489Assert.Equal("using alias2 = Test;", nameRef.Parent.ToString()); 2494Assert.Equal(": Test", nameRef.Parent.Parent.ToString()); 2500Assert.Equal("goto Test;", nameRef.Parent.ToString()); 2919var nameRef = tree1.GetRoot().DescendantNodes().OfType<IdentifierNameSyntax>().Where(id => id.Identifier.ValueText == "alias1" && !id.Parent.IsKind(SyntaxKind.NameEquals)).Single(); 2941nameRef = tree2.GetRoot().DescendantNodes().OfType<IdentifierNameSyntax>().Where(id => id.Identifier.ValueText == "alias2" && !id.Parent.IsKind(SyntaxKind.NameEquals)).Single(); 3944Assert.Equal("using alias1 = args;", nameRef.Parent.ToString()); 3956Assert.Equal("System.Console.WriteLine(args)", nameRef.Parent.Parent.Parent.ToString()); 3975Assert.Equal(": args", nameRef.Parent.Parent.ToString()); 3980Assert.Equal("System.Console.WriteLine(args)", nameRef.Parent.Parent.Parent.ToString()); 3985Assert.Equal("using alias2 = args;", nameRef.Parent.ToString()); 3990Assert.Equal(": args", nameRef.Parent.Parent.ToString()); 3995Assert.Equal("System.Console.WriteLine(args)", nameRef.Parent.Parent.Parent.ToString()); 4093Assert.Equal("using alias1 = args;", nameRef.Parent.ToString()); 4105Assert.Equal(": args", nameRef.Parent.Parent.ToString()); 4110Assert.Equal("System.Console.WriteLine(args)", nameRef.Parent.Parent.Parent.ToString()); 4115Assert.Equal("using alias2 = args;", nameRef.Parent.ToString()); 4120Assert.Equal(": args", nameRef.Parent.Parent.ToString()); 4125Assert.Equal("System.Console.WriteLine(args)", nameRef.Parent.Parent.Parent.ToString()); 6456Assert.True(syntaxTreeModel.TestOnlyMemberModels.ContainsKey(globalStatement.Parent)); 6458MemberSemanticModel mm = syntaxTreeModel.TestOnlyMemberModels[globalStatement.Parent]; 9707model.TryGetSpeculativeSemanticModel(root.DescendantNodes().Single(n => n is ExpressionStatementSyntax { Parent: GlobalStatementSyntax }).Span.End, nodeToSpeculate, out var speculativeModelInTopLevel); 9712model.TryGetSpeculativeSemanticModel(root.DescendantNodes().Single(n => n is ExpressionStatementSyntax { Parent: BlockSyntax }).Span.End, nodeToSpeculate, out var speculativeModelOutsideTopLevel);
Semantics\UnsafeTests.cs (2)
7850var callSyntax = syntax.Parent; 7917var callSyntax = syntax.Parent;
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (33)
Compilation\GetSemanticInfoTests.cs (4)
3640var cast = (CastExpressionSyntax)literal.Parent; 3673var cast = (CastExpressionSyntax)literal.Parent; 3709var cast1 = (CastExpressionSyntax)literal.Parent; 3721var cast2 = (CastExpressionSyntax)cast1.Parent;
Compilation\SemanticModelAPITests.cs (2)
3751var expr = identifier.FirstAncestorOrSelf<ArgumentSyntax>().Parent.Parent;
DeclarationTests.cs (1)
919for (var node = token.Parent; node != null; node = node.Parent)
DocumentationComments\CrefTests.cs (1)
5799if (typeSyntax.Parent.Kind() == SyntaxKind.NameMemberCref)
Symbols\CheckedUserDefinedOperatorsTests.cs (13)
7213Assert.Equal("System.Int64 C0.op_CheckedExplicit(C0 x)", model.GetSymbolInfo(xNode.Parent).Symbol.ToTestDisplayString()); 7214Assert.Equal("System.Int64 C0.op_CheckedExplicit(C0 x)", model.GetSymbolInfo(yNode.Parent).Symbol.ToTestDisplayString()); 7216var int64 = ((IMethodSymbol)model.GetSymbolInfo(xNode.Parent).Symbol).ReturnType; 7285Assert.Equal("System.Int64 C0.op_Explicit(C0 x)", model.GetSymbolInfo(xNode.Parent).Symbol.ToTestDisplayString()); 7286Assert.Equal("System.Int64 C0.op_Explicit(C0 x)", model.GetSymbolInfo(yNode.Parent).Symbol.ToTestDisplayString()); 7288var int64 = ((IMethodSymbol)model.GetSymbolInfo(xNode.Parent).Symbol).ReturnType; 7356Assert.Equal("System.Int64 C0.op_Explicit(C0 x)", model.GetSymbolInfo(xNode.Parent).Symbol.ToTestDisplayString()); 7357Assert.Equal("System.Int64 C0.op_Explicit(C0 x)", model.GetSymbolInfo(yNode.Parent).Symbol.ToTestDisplayString()); 7359var int64 = ((IMethodSymbol)model.GetSymbolInfo(xNode.Parent).Symbol).ReturnType; 7429Assert.Equal("C0 C0.op_CheckedUnaryNegation(C0 a)", model.GetSymbolInfo(xNode.Parent).Symbol.ToTestDisplayString()); 7430Assert.Equal("C0 C0.op_CheckedUnaryNegation(C0 a)", model.GetSymbolInfo(yNode.Parent).Symbol.ToTestDisplayString()); 7493Assert.Equal("C0 C0.op_UnaryNegation(C0 a)", model.GetSymbolInfo(xNode.Parent).Symbol.ToTestDisplayString()); 7494Assert.Equal("C0 C0.op_UnaryNegation(C0 a)", model.GetSymbolInfo(yNode.Parent).Symbol.ToTestDisplayString());
Symbols\ExtensionMethodTests.cs (5)
3012var call = (ExpressionSyntax)memberAccess.Parent; 3867Assert.Equal("Instance.SetMember", instance.Parent.ToString()); 3914Assert.Equal("Instance.SetMember", instance.Parent.ToString()); 3959Assert.Equal("Instance.SetMember", instance.Parent.ToString()); 4009Assert.Equal("Instance.SetMember", instance.Parent.ToString());
Symbols\FunctionPointerTypeSymbolTests.cs (2)
1168VerifyOperationTreeForNode(comp, model, functionPointerTypeSyntax.Parent, expectedOperationTree: @" 1274VerifyOperationTreeForNode(comp, model, functionPointerTypeSyntax.Parent, expectedOperationTree: @"
Symbols\Source\NullablePublicAPITests.cs (3)
1952var typeInfo = model.GetTypeInfoAndVerifyIOperation(((VariableDeclarationSyntax)variable.Parent).Type); 2293var typeInfo = model.GetTypeInfoAndVerifyIOperation(((DeclarationExpressionSyntax)variable.Parent).Type); 2563var type = ((DeclarationExpressionSyntax)variable.Parent).Type;
Symbols\Source\UsingAliasTests.cs (2)
699Assert.Equal("Short.MyClass", node.Parent.ToString()); 742Assert.Equal("Short.MyClass", node.Parent.ToString());
Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests (8)
Diagnostics\LocationsTests.cs (1)
458var expressionDiags = syntaxTree.GetDiagnostics(token.Parent.Parent);
ParentChecker.cs (2)
32var parentTrivia = trivia.GetStructure().Parent; 45var parentTrivia = trivia.GetStructure().Parent;
Syntax\StructuredTriviaTests.cs (4)
85var foundDocComment = result.Parent.Parent.Parent.Parent; 86Assert.Null(foundDocComment.Parent);
Syntax\SyntaxNodeTests.cs (1)
1358Assert.Null(trivia.GetStructure().Parent);
Microsoft.CodeAnalysis.CSharp.Test.Utilities (12)
CompilationTestUtils.cs (8)
370=> (expression.Parent is VariableDeclarationSyntax decl && decl.Type == expression) || 371(expression.Parent is ForEachStatementSyntax forEach && forEach.Type == expression) || 372(expression.Parent is DeclarationExpressionSyntax declExpr && declExpr.Type == expression) || 373(expression.Parent is RefTypeSyntax refType && isValidDeclaration(refType)); 528node = node.Parent; 543case IdentifierNameSyntax id when id.Parent is MemberAccessExpressionSyntax memberAccess && memberAccess.Name == node: 546case ExpressionSyntax expr when expr.Parent is ConditionalAccessExpressionSyntax cond && cond.WhenNotNull == node: 551case { Parent: var parent }:
CSharpTestBase.cs (4)
1757node = node.Parent; 1765if (node.Parent != null && node.Parent.ToString() == bindText) 1767node = node.Parent;
Microsoft.CodeAnalysis.CSharp.WinRT.UnitTests (1)
CodeGen\WinRTCollectionTests.cs (1)
7428var jsonObj = ((MemberAccessExpressionSyntax)add.Parent).Expression;
Microsoft.CodeAnalysis.CSharp.Workspaces (570)
Classification\ClassificationHelpers.cs (18)
184return interpolatedStringText.Parent is InterpolatedStringExpressionSyntax interpolatedString 212return GetClassificationTypeForConstructorOrDestructorParent(constructorDeclaration.Parent!); 216return GetClassificationTypeForConstructorOrDestructorParent(destructorDeclaration.Parent!); 236var varDecl = variableDeclarator.Parent as VariableDeclarationSyntax; 237return varDecl?.Parent switch 296var parent = identifierSyntax.Parent; 299parent = parent.Parent; 319parentNode = parentNode!.Parent!.Parent; 474if (token.Parent is IdentifierNameSyntax && token.Parent?.Parent is ExpressionStatementSyntax) 483token.Parent.Parent is VariableDeclarationSyntax && 484!(token.Parent.Parent.Parent is FieldDeclarationSyntax) && 485!(token.Parent.Parent.Parent is EventFieldDeclarationSyntax); 490&& token.Parent.Parent is TypeConstraintSyntax 491&& token.Parent.Parent.Parent is TypeParameterConstraintClauseSyntax;
Classification\SyntaxClassification\NameSyntaxClassifier.cs (1)
174if ((name.IsUnmanaged || name.IsNotNull) && name.Parent.IsKind(SyntaxKind.TypeConstraint))
Classification\Worker_DocumentationComments.cs (1)
185var classificationType = node.Parent switch
CodeGeneration\CSharpSyntaxGenerator.cs (32)
1964if (declaration.Parent != null) 1966return this.GetType(declaration.Parent); 2006if (vd.Parent != null && vd.Variables.Count == 1) 2008return AsIsolatedDeclaration(vd.Parent); 2015if (v.Parent != null && v.Parent.Parent != null) 2017return ClearTrivia(WithVariable(v.Parent.Parent, v)); 2024if (attr.Parent != null) 2026var attrList = (AttributeListSyntax)attr.Parent; 2075Contract.ThrowIfNull(vd.Parent); 2076return vd.Parent; 2085if (declaration.Parent != null) 2087return GetFullDeclaration(declaration.Parent); 2106var container = GetDeclaration(existingNode.Parent); 2758return AreSimilarExceptForSubDeclarations(decl1.Parent, decl2.Parent); 2806return SyntaxFactory.AreEquivalent(vd1.Type, vd2.Type) && AreSimilarExceptForSubDeclarations(vd1.Parent, vd2.Parent); 2846if (declaration.Parent.IsKind(SyntaxKind.GlobalStatement)) 2849declaration = declaration.Parent; 2885if (declaration.Parent.IsKind(SyntaxKind.GlobalStatement)) 2888declaration = declaration.Parent; 2956if (node.Parent.IsKind(SyntaxKind.GlobalStatement)) 2959node = node.Parent; 2981if (attr.Parent is AttributeListSyntax attrList && attrList.Attributes.Count == 1) 2990if (declaration.Parent != null && ((AttributeArgumentListSyntax)declaration.Parent).Arguments.Count == 1) 2993return RemoveNodeInternal(root, declaration.Parent, options); 3009if (declaration.Parent is BaseListSyntax baseList && baseList.Types.Count == 1) 3018var parent = declaration.Parent;
FindSymbols\CSharpDeclaredSymbolInfoFactoryService.cs (2)
94for (var current = node; current != null; current = current.Parent) 489=> typeDecl.Parent is BaseTypeDeclarationSyntax;
Formatting\TypingFormattingRule.cs (2)
69if (!SomeParentHasMissingCloseBrace(node.Parent)) 112node = node.Parent;
ReassignedVariable\CSharpReassignedVariableService.cs (1)
48current = current.Parent;
Recommendations\CSharpRecommendationServiceRunner.cs (2)
441VariableDeclaratorSyntax { Parent: VariableDeclarationSyntax { Parent: FieldDeclarationSyntax } }
Rename\CSharpRenameRewriterLanguageService.cs (4)
273=> accessor?.Parent?.Parent is PropertyDeclarationSyntax property // 3 null checks in one: accessor -> accessor list -> property declaration 539token.Parent.Parent is (kind: SyntaxKind.AliasQualifiedName or SyntaxKind.QualifiedCref or SyntaxKind.QualifiedName)) 1179if (token.Parent is TypeSyntax && token.Parent.Parent is TypeSyntax)
SemanticModelReuse\CSharpSemanticModelReuseLanguageService.cs (6)
32Contract.ThrowIfFalse(accessor.Parent is AccessorListSyntax); 33Contract.ThrowIfFalse(accessor.Parent.Parent is BasePropertyDeclarationSyntax); 34return (BasePropertyDeclarationSyntax)accessor.Parent.Parent; 42for (SyntaxNode? previous = null, current = node; current != null; previous = current, current = current.Parent)
Simplification\CSharpSimplificationService.cs (3)
114var parent = parentOfToken.Parent; 210var parent = currentTuple.Parent; 221var grandParent = parent.Parent;
Simplification\CSharpSimplificationService.Expander.cs (7)
80argument.Parent?.Parent is ObjectCreationExpressionSyntax objectCreationExpression) 254&& node.Parent is TupleExpressionSyntax tuple 624var parent = originalSimpleName.Parent; 881parent = parent.Parent; 950var parent = originalNode.Parent; 981else if (originalNode.Parent is CrefSyntax)
Simplification\Reducers\AbstractCSharpReducer.AbstractReductionRewriter.cs (6)
86for (var current = (SyntaxNode)expression; current != null; current = current.Parent) 100for (SyntaxNode? current = pattern; current != null; current = current.Parent) 108Contract.ThrowIfNull(lastPattern.Parent); 109return lastPattern.Parent; 119Contract.ThrowIfNull(topMostCref.Parent); 120return topMostCref.Parent;
Simplification\Reducers\CSharpInferredMemberNameReducer.Rewriter.cs (1)
55if (node.Parent.IsKind(SyntaxKind.TupleExpression))
Simplification\Reducers\CSharpMiscellaneousReducer.cs (6)
41parameterSyntax.Parent.IsParentKind(SyntaxKind.ParenthesizedLambdaExpression)) 124if (!CanHaveEmbeddedStatement(node.Parent)) 142if (!node.Parent.IsKind(SyntaxKind.IfStatement)) 148if (node.Parent?.Parent is (kind: SyntaxKind.IfStatement or SyntaxKind.ElseClause)) 160if (!FormattingRangeHelper.AreTwoTokensOnSameLine(node.Parent.GetFirstToken(), node.GetFirstToken().GetPreviousToken()))
Simplification\Simplifiers\AbstractCSharpSimplifier.cs (3)
265var nameofValueOpt = semanticModel.GetConstantValue(node.Parent.Parent.Parent);
Simplification\Simplifiers\NameSimplifier.cs (9)
241if (!name.Parent.IsKind(SyntaxKind.QualifiedName) && (inDeclarationContext || inMemberAccessContext)) 376if (name.Parent is QualifiedCrefSyntax qualifiedCrefParent && qualifiedCrefParent.Container == name) 386else if (name.Parent is QualifiedNameSyntax qualifiedParent && qualifiedParent.Left == name && 426if (name.Parent is NameMemberCrefSyntax) 496if (name.Parent.Kind() == SyntaxKind.Attribute || name.IsRightSideOfDotOrColonColon()) 563parent = parent.Parent; 663if (expression?.Parent is CastExpressionSyntax castExpression && 690name = (NameSyntax)name.Parent; 693if (name?.Parent is UsingDirectiveSyntax usingDirective &&
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\EmbeddedLanguages\VirtualChars\CSharpVirtualCharService.cs (1)
39if (token.Parent?.Parent is InterpolatedStringExpressionSyntax { StringStartToken.RawKind: (int)SyntaxKind.InterpolatedMultiLineRawStringStartToken })
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\ArgumentSyntaxExtensions.cs (3)
45if (argument.Parent is not BaseArgumentListSyntax argumentList || 46argumentList.Parent is null) 52var symbolInfo = semanticModel.GetSymbolInfo(argumentList.Parent, cancellationToken);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\AttributeArgumentSyntaxExtensions.cs (2)
33if (argument.Parent is not AttributeArgumentListSyntax argumentList) 36if (argumentList.Parent is not AttributeSyntax invocableExpression)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\DefaultExpressionSyntaxExtensions.cs (4)
40if (defaultExpression?.Parent is EqualsValueClauseSyntax equalsValueClause) 70equalsValueClause.Parent?.Parent is VariableDeclarationSyntax declaration) 74else if (equalsValueClause?.Parent is ParameterSyntax parameter)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\DirectiveSyntaxExtensions.cs (2)
21while (node.Parent != null || node is StructuredTriviaSyntax) 23node = node.Parent ?? node.ParentTrivia.Token.GetRequiredParent();
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\ExpressionSyntaxExtensions.cs (54)
23while (expression?.Parent is ParenthesizedExpressionSyntax parentExpr) 46=> expression.IsParentKind(SyntaxKind.NameMemberCref) && expression.Parent.IsParentKind(SyntaxKind.QualifiedCref); 49=> expression?.Parent is MemberAccessExpressionSyntax(SyntaxKind.SimpleMemberAccessExpression) memberAccess && memberAccess.Name == expression; 56return expression == (expression.Parent as MemberAccessExpressionSyntax)?.Name || 61=> expression?.Parent is MemberBindingExpressionSyntax memberBinding && 65=> expression?.Parent is QualifiedNameSyntax qualifiedName && qualifiedName.Right == expression; 68=> expression?.Parent is AliasQualifiedNameSyntax aliasName && aliasName.Name == expression; 99=> (expression?.Parent) is MemberAccessExpressionSyntax(SyntaxKind.SimpleMemberAccessExpression) memberAccess && 104(expression.Parent is MemberAccessExpressionSyntax memberAccess && memberAccess.Expression == expression); 107=> (expression?.Parent) is QualifiedNameSyntax qualifiedName && qualifiedName.Left == expression; 113=> expression?.Parent is InvocationExpressionSyntax invocation && 198=> expression?.Parent is ArgumentSyntax { RefOrOutKeyword: SyntaxToken(SyntaxKind.OutKeyword) } argument && 210while (expression?.Parent is ParenthesizedExpressionSyntax or PostfixUnaryExpressionSyntax(SyntaxKind.SuppressNullableWarningExpression)) 211expression = (ExpressionSyntax)expression.Parent; 213if (expression?.Parent is RefExpressionSyntax or 216refParent = expression.Parent; 225=> expression?.Parent is ArgumentSyntax { RefKindKeyword: SyntaxToken(SyntaxKind.InKeyword) }; 249if (expression.Parent != null) 283var parent = expr.Parent; 292if (parent.Parent?.Kind() == SyntaxKind.TupleExpression) 294expr = (TupleExpressionSyntax)parent.Parent; 338if (refParent.Parent is EqualsValueClauseSyntax { Parent: VariableDeclaratorSyntax { Parent: VariableDeclarationSyntax { Type: { } variableDeclarationType } } }) 356if (expression.Parent.IsKind(SyntaxKind.AddressOfExpression)) 367if (expression.Parent is MemberAccessExpressionSyntax { Parent: InvocationExpressionSyntax } memberAccess && 385if (expression.Parent is ArgumentSyntax) 400var nameEquals = expression?.Parent as NameEqualsSyntax; 406if (expression?.Parent is SyntaxNode parent) 422=> expression is IdentifierNameSyntax { Parent: NameColonSyntax }; 518return expression is { Parent.RawKind: not (int)SyntaxKind.ConditionalAccessExpression }; 521if (expression.Parent == null) 524switch (expression.Parent.Kind()) 554var parentConditionalAccessExpression = (ConditionalAccessExpressionSyntax)expression.Parent; 556!parentConditionalAccessExpression.Parent.IsKind(SyntaxKind.ConditionalAccessExpression); 561var isOrAsExpression = (BinaryExpressionSyntax)expression.Parent; 597if (expression.Parent is PrefixUnaryExpressionSyntax) 607while (topExpression.Parent is TypeSyntax typeSyntax) 621if (expression.Parent is PostfixUnaryExpressionSyntax or 640if ((expression.IsParentKind(SyntaxKind.NameEquals) && expression.Parent.IsParentKind(SyntaxKind.AttributeArgument)) || 650=> expression is { Parent: ArgumentSyntax { Parent: ArgumentListSyntax { Parent: InvocationExpressionSyntax invocation } } } && 902=> expression?.Parent is MemberAccessExpressionSyntax; 913var parent = topExpression.Parent; 945if (argument.Parent is TupleExpressionSyntax tupleExpression) 974for (SyntaxNode? current = returnStatement; current != null; current = current.Parent) 989if (equalsValue.Parent is VariableDeclaratorSyntax { Parent: VariableDeclarationSyntax { Type.IsVar: true } }) 1059if (initializerExpression.Parent is ArrayCreationExpressionSyntax arrayCreation) 1063if (initializerExpression.Parent is ImplicitArrayCreationExpressionSyntax) 1075if (initializerExpression.Parent is EqualsValueClauseSyntax equalsValue) 1079if (initializerExpression.Parent is StackAllocArrayCreationExpressionSyntax or ImplicitStackAllocArrayCreationExpressionSyntax)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\ParenthesizedExpressionSyntaxExtensions.cs (22)
29var nodeParent = node.Parent; 41? nodeParent.Parent as ExpressionSyntax 72if (nodeParent is EqualsValueClauseSyntax { Parent: VariableDeclaratorSyntax { Parent: VariableDeclarationSyntax varDecl } }) 326if (node.Parent is not ConstantPatternSyntax { Parent: IsPatternExpressionSyntax }) 506if (node?.Parent is CastExpressionSyntax castExpression) 564if (node.Parent is BinaryExpressionSyntax binaryExpression && 566(binaryExpression.IsParentKind(SyntaxKind.Argument) || binaryExpression.Parent is InitializerExpressionSyntax)) 618if (node.Parent is ArgumentSyntax argument) 620if (argument.Parent is ArgumentListSyntax argumentList) 629else if (node.Parent is InitializerExpressionSyntax initializer) 653if (node.Parent is ArgumentSyntax argument) 655if (argument.Parent is ArgumentListSyntax argumentList) 664else if (node.Parent is InitializerExpressionSyntax initializer) 702if (pattern is DiscardPatternSyntax && node.Parent is IsPatternExpressionSyntax) 717if (node.Parent is ParenthesizedPatternSyntax) 721if (node.Parent is IsPatternExpressionSyntax) 725if (node.Parent is SwitchExpressionArmSyntax) 729if (node.Parent is SubpatternSyntax) 733if (node.Parent is CasePatternSwitchLabelSyntax) 739return node.Parent is PatternSyntax patternParent &&
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SemanticModelExtensions.cs (29)
207if (type.Parent is BaseTypeSyntax baseType && 208baseType.Parent is BaseListSyntax baseList && 216else if (baseList.Types[0] == type.Parent) 225if (type?.Parent is VariableDeclarationSyntax variableDeclaration && 234type.Parent.IsParentKind(SyntaxKind.EqualsValueClause) && 235type.Parent.Parent.IsParentKind(SyntaxKind.VariableDeclarator) && 236type.Parent.Parent.Parent.IsParentKind(SyntaxKind.VariableDeclaration, out variableDeclaration) && 252if (type.Parent.Kind() 261type.Parent, cancellationToken).DeclaredAccessibility; 274if (type.IsParentKind(SyntaxKind.Parameter) && type.Parent.IsParentKind(SyntaxKind.ParameterList)) 276if (type.Parent.Parent.Parent?.Kind() 283type.Parent.Parent.Parent, cancellationToken).DeclaredAccessibility; 286if (type.Parent.Parent.IsParentKind(SyntaxKind.ConstructorDeclaration)) 288var symbol = semanticModel.GetDeclaredSymbol(type.Parent.Parent.Parent, cancellationToken); 381if (current.Parent is ForEachStatementSyntax foreachStatement && 388if (current.Parent is AnonymousObjectMemberDeclaratorSyntax { NameEquals: { } nameEquals } anonymousObjectMemberDeclarator && 433if (topExpression?.Parent is ArgumentSyntax argument) 440if (argument.Parent is BaseArgumentListSyntax argumentList) 443if (semanticModel.GetSymbolInfo(argumentList.Parent, cancellationToken).Symbol is IMethodSymbol member && index < member.Parameters.Length)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SimpleNameSyntaxExtensions.cs (6)
19return ((MemberAccessExpressionSyntax)name.Parent).Expression; 27return ((QualifiedNameSyntax)name.Parent).Left; 31return ((QualifiedCrefSyntax)name.Parent.Parent).Container; 52if (simpleName?.Parent is InvocationExpressionSyntax invocation && 59if (simpleName?.Parent is ElementAccessExpressionSyntax elementAccess &&
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\StatementSyntaxExtensions.cs (4)
40if (first.Parent.IsKind(SyntaxKind.GlobalStatement)) 41return second.Parent.IsKind(SyntaxKind.GlobalStatement); 43return first.Parent == second.Parent;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxNodeExtensions.cs (23)
43=> CodeAnalysis.CSharpExtensions.IsKind(node?.Parent, kind); 50result = (TNode)node.Parent!; 184if ((current?.Parent is MemberAccessExpressionSyntax(SyntaxKind.SimpleMemberAccessExpression) memberAccess && memberAccess.Name == current) || 185(current?.Parent is MemberBindingExpressionSyntax memberBinding && memberBinding.Name == current)) 187current = current.Parent; 201current.Parent is not ConditionalAccessExpressionSyntax) 203current = current.Parent; 233if (current?.Parent is ConditionalAccessExpressionSyntax conditional1 && 239if (current?.Parent is ConditionalAccessExpressionSyntax conditional2 && 259while (current?.Parent is ConditionalAccessExpressionSyntax conditional && 286=> node?.Parent is AssignmentExpressionSyntax(SyntaxKind.SimpleAssignmentExpression) assignment && 290=> node?.Parent is AssignmentExpressionSyntax assignment && assignment.Left == node; 293=> node?.Parent is AssignmentExpressionSyntax assignment && assignment.Right == node; 297return node?.Parent != null && 298node.Parent.IsCompoundAssignExpression() && 299((AssignmentExpressionSyntax)node.Parent).Left == node; 335for (var current = node; current != null; current = current.Parent) 358return !current.Parent.IsKind(SyntaxKind.CompilationUnit); 674=> node?.Parent is EqualsValueClauseSyntax { Parent: VariableDeclaratorSyntax } equalsValue && 690current = current.Parent; 792for (var current = node; current != null; current = current.Parent) 841for (var current = node; current != null; current = current.Parent)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\VariableDeclaratorExtensions.cs (1)
15if (declarator.Parent is VariableDeclarationSyntax variableDeclaration)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Engine\Trivia\CSharpTriviaFormatter.DocumentationCommentExteriorCommentRewriter.cs (1)
86currentParent = currentParent.Parent;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\FormattingHelpers.cs (14)
109if (token.Parent.IsKind(SyntaxKind.PositionalPatternClause) && token.Parent.Parent.IsKind(SyntaxKind.RecursivePattern)) 112return token.Parent.Parent.GetFirstToken() != token; 125=> token.Kind() == SyntaxKind.OpenParenToken && token.Parent.IsKind(SyntaxKind.ParameterList) && token.Parent.Parent.IsKind(SyntaxKind.ParenthesizedLambdaExpression); 134return node.Parent?.Kind() is SyntaxKind.SimpleLambdaExpression or SyntaxKind.ParenthesizedLambdaExpression; 203&& statementOrElse.Parent != null 204&& statementOrElse.Parent.IsEmbeddedStatementOwner(); 279token.Parent.Parent.IsKind(SyntaxKind.PropertyDeclaration); 383token.Parent?.Parent is QueryExpressionSyntax queryExpression && 391var parent = initializer.Parent; 415return anonymousObjectInitializer.Parent is AnonymousObjectCreationExpressionSyntax; 427var parent = initializer.Parent; 447var parent = anonymousObjectInitializer.Parent; 483return token.Parent.Parent is LabeledStatementSyntax; 530currentToken.Parent.Parent is DeclarationExpressionSyntax;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\AnchorIndentationFormattingRule.cs (2)
35if (block.Parent is null or BlockSyntax) 43block.Parent.GetFirstToken(includeZeroWidth: true),
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\BaseFormattingRule.cs (2)
179RoslynDebug.AssertNotNull(node.Parent); 182firstTokenOfNode = node.Parent.GetFirstToken(includeZeroWidth: true);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\ElasticTriviaFormattingRule.cs (1)
406if (parent.Parent is ParameterSyntax)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\IndentBlockFormattingRule.cs (9)
67if (node is TypeParameterConstraintClauseSyntax { Parent: { } declaringNode }) 108RoslynDebug.AssertNotNull(node.Parent); 109var switchStatement = (SwitchStatementSyntax)node.Parent; 188if (propertyPatternClause.Parent is RecursivePatternSyntax { Parent: { } recursivePatternParent }) 233if (node.IsKind(SyntaxKind.ArrayInitializerExpression) && node.Parent != null && node.Parent.IsKind(SyntaxKind.ArrayCreationExpression)) 257if (node.Parent is SwitchExpressionArmSyntax arm && arm.Pattern == node) 267if (node.Parent != null && node.Kind() is SyntaxKind.ListPattern or SyntaxKind.CollectionExpression)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\NewLineUserSettingFormattingRule.cs (7)
49var parentKind = node.Parent?.Kind(); 85&& previousToken.Parent!.Parent == currentToken.Parent.Parent) 165var currentTokenParentParent = currentToken.Parent.Parent; 277|| previousToken.Parent!.Parent != currentToken.Parent.Parent) 366var currentTokenParentParent = currentToken.Parent.Parent;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\SuppressFormattingRule.cs (3)
133var constructorDeclarationNode = constructorInitializerNode.Parent as ConstructorDeclarationSyntax; 386if (initializer?.Parent != null) 388AddInitializerSuppressOperations(list, initializer.Parent, initializer.Expressions);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\TokenBasedFormattingRule.cs (3)
211var attributeOwner = previousToken.Parent?.Parent; 240RoslynDebug.AssertNotNull(currentUsing.Parent); 242var usings = GetUsings(currentUsing.Parent);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\WrappingFormattingRule.cs (1)
150firstTokenOfNode = node.Parent!.GetFirstToken(includeZeroWidth: true);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Indentation\CSharpSmartTokenFormatter.cs (1)
75endToken.Parent.Parent?.Kind() is SyntaxKind.TryStatement or SyntaxKind.DoStatement;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SemanticFacts\CSharpSemanticFacts.cs (3)
340case IdentifierNameSyntax { Parent: PrimaryConstructorBaseTypeSyntax baseType }: 439var expression = simpleName.Parent switch 446if (expression.Parent is not InvocationExpressionSyntax)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpAccessibilityFacts.cs (6)
242if (vd.Variables.Count == 1 && vd.Parent == null) 255var vd = declaration.Parent as VariableDeclarationSyntax; 287if (declaration.Parent is not AttributeListSyntax parentList || parentList.Attributes.Count > 1) 323=> node?.Parent.IsKind(SyntaxKind.FieldDeclaration) ?? false; 326=> node?.Parent.IsKind(SyntaxKind.EventFieldDeclaration) ?? false; 329=> node?.Parent.IsKind(SyntaxKind.LocalDeclarationStatement) ?? false;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpBlockFacts.cs (2)
29=> statement.Parent switch 33GlobalStatementSyntax globalStatement => globalStatement.Parent,
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpSyntaxFacts.cs (30)
165=> node?.Parent is MemberAccessExpressionSyntax memberAccess && memberAccess.Name == node; 196=> node?.Parent is UsingDirectiveSyntax usingDirective && 246if (firstStatement.Parent == secondStatement.Parent) 249if (IsGlobalStatement(firstStatement.Parent) 250&& IsGlobalStatement(secondStatement.Parent) 251&& firstStatement.Parent.Parent == secondStatement.Parent.Parent) 265return node.Parent is BaseMethodDeclarationSyntax or 536if (semanticModel != null && token.Parent is BracketedArgumentListSyntax { Parent: ElementAccessExpressionSyntax elementAccessExpression }) 645node.Parent.IsParentKind(SyntaxKind.Subpattern); 657if (identifier.Parent.IsParentKind(SyntaxKind.WithInitializerExpression)) 659var withInitializer = identifier.Parent.GetRequiredParent(); 663else if (identifier.Parent.IsParentKind(SyntaxKind.ObjectInitializerExpression)) 665var objectInitializer = identifier.Parent.GetRequiredParent(); 686Parent: BaseObjectCreationExpressionSyntax or ArrayCreationExpressionSyntax or ImplicitArrayCreationExpressionSyntax 689creationExpression = node.Parent; 735node = node.Parent; 782var parent = node.GetAncestor<TypeDeclarationSyntax>() ?? node.Parent; 1009var parent = node.Parent; 1182=> node?.Parent?.Kind() is SyntaxKind.PostIncrementExpression or SyntaxKind.PreIncrementExpression; 1185=> node?.Parent?.Kind() is SyntaxKind.PostDecrementExpression or SyntaxKind.PreDecrementExpression; 1246node.Parent is AttributeListSyntax attributeList && 1275return node.Parent?.Parent?.Kind() is SyntaxKind.FieldDeclaration or SyntaxKind.EventFieldDeclaration; 1359=> node?.Parent is ForEachStatementSyntax foreachStatement && foreachStatement.Expression == node; 1402=> ((VariableDeclarationSyntax)((VariableDeclaratorSyntax)node).Parent!).Type; 1408=> node?.Parent is PropertyDeclarationSyntax propertyDeclaration && propertyDeclaration.Initializer == node;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Simplification\CSharpInferredMemberNameSimplifier.cs (3)
16if (node.NameColon == null || !node.Parent.IsKind(SyntaxKind.TupleExpression)) 26if (RemovalCausesAmbiguity(((TupleExpressionSyntax)node.Parent).Arguments, node)) 47if (RemovalCausesAmbiguity(((AnonymousObjectCreationExpressionSyntax)node.Parent!).Initializers, node))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Simplification\Simplifiers\CastSimplifier.cs (30)
125if (leftOrRightChild.Parent is BinaryExpressionSyntax(SyntaxKind.EqualsExpression or SyntaxKind.NotEqualsExpression) binary) 159if (castExpression.WalkUpParentheses().Parent is PrefixUnaryExpressionSyntax(SyntaxKind.BitwiseNotExpression) parent && 160parent.WalkUpParentheses().Parent is CastExpressionSyntax parentCast) 192if (isDefaultLiteralCast && castNode.WalkUpParentheses().Parent is PatternSyntax or CaseSwitchLabelSyntax) 364if (rewrittenConversion.IsExplicit && castNode.WalkUpParentheses().Parent is not InterpolationSyntax) 451if (castNode.WalkUpParentheses().Parent is MemberAccessExpressionSyntax memberAccessExpression) 484if (castNode.WalkUpParentheses().Parent is InvocationExpressionSyntax invocationExpression) 503if (castNode.WalkUpParentheses().Parent is BinaryExpressionSyntax(SyntaxKind.IsExpression) isExpression && 713if (castNode.WalkUpParentheses().Parent is not MemberAccessExpressionSyntax { Parent: InvocationExpressionSyntax } memberAccessExpression) 832if (parent.Parent is not ConditionalExpressionSyntax originalConditionalExpression) 1008if (parent.Parent is ConditionalExpressionSyntax conditionalExpression) 1078if (castNode.Parent is AssignmentExpressionSyntax assignmentExpression && 1085else if (castNode.Parent is InitializerExpressionSyntax(SyntaxKind.ArrayInitializerExpression) arrayInitializer) 1091else if (castNode.Parent is EqualsValueClauseSyntax equalsValue && 1093equalsValue.Parent is VariableDeclaratorSyntax variableDeclarator) 1117for (SyntaxNode? current = expression; current != null; current = current.Parent) 1132for (SyntaxNode? currentOld = castNode.WalkUpParentheses().Parent, currentNew = rewrittenExpression.WalkUpParentheses().Parent; 1134currentOld = currentOld.Parent, currentNew = currentNew.Parent) 1188for (SyntaxNode? currentOld = castNode.WalkUpParentheses().Parent, currentNew = rewrittenExpression.WalkUpParentheses().Parent; 1190currentOld = currentOld.Parent, currentNew = currentNew.Parent) 1218for (SyntaxNode? currentOld = castNode.WalkUpParentheses().Parent, currentNew = rewrittenExpression.WalkUpParentheses().Parent; 1220currentOld = currentOld.Parent, currentNew = currentNew.Parent) 1494if (castNode.WalkUpParentheses().Parent is InterpolationSyntax)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\FormattingRangeHelper.cs (9)
187var containerOfList = parent.Parent; 203var parentOfParent = parent.Parent; 337RoslynDebug.AssertNotNull(previousToken.Parent?.Parent); 338var labelNode = previousToken.Parent.Parent; 381RoslynDebug.AssertNotNull(node.Parent); 383node = node.Parent; 390node = node.Parent; 400node = node.Parent; 442return token.Parent.Parent as MemberDeclarationSyntax;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\SpeculationAnalyzer.cs (6)
297Debug.Assert(previousOriginalNode == null || previousOriginalNode.Parent == currentOriginalNode); 298Debug.Assert(previousReplacedNode == null || previousReplacedNode.Parent == currentReplacedNode); 441var oldSwitchStatement = (SwitchStatementSyntax)originalCaseSwitchLabel.Parent.Parent; 442var newSwitchStatement = (SwitchStatementSyntax)newCaseSwitchLabel.Parent.Parent;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\TypeStyle\CSharpTypeStyleHelper.cs (2)
106var isSupportedParentKind = variableDeclaration.Parent is (kind: 122switch (declaration.Parent)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\TypeStyle\CSharpUseExplicitTypeHelper.cs (6)
72if (typeName.Parent is DeclarationExpressionSyntax declExpression && 85if (typeName.Parent is VariableDeclarationSyntax variableDeclaration && 86typeName.Parent.Parent is (kind: SyntaxKind.LocalDeclarationStatement or SyntaxKind.ForStatement or SyntaxKind.UsingStatement)) 99if ((variableDeclaration.Parent as LocalDeclarationStatementSyntax)?.IsConst == true) 104else if (typeName.Parent is ForEachStatementSyntax foreachStatement &&
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\TypeStyle\CSharpUseImplicitTypeHelper.cs (10)
112if (typeName.Parent is VariableDeclarationSyntax variableDeclaration && 113typeName.Parent.Parent is (kind: 119if (variableDeclaration.Parent is LocalDeclarationStatementSyntax { IsConst: true }) 146else if (typeName.Parent is ForEachStatementSyntax foreachStatement && 155else if (typeName.Parent is DeclarationExpressionSyntax declarationExpression && 217if (declarationExpression.Parent is not ArgumentSyntax 219Parent: ArgumentListSyntax { Parent: InvocationExpressionSyntax invocationExpression } 293if (n.Parent is MemberAccessExpressionSyntax memberAccessParent && memberAccessParent.Expression == n)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpCodeGenerationHelpers.cs (3)
280&& reusableSyntaxNode.Parent is VariableDeclarationSyntax variableDeclarationNode 281&& reusableSyntaxNode.Parent.Parent is FieldDeclarationSyntax fieldDeclarationNode)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpDeclarationComparer.cs (5)
345for (var node = parent; node != null; node = node.Parent) 388var xAccessibility = GetAccessibilityPrecedence(xModifiers, x.Parent ?? y.Parent); 389var yAccessibility = GetAccessibilityPrecedence(yModifiers, y.Parent ?? x.Parent);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeRefactorings\CSharpRefactoringHelpersService.cs (2)
97var declaration = declarator.Parent; 98if (declaration?.Parent is LocalDeclarationStatementSyntax localDeclarationStatement)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\CSharpSyntaxContext.cs (4)
231targetToken.Parent.Parent is (kind: SyntaxKind.ClassDeclaration or SyntaxKind.RecordDeclaration); 393token.Parent.Parent is ParameterSyntax { Parent: ParameterListSyntax { Parent: RecordDeclarationSyntax record } }) 506FromClauseSyntax { Parent: QueryExpressionSyntax queryExpression } fromClause => queryExpression.FromClause == fromClause,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTokenExtensions.cs (20)
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() 180var container = token.Parent.Parent; 261var container = token.Parent.Parent; 262if (container is IncompleteMemberSyntax && container.Parent is CompilationUnitSyntax) 451targetToken.Parent.Parent.IsKind(SyntaxKind.Argument) && 452targetToken.Parent.Parent.Parent.IsKind(SyntaxKind.ArgumentList)) 454var owner = targetToken.Parent.Parent.Parent.Parent; 470if (targetToken.Parent?.Parent?.Kind() 591targetToken.Parent.Parent is AccessorDeclarationSyntax) 606targetToken.Parent.Parent is AccessorDeclarationSyntax) 618if (node?.Parent is TypeDeclarationSyntax(SyntaxKind.InterfaceDeclaration) typeDecl) 620else if (node?.Parent is DelegateDeclarationSyntax delegateDecl) 651targetToken.Parent.Parent.IsKind(SyntaxKind.TypeParameter) && 652IsGenericInterfaceOrDelegateTypeParameterList(targetToken.Parent.Parent.Parent))
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTreeExtensions.cs (58)
99parent = attributeList.Parent; 179token.Parent.Parent is BaseTypeDeclarationSyntax) 196token.Parent.Parent is BaseTypeDeclarationSyntax) 208token.Parent.Parent is MemberDeclarationSyntax) 228var container = token.Parent.Parent?.Parent; 492token.Parent.Parent is MemberDeclarationSyntax) 519var container = token.Parent?.Parent?.Parent; 778token.Parent is BaseListSyntax { Parent: not EnumDeclarationSyntax }) 949{ Parent: TypeSyntax { Parent.RawKind: (int)SyntaxKind.FunctionPointerParameter } } => true, 1008name.Parent?.Parent is ConditionalExpressionSyntax conditional && 1010conditional.Parent.IsParentKind(SyntaxKind.GlobalStatement)) 1098token.Parent.Parent is ParameterSyntax parameter3 && 1099parameter3.Parent is ParameterListSyntax parameterList3 && 1114parameter4 = scopedIdentifierName.Parent as ParameterSyntax; 1118if (parameter4 is { Parent: ParameterListSyntax parameterList4 } && 1128=> parameterList.Parent switch 1267parent = token.Parent.Parent; 1269else if (token.IsKind(SyntaxKind.IdentifierToken) && token.Text == "scoped" && token.Parent is IdentifierNameSyntax scopedIdentifierName && scopedIdentifierName.Parent.IsKind(SyntaxKind.Parameter)) 1271parent = scopedIdentifierName.Parent.Parent; 1350leftToken.Parent.Parent is (kind: SyntaxKind.QualifiedName or SyntaxKind.SimpleMemberAccessExpression)) 1352var possibleCommaOrParen = FindTokenOnLeftOfNode(leftToken.Parent.Parent); 1434leftToken.Parent is SingleVariableDesignationSyntax { Parent: DeclarationPatternSyntax }; 1520while (typeSyntax.Parent is TypeSyntax parentTypeSyntax) 1525if (typeSyntax.Parent is BinaryExpressionSyntax binaryExpressionSyntax && 1556if (node is CaseSwitchLabelSyntax { Parent: SwitchSectionSyntax }) 1584possibleCommaOrParen.Parent?.Parent is ParenthesizedLambdaExpressionSyntax parenthesizedLambda) 1652if (outer.Parent is ForEachStatementSyntax @foreach) 1673if (node.Parent.IsKind(SyntaxKind.ParenthesizedExpression)) 1675node = node.Parent; 1679if (node.Parent.IsKind(SyntaxKind.Argument) && node.Parent.Parent.IsKind(SyntaxKind.TupleExpression)) 1681node = node.Parent.Parent; 1693leftToken.Parent?.Parent is InvocationExpressionSyntax invocation) 1801parent.Parent?.Parent is (kind: 1809if (parent.Parent is (kind: SyntaxKind.ForEachStatement or SyntaxKind.ForEachVariableStatement)) 1865if (token.IsKind(SyntaxKind.IdentifierToken) && token.Text == "scoped" && token.Parent.IsKind(SyntaxKind.IdentifierName) && token.Parent.Parent is VariableDeclarationSyntax or ExpressionStatementSyntax or IncompleteMemberSyntax) 2078equalsValue.Parent.IsParentKind(SyntaxKind.VariableDeclaration)) 2348type.Parent?.Parent is LocalDeclarationStatementSyntax declStatement) 2501token.Parent?.Parent is ObjectCreationExpressionSyntax objectCreation) 2738=> token.Parent?.Parent is InvocationExpressionSyntax invocation && 2855nameExpr = (ExpressionSyntax)nameExpr.Parent!; 2866token.Parent.Parent is (kind: SyntaxKind.ObjectInitializerExpression or SyntaxKind.CollectionInitializerExpression)) 2875if (token.Parent.Parent is ArgumentSyntax { RefOrOutKeyword.RawKind: (int)SyntaxKind.OutKeyword }) 2911if (name.Parent != null) 2913switch (name.Parent.Kind()) 2916return ((QualifiedNameSyntax)name.Parent).Right == name; 2918return ((AliasQualifiedNameSyntax)name.Parent).Name == name; 2920return ((MemberAccessExpressionSyntax)name.Parent).Name == name; 3018token.Parent?.Parent is BinaryExpressionSyntax(SyntaxKind.IsExpression) binaryExpression && 3025token.Parent?.Parent is DeclarationPatternSyntax declarationExpression &&
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\NameSyntaxExtensions.cs (1)
54if (nameSyntax.Parent?.Kind()
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Indentation\CSharpIndentationService.cs (3)
133!argument.Parent.IsKind(SyntaxKind.ThisConstructorInitializer) && 196RoslynDebug.AssertNotNull(node.Parent); 199var baseToken = node.Parent.GetFirstToken(includeZeroWidth: true);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Indentation\CSharpIndentationService.Indenter.cs (9)
224(token.Parent.Parent is StatementSyntax || token.Parent.Parent is ElseClauseSyntax)); 226var embeddedStatementOwner = token.Parent.Parent; 229RoslynDebug.AssertNotNull(embeddedStatementOwner.Parent); 230embeddedStatementOwner = embeddedStatementOwner.Parent; 252token.Parent.Parent.IsKind(SyntaxKind.PropertyDeclaration)) 404if (queryExpressionClause.Parent is not QueryBodySyntax queryBody) 427RoslynDebug.AssertNotNull(queryBody.Parent); 428return indenter.GetIndentationOfToken(queryBody.Parent.GetFirstToken(includeZeroWidth: true));
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpReplaceDiscardDeclarationsWithAssignmentsService.cs (2)
102declarationPattern.Parent is IsPatternExpressionSyntax isPatternExpression) 210if (_localDeclarationStatement.Parent is BlockSyntax or SwitchSectionSyntax)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpSemanticFactsService.cs (1)
48if (SyntaxFacts.IsParameterList(container) && SyntaxFacts.IsLocalFunctionStatement(container.Parent))
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpTypeInferenceService.TypeInferrer.cs (54)
134var parent = node.Parent; 277if (argument is { Parent.Parent: ConstructorInitializerSyntax initializer }) 283if (argument is { Parent.Parent: InvocationExpressionSyntax invocation }) 289if (argument is { Parent.Parent: BaseObjectCreationExpressionSyntax creation }) 300if (argument is { Parent.Parent: PrimaryConstructorBaseTypeSyntax primaryConstructorBaseType }) 307if (argument is { Parent.Parent: ElementAccessExpressionSyntax elementAccess }) 318if (argument is { Parent: TupleExpressionSyntax tupleExpression }) 323if (argument.Parent.IsParentKind(SyntaxKind.ImplicitElementAccess) && 324argument.Parent.Parent.IsParentKind(SyntaxKind.SimpleAssignmentExpression) && 325argument.Parent.Parent.Parent.IsParentKind(SyntaxKind.ObjectInitializerExpression) && 326argument.Parent.Parent.Parent.Parent?.Parent is BaseObjectCreationExpressionSyntax objectCreation) 377if (argument.Parent != null) 379if (argument.Parent.Parent is AttributeSyntax attribute) 517switch (argumentList.Parent) 547if (attributeArgumentList.Parent is AttributeSyntax attribute) 743var argumentCount = argumentOpt?.Parent is BaseArgumentListSyntax baseArgumentList ? baseArgumentList.Arguments.Count : -1; 896if (bracketedArgumentList.Parent is ElementAccessExpressionSyntax elementAccess) 1214if (equalsValue?.Parent is VariableDeclaratorSyntax varDecl) 1217if (equalsValue?.Parent is PropertyDeclarationSyntax propertyDecl) 1221SemanticModel.GetDeclaredSymbol(equalsValue.Parent, CancellationToken) is IParameterSymbol parameter) 1356if (initializerExpression?.Parent is ImplicitArrayCreationExpressionSyntax implicitArray) 1384else if (initializerExpression?.Parent is EqualsValueClauseSyntax equalsValueClause) 1394else if (initializerExpression?.Parent is ArrayCreationExpressionSyntax arrayCreation) 1404else if (initializerExpression?.Parent is ObjectCreationExpressionSyntax objectCreation) 1428var assignExpression = (AssignmentExpressionSyntax)initializerExpression.Parent; 1497if (singleVariableDesignation.Parent is DeclarationPatternSyntax declarationPattern) 1635if (memberDeclarator.NameEquals != null && memberDeclarator.Parent is AnonymousObjectCreationExpressionSyntax) 1641var types = InferTypes((AnonymousObjectCreationExpressionSyntax)memberDeclarator.Parent); 1660return nameColon.Parent switch 1676return expressionColon.Parent switch 1728memberAccessExpression?.Parent is InvocationExpressionSyntax invocation && 1729memberAccessExpression.Parent.IsParentKind(SyntaxKind.AwaitExpression)) 1851if (nameColon.Parent is SubpatternSyntax subpattern) 1861if (expressionColon.Parent is SubpatternSyntax subpattern) 1878if (nameEquals.Parent is AttributeArgumentSyntax attributeArgumentSyntax) 2036=> InferTypeInMethodLikeDeclaration(arrowClause.Parent); 2072if (arm.Parent is SwitchExpressionSyntax switchExpression) 2120var switchStatement = (SwitchStatementSyntax)switchLabel.Parent.Parent; 2186variableDeclarator.Parent is not VariableDeclarationSyntax variableDeclaration) 2254var inferredFutureUsage = InferTypeBasedOnLaterUsage(symbol, afterNode: left.Parent);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\InitializeParameter\InitializeParameterHelpers.cs (1)
121if (node is IdentifierNameSyntax { Parent: not NameColonSyntax } identifierName &&
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Utilities\CSharpSimplificationHelpers.cs (1)
33var parent = parentOfToken.Parent;
Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities (4)
Structure\AbstractSyntaxNodeStructureProviderTests.cs (4)
31while (node.Parent is TSyntaxNode) 33if ((position == node.SpanStart && position == node.Parent.SpanStart) || 34(position == node.Span.End && position == node.Parent.Span.End)) 36node = (TSyntaxNode)node.Parent;
Microsoft.CodeAnalysis.EditorFeatures.UnitTests (1)
Utilities\SymbolEquivalenceComparerTests.cs (1)
1893invocation ??= method_root.Parent.DescendantNodes().OfType<TInvocation>().First();
Microsoft.CodeAnalysis.EditorFeatures2.UnitTests (6)
Expansion\AbstractExpansionTest.vb (3)
59While Not node Is Nothing And Not node.Parent Is Nothing And node.Parent.SpanStart = node.SpanStart 60node = node.Parent
Simplification\AbstractSimplificationTests.vb (3)
134While Not node Is Nothing And Not node.Parent Is Nothing And node.Parent.SpanStart = node.SpanStart 135node = node.Parent
Microsoft.CodeAnalysis.Features (158)
AddImport\SymbolReferenceFinder.cs (5)
167hasIncompleteParentMember = nameNode?.Parent?.RawKind == syntaxFacts.SyntaxKinds.IncompleteMember; 303? syntaxFacts.GetExpressionOfMemberAccessExpression(nameNode.Parent, allowImplicitTarget: true) 304: syntaxFacts.GetTargetOfMemberBinding(nameNode.Parent); 370methodSymbols, nameNode.Parent, cancellationToken); 426methodSymbols, _node.Parent, cancellationToken);
AddImport\SymbolReferenceFinder_PackageAssemblySearch.cs (2)
78while (_syntaxFacts.IsQualifiedName(current.Parent)) 79current = current.Parent;
CodeFixes\Suppression\AbstractSuppressionCodeFixProvider.RemoveSuppressionCodeAction_Attribute.cs (1)
56? attributeNode.Parent
CodeLens\CodeLensReferencesService.cs (1)
193node = node.Parent;
CodeRefactorings\AddAwait\AbstractAddAwaitCodeRefactoringProvider.cs (1)
73if (syntaxFacts.IsExpressionOfInvocationExpression(node.Parent))
CodeRefactorings\MoveType\AbstractMoveTypeService.cs (1)
165=> typeNode.Parent is TTypeDeclarationSyntax;
Completion\Providers\AbstractInternalsVisibleToCompletionProvider.cs (6)
103while (syntaxFactsService.IsElementAccessExpression(node.Parent) || syntaxFactsService.IsBinaryExpression(node.Parent)) 105node = node.Parent; 109var attributeSyntaxNodeCandidate = node.Parent?.Parent?.Parent;
ConvertAutoPropertyToFullProperty\AbstractConvertAutoPropertyToFullPropertyCodeRefactoringProvider.cs (1)
66if (containingProperty?.Parent is not TTypeDeclarationNode)
ConvertForToForEach\AbstractConvertForToForEachCodeRefactoringProvider.cs (13)
156var argument = current.Parent; 161var argumentList = argument?.Parent; 196if (syntaxFacts.IsElementAccessExpression(argumentList.Parent)) 198var expr = syntaxFacts.GetExpressionOfElementAccessExpression(argumentList.Parent); 210if (syntaxFacts.IsInvocationExpression(argumentList.Parent)) 212var invokedExpression = syntaxFacts.GetExpressionOfInvocationExpression(argumentList.Parent); 424if (syntaxFacts.AreEquivalent(current.Parent, indexExpression)) 430else if (syntaxFacts.AreEquivalent(current.Parent?.Parent, elementAtExpression)) 441var shouldWarn = syntaxFacts.IsArgument(current.Parent); 444syntaxFacts.IsMemberAccessExpression(current.Parent) && 445syntaxFacts.IsInvocationExpression(current.Parent.Parent);
ConvertIfToSwitch\AbstractConvertIfToSwitchCodeRefactoringProvider.Rewriting.cs (1)
53var nodesToRemove = sections.Skip(1).Select(s => s.SyntaxToRemove).Where(s => s.Parent == ifStatement.Parent);
ConvertToInterpolatedString\AbstractConvertConcatenationToInterpolatedStringRefactoringProvider.cs (1)
62IsStringConcat(syntaxFacts, top.Parent, semanticModel, cancellationToken))
Debugging\AbstractDataTipInfoGetter.cs (2)
33if (expression.Parent is TMemberExpressionSyntax { Parent: TInvocationExpressionSyntax invocation } memberAccess &&
EditAndContinue\AbstractEditAndContinueAnalyzer.cs (7)
276var current = node.Parent; 290current = current.Parent; 369var current = node.Parent; 393current = current.Parent; 1726oldNode = oldNode.Parent; 1752return HasEdit(editMap, node.Parent, edit.Kind); 2018current = current.Parent;
EmbeddedLanguages\AbstractLanguageDetector.cs (4)
71syntaxFacts.IsArgument(token.Parent.Parent)) 73options = GetOptionsFromSiblingArgument(token.Parent.Parent, semanticModel, cancellationToken) ?? 103syntaxFacts.IsArgument(token.Parent.Parent) && 104IsArgumentToWellKnownAPI(token, token.Parent.Parent, semanticModel, cancellationToken, out options);
EmbeddedLanguages\DateAndTime\LanguageServices\DateAndTimeLanguageDetector.cs (4)
57var interpolation = interpolationFormatClause?.Parent; 75var argumentList = argumentNode.Parent; 76var invocationOrCreation = argumentList?.Parent; 130syntaxFacts.IsArgument(token.Parent!.Parent);
EmbeddedLanguages\EmbeddedLanguageDetector.cs (4)
97syntaxFacts.IsBinaryExpression(token.Parent.Parent) && 98syntaxFacts.SyntaxKinds.AddExpression == token.Parent.Parent.RawKind) 103for (var node = token.Parent; node != null; node = node.Parent) 167var interpolation = interpolationFormatClause?.Parent;
ExtractMethod\MethodExtractor.CodeGenerator.cs (4)
169mappedMember = mappedMember.Parent?.RawKind == syntaxKinds.GlobalStatement 170? mappedMember.Parent 174? mappedMember.Parent 178var destination = mappedMember.Parent ?? mappedMember;
ExtractMethod\MethodExtractor.cs (2)
129? insertionPointNode.Parent 131destination = mappedPoint.Parent ?? mappedPoint;
ExtractMethod\SelectionValidator.cs (1)
166if (firstStatement != null && stmt.Span.End <= textSpan.End && stmt.Parent == firstStatement.Parent)
FullyQualify\AbstractFullyQualifyService.cs (1)
168var rightSide = syntaxFacts.GetRightSideOfDot(simpleName.Parent);
InlineMethod\AbstractInlineMethodRefactoringProvider.cs (9)
165if (_syntaxFacts.IsThrowStatement(inlineExpression.Parent) || _syntaxFacts.IsThrowExpression(inlineExpression)) 204&& !_syntaxFacts.IsExpressionStatement(calleeInvocationNode.Parent)) 440if (_syntaxFacts.IsThrowStatement(rawInlineExpression.Parent) 441&& _syntaxFacts.IsExpressionStatement(calleeInvocationNode.Parent)) 449&& _syntaxFacts.IsExpressionStatement(calleeInvocationNode.Parent)) 464if (_syntaxFacts.IsExpressionStatement(calleeInvocationNode.Parent) 504if (_syntaxFacts.IsThrowStatement(rawInlineExpression.Parent)) 524if (!_syntaxFacts.IsExpressionStatement(calleeInvocationNode.Parent) 574for (SyntaxNode? node = calleeMethodInvocationNode; node != null; node = node.Parent)
IntroduceParameter\IntroduceParameterDocumentRewriter.cs (2)
102var declarator = _expression?.Parent?.Parent;
IntroduceVariable\AbstractIntroduceVariableService.State.cs (5)
210while (syntaxFacts.IsParenthesizedExpression(current.Parent)) 211current = (TExpressionSyntax)current.Parent; 213if (!syntaxFacts.IsEqualsValueClause(current.Parent)) 216var equalsValue = current.Parent; 217if (!syntaxFacts.IsVariableDeclarator(equalsValue.Parent))
InvertIf\AbstractInvertIfCodeRefactoringProvider.cs (1)
358ifNode.Parent == subsequentStatementRanges[0].Parent;
InvertIf\AbstractInvertIfCodeRefactoringProvider.StatementRange.cs (3)
22Debug.Assert(firstStatement.Parent != null); 23Debug.Assert(firstStatement.Parent == lastStatement.Parent);
InvertLogical\AbstractInvertLogicalCodeRefactoringProvider.cs (4)
55while (expression.Parent?.RawKind == expression.RawKind) 57expression = expression.Parent; 67syntaxFacts.IsLogicalAndExpression(expression.Parent) || syntaxFacts.IsLogicalOrExpression(expression.Parent))
NameTupleElement\AbstractNameTupleElementCodeRefactoringProvider.cs (1)
50var argument = potentialArguments.FirstOrDefault(n => n?.Parent is TTupleExpressionSyntax);
RemoveUnusedVariable\AbstractRemoveUnusedVariableCodeFixProvider.cs (2)
176if (variableDeclarator.Parent?.Parent is TLocalDeclarationStatement candidate)
ReplaceConditionalWithStatements\AbstractReplaceConditionalWithStatementsCodeRefactoringProvider.cs (8)
132var parentStatement = topExpression.Parent as TStatementSyntax; 154if (topExpression.Parent is TEqualsValueClauseSyntax equalsValue && 155equalsValue.Parent is TVariableDeclaratorSyntax variableDeclarator) 179if (current.Parent is TExpressionSyntax parentExpression) 185if (current.Parent is TArgumentSyntax { Parent: TArgumentListSyntax { Parent: TExpressionSyntax argumentParent } }) 241var isGlobalStatement = syntaxFacts.IsGlobalStatement(localDeclarationStatement.Parent);
ReplaceDocCommentTextWithTag\AbstractReplaceDocCommentTextWithTagCodeRefactoringProvider.cs (1)
131for (var node = token.Parent; node != null; node = node.Parent)
ReplacePropertyWithMethods\AbstractReplacePropertyWithMethodsService.cs (6)
121_expression = (TExpressionSyntax)_expression.Parent!; 124Contract.ThrowIfNull(_expression.Parent, $"Parent of {_expression} is null."); 251else if (_syntaxFacts.IsInferredAnonymousObjectMemberDeclarator(_expression.Parent)) //.IsParentKind(SyntaxKind.AnonymousObjectMemberDeclarator)) 255var declarator = _expression.Parent; 291Contract.ThrowIfNull(_expression.Parent, $"Parent of {_expression} is null."); 296_expression.Parent,
SignatureHelp\CommonSignatureHelpUtilities.cs (2)
150if (initializer is not { Parent: not null }) 160var parentOperation = semanticModel.GetOperation(initializer.Parent, cancellationToken) as IObjectOrCollectionInitializerOperation;
SimplifyThisOrMe\AbstractSimplifyThisOrMeDiagnosticAnalyzer.cs (1)
57if (node.Parent is not TMemberAccessExpressionSyntax memberAccessExpression)
Snippets\SnippetProviders\AbstractConsoleSnippetProvider.cs (1)
96var nearestExpression = closestNode.FirstAncestorOrSelf<TExpressionSyntax>(static exp => exp.Parent is TExpressionStatementSyntax or TLambdaExpressionSyntax);
SpellCheck\AbstractSpellCheckSpanService.cs (1)
104AddStringSpans(token, canContainEscapes: !_syntaxFacts.IsVerbatimInterpolatedStringExpression(token.Parent.Parent));
SplitOrMergeIfStatements\AbstractMergeIfStatementsCodeRefactoringProvider.cs (1)
115while (statements is [{ Parent: var parent }, ..] &&
SplitOrMergeIfStatements\Consecutive\AbstractMergeConsecutiveIfStatementsCodeRefactoringProvider.cs (2)
234blockFacts.IsExecutableBlock(ifOrElseIf.Parent)) 236var blockStatements = blockFacts.GetExecutableBlockStatements(ifOrElseIf.Parent);
SplitOrMergeIfStatements\Consecutive\AbstractSplitIntoConsecutiveIfStatementsCodeRefactoringProvider.cs (1)
89if (!blockFacts.IsExecutableBlock(ifOrElseIf.Parent))
SplitOrMergeIfStatements\Nested\AbstractMergeNestedIfStatementsCodeRefactoringProvider.cs (5)
99if (blockFacts.IsStatementContainer(statement.Parent)) 101var statements = blockFacts.GetStatementContainerStatements(statement.Parent); 105if (rootStatements.Count > 0 && ifGenerator.IsIfOrElseIf(rootStatements[0].Parent)) 107ifOrElseIf = rootStatements[0].Parent; 175var statements = blockFacts.GetStatementContainerStatements(innerIfStatement.Parent);
src\Analyzers\Core\Analyzers\ConvertTypeofToNameof\AbstractConvertTypeOfToNameOfDiagnosticAnalyzer.cs (1)
42var parent = node.Parent;
src\Analyzers\Core\Analyzers\RemoveUnnecessaryParentheses\AbstractRemoveUnnecessaryParenthesesDiagnosticAnalyzer.cs (1)
73var parentKind = parenthesizedExpression.Parent?.RawKind;
src\Analyzers\Core\Analyzers\UseAutoProperty\AbstractUseAutoPropertyAnalyzer.cs (2)
324fieldDeclaration = variableDeclarator?.Parent?.Parent as TFieldDeclaration;
src\Analyzers\Core\Analyzers\UseIsNullCheck\AbstractUseIsNullForReferenceEqualsDiagnosticAnalyzer.cs (1)
134var negated = syntaxFacts.IsLogicalNotExpression(invocation.Parent);
src\Analyzers\Core\Analyzers\UseNullPropagation\AbstractUseNullPropagationDiagnosticAnalyzer_IfStatement.cs (1)
77if (whenPartMatch.Parent is TMemberAccessExpressionSyntax memberAccess)
src\Analyzers\Core\CodeFixes\AddAnonymousTypeMemberName\AbstractAddAnonymousTypeMemberNameCodeFixProvider.cs (3)
64if (node.Parent is not TAnonymousObjectMemberDeclaratorSyntax declarator) 75if (declarator.Parent is not TAnonymousObjectInitializer) 126var anonymousType = current.Parent;
src\Analyzers\Core\CodeFixes\AddExplicitCast\AbstractAddExplicitCastCodeFixProvider.cs (3)
129if (syntaxFacts.IsParenthesizedExpression(currentTarget.Parent)) 131return (currentTarget.Parent, currentTarget.Parent.ReplaceNode(currentTarget, currentReplacement).WithAdditionalAnnotations(Simplifier.Annotation));
src\Analyzers\Core\CodeFixes\GenerateVariable\AbstractGenerateVariableService.State.cs (1)
439if (syntaxKinds.AddressOfExpression == SimpleNameOrMemberAccessExpressionOpt.Parent?.RawKind)
src\Analyzers\Core\CodeFixes\RemoveUnusedParametersAndValues\AbstractRemoveUnusedValuesCodeFixProvider.cs (11)
482if (declaredLocal == null && node.Parent is TCatchStatementSyntax) 484declaredLocal = semanticModel.GetDeclaredSymbol(node.Parent, cancellationToken) as ILocalSymbol; 519if (node.Parent is TStatementSyntax) 522nodesToRemove.Add(node.Parent); 524else if (node.Parent is TExpressionSyntax && node.Parent.Parent is TExpressionStatementSyntax) 527nodesToRemove.Add(node.Parent.Parent); 695n => n.Parent is TSwitchCaseBlockSyntax || 696blockFacts.IsExecutableBlock(n.Parent) &&
src\Analyzers\Core\CodeFixes\SimplifyInterpolation\AbstractSimplifyInterpolationCodeFixProvider.cs (1)
63interpolationSyntax.Parent is TInterpolatedStringExpressionSyntax interpolatedString)
src\Analyzers\Core\CodeFixes\UseCompoundAssignment\AbstractUseCompoundAssignmentCodeFixProvider.cs (1)
103if (syntaxFacts.IsSimpleAssignmentStatement(currentAssignment.Parent))
src\Analyzers\Core\CodeFixes\UseConditionalExpression\AbstractUseConditionalExpressionCodeFixProvider.cs (2)
165while (sourceSyntax is { Parent.RawKind: var kind } && kind == suppressKind) 166sourceSyntax = sourceSyntax.Parent;
src\Analyzers\Core\CodeFixes\UseNullPropagation\AbstractUseNullPropagationCodeFixProvider.cs (5)
184var isElseIf = syntaxFacts.IsElseClause(ifStatement.Parent); 199TryGetBlock(whenTrueStatement.Parent, out var block)) 217nodeToBeReplaced = ifStatement.Parent!; 240if (syntaxFacts.IsSimpleMemberAccessExpression(match.Parent)) 242var memberAccess = match.Parent;
UseAutoProperty\AbstractUseAutoPropertyCodeFixProvider.cs (3)
325if (fieldToRemove.Parent == property.Parent && 326fieldToRemove.Parent is TTypeDeclarationSyntax typeDeclaration)
UseNamedArguments\AbstractUseNamedArgumentsCodeRefactoringProvider.cs (2)
70if (argument.Parent is not TArgumentListSyntax argumentList) 144var argumentList = (TArgumentListSyntax)firstArgument.Parent!;
Wrapping\BinaryExpression\AbstractBinaryExpressionWrapper.cs (1)
66if (binaryExpr.Parent is TBinaryExpressionSyntax parentBinary &&
Wrapping\ChainedExpression\AbstractChainedExpressionWrapper.cs (1)
86if (IsDecomposableChainPart(node.Parent))
Microsoft.CodeAnalysis.Features.Test.Utilities (1)
EditAndContinue\EditAndContinueTestVerifier.cs (1)
394result = result.Parent!;
Microsoft.CodeAnalysis.Test.Utilities (38)
CommonTestBase.cs (1)
705node = node.Parent;
Compilation\ControlFlowGraphVerifier.cs (30)
546VisualBasicSyntaxNode parent = syntax.Parent; 573VisualBasicSyntaxNode parent = syntax.Parent; 611if (syntax.Parent is CSharp.Syntax.SwitchStatementSyntax switchStmt && switchStmt.Expression == syntax) 616if (syntax.Parent is CSharp.Syntax.SwitchExpressionSyntax switchExpr && switchExpr.GoverningExpression == syntax) 627if (syntax.Parent is VisualBasic.Syntax.SelectStatementSyntax switchStmt && switchStmt.Expression == syntax) 654if (syntax.Parent is CSharp.Syntax.CommonForEachStatementSyntax forEach && forEach.Expression == syntax) 665if (syntax.Parent is VisualBasic.Syntax.ForEachStatementSyntax forEach && forEach.Expression == syntax) 836if (syntax.Parent is CSharp.Syntax.ConditionalAccessExpressionSyntax access && 847if (syntax.Parent is VisualBasic.Syntax.ConditionalAccessExpressionSyntax access && 868return referenceSyntax.Parent is AssignmentExpressionSyntax conditionalAccess && 881return referenceSyntax.Parent is CSharp.Syntax.AssignmentExpressionSyntax 884Parent: InitializerExpressionSyntax { Parent: CSharp.Syntax.ObjectCreationExpressionSyntax }, 1000assignment.Syntax.Parent is VisualBasic.Syntax.ForStatementSyntax forStmt && 1049if (syntax.Parent is CSharp.Syntax.ConditionalAccessExpressionSyntax access && 1060if (syntax.Parent is VisualBasic.Syntax.ConditionalAccessExpressionSyntax access && 1116if (syntax.Parent is CSharp.Syntax.WithExpressionSyntax withExpr 1125if (syntax.Parent?.Parent is CSharp.Syntax.UsingStatementSyntax usingStmt && 1126usingStmt.Declaration == syntax.Parent) 1131CSharpSyntaxNode parent = syntax.Parent; 1144if ((parent = parent.Parent)?.Kind() == CSharp.SyntaxKind.BracketedArgumentList && 1145(parent = parent.Parent)?.Kind() == CSharp.SyntaxKind.ImplicitElementAccess && 1146parent.Parent is AssignmentExpressionSyntax assignment && assignment.Kind() == CSharp.SyntaxKind.SimpleAssignmentExpression && 1148assignment.Parent?.Kind() == CSharp.SyntaxKind.ObjectInitializerExpression && 1222VisualBasicSyntaxNode parent = syntax.Parent; 1284while (syntax.Parent is CSharp.Syntax.ParenthesizedExpressionSyntax or 1287syntax = syntax.Parent; 1295while (syntax.Parent?.Kind() == VisualBasic.SyntaxKind.ParenthesizedExpression) 1297syntax = syntax.Parent;
Syntax\NodeHelpers.cs (7)
98while (retVal.Parent != null) 100retVal = retVal.Parent; 109var retVal = node.Parent == null ? node : node.Parent; 110while (retVal.Parent != null) 112retVal = retVal.Parent; 125retVal = retVal.Parent;
Microsoft.CodeAnalysis.UnitTests (2)
CommonSyntaxTests.cs (2)
223Assert.Equal(CSharp.SyntaxKind.ParenthesizedExpression, CSharp.CSharpExtensions.Kind(trackedB.Parent)); 246Assert.Equal(CSharp.SyntaxKind.ParenthesizedExpression, CSharp.CSharpExtensions.Kind(trackedB.Parent));
Microsoft.CodeAnalysis.VisualBasic (175)
Analysis\FlowAnalysis\DataFlowPass.vb (1)
1607Dim variableIsUsedDirectlyAndIsAlwaysAssigned = DeclaredVariableIsAlwaysAssignedBeforeInitializer(node.Syntax.Parent, node.InitializerOpt, placeholder)
Binding\Binder_Conversions.vb (5)
465TypeOf argument.Syntax.Parent Is BinaryExpressionSyntax OrElse 466TypeOf argument.Syntax.Parent Is UnaryExpressionSyntax OrElse 467TypeOf argument.Syntax.Parent Is TupleExpressionSyntax OrElse 468(TypeOf argument.Syntax.Parent Is AssignmentStatementSyntax AndAlso argument.Syntax.Parent.Kind <> SyntaxKind.SimpleAssignmentStatement),
Binding\Binder_Expressions.vb (7)
3652If node.Parent Is Nothing OrElse 3653node.Parent.Kind <> SyntaxKind.NamedFieldInitializer Then 3695Dim parent = syntax.Parent 3704Return syntax.Parent IsNot Nothing AndAlso 3705syntax.Parent.Kind = SyntaxKind.NameOfExpression AndAlso 3706DirectCast(syntax.Parent, NameOfExpressionSyntax).Argument Is syntax 4033Dim parent = TryCast(argumentExpression.Parent, SimpleArgumentSyntax)
Binding\Binder_Initializers.vb (3)
291If equalsValueOrAsNewSyntax.Parent IsNot Nothing Then 293fieldSymbols.Length = DirectCast(equalsValueOrAsNewSyntax.Parent, VariableDeclaratorSyntax).Names.Count) 296For Each name In DirectCast(equalsValueOrAsNewSyntax.Parent, VariableDeclaratorSyntax).Names
Binding\Binder_Invocation.vb (4)
1321If result.Parent IsNot Nothing AndAlso result.Parent.IsKind(SyntaxKind.AddressOfExpression) Then 1488node.Parent IsNot Nothing AndAlso 1489node.Parent.Kind = SyntaxKind.NamedFieldInitializer AndAlso
Binding\Binder_Query.vb (3)
587Dim fromClauseSyntax = DirectCast(source.Syntax.Parent, FromClauseSyntax) 622boundCallOrBadExpression = BindQueryOperatorCall(source.Syntax.Parent, source, 630Return New BoundQueryClause(source.Syntax.Parent,
Binding\Binder_Statements.vb (1)
4472syntaxNodeForErrors = declarationSyntax.Parent
Binding\Binder_Utils.vb (4)
1279If TypeOf containingSyntax.Parent Is MethodBlockBaseSyntax OrElse TypeOf containingSyntax.Parent Is PropertyBlockSyntax Then 1280containingSyntax = containingSyntax.Parent 1282Return TryCast(containingSyntax.Parent, TypeBlockSyntax)
Binding\Binder_WithBlock.vb (1)
342node = node.Parent
Binding\BinderFactory.BinderFactoryVisitor.vb (3)
85If _factory.InScript AndAlso node.Parent.Kind = SyntaxKind.CompilationUnit Then 87Return GetBinderForNodeAndUsage(DirectCast(node.Parent, VisualBasicSyntaxNode), NodeUsage.TopLevelExecutableStatement, DirectCast(node.Parent, VisualBasicSyntaxNode), _position)
Binding\BinderFactory.vb (1)
116node = node.Parent
Binding\MemberSemanticModel.vb (16)
1335Debug.Assert(current.Parent.Kind = SyntaxKind.WithStatement) 1336Debug.Assert(current.Parent.Parent.Kind = SyntaxKind.WithBlock) 1338current = current.Parent.Parent 1346current = current.Parent 1360current = current.Parent 1706node.Parent IsNot Nothing AndAlso node.Parent.Kind = SyntaxKind.ObjectMemberInitializer AndAlso 1707node.Parent.Parent IsNot Nothing AndAlso node.Parent.Parent.Kind = SyntaxKind.AnonymousObjectCreationExpression Then 1911Dim parent As SyntaxNode = syntax.Parent 1916parent = parent.Parent 1994node = node.Parent
Compilation\SemanticModel.vb (21)
558node = node.Parent 998parentSyntax Is boundNodes.LowestBoundNode.Syntax.Parent AndAlso 1429parentSyntax Is lowestBoundNode.Syntax.Parent AndAlso 3531If declaringSyntax.Parent IsNot Nothing AndAlso TypeOf declaringSyntax.Parent Is NamespaceBlockSyntax Then 3532Return declaringSyntax.Parent 3537If declaringSyntax.Parent IsNot Nothing AndAlso TypeOf declaringSyntax.Parent Is TypeBlockSyntax Then 3538Return declaringSyntax.Parent 3541If declaringSyntax.Parent IsNot Nothing AndAlso TypeOf declaringSyntax.Parent Is EnumBlockSyntax Then 3542Return declaringSyntax.Parent 3547If declaringSyntax.Parent IsNot Nothing AndAlso TypeOf declaringSyntax.Parent Is MethodBlockBaseSyntax Then 3548Return declaringSyntax.Parent 3553If declaringSyntax.Parent IsNot Nothing AndAlso TypeOf declaringSyntax.Parent Is EventBlockSyntax Then 3554Return declaringSyntax.Parent 3559If declaringSyntax.Parent IsNot Nothing AndAlso TypeOf declaringSyntax.Parent Is PropertyBlockSyntax Then 3560Return declaringSyntax.Parent
Lowering\Instrumentation\DebugInfoInjector.vb (6)
109Dim aggregateClause = DirectCast(original.Syntax.Parent.Parent, AggregateClauseSyntax) 135Debug.Assert(original.Syntax.Parent.IsKind(SyntaxKind.ExpressionRangeVariable)) 229syntax = DirectCast(original.Syntax.Parent, MultiLineIfBlockSyntax).EndIfStatement 239Return New BoundSequencePoint(DirectCast(original.AlternativeOpt.Syntax.Parent, MultiLineIfBlockSyntax).EndIfStatement, 403syntaxForSequencePoint = localDeclaration.Syntax.Parent
Lowering\Instrumentation\DebugInfoInjector_SequencePoints.vb (9)
13Debug.Assert(containingCatchWithFilter.ExceptionFilterOpt.Syntax.Parent.IsKind(SyntaxKind.CatchFilterClause)) 15Return AddConditionSequencePoint(condition, containingCatchWithFilter.ExceptionFilterOpt.Syntax.Parent, currentMethodOrLambda, local, shareLocal:=False) 119If syntax.Parent.IsKind(SyntaxKind.PropertyStatement) Then 122Dim propertyStatement = DirectCast(syntax.Parent, PropertyStatementSyntax) 131Dim declarator = DirectCast(syntax.Parent, VariableDeclaratorSyntax) 137Return New BoundSequencePoint(syntax.Parent, rewrittenStatement) 149Return New BoundSequencePoint(syntax.Parent, rewrittenStatement) 154Debug.Assert(syntax.Parent.Kind = SyntaxKind.VariableDeclarator) 162Dim declarator = DirectCast(syntax.Parent, VariableDeclaratorSyntax)
Lowering\Instrumentation\Instrumenter.vb (3)
218Debug.Assert(original.AlternativeOpt.Syntax.Parent.Kind = SyntaxKind.MultiLineIfBlock) 265Debug.Assert(original.ExceptionFilterOpt.Syntax.Parent.IsKind(SyntaxKind.CatchFilterClause)) 379Debug.Assert(original.Syntax.Parent.Kind = SyntaxKind.VariableDeclarator)
Lowering\LambdaRewriter\LambdaRewriter.vb (2)
1279Dim curSyntax = lambdaSyntax.Parent 1297curSyntax = curSyntax.Parent
Lowering\LocalRewriter\LocalRewriter.vb (1)
302((node.Syntax.Kind = SyntaxKind.SimpleAsClause AndAlso node.Syntax.Parent.Kind = SyntaxKind.CollectionRangeVariable) OrElse
Lowering\LocalRewriter\LocalRewriter_SelectCase.vb (1)
233Dim selectStatementSyntax = DirectCast(selectExprStmtSyntax.Parent, SelectBlockSyntax).SelectStatement
Lowering\LocalRewriter\LocalRewriter_SyncLock.vb (2)
182If syntaxNode.Parent.Kind = SyntaxKind.SyncLockStatement Then 183tempLockTaken = New SynthesizedLocal(Me._currentMethodOrLambda, enterMethod.Parameters(1).Type, SynthesizedLocalKind.LockTaken, DirectCast(syntaxNode.Parent, SyncLockStatementSyntax))
Lowering\LocalRewriter\LocalRewriter_UnstructuredExceptionHandling.vb (23)
480If statement.Syntax.Parent IsNot Nothing AndAlso statement.Syntax.Parent.Kind = SyntaxKind.EraseStatement Then 496statement.Syntax.Parent Is Nothing OrElse 497statement.Syntax.Parent.Kind <> SyntaxKind.VariableDeclarator OrElse 498statement.Syntax.Parent.Parent Is Nothing OrElse 499statement.Syntax.Parent.Parent.Kind <> SyntaxKind.LocalDeclarationStatement Then 505Not (TypeOf statement.Syntax.Parent Is ReDimStatementSyntax) Then 525statement.Syntax.Parent IsNot Nothing AndAlso 526statement.Syntax.Parent.Kind = SyntaxKind.MultiLineIfBlock AndAlso 527_unstructuredExceptionHandlingResumableStatements.ContainsKey(statement.Syntax.Parent)) 531statement.Syntax.Parent IsNot Nothing AndAlso 532statement.Syntax.Parent.Kind = SyntaxKind.SelectBlock AndAlso 533_unstructuredExceptionHandlingResumableStatements.ContainsKey(statement.Syntax.Parent)) 537statement.Syntax.Parent IsNot Nothing AndAlso 538statement.Syntax.Parent.Kind = SyntaxKind.VariableDeclarator AndAlso 539statement.Syntax.Parent.Parent IsNot Nothing AndAlso 540statement.Syntax.Parent.Parent.Kind = SyntaxKind.LocalDeclarationStatement) 544TypeOf statement.Syntax.Parent Is ReDimStatementSyntax) OrElse 546TypeOf statement.Syntax.Parent Is EraseStatementSyntax))
Operations\VisualBasicOperationFactory.vb (2)
1331Return TryCast(syntax.Parent, MethodBlockBaseSyntax)?.EndBlockStatement Is syntax OrElse 1332TryCast(syntax.Parent, MultiLineLambdaExpressionSyntax)?.EndSubOrFunctionStatement Is syntax
Operations\VisualBasicOperationFactory_Methods.vb (1)
348Dim syntax As SyntaxNode = If(value.Syntax?.Parent, expression.Syntax)
Semantics\OverloadResolution.vb (2)
3775Dim parent As SyntaxNode = syntax.Parent 3784parent = parent.Parent
Symbols\Source\LocalSymbol.vb (5)
548Dim propertyBlock = DirectCast(node.Parent, PropertyBlockSyntax) 551Dim eventBlock = DirectCast(node.Parent, EventBlockSyntax) 558node = _identifierToken.Parent.Parent 564node = node.Parent 571node = node.Parent
Symbols\Source\SourceEventSymbol.vb (1)
457Dim eventBlock = Me._syntaxRef.GetSyntax(cancellationToken).Parent
Symbols\Source\SourceMethodSymbol.vb (1)
752Return TryCast(decl.Parent, MethodBlockBaseSyntax)
Symbols\Symbol_Attributes.vb (2)
362Dim parent = syntaxList.Node.Parent 364If parent.IsKind(SyntaxKind.AttributesStatement) AndAlso parent.Parent.IsKind(SyntaxKind.CompilationUnit) Then
Symbols\Tuples\TupleTypeSymbol.vb (1)
1124diagnostics.Add(ERRID.WRN_TupleLiteralNameMismatch, literal.Arguments(i).Syntax.Parent.Location, sourceName, destination)
Syntax\LambdaUtilities.vb (21)
51Dim lambda = lambdaBody.Parent 115Dim parent = node?.Parent 147Dim clause = parent.Parent 176Dim parentClause = clause.Parent 178clause = clause.Parent 191Dim parentClause = parent.Parent 206Dim joinClause = DirectCast(parent.Parent, JoinClauseSyntax) 334Dim firstCondition = DirectCast(node.Parent, JoinClauseSyntax).JoinConditions.First 382Dim clause = lambda.Parent 403Dim clause = lambda.Parent 423Dim joinClause = DirectCast(lambda.Parent, JoinClauseSyntax) 538Dim clause = expressionRangeVariable.Parent 560Dim clause = collectionRangeVariable.Parent 581Return clause.Parent.IsKind(SyntaxKind.QueryExpression) AndAlso 582clause Is DirectCast(clause.Parent, QueryExpressionSyntax).Clauses.First 604Return joinCondition Is DirectCast(joinCondition.Parent, JoinClauseSyntax).JoinConditions.First 701If node.Parent?.Parent IsNot Nothing AndAlso 702node.Parent.Parent.Parent Is Nothing Then
Syntax\NamespaceDeclarationSyntaxReference.vb (1)
28node = node.Parent
Syntax\SyntaxBindingUtilities.vb (3)
19node.IsKind(SyntaxKind.ModifiedIdentifier) AndAlso node.Parent.IsKind(SyntaxKind.VariableDeclarator) AndAlso node.Parent.Parent.IsKind(SyntaxKind.UsingStatement) OrElse
Syntax\SyntaxFactory.vb (1)
1050node = node.Parent
Syntax\SyntaxFacts.vb (10)
127Dim parent = node.Parent 135Dim parent = node.Parent 152Dim parent = node.Parent 165Dim parent = node.Parent 641nextNode = nextNode.Parent 672Dim parent1 = TryCast(node.Parent, NameColonEqualsSyntax) 869token.Parent.Parent.Kind = SyntaxKind.NamedFieldInitializer 974Dim n = TryCast(token.Parent.Parent, XmlNodeSyntax) 1160Dim parent = node.Parent 1170parent = node.Parent
Syntax\SyntaxNodeRemover.vb (2)
241Me.AddDirectives(node.Parent, GetRemovedSpan(span, fullSpan)) 265Me.AddDirectives(node.Parent, GetRemovedSpan(span, fullSpan))
Syntax\SyntaxNormalizer.vb (2)
213Not (tokenParent IsNot Nothing AndAlso tokenParent.Parent IsNot Nothing AndAlso tokenParent.Parent.Kind = SyntaxKind.CrefReference) AndAlso
Syntax\VisualBasicSyntaxNode.vb (2)
68current = rootCandidate.Parent 120Return DirectCast(MyBase.Parent, VisualBasicSyntaxNode)
Syntax\VisualBasicSyntaxTree.vb (1)
392node = node.Parent
Microsoft.CodeAnalysis.VisualBasic.CodeStyle (267)
src\Analyzers\VisualBasic\Analyzers\AddRequiredParentheses\VisualBasicAddRequiredParenthesesDiagnosticAnalyzer.vb (1)
60Return TryCast(binary.Parent, ExpressionSyntax)
src\Analyzers\VisualBasic\Analyzers\ConvertTypeofToNameof\VisualBasicConvertTypeOfToNameOfDiagnosticAnalyzer.vb (1)
26Dim isParentValid = node.Parent.GetType() Is GetType(MemberAccessExpressionSyntax)
src\Analyzers\VisualBasic\Analyzers\RemoveUnnecessaryImports\VisualBasicRemoveUnnecessaryImportsDiagnosticAnalyzer.vb (2)
41If Not result.Contains(clause.Parent) Then 42Dim statement = DirectCast(clause.Parent, ImportsStatementSyntax)
src\Analyzers\VisualBasic\Analyzers\RemoveUnnecessaryParentheses\VisualBasicRemoveUnnecessaryParenthesesDiagnosticAnalyzer.vb (1)
51Dim parentBinary = TryCast(parenthesizedExpression.Parent, BinaryExpressionSyntax)
src\Analyzers\VisualBasic\Analyzers\RemoveUnusedMembers\VisualBasicRemoveUnusedMembersDiagnosticAnalyzer.vb (3)
58Select(Function(n) If(TryCast(n, TypeStatementSyntax)?.Parent, n)). 68Dim declarator = TryCast(modifiedIdentifier?.Parent, VariableDeclaratorSyntax) 69Dim field = TryCast(declarator?.Parent, FieldDeclarationSyntax)
src\Analyzers\VisualBasic\Analyzers\RemoveUnusedParametersAndValues\VisualBasicRemoveUnusedParametersAndValuesDiagnosticAnalyzer.vb (1)
56Dim methodSyntax = TryCast(node.Parent, MethodBlockBaseSyntax)
src\Analyzers\VisualBasic\Analyzers\UseAutoProperty\Utilities.vb (2)
10Dim declarator = DirectCast(identifier.Parent, VariableDeclaratorSyntax) 18Dim field = DirectCast(declarator.Parent, FieldDeclarationSyntax)
src\Analyzers\VisualBasic\Analyzers\UseAutoProperty\VisualBasicUseAutoPropertyAnalyzer.vb (3)
79Dim declarator = TryCast(variable.Parent, VariableDeclaratorSyntax) 105Dim accessor = TryCast(TryCast(getMethod.DeclaringSyntaxReferences(0).GetSyntax(cancellationToken), AccessorStatementSyntax)?.Parent, AccessorBlockSyntax) 128Dim setAccessor = TryCast(TryCast(setMethod.DeclaringSyntaxReferences(0).GetSyntax(cancellationToken), AccessorStatementSyntax)?.Parent, AccessorBlockSyntax)
src\Analyzers\VisualBasic\Analyzers\UseInferredMemberName\VisualBasicUseInferredMemberNameDiagnosticAnalyzer.vb (3)
45Dim argument = DirectCast(nameColonEquals.Parent, SimpleArgumentSyntax) 66If Not fieldInitializer.Parent.Parent.IsKind(SyntaxKind.AnonymousObjectCreationExpression) Then
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Extensions\ArgumentSyntaxExtensions.vb (2)
30Dim argumentList = TryCast(argument.Parent, ArgumentListSyntax) 36Dim symbolInfo = semanticModel.GetSymbolInfo(argumentList.Parent, cancellationToken)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Extensions\DirectiveSyntaxExtensions.vb (3)
26While node IsNot Nothing AndAlso (node.Parent IsNot Nothing OrElse TypeOf node Is StructuredTriviaSyntax) 27If node.Parent IsNot Nothing Then 28node = node.Parent
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Extensions\ExpressionSyntaxExtensions.vb (33)
16expression = DirectCast(expression.Parent, ExpressionSyntax) 38(expression.IsParentKind(SyntaxKind.QualifiedName) AndAlso DirectCast(expression.Parent, QualifiedNameSyntax).Left Is expression) OrElse 39(expression.IsParentKind(SyntaxKind.SimpleMemberAccessExpression) AndAlso DirectCast(expression.Parent, MemberAccessExpressionSyntax).Expression Is expression) 59DirectCast(expression.Parent, MemberAccessExpressionSyntax).Name Is expression 64Return TypeOf expression?.Parent Is MemberAccessExpressionSyntax AndAlso 65DirectCast(expression.Parent, MemberAccessExpressionSyntax).Name Is expression 81DirectCast(expression.Parent, QualifiedNameSyntax).Right Is expression 87DirectCast(expression.Parent, QualifiedNameSyntax).Left Is expression 156Dim unaryParent = TryCast(expression.WalkUpParentheses().Parent, UnaryExpressionSyntax) 279Dim simpleArgument = TryCast(expression?.Parent, SimpleArgumentSyntax) 290Dim argumentList = TryCast(simpleArgument.Parent, ArgumentListSyntax) 293Dim parent = argumentList.Parent 328expression = TryCast(expression.Parent, ExpressionSyntax) 337Dim assignmentStatement = DirectCast(expression.Parent, AssignmentStatementSyntax) 344expression.Parent.IsParentKind(SyntaxKind.SimpleArgument) Then 372expression = TryCast(expression.Parent, ExpressionSyntax) 380If TypeOf expression.Parent Is AssignmentStatementSyntax Then 381Dim assignmentStatement = DirectCast(expression.Parent, AssignmentStatementSyntax) 392If TypeOf expression.Parent Is MemberAccessExpressionSyntax Then 393Dim memberAccess = DirectCast(expression.Parent, MemberAccessExpressionSyntax) 498If TypeOf expression.Parent Is InvocationExpressionSyntax Then 551If TypeOf expression.Parent Is BinaryExpressionSyntax OrElse 552TypeOf expression.Parent Is AssignmentStatementSyntax OrElse 553TypeOf expression.Parent Is WhileOrUntilClauseSyntax OrElse 554TypeOf expression.Parent Is SingleLineLambdaExpressionSyntax OrElse 555TypeOf expression.Parent Is AwaitExpressionSyntax Then 572If TypeOf expression.Parent Is ExpressionRangeVariableSyntax AndAlso 573TypeOf expression.Parent.Parent Is QueryClauseSyntax Then 574Dim rangeVariable = DirectCast(expression.Parent, ExpressionRangeVariableSyntax) 575Dim selectClause = TryCast(rangeVariable.Parent, SelectClauseSyntax) 584Dim queryExpression = TryCast(selectClause.Parent, QueryExpressionSyntax) 589Dim aggregateClause = TryCast(selectClause.Parent, AggregateClauseSyntax)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Extensions\InvocationExpressionSyntaxExtensions.vb (1)
60Return DirectCast(invocationExpression.Parent, ConditionalAccessExpressionSyntax).Expression
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Extensions\MemberAccessExpressionSyntaxExtensions.vb (8)
50If TypeOf memberAccess.Parent Is InvocationExpressionSyntax Then 51statement = memberAccess.Parent.Parent 54statement = memberAccess.Parent 60DirectCast(statement.Parent, ConstructorBlockSyntax).Statements.First() Is statement 111TypeOf current.Parent Is ObjectCreationExpressionSyntax Then 112Return DirectCast(current.Parent, ExpressionSyntax) 115current = current.Parent
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Extensions\ParenthesizedExpressionSyntaxExtensions.vb (22)
139Dim interpolation = DirectCast(node.Parent, InterpolationSyntax) 158If node.Parent.IsParentKind(SyntaxKind.ObjectCollectionInitializer) AndAlso 159DirectCast(node.Parent.Parent, ObjectCollectionInitializerSyntax).Initializer Is node.Parent Then 166If node.Parent.IsParentKind(SyntaxKind.CollectionInitializer) AndAlso 167node.Parent.Parent.IsParentKind(SyntaxKind.ObjectCollectionInitializer) AndAlso 168DirectCast(node.Parent.Parent.Parent, ObjectCollectionInitializerSyntax).Initializer Is node.Parent.Parent Then 280If TypeOf node.Parent Is ArgumentSyntax Then 284Dim argument = DirectCast(node.Parent, ArgumentSyntax) 301Dim parentInvocation = DirectCast(node.Parent, InvocationExpressionSyntax) 353Dim parentExpression = TryCast(node.Parent, ExpressionSyntax) 453If (node.Parent.Kind = SyntaxKind.InvocationExpression OrElse 454node.Parent.Kind = SyntaxKind.IsExpression OrElse 455node.Parent.Kind = SyntaxKind.TypeOfIsExpression OrElse 456node.Parent.Kind = SyntaxKind.TypeOfIsNotExpression) Then 466node.Parent.Kind = SyntaxKind.XmlEmbeddedExpression Then
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Extensions\SemanticModelExtensions.vb (55)
113type.Parent.IsParentKind(SyntaxKind.VariableDeclarator) Then 114If type.Parent.Parent.IsParentKind(SyntaxKind.FieldDeclaration) OrElse 115type.Parent.Parent.IsParentKind(SyntaxKind.EventStatement) Then 116Dim variableDeclarator = DirectCast(type.Parent.Parent, VariableDeclaratorSyntax) 127type.Parent.IsParentKind(SyntaxKind.AsNewClause) AndAlso 128type.Parent.Parent.IsParentKind(SyntaxKind.VariableDeclarator) Then 129If type.Parent.Parent.Parent.IsParentKind(SyntaxKind.FieldDeclaration) OrElse 130type.Parent.Parent.Parent.IsParentKind(SyntaxKind.EventStatement) Then 131Dim variableDeclarator = DirectCast(type.Parent.Parent.Parent, VariableDeclaratorSyntax) 140If type.Parent.IsParentKind(SyntaxKind.DelegateFunctionStatement) OrElse 141type.Parent.IsParentKind(SyntaxKind.FunctionStatement) OrElse 142type.Parent.IsParentKind(SyntaxKind.PropertyStatement) OrElse 143type.Parent.IsParentKind(SyntaxKind.EventStatement) OrElse 144type.Parent.IsParentKind(SyntaxKind.OperatorStatement) Then 146type.Parent.Parent, cancellationToken).DeclaredAccessibility 151type.Parent.IsParentKind(SyntaxKind.Parameter) AndAlso 152type.Parent.Parent.IsParentKind(SyntaxKind.ParameterList) Then 153If type.Parent.Parent.Parent.IsParentKind(SyntaxKind.DelegateFunctionStatement) OrElse 154type.Parent.Parent.Parent.IsParentKind(SyntaxKind.FunctionStatement) OrElse 155type.Parent.Parent.Parent.IsParentKind(SyntaxKind.PropertyStatement) OrElse 156type.Parent.Parent.Parent.IsParentKind(SyntaxKind.OperatorStatement) OrElse 157type.Parent.Parent.Parent.IsParentKind(SyntaxKind.SubNewStatement) OrElse 158type.Parent.Parent.Parent.IsParentKind(SyntaxKind.SubStatement) Then 160type.Parent.Parent.Parent.Parent, cancellationToken).DeclaredAccessibility 232If TypeOf topExpression.Parent Is ArgumentSyntax Then 233Dim argument = DirectCast(topExpression.Parent, ArgumentSyntax) 240Dim argumentList = TryCast(argument.Parent, ArgumentListSyntax) 243Dim member = TryCast(semanticModel.GetSymbolInfo(argumentList.Parent, cancellationToken).Symbol, IMethodSymbol)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Extensions\StatementSyntaxExtensions.vb (1)
745DirectCast(statement.Parent, ConstructorBlockSyntax).Statements.FirstOrDefault() Is statement Then
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Extensions\SyntaxNodeExtensions.vb (24)
19node.Parent.IsKind(kind) 25IsKind(node.Parent, kind1, kind2) 31IsKind(node.Parent, kind1, kind2, kind3) 681singleLineIf = DirectCast(executableBlock.Parent, SingleLineIfStatementSyntax) 730current = singleLineIf.Parent 788DirectCast(node.Parent, AssignmentStatementSyntax).Left Is node 794node.Parent.IsAnyAssignmentStatement() AndAlso 795DirectCast(node.Parent, AssignmentStatementSyntax).Left Is node 807node.Parent.IsCompoundAssignmentStatement() AndAlso 808DirectCast(node.Parent, AssignmentStatementSyntax).Left Is node 986node = DirectCast(node.Parent, ExpressionSyntax) 995TypeOf node.Parent IsNot ConditionalAccessExpressionSyntax 997node = TryCast(node.Parent, ExpressionSyntax) 1027If TypeOf node?.Parent Is ConditionalAccessExpressionSyntax AndAlso 1028DirectCast(node.Parent, ConditionalAccessExpressionSyntax).Expression Is node Then 1030node = DirectCast(node.Parent, ExpressionSyntax) 1033If TypeOf node?.Parent Is ConditionalAccessExpressionSyntax AndAlso 1034DirectCast(node.Parent, ConditionalAccessExpressionSyntax).WhenNotNull Is node Then 1036node = DirectCast(node.Parent, ExpressionSyntax) 1053While TypeOf node?.Parent Is ConditionalAccessExpressionSyntax 1054Dim conditionalParent = DirectCast(node.Parent, ConditionalAccessExpressionSyntax) 1098current = current.Parent 1221Dim parent As SyntaxNode = node.Parent 1262Dim parent As SyntaxNode = node.Parent
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Extensions\SyntaxTreeExtensions.vb (2)
71current = current.Parent 92node = node.Parent
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Extensions\VariableDeclaratorSyntaxExtensions.vb (1)
54Not DirectCast(variableDeclarator.Parent, FieldDeclarationSyntax).Modifiers.Any(SyntaxKind.ConstKeyword) Then
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Services\SemanticFacts\VisualBasicSemanticFacts.vb (5)
244TypeOf argument.Parent Is ArgumentListSyntax AndAlso 245TypeOf argument.Parent.Parent Is AttributeSyntax Then 314Dim parent As SyntaxNode = node.Parent 324parent = current.Parent
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Services\SyntaxFacts\VisualBasicAccessibilityFacts.vb (5)
65Not declaration.Parent.IsKind(SyntaxKind.ModuleBlock) 69CanHaveAccessibility(declaration.Parent), 74CanHaveAccessibility(declaration.Parent), 160Return GetModifierTokens(declaration.Parent) 166Return GetModifierTokens(declaration.Parent)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Services\SyntaxFacts\VisualBasicBlockFacts.vb (2)
24Return If(IsExecutableBlock(statement.Parent), statement.Parent, Nothing)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Services\SyntaxFacts\VisualBasicSyntaxFacts.vb (47)
164Dim memberAccess = TryCast(node?.Parent, MemberAccessExpressionSyntax) 195DirectCast(node.Parent, SimpleImportsClauseSyntax).Name Is node 232Return firstStatement.Parent Is secondStatement.Parent 249Dim memberAccess = TryCast(token.Parent.Parent, MemberAccessExpressionSyntax) 258Dim memberAccess = TryCast(token.Parent.Parent, MemberAccessExpressionSyntax) 625identifierName.Parent.IsParentKind(SyntaxKind.SimpleArgument) AndAlso 626identifierName.Parent.Parent.IsParentKind(SyntaxKind.ArgumentList) AndAlso 627identifierName.Parent.Parent.Parent.IsParentKind(SyntaxKind.Attribute) 642Dim parent = node.Parent 649node = node.Parent 664initializedInstance = identifier.Parent.Parent.Parent 673If TypeOf node.Parent Is ArrayCreationExpressionSyntax Then 674creationExpression = node.Parent 676ElseIf TypeOf node.Parent Is ObjectCollectionInitializerSyntax AndAlso 677TypeOf node.Parent.Parent Is ObjectCreationExpressionSyntax Then 678creationExpression = node.Parent.Parent 702If TypeOf node Is MethodBlockBaseSyntax AndAlso Not TypeOf node.Parent Is PropertyBlockSyntax Then 706If TypeOf node Is MethodBaseSyntax AndAlso Not TypeOf node.Parent Is MethodBlockBaseSyntax Then 710If TypeOf node Is PropertyStatementSyntax AndAlso Not TypeOf node.Parent Is PropertyBlockSyntax Then 714If TypeOf node Is EventStatementSyntax AndAlso Not TypeOf node.Parent Is EventBlockSyntax Then 735If TypeOf node Is MethodBlockBaseSyntax AndAlso Not TypeOf node.Parent Is PropertyBlockSyntax Then 739If TypeOf node Is MethodBaseSyntax AndAlso Not TypeOf node.Parent Is MethodBlockBaseSyntax Then 767node = node.Parent 780If TypeOf node Is MethodStatementSyntax AndAlso Not TypeOf node.Parent Is MethodBlockBaseSyntax Then 784If TypeOf node Is SubNewStatementSyntax AndAlso Not TypeOf node.Parent Is MethodBlockBaseSyntax Then 788If TypeOf node Is OperatorStatementSyntax AndAlso Not TypeOf node.Parent Is MethodBlockBaseSyntax Then 792If TypeOf node Is PropertyStatementSyntax AndAlso Not TypeOf node.Parent Is PropertyBlockSyntax Then 796If TypeOf node Is EventStatementSyntax AndAlso Not TypeOf node.Parent Is EventBlockSyntax Then 944Dim parent = node.Parent 947parent = parent.Parent 955parent = parent.Parent 1078Dim parent = node.Parent 1202Return IsLeftSideOfDot(node) AndAlso TryCast(node.Parent.Parent, ImplementsClauseSyntax) IsNot Nothing 1328If (node.Parent.IsKind(SyntaxKind.FieldDeclaration)) Then 1454Return node IsNot Nothing AndAlso TryCast(node.Parent, ForEachStatementSyntax)?.Expression Is node 1534Return node IsNot Nothing AndAlso TryCast(node.Parent, PropertyStatementSyntax)?.Initializer Is node 1659Return node.Parent IsNot Nothing AndAlso node.Parent.IsKind(kind)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Simplification\VisualBasicInferredMemberNameSimplifier.vb (2)
20If RemovalCausesAmbiguity(DirectCast(node.Parent, TupleExpressionSyntax).Arguments, node) Then 35Dim parentMemberInitializer As ObjectMemberInitializerSyntax = DirectCast(node.Parent, ObjectMemberInitializerSyntax)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Utilities\CastAnalyzer.vb (4)
35Dim argument = TryCast(_castNode.WalkUpParentheses().Parent, ArgumentSyntax) 59Dim parent = expression.Parent 75Dim returnedType = AsTypeInVariableDeclarator(parentEqualsValue.Parent, semanticModel) 362Dim parentNode = expression.Parent
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Utilities\SpeculationAnalyzer.vb (2)
339Debug.Assert(previousOriginalNode Is Nothing OrElse previousOriginalNode.Parent Is currentOriginalNode) 340Debug.Assert(previousReplacedNode Is Nothing OrElse previousReplacedNode.Parent Is currentReplacedNode)
src\Workspaces\VisualBasic\Portable\Formatting\DefaultOperationProvider.vb (12)
84If previousToken.Parent.Parent IsNot Nothing AndAlso TypeOf previousToken.Parent.Parent Is ParameterSyntax Then 95currentToken.Parent.Parent IsNot Nothing AndAlso TypeOf currentToken.Parent.Parent Is ParameterSyntax Then 137Dim [imports] = DirectCast(previousImports.Parent, CompilationUnitSyntax).Imports 185TypeOf xmlDeclaration.Parent Is XmlDocumentSyntax AndAlso 186Not TypeOf xmlDeclaration.Parent.Parent Is XmlNodeSyntax Then 193TypeOf startTag.Parent Is XmlElementSyntax AndAlso 194Not TypeOf startTag.Parent.Parent Is XmlNodeSyntax Then 201Not TypeOf emptyTag.Parent Is XmlNodeSyntax Then
src\Workspaces\VisualBasic\Portable\Formatting\FormattingHelpers.vb (6)
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) 278If token.Parent.Parent Is Nothing Then
src\Workspaces\VisualBasic\Portable\Formatting\Rules\ElasticTriviaFormattingRule.vb (7)
116currentToken.Parent.Parent.Kind = SyntaxKind.ObjectCollectionInitializer Then 150previousToken.Parent.Parent.Kind = SyntaxKind.ObjectCollectionInitializer Then 158previousToken.Parent.Parent.Kind = SyntaxKind.ObjectCollectionInitializer Then 166currentToken.Parent.Parent.Kind = SyntaxKind.CollectionInitializer Then 179currentToken.Parent.Parent.Kind = SyntaxKind.ObjectCollectionInitializer Then 187If attributeNode IsNot Nothing AndAlso TypeOf attributeNode.Parent Is StatementSyntax AndAlso 257Return TryCast(node, TStatement) IsNot Nothing AndAlso TryCast(node.Parent, TBlock) IsNot Nothing
src\Workspaces\VisualBasic\Portable\Formatting\Rules\NodeBasedFormattingRule.vb (6)
208outerBlock = outerBlock.Parent 229If Not TypeOf node.Parent Is XmlNodeSyntax Then 244If Not TypeOf xmlNode.Parent Is XmlNodeSyntax Then 249If Not TypeOf xmlNode.Parent Is XmlNodeSyntax Then 255If TypeOf xmlNode.Parent Is XmlEmbeddedExpressionSyntax Then 267Dim element = TryCast(xmlNode.Parent, XmlElementSyntax)
Microsoft.CodeAnalysis.VisualBasic.CodeStyle.Fixes (105)
src\Analyzers\VisualBasic\CodeFixes\AddExplicitCast\ArgumentFixer.vb (1)
37Dim parent = newArgumentList.Parent
src\Analyzers\VisualBasic\CodeFixes\AddExplicitCast\VisualBasicAddExplicitCastCodeFixProvider.vb (1)
71Dim invocationNode = argumentList.Parent
src\Analyzers\VisualBasic\CodeFixes\GenerateConstructor\VisualBasicGenerateConstructorService.vb (12)
52TryCast(node.Parent, MemberAccessExpressionSyntax).IsConstructorInitializer() AndAlso 53node.Parent.Parent.Kind = SyntaxKind.InvocationExpression 64Dim memberAccess = DirectCast(simpleName.Parent, MemberAccessExpressionSyntax) 65Dim invocation = DirectCast(memberAccess.Parent, InvocationExpressionSyntax) 100Dim name = If(simpleName.IsRightSideOfQualifiedName(), DirectCast(simpleName.Parent, NameSyntax), simpleName) 102If TypeOf name.Parent Is ObjectCreationExpressionSyntax Then 103Dim objectCreationExpression = DirectCast(name.Parent, ObjectCreationExpressionSyntax) 135Dim name = If(simpleName.IsRightSideOfQualifiedName(), DirectCast(simpleName.Parent, NameSyntax), simpleName) 137If TypeOf name.Parent Is AttributeSyntax Then 138Dim attribute = DirectCast(name.Parent, AttributeSyntax) 174Dim constructorStatements = constructor.DeclaringSyntaxReferences(0).GetSyntax(cancellationToken).Parent.GetStatements()
src\Analyzers\VisualBasic\CodeFixes\GenerateDefaultConstructors\VisualBasicGenerateDefaultConstructorsService.vb (1)
48classType = TryCast(semanticDocument.SemanticModel.GetDeclaredSymbol(baseList.Parent, cancellationToken), INamedTypeSymbol)
src\Analyzers\VisualBasic\CodeFixes\GenerateEnumMember\VisualBasicGenerateEnumMemberService.vb (2)
31Dim memberAccess = TryCast(identifierName.Parent, MemberAccessExpressionSyntax) 38Dim invocation = DirectCast(simpleNameOrMemberAccessExpression.Parent, InvocationExpressionSyntax)
src\Analyzers\VisualBasic\CodeFixes\GenerateParameterizedMember\VisualBasicGenerateMethodService.vb (10)
51Dim implementsClause = DirectCast(qualifiedName.Parent, ImplementsClauseSyntax) 56Dim methodStatement = DirectCast(implementsClause.Parent, MethodStatementSyntax) 84Dim memberAccess = TryCast(simpleName?.Parent, MemberAccessExpressionSyntax) 85Dim conditionalMemberAccessInvocationExpression = TryCast(simpleName?.Parent?.Parent?.Parent, ConditionalAccessExpressionSyntax) 86Dim conditionalMemberAccessSimpleMemberAccess = TryCast(simpleName?.Parent?.Parent, ConditionalAccessExpressionSyntax) 116invocationExpressionOpt = DirectCast(simpleNameOrMemberAccessExpression.Parent, InvocationExpressionSyntax) 126ElseIf simpleNameOrMemberAccessExpression?.Parent?.IsKind(SyntaxKind.AddressOfExpression, SyntaxKind.NameOfExpression) Then
src\Analyzers\VisualBasic\CodeFixes\ImplementInterface\VisualBasicImplementInterfaceCodeFixProvider.vb (1)
28Return TypeOf type.Parent Is ImplementsStatementSyntax
src\Analyzers\VisualBasic\CodeFixes\ImplementInterface\VisualBasicImplementInterfaceService.vb (3)
55ElseIf TypeOf node Is TypeSyntax AndAlso TypeOf node.Parent Is ImplementsStatementSyntax Then 57implementsStatement = DirectCast(node.Parent, ImplementsStatementSyntax) 76classOrStructDecl = implementsStatement.Parent
src\Analyzers\VisualBasic\CodeFixes\Iterator\VisualBasicConvertToIteratorCodeFixProvider.vb (1)
52If identifier.Parent.Kind <> SyntaxKind.InvocationExpression Then
src\Analyzers\VisualBasic\CodeFixes\MakeFieldReadonly\VisualBasicMakeFieldReadonlyCodeFixProvider.vb (2)
27Dim initializer = CType(declaration.Parent, VariableDeclaratorSyntax).Initializer?.Value 29initializer = TryCast(CType(declaration.Parent, VariableDeclaratorSyntax).AsClause, AsNewClauseSyntax)?.NewExpression
src\Analyzers\VisualBasic\CodeFixes\MakeTypeAbstract\VisualBasicMakeTypeAbstractCodeFixProvider.vb (1)
36typeDeclaration = TryCast(classStatement.Parent, ClassBlockSyntax)
src\Analyzers\VisualBasic\CodeFixes\RemoveUnusedParametersAndValues\VisualBasicRemoveUnusedValuesCodeFixProvider.vb (1)
75Return TryCast(declarator.Parent, LocalDeclarationStatementSyntax)
src\Analyzers\VisualBasic\CodeFixes\UseConditionalExpression\VisualBasicUseConditionalExpressionForAssignmentCodeFixProvider.vb (1)
47Return DirectCast(declarator.Syntax.Parent, VariableDeclaratorSyntax)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\CodeGeneration\VisualBasicCodeGenerationHelpers.vb (2)
216Dim variableDeclarator = TryCast(modifiedIdentifierNode.Parent, VariableDeclaratorSyntax) 218Dim fieldDecl = TryCast(variableDeclarator.Parent, FieldDeclarationSyntax)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\CodeGeneration\VisualBasicDeclarationComparer.vb (3)
325declaration = declaration.Parent 328Dim node = declaration.Parent 345node = node.Parent
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\CodeRefactorings\VisualBasicRefactoringHelpersService.vb (9)
76Yield node.Parent 81If TypeOf node Is ForEachStatementSyntax And TypeOf node.Parent Is ForEachBlockSyntax Then 83Yield foreachStatement.Parent 86If TypeOf node Is ForStatementSyntax And TypeOf node.Parent Is ForBlockSyntax Then 88Yield forStatement.Parent 93If TypeOf declarator.Parent Is LocalDeclarationStatementSyntax Then 94Dim localDeclarationStatement = CType(declarator.Parent, LocalDeclarationStatementSyntax) 105Return (TypeOf node Is ModifiedIdentifierSyntax) AndAlso (TypeOf node.Parent Is ParameterSyntax) AndAlso (CType(node.Parent, ParameterSyntax).Identifier Is node)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\Extensions\ContextQuery\SyntaxTreeExtensions.vb (7)
323TypeOf targetToken.Parent.Parent Is NewExpressionSyntax Then 325Dim symbolInfo = semanticModel.GetSymbolInfo(DirectCast(targetToken.Parent.Parent, NewExpressionSyntax).Type(), cancellationToken) 444TypeOf targetToken.Parent.Parent Is LambdaHeaderSyntax Then 471targetToken.Parent.Parent.IsKind(SyntaxKind.Attribute) Then 691ancestor = ancestor.Parent.Parent 709ancestor = ancestor.Parent
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\Extensions\ContextQuery\VisualBasicSyntaxContext.vb (10)
144Dim methodStatement = TryCast(asClause?.Parent, MethodBaseSyntax) 213If TypeOf collectionRange.Parent Is FromClauseSyntax AndAlso TypeOf collectionRange.Parent.Parent Is QueryExpressionSyntax Then 214Dim fromClause = DirectCast(collectionRange.Parent, FromClauseSyntax) 215Dim queryExpression = DirectCast(collectionRange.Parent.Parent, QueryExpressionSyntax) 220If fromClause.Variables.FirstOrDefault() Is collectionRange AndAlso queryExpression.Clauses.FirstOrDefault() Is collectionRange.Parent Then 223ElseIf TypeOf collectionRange.Parent Is SimpleJoinClauseSyntax OrElse TypeOf collectionRange.Parent Is GroupJoinClauseSyntax Then
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\Extensions\ExpressionSyntaxExtensions.vb (3)
201Return DirectCast(statement.Parent, ConstructorBlockSyntax).Statements(0) Is statement 206Dim simpleArgument = TryCast(expression.Parent, SimpleArgumentSyntax) 253Return TypeOf expression?.Parent Is MemberAccessExpressionSyntax
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\Extensions\ParameterSyntaxExtensions.vb (2)
16parameter.Parent.Parent.IsKind(SyntaxKind.FunctionLambdaHeader, SyntaxKind.SubLambdaHeader) Then
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\Extensions\SimpleNameSyntaxExtensions.vb (3)
15Return DirectCast(name.Parent, MemberAccessExpressionSyntax).Expression 17Return DirectCast(name.Parent, QualifiedNameSyntax).Left 37Dim invocationExpression = DirectCast(simpleName.Parent, InvocationExpressionSyntax)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\Indentation\VisualBasicIndentationService.vb (2)
105currentNode = currentNode.Parent 115currentNode = currentNode.Parent
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\LanguageServices\InitializeParameter\VisualBasicInitializeParameterService.vb (1)
29Return TryCast(TryCast(reference, AccessorStatementSyntax)?.Parent, AccessorBlockSyntax)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\LanguageServices\VisualBasicTypeInferenceService.TypeInferrer.vb (26)
57Dim parent = node.Parent 158Function(nameColonEquals As NameColonEqualsSyntax) InferTypeInArgumentList(TryCast(nameColonEquals.Parent.Parent, ArgumentListSyntax), DirectCast(nameColonEquals.Parent, ArgumentSyntax)), 177Return If(parameterList.Parent IsNot Nothing, 178InferTypeInLambda(TryCast(parameterList.Parent.Parent, LambdaExpressionSyntax)), 184If TypeOf argument.Parent Is ArgumentListSyntax Then 186DirectCast(argument.Parent, ArgumentListSyntax), argument, previousToken) 189If TypeOf argument.Parent Is TupleExpressionSyntax Then 191DirectCast(argument.Parent, TupleExpressionSyntax), 231If argumentList.Parent IsNot Nothing Then 236Dim invocation = TryCast(argumentList.Parent, InvocationExpressionSyntax) 274ElseIf invocation.Parent.IsKind(SyntaxKind.ConditionalAccessExpression) Then 275targetExpression = DirectCast(invocation.Parent, ConditionalAccessExpressionSyntax).Expression 291Dim creation = TryCast(argumentList.Parent, ObjectCreationExpressionSyntax) 316Dim attribute = TryCast(argumentList.Parent, AttributeSyntax) 602Dim variableDeclarator = DirectCast(equalsValue.Parent, VariableDeclaratorSyntax) 626Dim propertySyntax = CType(equalsValue.Parent, PropertyStatementSyntax) 798If TypeOf switchStatementSyntax.Parent Is SelectBlockSyntax Then 799Dim firstCase = DirectCast(switchStatementSyntax.Parent, SelectBlockSyntax).CaseBlocks.SelectMany(Function(c) c.CaseStatement.Cases).OfType(Of SimpleCaseClauseSyntax).FirstOrDefault() 912memberAccessExpression.Parent.IsParentKind(SyntaxKind.AwaitExpression) Then 913Return InferTypes(DirectCast(memberAccessExpression.Parent, ExpressionSyntax)) 932Dim invocation = DirectCast(memberAccessExpression.Parent, InvocationExpressionSyntax) 1064Dim objectInitializer = TryCast(collectionInitializer.Parent, ObjectCollectionInitializerSyntax) 1065Dim objectCreation = TryCast(objectInitializer?.Parent, ObjectCreationExpressionSyntax)
Microsoft.CodeAnalysis.VisualBasic.EditorFeatures (15)
AutomaticEndConstructCorrection\AutomaticEndConstructCorrector.vb (4)
200If token.Parent.Parent Is Nothing Then 204Dim beginNode = token.Parent.Parent.TypeSwitch( 235If token.Parent.Parent Is Nothing Then 239Return token.Parent.Parent.TypeSwitch(
EndConstructGeneration\EndConstructStatementVisitor_LambdaHeader.vb (1)
12Dim singleLineExpressionSyntax = TryCast(node.Parent, SingleLineLambdaExpressionSyntax)
GoToBase\VisualBasicGoToBaseService.vb (1)
27Dim constructorBlock = TryCast(subNew.Parent, ConstructorBlockSyntax)
ImplementAbstractClass\ImplementAbstractClassCommandHandler.vb (3)
41If typeSyntax.Parent.Kind <> SyntaxKind.InheritsStatement Then 45Dim classBlock = TryCast(typeSyntax.Parent.Parent, ClassBlockSyntax)
ImplementInterface\ImplementInterfaceCommandHandler.vb (2)
42If typeSyntax.Parent.Kind <> SyntaxKind.ImplementsStatement Then 52typeSyntax.Parent,
LineCommit\CommitFormatter.vb (1)
249node = node.Parent
Utilities\LineAdjustmentFormattingRule.vb (3)
30current.Parent.Parent.IsKind(SyntaxKind.ConstructorBlock, SyntaxKind.SubBlock)) OrElse 32current.Parent.Parent.Kind = SyntaxKind.FunctionBlock) AndAlso 33Not DirectCast(current.Parent.Parent, MethodBlockSyntax).Statements.Any() Then
Microsoft.CodeAnalysis.VisualBasic.Emit.UnitTests (1)
Emit\EditAndContinue\EditAndContinueTestBase.vb (1)
185node = node.Parent
Microsoft.CodeAnalysis.VisualBasic.Features (438)
ChangeSignature\ChangeSignatureFormattingRule.vb (2)
23If node.Parent IsNot Nothing Then 27node.Parent.GetFirstToken(),
ChangeSignature\VisualBasicChangeSignatureService.vb (2)
170current = current.Parent 268matchingNode = matchingNode.Parent
CodeFixes\GenerateEndConstruct\GenerateEndConstructCodeFixProvider.vb (11)
83If endStatement.Parent.Kind = SyntaxKind.PropertyBlock Then 87Function(c) GeneratePropertyEndConstructAsync(context.Document, DirectCast(endStatement.Parent, PropertyBlockSyntax), c), 94If endStatement?.Parent?.Parent.Kind = SyntaxKind.PropertyBlock Then 98Function(c) GeneratePropertyEndConstructAsync(context.Document, DirectCast(endStatement.Parent.Parent, PropertyBlockSyntax), c), 119Dim begin = GetBeginStatement(node.Parent) 216Dim nextNode = endStatement.Parent.GetLastToken().GetNextToken().Parent 221Dim updatedParent = DirectCast(endStatement.Parent, EnumBlockSyntax).WithEndEnumStatement(SyntaxFactory.EndEnumStatement()) 222Dim updatedDocument = Await document.ReplaceNodeAsync(endStatement.Parent, updatedParent.WithAdditionalAnnotations(Formatter.Annotation), cancellationToken).ConfigureAwait(False) 251Dim insertionPoint = GetBeginStatement(endStatement.Parent).FullSpan.End
CodeFixes\GenerateEvent\GenerateEventCodeFixProvider.vb (3)
247If Not node.IsParentKind(SyntaxKind.ImplementsClause) OrElse Not node.Parent.IsParentKind(SyntaxKind.EventStatement) Then 264Dim boundEvent = TryCast(semanticModel.GetDeclaredSymbol(node.Parent.Parent, cancellationToken), IEventSymbol)
CodeFixes\Suppression\VisualBasicSuppressionCodeFixProvider.vb (1)
212Dim attributeList = TryCast(attributeSyntax.Parent, AttributeListSyntax)
CodeLens\VisualBasicDisplayInfoService.vb (3)
52Return GetDisplayNode(node.Parent) 132If IsAccessorForDefaultProperty(symbol) AndAlso node.Parent.IsKind(SyntaxKind.PropertyBlock) Then 133Return GetDisplayName(semanticModel, node.Parent)
CodeRefactorings\InlineTemporary\VisualBasicInlineTemporaryCodeRefactoringProvider.ReferenceRewriter.vb (1)
69node.Parent.IsParentKind(SyntaxKind.TupleExpression) Then
CodeRefactorings\InlineTemporary\VisualBasicInlineTemporaryCodeRefactoringProvider.vb (10)
46Dim localDeclarationStatement = DirectCast(variableDeclarator.Parent, LocalDeclarationStatementSyntax) 156Dim variableDeclarator = DirectCast(modifiedIdentifier.Parent, VariableDeclaratorSyntax) 157Dim localDeclaration = DirectCast(variableDeclarator.Parent, LocalDeclarationStatementSyntax) 251Dim variableDeclarator = DirectCast(modifiedIdentifier.Parent, VariableDeclaratorSyntax) 252Dim localDeclaration = DirectCast(variableDeclarator.Parent, LocalDeclarationStatementSyntax) 254Return localDeclaration.Parent 258Dim variableDeclarator = DirectCast(modifiedIdentifier.Parent, VariableDeclaratorSyntax) 259Dim localDeclaration = DirectCast(variableDeclarator.Parent, LocalDeclarationStatementSyntax) 273Dim variableDeclarator = DirectCast(modifiedIdentifier.Parent, VariableDeclaratorSyntax) 274Dim localDeclaration = DirectCast(variableDeclarator.Parent, LocalDeclarationStatementSyntax)
CodeRefactorings\MoveType\VisualBasicMoveTypeService.vb (1)
29Return TryCast(typeStatement?.Parent, TypeBlockSyntax)
CodeRefactorings\SyncNamespace\VisualBasicChangeNamespaceService.vb (2)
34old = nameRef.Parent 45old = nameRef.Parent
Completion\CompletionProviders\CrefCompletionProvider.vb (1)
140Dim xmlAttribute = DirectCast(token.Parent.Parent, XmlAttributeSyntax)
Completion\CompletionProviders\ImplementsClauseCompletionProvider.vb (1)
272parent = parent.Parent
Completion\CompletionProviders\NamedParameterCompletionProvider.vb (2)
77Dim parameterLists = GetParameterLists(semanticModel, position, argumentList.Parent, cancellationToken) 223current = current.Parent
Completion\CompletionProviders\XmlDocCommentCompletionProvider.vb (1)
202Dim element = TryCast(endTag.Parent, XmlElementSyntax)
Completion\KeywordRecommenders\Declarations\ImplementsKeywordRecommender.vb (2)
44TypeOf typeStatement.Parent Is TypeBlockSyntax AndAlso 45DirectCast(typeStatement.Parent, TypeBlockSyntax).Implements.Count > 0 Then
Completion\KeywordRecommenders\RecommendationHelpers.vb (1)
23Return If(node Is Nothing, Nothing, node.Parent)
Completion\KeywordRecommenders\Statements\FinallyKeywordRecommender.vb (1)
58parent = parent.Parent
ConvertAutoPropertyToFullProperty\VisualBasicConvertAutoPropertyToFullProperty.vb (1)
87Return DirectCast(syntaxNode, TypeStatementSyntax).Parent
Debugging\DataTipInfoGetter.vb (3)
52expression = DirectCast(expression.Parent, ExpressionSyntax) 56If expression.Parent.IsKind(SyntaxKind.InvocationExpression) Then 57expression = DirectCast(expression.Parent, ExpressionSyntax)
Debugging\ProximityExpressionsGetter.RelevantExpressionsCollector.vb (8)
24TypeOf node.Parent Is TypeArgumentListSyntax OrElse 25TypeOf node.Parent Is AsClauseSyntax OrElse 26(node.Parent.Parent IsNot Nothing AndAlso TypeOf node.Parent.Parent Is AsClauseSyntax) OrElse 27TypeOf node.Parent Is ImplementsClauseSyntax Then 31If node.Parent.IsKind(SyntaxKind.NameColonEquals) Then
Debugging\ProximityExpressionsGetter.Worker.vb (4)
103If TypeOf _parentStatement.Parent Is MethodBlockBaseSyntax Then 104Dim methodBlock = DirectCast(_parentStatement.Parent, MethodBlockBaseSyntax) 120If TypeOf _parentStatement.Parent Is CatchBlockSyntax Then 121Dim catchBlock = DirectCast(_parentStatement.Parent, CatchBlockSyntax)
EditAndContinue\BreakpointSpans.vb (12)
84node = node.Parent 244If node.Parent.IsKind(SyntaxKind.PropertyBlock) Then 274If name.ArrayBounds IsNot Nothing OrElse DirectCast(name.Parent, VariableDeclaratorSyntax).Names.Count > 1 Then 277Return CreateSpan(name.Parent) 335Dim query = DirectCast(fromClause.Parent, QueryExpressionSyntax) 377If collectionRangeVariable.Parent.Kind = SyntaxKind.FromClause Then 378Dim fromClause = DirectCast(collectionRangeVariable.Parent, FromClauseSyntax) 379Dim query = DirectCast(fromClause.Parent, QueryExpressionSyntax) 441If expression Is Nothing OrElse expression.Parent Is Nothing Then 445Select Case expression.Parent.Kind 447Dim joinCondition = DirectCast(expression.Parent, JoinConditionSyntax) 451Dim lambda = DirectCast(expression.Parent, SingleLineLambdaExpressionSyntax)
EditAndContinue\DeclarationBody\FieldOrPropertyDeclarationBody.vb (5)
53Return OneOrMany.Create(OtherActiveStatementContainer.Parent) 65OtherActiveStatementContainer.Parent, 66newFieldBody.OtherActiveStatementContainer.Parent, 72Return comparer.ComputeMatch(OtherActiveStatementContainer.Parent, newFieldBody.OtherActiveStatementContainer.Parent, knownMatches)
EditAndContinue\DeclarationBody\FieldWithMultipleAsNewClauseDeclarationBody.vb (2)
31Return DirectCast(DirectCast(_modifedIdentifier.Parent, VariableDeclaratorSyntax).AsClause, AsNewClauseSyntax).NewExpression 48Return _modifedIdentifier.Parent
EditAndContinue\DeclarationBody\VisualBasicLambdaBody.vb (18)
18Debug.Assert(TypeOf node.Parent Is LambdaExpressionSyntax OrElse TypeOf node Is ExpressionSyntax) 36Return If(TypeOf _node.Parent Is LambdaExpressionSyntax, _node.Parent, _node) 45Return model.AnalyzeDataFlow(If(TryCast(_node.Parent, LambdaExpressionSyntax), _node)).CapturedInside 67If TypeOf _node.Parent Is LambdaExpressionSyntax Then 69Dim comparer = New SyntaxComparer(_node.Parent, newLambdaBody._node.Parent, _node.Parent.ChildNodes(), newLambdaBody._node.Parent.ChildNodes(), matchingLambdas:=True, compareStatementSyntax:=True) 70Return comparer.ComputeMatch(_node.Parent, newLambdaBody._node.Parent, knownMatches) 73Dim comparer = New SyntaxComparer(_node.Parent, newLambdaBody._node.Parent, {_node}, {newLambdaBody._node}, matchingLambdas:=False, compareStatementSyntax:=True) 74Return comparer.ComputeMatch(_node.Parent, newLambdaBody._node.Parent, knownMatches) 81If TypeOf _node.Parent Is LambdaExpressionSyntax Then 82Dim oldSingleLineLambda = TryCast(_node.Parent, SingleLineLambdaExpressionSyntax) 83Dim newSingleLineLambda = TryCast(newLambdaBody._node.Parent, SingleLineLambdaExpressionSyntax)
EditAndContinue\SyntaxComparer.vb (3)
694nodeOpt.Parent.IsKind(SyntaxKind.GroupByClause) AndAlso 695nodeOpt.SpanStart < DirectCast(nodeOpt.Parent, GroupByClauseSyntax).ByKeyword.SpanStart Then 858If nodeOpt IsNot Nothing AndAlso nodeOpt.Parent.IsParentKind(SyntaxKind.AttributesStatement) Then
EditAndContinue\SyntaxUtilities.vb (29)
48Dim variableDeclarator = DirectCast(node.Parent, VariableDeclaratorSyntax) 49Dim fieldDeclaration = DirectCast(variableDeclarator.Parent, FieldDeclarationSyntax) 107Return node.Parent.Parent.IsKind(SyntaxKind.FieldDeclaration) AndAlso DirectCast(node.Parent, VariableDeclaratorSyntax).Names.Count > 1 114Return node.Parent.IsKind(SyntaxKind.FieldDeclaration) AndAlso node.Names.Count = 1 160If syntax.Parent.Kind = SyntaxKind.EqualsValue Then 161If syntax.Parent.Parent.IsKind(SyntaxKind.PropertyStatement) Then 165Debug.Assert(syntax.Parent.Parent.IsKind(SyntaxKind.VariableDeclarator)) 166Debug.Assert(syntax.Parent.Parent.Parent.IsKind(SyntaxKind.FieldDeclaration)) 168ElseIf syntax.Parent.Kind = SyntaxKind.AsNewClause Then 169If syntax.Parent.Parent.IsKind(SyntaxKind.PropertyStatement) Then 173Debug.Assert(syntax.Parent.Parent.IsKind(SyntaxKind.VariableDeclarator)) 174Debug.Assert(syntax.Parent.Parent.Parent.IsKind(SyntaxKind.FieldDeclaration)) 181Debug.Assert(syntax.Parent.IsKind(SyntaxKind.ModifiedIdentifier)) 182Debug.Assert(syntax.Parent.Parent.IsKind(SyntaxKind.VariableDeclarator)) 183Debug.Assert(syntax.Parent.Parent.Parent.IsKind(SyntaxKind.FieldDeclaration)) 212Not propertyDeclaration.Parent.IsKind(SyntaxKind.PropertyBlock) AndAlso
EditAndContinue\VisualBasicEditAndContinueAnalyzer.vb (60)
62If Not current.Parent.IsKind(SyntaxKind.PropertyBlock) Then 68If current.Parent.IsKind(SyntaxKind.FieldDeclaration) Then 81If current.Parent.Parent.IsKind(SyntaxKind.FieldDeclaration) Then 87current = current.Parent 106If declaration.Kind = SyntaxKind.ModifiedIdentifier AndAlso declaration.Parent.Kind = SyntaxKind.VariableDeclarator Then 107Dim variableDeclarator = CType(declaration.Parent, VariableDeclaratorSyntax) 157While node.Span.Length < span.Length AndAlso node.Parent.SpanStart = position 158node = node.Parent 159partnerStatement = partnerStatement?.Parent 168node = node.Parent 170partnerStatement = partnerStatement.Parent 178node.Parent.IsKind(SyntaxKind.VariableDeclarator) AndAlso 179DirectCast(node.Parent, VariableDeclaratorSyntax).Names.Count = 1 Then 180node = node.Parent 201node = node.Parent 240Return (DirectCast(declaration.Parent, PropertyBlockSyntax).PropertyStatement.ParameterList, 372Dim parent = statement.Parent 439AreEquivalentIgnoringLambdaBodies(DirectCast(oldStatement.Parent, VariableDeclaratorSyntax).AsClause, 440DirectCast(newStatement.Parent, VariableDeclaratorSyntax).AsClause) 464Return modifiedIdentifier.Parent.IsKind(SyntaxKind.VariableDeclarator) AndAlso 465DirectCast(modifiedIdentifier.Parent, VariableDeclaratorSyntax).Names.Count > 1 482Return node.Parent.FirstAncestorOrSelf(Of TypeBlockSyntax)() ' TODO: EnbumBlock? 488Debug.Assert(declaration.Parent.IsKind(SyntaxKind.VariableDeclarator) OrElse 489declaration.Parent.IsKind(SyntaxKind.Parameter)) 491If Not declaration.Parent.IsKind(SyntaxKind.VariableDeclarator) Then 495Dim declarator = DirectCast(declaration.Parent, VariableDeclaratorSyntax) 658Dim ctor = TryCast(symbol.DeclaringSyntaxReferences(0).GetSyntax(cancellationToken).Parent, ConstructorBlockSyntax) 961Return If(node.IsKind(SyntaxKind.ModifiedIdentifier), node.Parent.Parent.Parent, node.Parent.Parent) 1186Return TryGetDiagnosticSpanImpl(node.Parent, editKind) 1299Return TryGetDiagnosticSpanImpl(node.Parent, editKind) 1521Return TryGetDisplayNameImpl(node.Parent, editKind) 1678Return TryGetDisplayNameImpl(node.Parent, editKind) 1835If node.Parent.IsParentKind(SyntaxKind.AttributesStatement) Then 1871If oldNode.Parent.IsParentKind(SyntaxKind.AttributesStatement) Then 1893If newNode.Parent.IsParentKind(SyntaxKind.AttributesStatement) Then 1916edit.OldNode.Parent.IsKind(SyntaxKind.VariableDeclarator) Then 1918If HasEdit(editMap, edit.OldNode.Parent.Parent, EditKind.Delete) Then 1924edit.NewNode.Parent.IsKind(SyntaxKind.VariableDeclarator) Then 1926If HasEdit(editMap, edit.NewNode.Parent.Parent, EditKind.Insert) Then 2071Debug.Assert(node.Parent.Kind = SyntaxKind.TryBlock) 2072node = node.Parent 2085Debug.Assert(node.Parent IsNot Nothing) 2086node = node.Parent 2146Return DirectCast(node.Parent, TryBlockSyntax).Span 2192Select Case node.Parent.Kind() 2207node = node.Parent 2240Return awaitExpression.Parent.Parent Is containingStatementPart 2248Return awaitExpression.Parent.Parent Is containingStatementPart 2253Return awaitExpression.Parent.Parent.Parent Is containingStatementPart
EncapsulateField\VisualBasicEncapsulateFieldService.vb (1)
95Return TypeOf field.Parent Is TypeBlockSyntax
ExtractMethod\Extensions.vb (6)
35Return statement.Parent 43If node.Parent.IsStatementContainerNode() AndAlso 45node.Parent.ContainStatement(DirectCast(node, ExecutableStatementSyntax)) Then 49node = node.Parent 84node = node.Parent 464Return TypeOf node Is ExpressionSyntax AndAlso TypeOf node.Parent Is CastExpressionSyntax
ExtractMethod\VisualBasicMethodExtractor.VisualBasicCodeGenerator.CallSiteContainerRewriter.vb (3)
41Contract.ThrowIfFalse(Me._firstStatementOrFieldToReplace.Parent Is Me._lastStatementOrFieldToReplace.Parent) 58Return Me._firstStatementOrFieldToReplace.Parent
ExtractMethod\VisualBasicMethodExtractor.VisualBasicCodeGenerator.ExpressionCodeGenerator.vb (3)
43expression.Parent.IsParentKind(SyntaxKind.VariableDeclarator) Then 45Dim varDecl = DirectCast(expression.Parent.Parent, VariableDeclaratorSyntax)
ExtractMethod\VisualBasicSelectionResult.vb (6)
79current = current.Parent 105Return Me.GetFirstStatementUnderContainer().Parent 164Dim castExpression = TryCast(node.Parent, CastExpressionSyntax) 255If statement.Parent.ContainStatement(statement) Then 277Contract.ThrowIfFalse(lastStatement.Parent Is (GetFirstStatementUnderContainer()).Parent) 287containingScope.Parent _
ExtractMethod\VisualBasicSelectionValidator.vb (4)
432If statement1.Parent.IsStatementContainerNode() Then 433Dim contain1 = statement1.Parent.ContainStatement(statement1) 434Dim contain2 = statement2.Parent.ContainStatement(statement2) 437Dim parent = statement1.Parent _
GenerateMember\GenerateVariable\VisualBasicGenerateVariableService.vb (7)
40Dim implementsClause = DirectCast(qualifiedName.Parent, ImplementsClauseSyntax) 44Dim propertyBlock = TryCast(implementsClause.Parent, PropertyBlockSyntax) 46DirectCast(implementsClause.Parent, PropertyStatementSyntax), 76Dim memberAccess = TryCast(identifierName.Parent, MemberAccessExpressionSyntax) 83Dim conditionalMemberAccess = TryCast(identifierName.Parent.Parent, ConditionalAccessExpressionSyntax) 95Not simpleNameOrMemberAccessExpression.Parent.IsKind(SyntaxKind.NameOfExpression, SyntaxKind.NamedFieldInitializer) Then
GenerateType\VisualBasicGenerateTypeService.vb (54)
57expression.Parent.IsParentKind(SyntaxKind.TypeParameterMultipleConstraintClause) Then 59Dim typeConstraint = DirectCast(expression.Parent, TypeConstraintSyntax) 60Dim constraintClause = DirectCast(typeConstraint.Parent, TypeParameterMultipleConstraintClauseSyntax) 100nameOrMemberAccessExpression = DirectCast(simpleName.Parent, ExpressionSyntax) 110If TypeOf nameOrMemberAccessExpression.Parent Is BinaryExpressionSyntax Then 147simpleName.Parent Is token.Parent Then 155If nameOrMemberAccessExpression.Parent.IsKind(SyntaxKind.InvocationExpression) Then 163Dim parent = TryCast(simpleName.Parent, QualifiedNameSyntax) 195If simpleName.Parent IsNot Nothing AndAlso TypeOf simpleName.Parent IsNot QualifiedNameSyntax Then 205If nameOrMemberAccessExpression.Parent IsNot Nothing AndAlso TypeOf nameOrMemberAccessExpression.Parent Is QualifiedNameSyntax Then 229nameOrMemberAccessExpression.Parent.IsParentKind(SyntaxKind.Parameter) AndAlso 230nameOrMemberAccessExpression.Parent.Parent.IsParentKind(SyntaxKind.ParameterList) AndAlso 231(nameOrMemberAccessExpression.Parent.Parent.Parent.IsParentKind(SyntaxKind.AddHandlerAccessorStatement) OrElse 232nameOrMemberAccessExpression.Parent.Parent.Parent.IsParentKind(SyntaxKind.RemoveHandlerAccessorStatement)) Then 246If (nameOrMemberAccessExpression.IsKind(SyntaxKind.SimpleMemberAccessExpression) OrElse (nameOrMemberAccessExpression.Parent IsNot Nothing AndAlso nameOrMemberAccessExpression.IsParentKind(SyntaxKind.SimpleMemberAccessExpression))) _ 253outerMostMemberAccessExpression = DirectCast(nameOrMemberAccessExpression.Parent, ExpressionSyntax) 265If TypeOf nameOrMemberAccessExpression.Parent Is ObjectCreationExpressionSyntax Then 266Dim objectCreationExpressionOpt = DirectCast(nameOrMemberAccessExpression.Parent, ObjectCreationExpressionSyntax) 314nameOrMemberAccessExpression.Parent.IsParentKind(SyntaxKind.VariableDeclarator) Then 315variableDeclarator = DirectCast(nameOrMemberAccessExpression.Parent.Parent, VariableDeclaratorSyntax) 337ElseIf TypeOf nameOrMemberAccessExpression.Parent Is CastExpressionSyntax Then 341Dim expressionToBeCasted = DirectCast(nameOrMemberAccessExpression.Parent, CastExpressionSyntax).Expression 433DirectCast(enclosingNamespace.Parent, NamespaceBlockSyntax).EndNamespaceStatement.GetLocation()) 536If TypeOf expression.Parent Is InheritsStatementSyntax Then 537If expression.Parent.Parent IsNot Nothing AndAlso TypeOf expression.Parent.Parent Is InterfaceBlockSyntax Then 544ElseIf TypeOf expression.Parent Is ImplementsStatementSyntax Then 561node.Parent IsNot Nothing AndAlso 562TypeOf node.Parent Is TypeBlockSyntax Then 564Return IsAllContainingTypeBlocksPublic(node.Parent) 568node.Parent IsNot Nothing AndAlso TypeOf node.Parent Is TypeStatementSyntax AndAlso 569node.Parent.Parent IsNot Nothing AndAlso TypeOf node.Parent.Parent Is TypeBlockSyntax Then 570Return IsAllContainingTypeBlocksPublic(node.Parent.Parent) 574node.Parent IsNot Nothing AndAlso TypeOf node.Parent Is TypeBlockSyntax Then 579node.Parent IsNot Nothing AndAlso TypeOf node.Parent Is TypeBlockSyntax Then 583node = node.Parent 676Dim fieldInitializer = TryCast(propIdentifierName.Parent, NamedFieldInitializerSyntax)
GoToDefinition\VisualBasicGoToDefinitionSymbolService.vb (6)
109node = node.Parent 121node = node.Parent 133node = node.Parent 145node = node.Parent 157node = node.Parent 169node = node.Parent
IntroduceParameter\VisualBasicIntroduceParameterCodeRefactoringProvider.vb (1)
27Return TryCast(variableDecl.Parent, LocalDeclarationStatementSyntax)
IntroduceVariable\VisualBasicIntroduceVariableService.Rewriter.vb (1)
74TypeOf node.Parent Is TupleExpressionSyntax Then
IntroduceVariable\VisualBasicIntroduceVariableService.vb (2)
73If TypeOf expression.Parent Is CallStatementSyntax Then 82expression.Parent.IsParentKind(SyntaxKind.VariableDeclarator) Then
IntroduceVariable\VisualBasicIntroduceVariableService_IntroduceLocal.vb (3)
103Dim parent = TryCast(current.Parent, SingleLineLambdaExpressionSyntax) 110current = TryCast(current.Parent, ExpressionSyntax) 130oldOutermostBlock = oldOutermostBlock.Parent
InvertIf\VisualBasicInvertIfCodeRefactoringProvider.SingleLine.vb (1)
26Return TypeOf ifNode.Parent IsNot SingleLineLambdaExpressionSyntax AndAlso
InvertIf\VisualBasicInvertIfCodeRefactoringProvider.vb (1)
64Dim parent = node.Parent
LineSeparators\VisualBasicLineSeparatorService.vb (1)
138If lastChild.Parent.Kind() = SyntaxKind.CompilationUnit Then
QuickInfo\VisualBasicSemanticQuickInfoProvider.vb (3)
133found = token.Parent.Parent 143token.Parent?.Parent.IsKind(SyntaxKind.InvocationExpression) = True Then 144found = token.Parent.Parent
RemoveUnusedVariable\VisualBasicRemoveUnusedVariableCodeFixProvider.vb (1)
37node = node.Parent
ReplaceMethodWithProperty\VisualBasicReplaceMethodWithPropertyService.vb (7)
58Return DirectCast(declaration.Parent, DeclarationStatementSyntax) 150Dim parentExpression = If(nameNode.IsRightSideOfDot(), DirectCast(nameNode.Parent, ExpressionSyntax), nameNode) 151Dim root = If(parentExpression.IsParentKind(SyntaxKind.InvocationExpression), parentExpression.Parent, parentExpression) 179Dim parentExpression = If(nameNode.IsRightSideOfDot(), DirectCast(nameNode.Parent, ExpressionSyntax), nameNode) 181Not parentExpression.Parent.IsParentKind(SyntaxKind.ExpressionStatement) Then 190parentExpression.Parent.Parent,
ReplacePropertyWithMethods\VisualBasicReplacePropertyWithMethods.vb (8)
93If TypeOf getAccessorDeclaration?.Parent Is AccessorBlockSyntax Then 94Dim block = DirectCast(getAccessorDeclaration.Parent, AccessorBlockSyntax) 126If TypeOf setAccessorDeclaration?.Parent Is AccessorBlockSyntax Then 127Dim block = DirectCast(setAccessorDeclaration.Parent, AccessorBlockSyntax) 214propertyDeclaration.Parent, 219Dim simpleNameCref = TryCast(identifierName.Parent, CrefReferenceSyntax) 224Dim qualifiedName = TryCast(identifierName.Parent, QualifiedNameSyntax) 229Return TryCast(qualifiedName.Parent, CrefReferenceSyntax)
SignatureHelp\AttributeSignatureHelpProvider.vb (1)
45TypeOf token.Parent.Parent Is AttributeSyntax
SignatureHelp\CollectionInitializerSignatureHelpProvider.vb (1)
56document, collectionInitializer.Parent, options, cancellationToken).ConfigureAwait(False)
SignatureHelp\GenericNameSignatureHelpProvider.vb (1)
55TypeOf token.Parent.Parent Is GenericNameSyntax
SignatureHelp\InvocationExpressionSignatureHelpProvider.vb (3)
56TypeOf token.Parent.Parent Is InvocationExpressionSyntax 79Dim targetExpression = If(invocationExpression.Expression Is Nothing AndAlso invocationExpression.Parent.IsKind(SyntaxKind.ConditionalAccessExpression), 80DirectCast(invocationExpression.Parent, ConditionalAccessExpressionSyntax).Expression,
SignatureHelp\MidAssignmentSignatureHelpProvider.vb (1)
30token.Parent.Parent.IsParentKind(SyntaxKind.MidAssignmentStatement)
SignatureHelp\ObjectCreationExpressionSignatureHelpProvider.vb (1)
55TypeOf token.Parent.Parent Is ObjectCreationExpressionSyntax
SignatureHelp\RaiseEventStatementSignatureHelpProvider.vb (1)
54TypeOf token.Parent.Parent Is RaiseEventStatementSyntax
SplitOrMergeIfStatements\VisualBasicIfLikeStatementGenerator.vb (17)
28If TypeOf expression.Parent Is IfStatementSyntax AndAlso 29DirectCast(expression.Parent, IfStatementSyntax).Condition Is expression AndAlso 30TypeOf expression.Parent.Parent Is MultiLineIfBlockSyntax Then 31ifOrElseIf = expression.Parent.Parent 35If TypeOf expression.Parent Is ElseIfStatementSyntax AndAlso 36DirectCast(expression.Parent, ElseIfStatementSyntax).Condition Is expression AndAlso 37TypeOf expression.Parent.Parent Is ElseIfBlockSyntax Then 38ifOrElseIf = expression.Parent.Parent 48Dim ifBlock = DirectCast(node.Parent, MultiLineIfBlockSyntax) 66ifBlock = DirectCast(ifOrElseIf.Parent, MultiLineIfBlockSyntax) 91Return ifOrElseIf.Parent 103Dim ifBlock = DirectCast(elseIfBlock.Parent, MultiLineIfBlockSyntax) 146Dim ifBlock = DirectCast(elseIfBlock.Parent, MultiLineIfBlockSyntax)
SplitOrMergeIfStatements\VisualBasicMergeConsecutiveIfStatementsCodeRefactoringProvider.vb (4)
23If TypeOf node Is IfStatementSyntax AndAlso TypeOf node.Parent Is MultiLineIfBlockSyntax Then 32ifOrElseIf = node.Parent 46If TypeOf node Is ElseIfStatementSyntax AndAlso TypeOf node.Parent Is ElseIfBlockSyntax Then 54ifOrElseIf = node.Parent
SplitOrMergeIfStatements\VisualBasicMergeNestedIfStatementsCodeRefactoringProvider.vb (4)
23If TypeOf node Is IfStatementSyntax And TypeOf node.Parent Is MultiLineIfBlockSyntax Then 32ifOrElseIf = node.Parent 54If TypeOf node Is ElseIfStatementSyntax AndAlso TypeOf node.Parent Is ElseIfBlockSyntax Then 62ifOrElseIf = node.Parent
src\Analyzers\VisualBasic\Analyzers\AddRequiredParentheses\VisualBasicAddRequiredParenthesesDiagnosticAnalyzer.vb (1)
60Return TryCast(binary.Parent, ExpressionSyntax)
src\Analyzers\VisualBasic\Analyzers\ConvertTypeofToNameof\VisualBasicConvertTypeOfToNameOfDiagnosticAnalyzer.vb (1)
26Dim isParentValid = node.Parent.GetType() Is GetType(MemberAccessExpressionSyntax)
src\Analyzers\VisualBasic\Analyzers\RemoveUnnecessaryImports\VisualBasicRemoveUnnecessaryImportsDiagnosticAnalyzer.vb (2)
41If Not result.Contains(clause.Parent) Then 42Dim statement = DirectCast(clause.Parent, ImportsStatementSyntax)
src\Analyzers\VisualBasic\Analyzers\RemoveUnnecessaryParentheses\VisualBasicRemoveUnnecessaryParenthesesDiagnosticAnalyzer.vb (1)
51Dim parentBinary = TryCast(parenthesizedExpression.Parent, BinaryExpressionSyntax)
src\Analyzers\VisualBasic\Analyzers\RemoveUnusedMembers\VisualBasicRemoveUnusedMembersDiagnosticAnalyzer.vb (3)
58Select(Function(n) If(TryCast(n, TypeStatementSyntax)?.Parent, n)). 68Dim declarator = TryCast(modifiedIdentifier?.Parent, VariableDeclaratorSyntax) 69Dim field = TryCast(declarator?.Parent, FieldDeclarationSyntax)
src\Analyzers\VisualBasic\Analyzers\RemoveUnusedParametersAndValues\VisualBasicRemoveUnusedParametersAndValuesDiagnosticAnalyzer.vb (1)
56Dim methodSyntax = TryCast(node.Parent, MethodBlockBaseSyntax)
src\Analyzers\VisualBasic\Analyzers\UseAutoProperty\Utilities.vb (2)
10Dim declarator = DirectCast(identifier.Parent, VariableDeclaratorSyntax) 18Dim field = DirectCast(declarator.Parent, FieldDeclarationSyntax)
src\Analyzers\VisualBasic\Analyzers\UseAutoProperty\VisualBasicUseAutoPropertyAnalyzer.vb (3)
79Dim declarator = TryCast(variable.Parent, VariableDeclaratorSyntax) 105Dim accessor = TryCast(TryCast(getMethod.DeclaringSyntaxReferences(0).GetSyntax(cancellationToken), AccessorStatementSyntax)?.Parent, AccessorBlockSyntax) 128Dim setAccessor = TryCast(TryCast(setMethod.DeclaringSyntaxReferences(0).GetSyntax(cancellationToken), AccessorStatementSyntax)?.Parent, AccessorBlockSyntax)
src\Analyzers\VisualBasic\Analyzers\UseInferredMemberName\VisualBasicUseInferredMemberNameDiagnosticAnalyzer.vb (3)
45Dim argument = DirectCast(nameColonEquals.Parent, SimpleArgumentSyntax) 66If Not fieldInitializer.Parent.Parent.IsKind(SyntaxKind.AnonymousObjectCreationExpression) Then
src\Analyzers\VisualBasic\CodeFixes\AddExplicitCast\ArgumentFixer.vb (1)
37Dim parent = newArgumentList.Parent
src\Analyzers\VisualBasic\CodeFixes\AddExplicitCast\VisualBasicAddExplicitCastCodeFixProvider.vb (1)
71Dim invocationNode = argumentList.Parent
src\Analyzers\VisualBasic\CodeFixes\GenerateConstructor\VisualBasicGenerateConstructorService.vb (12)
52TryCast(node.Parent, MemberAccessExpressionSyntax).IsConstructorInitializer() AndAlso 53node.Parent.Parent.Kind = SyntaxKind.InvocationExpression 64Dim memberAccess = DirectCast(simpleName.Parent, MemberAccessExpressionSyntax) 65Dim invocation = DirectCast(memberAccess.Parent, InvocationExpressionSyntax) 100Dim name = If(simpleName.IsRightSideOfQualifiedName(), DirectCast(simpleName.Parent, NameSyntax), simpleName) 102If TypeOf name.Parent Is ObjectCreationExpressionSyntax Then 103Dim objectCreationExpression = DirectCast(name.Parent, ObjectCreationExpressionSyntax) 135Dim name = If(simpleName.IsRightSideOfQualifiedName(), DirectCast(simpleName.Parent, NameSyntax), simpleName) 137If TypeOf name.Parent Is AttributeSyntax Then 138Dim attribute = DirectCast(name.Parent, AttributeSyntax) 174Dim constructorStatements = constructor.DeclaringSyntaxReferences(0).GetSyntax(cancellationToken).Parent.GetStatements()
src\Analyzers\VisualBasic\CodeFixes\GenerateDefaultConstructors\VisualBasicGenerateDefaultConstructorsService.vb (1)
48classType = TryCast(semanticDocument.SemanticModel.GetDeclaredSymbol(baseList.Parent, cancellationToken), INamedTypeSymbol)
src\Analyzers\VisualBasic\CodeFixes\GenerateEnumMember\VisualBasicGenerateEnumMemberService.vb (2)
31Dim memberAccess = TryCast(identifierName.Parent, MemberAccessExpressionSyntax) 38Dim invocation = DirectCast(simpleNameOrMemberAccessExpression.Parent, InvocationExpressionSyntax)
src\Analyzers\VisualBasic\CodeFixes\GenerateParameterizedMember\VisualBasicGenerateMethodService.vb (10)
51Dim implementsClause = DirectCast(qualifiedName.Parent, ImplementsClauseSyntax) 56Dim methodStatement = DirectCast(implementsClause.Parent, MethodStatementSyntax) 84Dim memberAccess = TryCast(simpleName?.Parent, MemberAccessExpressionSyntax) 85Dim conditionalMemberAccessInvocationExpression = TryCast(simpleName?.Parent?.Parent?.Parent, ConditionalAccessExpressionSyntax) 86Dim conditionalMemberAccessSimpleMemberAccess = TryCast(simpleName?.Parent?.Parent, ConditionalAccessExpressionSyntax) 116invocationExpressionOpt = DirectCast(simpleNameOrMemberAccessExpression.Parent, InvocationExpressionSyntax) 126ElseIf simpleNameOrMemberAccessExpression?.Parent?.IsKind(SyntaxKind.AddressOfExpression, SyntaxKind.NameOfExpression) Then
src\Analyzers\VisualBasic\CodeFixes\ImplementInterface\VisualBasicImplementInterfaceCodeFixProvider.vb (1)
28Return TypeOf type.Parent Is ImplementsStatementSyntax
src\Analyzers\VisualBasic\CodeFixes\ImplementInterface\VisualBasicImplementInterfaceService.vb (3)
55ElseIf TypeOf node Is TypeSyntax AndAlso TypeOf node.Parent Is ImplementsStatementSyntax Then 57implementsStatement = DirectCast(node.Parent, ImplementsStatementSyntax) 76classOrStructDecl = implementsStatement.Parent
src\Analyzers\VisualBasic\CodeFixes\Iterator\VisualBasicConvertToIteratorCodeFixProvider.vb (1)
52If identifier.Parent.Kind <> SyntaxKind.InvocationExpression Then
src\Analyzers\VisualBasic\CodeFixes\MakeFieldReadonly\VisualBasicMakeFieldReadonlyCodeFixProvider.vb (2)
27Dim initializer = CType(declaration.Parent, VariableDeclaratorSyntax).Initializer?.Value 29initializer = TryCast(CType(declaration.Parent, VariableDeclaratorSyntax).AsClause, AsNewClauseSyntax)?.NewExpression
src\Analyzers\VisualBasic\CodeFixes\MakeTypeAbstract\VisualBasicMakeTypeAbstractCodeFixProvider.vb (1)
36typeDeclaration = TryCast(classStatement.Parent, ClassBlockSyntax)
src\Analyzers\VisualBasic\CodeFixes\RemoveUnusedParametersAndValues\VisualBasicRemoveUnusedValuesCodeFixProvider.vb (1)
75Return TryCast(declarator.Parent, LocalDeclarationStatementSyntax)
src\Analyzers\VisualBasic\CodeFixes\UseConditionalExpression\VisualBasicUseConditionalExpressionForAssignmentCodeFixProvider.vb (1)
47Return DirectCast(declarator.Syntax.Parent, VariableDeclaratorSyntax)
src\Compilers\VisualBasic\Portable\Syntax\LambdaUtilities.vb (23)
51Dim lambda = lambdaBody.Parent 90Dim newJoinClause = DirectCast(newJoinCondition.Parent, JoinClauseSyntax) 115Dim parent = node?.Parent 147Dim clause = parent.Parent 176Dim parentClause = clause.Parent 178clause = clause.Parent 191Dim parentClause = parent.Parent 206Dim joinClause = DirectCast(parent.Parent, JoinClauseSyntax) 269Dim clause = rangeVariable.Parent 334Dim firstCondition = DirectCast(node.Parent, JoinClauseSyntax).JoinConditions.First 382Dim clause = lambda.Parent 403Dim clause = lambda.Parent 423Dim joinClause = DirectCast(lambda.Parent, JoinClauseSyntax) 538Dim clause = expressionRangeVariable.Parent 560Dim clause = collectionRangeVariable.Parent 581Return clause.Parent.IsKind(SyntaxKind.QueryExpression) AndAlso 582clause Is DirectCast(clause.Parent, QueryExpressionSyntax).Clauses.First 604Return joinCondition Is DirectCast(joinCondition.Parent, JoinClauseSyntax).JoinConditions.First 701If node.Parent?.Parent IsNot Nothing AndAlso 702node.Parent.Parent.Parent Is Nothing Then
Structure\Providers\AccessorDeclarationStructureProvider.vb (1)
22Dim block = TryCast(accessorDeclaration.Parent, AccessorBlockSyntax)
Structure\Providers\CollectionInitializerStructureProvider.vb (1)
24If TypeOf node.Parent IsNot ObjectCollectionInitializerSyntax Then
Structure\Providers\ConstructorDeclarationStructureProvider.vb (1)
23Dim block = TryCast(constructorDeclaration.Parent, ConstructorBlockSyntax)
Structure\Providers\EnumDeclarationStructureProvider.vb (1)
22Dim block = TryCast(enumDeclaration.Parent, EnumBlockSyntax)
Structure\Providers\EventDeclarationStructureProvider.vb (1)
22Dim block = TryCast(eventDeclaration.Parent, EventBlockSyntax)
Structure\Providers\MethodDeclarationStructureProvider.vb (1)
22Dim block = TryCast(methodDeclaration.Parent, MethodBlockSyntax)
Structure\Providers\NamespaceDeclarationStructureProvider.vb (1)
22Dim block = TryCast(namespaceDeclaration.Parent, NamespaceBlockSyntax)
Structure\Providers\ObjectCreationInitializerStructureProvider.vb (1)
35hintSpan:=node.Parent.Span,
Structure\Providers\OperatorDeclarationStructureProvider.vb (1)
22Dim block = TryCast(operatorDeclaration.Parent, OperatorBlockSyntax)
Structure\Providers\PropertyDeclarationStructureProvider.vb (1)
22Dim block = TryCast(propertyDeclaration.Parent, PropertyBlockSyntax)
Structure\Providers\TypeDeclarationStructureProvider.vb (1)
22Dim block = TryCast(typeDeclaration.Parent, TypeBlockSyntax)
Structure\VisualBasicStructureHelpers.vb (1)
216Dim attributeOwner = firstToken.Parent.Parent
UseAutoProperty\VisualBasicUseAutoPropertyCodeFixProvider.vb (2)
28node = node.Parent 96Dim declarator = TryCast(identifier?.Parent, VariableDeclaratorSyntax)
UseNamedArguments\VisualBasicUseNamedArgumentsCodeRefactoringProvider.vb (3)
30If argument.Parent.IsParentKind(SyntaxKind.Attribute) Then 34Return argument.Parent.Parent
Wrapping\SeparatedSyntaxList\VisualBasicArgumentWrapper.vb (1)
83current = current.Parent
Microsoft.CodeAnalysis.VisualBasic.Features.UnitTests (1)
EditAndContinue\VisualBasicEditAndContinueAnalyzerTests.vb (1)
42node = node.Parent
Microsoft.CodeAnalysis.VisualBasic.Semantic.UnitTests (164)
Compilation\GetImportScopesTests.vb (1)
54TypeOf syntax.Parent Is SimpleImportsClauseSyntax AndAlso
Compilation\SemanticModelAPITests.vb (1)
2744Dim expr = DirectCast(node.Parent, BinaryExpressionSyntax)
Compilation\SemanticModelGetDeclaredSymbolAPITests.vb (10)
1772Assert.Equal(i1Symbol, model.GetDeclaredSymbol(DirectCast(i1Syntax.Parent, TypeBlockSyntax))) 1773Assert.Equal(i2Symbol, model.GetDeclaredSymbol(DirectCast(i2Syntax.Parent, TypeBlockSyntax))) 1774Assert.Equal(c1Symbol, model.GetDeclaredSymbol(DirectCast(c1Syntax.Parent, TypeBlockSyntax))) 1775Assert.Equal(c2Symbol, model.GetDeclaredSymbol(DirectCast(c2Syntax.Parent, TypeBlockSyntax))) 1776Assert.Equal(e2Symbol, model.GetDeclaredSymbol(DirectCast(e2Syntax.Parent, EnumBlockSyntax))) 1777Assert.Equal(nsSymbol, model.GetDeclaredSymbol(DirectCast(nsSyntax.Parent, NamespaceBlockSyntax))) 2429Assert.Equal("NS.", node.Parent.ToString().Trim()) 2437Assert.Equal("Dummy.", node.Parent.ToString().Trim()) 2443Assert.Equal("F.", node.Parent.ToString().Trim()) 2449Assert.Equal("P.", node.Parent.ToString().Trim())
FlowAnalysis\FlowTestBase.vb (6)
113Where s.Parent Is e.Parent AndAlso TypeOf s Is ExecutableStatementSyntax AndAlso TypeOf e Is ExecutableStatementSyntax 127Where s.Parent Is e.Parent AndAlso TypeOf s Is ExecutableStatementSyntax AndAlso TypeOf e Is ExecutableStatementSyntax 184startNode = startNode.Parent 202endNode = endNode.Parent
FlowAnalysis\RegionAnalysisTests.vb (1)
5194Dim stmtSyntaxNode = DirectCast(selectSyntaxNode.Parent, SelectBlockSyntax).CaseBlocks(0).CaseStatement
Semantics\CompoundAssignment.vb (3)
1023midExpression = DirectCast(node1.Parent.Parent.Parent, MidExpressionSyntax)
Semantics\ConditionalAccessTests.vb (11)
654Dim member = DirectCast(node1.Parent, MemberAccessExpressionSyntax) 666Dim conditional = DirectCast(member.Parent, ConditionalAccessExpressionSyntax) 1334Dim conditional = DirectCast(node1.Parent, ConditionalAccessExpressionSyntax) 1369Dim conditional = DirectCast(node2.Parent, ConditionalAccessExpressionSyntax) 1403Dim conditional = DirectCast(node3.Parent, ConditionalAccessExpressionSyntax) 1501Dim member = DirectCast(node1.Parent, XmlMemberAccessExpressionSyntax) 1512Dim conditional = DirectCast(member.Parent, ConditionalAccessExpressionSyntax) 1544Dim member = DirectCast(node2.Parent, XmlMemberAccessExpressionSyntax) 1555Dim conditional = DirectCast(member.Parent, ConditionalAccessExpressionSyntax) 1587Dim member = DirectCast(node3.Parent, XmlMemberAccessExpressionSyntax) 1598Dim conditional = DirectCast(member.Parent, ConditionalAccessExpressionSyntax)
Semantics\GetSemanticInfoTests.vb (2)
5643Dim directCastExpr = DirectCast(parenthesizedExpr.Parent, DirectCastExpressionSyntax) 5680Dim tryCastExpr = DirectCast(parenthesizedExpr.Parent, TryCastExpressionSyntax)
Semantics\Lambda_AnonymousDelegateInference.vb (6)
441Dim typeInfo As TypeInfo = semanticModel.GetTypeInfo(DirectCast(node1.Parent, LambdaExpressionSyntax)) 446Dim conv = semanticModel.GetConversion(node1.Parent) 453Dim typeInfo As TypeInfo = semanticModel.GetTypeInfo(DirectCast(node2.Parent, LambdaExpressionSyntax)) 458Dim conv = semanticModel.GetConversion(node2.Parent) 465Dim typeInfo As TypeInfo = semanticModel.GetTypeInfo(DirectCast(node3.Parent, LambdaExpressionSyntax)) 470Dim conv = semanticModel.GetConversion(node3.Parent)
Semantics\Lambda_Relaxation.vb (66)
42Dim typeInfo As TypeInfo = semanticModel.GetTypeInfo(DirectCast(node1.Parent, LambdaExpressionSyntax)) 47Dim conv = semanticModel.GetConversion(node1.Parent) 158Dim typeInfo As TypeInfo = semanticModel.GetTypeInfo(DirectCast(node1.Parent, LambdaExpressionSyntax)) 163Dim conv = semanticModel.GetConversion(node1.Parent) 256Dim typeInfo As TypeInfo = semanticModel.GetTypeInfo(DirectCast(node1.Parent, LambdaExpressionSyntax)) 261Dim conv = semanticModel.GetConversion(node1.Parent) 354Dim typeInfo As TypeInfo = semanticModel.GetTypeInfo(DirectCast(node1.Parent, LambdaExpressionSyntax)) 359Dim conv = semanticModel.GetConversion(node1.Parent) 449Dim typeInfo As TypeInfo = semanticModel.GetTypeInfo(DirectCast(node1.Parent, LambdaExpressionSyntax)) 454Dim conv = semanticModel.GetConversion(node1.Parent) 855Dim typeInfo As TypeInfo = semanticModel.GetTypeInfo(DirectCast(node1.Parent, LambdaExpressionSyntax)) 860Dim conv = semanticModel.GetConversion(node1.Parent) 930Dim typeInfo As TypeInfo = semanticModel.GetTypeInfo(DirectCast(node1.Parent, LambdaExpressionSyntax)) 934Dim conv = semanticModel.GetConversion(node1.Parent) 975Dim typeInfo As TypeInfo = semanticModel.GetTypeInfo(DirectCast(node1.Parent, LambdaExpressionSyntax)) 980Dim conv = semanticModel.GetConversion(node1.Parent) 1030Dim typeInfo As TypeInfo = semanticModel.GetTypeInfo(DirectCast(node1.Parent, LambdaExpressionSyntax)) 1035Dim conv = semanticModel.GetConversion(node1.Parent) 1043Dim typeInfo = semanticModel.GetTypeInfo(DirectCast(node2.Parent, LambdaExpressionSyntax)) 1048Dim conv = semanticModel.GetConversion(node2.Parent) 1185Dim typeInfo As TypeInfo = semanticModel.GetTypeInfo(DirectCast(node1.Parent, LambdaExpressionSyntax)) 1190Dim conv = semanticModel.GetConversion(node1.Parent) 1197Dim typeInfo = semanticModel.GetTypeInfo(DirectCast(node2.Parent, LambdaExpressionSyntax)) 1202Dim conv = semanticModel.GetConversion(node2.Parent) 1247Dim typeInfo As TypeInfo = semanticModel.GetTypeInfo(DirectCast(node1.Parent, LambdaExpressionSyntax)) 1252Dim conv = semanticModel.GetConversion(node1.Parent) 1298Dim typeInfo As TypeInfo = semanticModel.GetTypeInfo(DirectCast(node1.Parent, LambdaExpressionSyntax)) 1303Dim conv = semanticModel.GetConversion(node1.Parent) 1310Dim typeInfo As TypeInfo = semanticModel.GetTypeInfo(DirectCast(node2.Parent, LambdaExpressionSyntax)) 1315Dim conv = semanticModel.GetConversion(node2.Parent) 1411Dim typeInfo As TypeInfo = semanticModel.GetTypeInfo(DirectCast(node1.Parent, LambdaExpressionSyntax)) 1416Dim conv = semanticModel.GetConversion(node1.Parent) 1423Dim typeInfo As TypeInfo = semanticModel.GetTypeInfo(DirectCast(node2.Parent, LambdaExpressionSyntax)) 1428Dim conv = semanticModel.GetConversion(node2.Parent) 1456Dim typeInfo As TypeInfo = semanticModel.GetTypeInfo(DirectCast(node1.Parent, LambdaExpressionSyntax)) 1461Dim conv = semanticModel.GetConversion(node1.Parent) 1468Dim typeInfo As TypeInfo = semanticModel.GetTypeInfo(DirectCast(node2.Parent, LambdaExpressionSyntax)) 1473Dim conv = semanticModel.GetConversion(node2.Parent) 1522Dim typeInfo As TypeInfo = semanticModel.GetTypeInfo(DirectCast(node1.Parent, LambdaExpressionSyntax)) 1527Dim conv = semanticModel.GetConversion(node1.Parent) 1621Dim typeInfo As TypeInfo = semanticModel.GetTypeInfo(DirectCast(node1.Parent, LambdaExpressionSyntax)) 1626Dim conv = semanticModel.GetConversion(node1.Parent) 1698Dim typeInfo As TypeInfo = semanticModel.GetTypeInfo(DirectCast(node1.Parent, LambdaExpressionSyntax)) 1703Dim conv = semanticModel.GetConversion(node1.Parent) 1752Dim typeInfo As TypeInfo = semanticModel.GetTypeInfo(DirectCast(node1.Parent, LambdaExpressionSyntax)) 1757Dim conv = semanticModel.GetConversion(node1.Parent) 1764Dim typeInfo As TypeInfo = semanticModel.GetTypeInfo(DirectCast(node2.Parent, LambdaExpressionSyntax)) 1769Dim conv = semanticModel.GetConversion(node2.Parent) 1912Dim typeInfo As TypeInfo = semanticModel.GetTypeInfo(DirectCast(node1.Parent, LambdaExpressionSyntax)) 1917Dim conv = semanticModel.GetConversion(node1.Parent) 1924Dim typeInfo As TypeInfo = semanticModel.GetTypeInfo(DirectCast(node2.Parent, LambdaExpressionSyntax)) 1929Dim conv = semanticModel.GetConversion(node2.Parent) 1936Dim typeInfo As TypeInfo = semanticModel.GetTypeInfo(DirectCast(node3.Parent, LambdaExpressionSyntax)) 1941Dim conv = semanticModel.GetConversion(node3.Parent) 1948Dim typeInfo As TypeInfo = semanticModel.GetTypeInfo(DirectCast(node4.Parent, LambdaExpressionSyntax)) 1953Dim conv = semanticModel.GetConversion(node4.Parent) 2004Dim typeInfo As TypeInfo = semanticModel.GetTypeInfo(DirectCast(node1.Parent, LambdaExpressionSyntax)) 2009Dim conv = semanticModel.GetConversion(node1.Parent) 2057Dim typeInfo As TypeInfo = semanticModel.GetTypeInfo(DirectCast(node1.Parent, LambdaExpressionSyntax)) 2062Dim conv = semanticModel.GetConversion(node1.Parent) 2149Dim typeInfo As TypeInfo = semanticModel.GetTypeInfo(DirectCast(node1.Parent, LambdaExpressionSyntax)) 2154Dim conv = semanticModel.GetConversion(node1.Parent) 2177Dim typeInfo As TypeInfo = semanticModel.GetTypeInfo(DirectCast(node1.Parent, LambdaExpressionSyntax)) 2182Dim conv = semanticModel.GetConversion(node1.Parent) 2232Dim typeInfo As TypeInfo = semanticModel.GetTypeInfo(DirectCast(node1.Parent, LambdaExpressionSyntax)) 2237Dim conv = semanticModel.GetConversion(node1.Parent)
Semantics\LambdaSemanticInfoTests.vb (4)
181semanticInfo = CompilationUtils.GetSemanticInfoSummary(semanticModel, DirectCast(node.Parent.Parent, ExpressionSyntax)) 543Assert.Same(e, semanticModel.GetDeclaredSymbol(node1.Parent)) 544Assert.Same(e, semanticModel.GetDeclaredSymbol(DirectCast(node1.Parent, ParameterSyntax)))
Semantics\MultiDimensionalTest.vb (1)
335Dim node = DirectCast(GetSyntaxNode(Of VariableDeclaratorSyntax)(compilation, SyntaxKind.VariableDeclarator, index).Parent, StatementSyntax)
Semantics\Parenthesized.vb (2)
245Dim typeInfo As TypeInfo = semanticModel.GetTypeInfo(DirectCast(node1.Parent, LambdaExpressionSyntax)) 250Dim conv = semanticModel.GetConversion(node1.Parent)
Semantics\QueryExpressions_SemanticModel.vb (50)
125Assert.Same(s6, semanticModel1.GetDeclaredSymbol(DirectCast(node6.Parent, CollectionRangeVariableSyntax))) 126Assert.Same(s6, semanticModel1.GetDeclaredSymbol(node6.Parent)) 1423Dim orderBy = DirectCast(node1.Parent.Parent, OrderByClauseSyntax) 1661Dim x1 = DirectCast(semanticModel.GetDeclaredSymbol(node1.Parent), RangeVariableSymbol) 1665Assert.Same(x1, semanticModel.GetDeclaredSymbol(DirectCast(node1.Parent, ExpressionRangeVariableSyntax).NameEquals.Identifier)) 1690Dim w1 = DirectCast(semanticModel.GetDeclaredSymbol(node4.Parent), RangeVariableSymbol) 1694Assert.Same(w1, semanticModel.GetDeclaredSymbol(DirectCast(node4.Parent, ExpressionRangeVariableSyntax).NameEquals.Identifier)) 2117Dim x1 = DirectCast(semanticModel.GetDeclaredSymbol(node1.Parent), RangeVariableSymbol) 2121Assert.Same(x1, semanticModel.GetDeclaredSymbol(DirectCast(node1.Parent, CollectionRangeVariableSyntax).Identifier)) 2139Dim w1 = DirectCast(semanticModel.GetDeclaredSymbol(node4.Parent), RangeVariableSymbol) 2143Assert.Same(w1, semanticModel.GetDeclaredSymbol(DirectCast(node4.Parent, CollectionRangeVariableSyntax).Identifier)) 2683Dim i1 = DirectCast(semanticModel.GetDeclaredSymbol(node1.Parent.Parent), RangeVariableSymbol) 2687Assert.Same(i1, semanticModel.GetDeclaredSymbol(DirectCast(node1.Parent.Parent, ExpressionRangeVariableSyntax).NameEquals.Identifier)) 2688Assert.Same(i1, semanticModel.GetDeclaredSymbol(DirectCast(DirectCast(node1.Parent.Parent, ExpressionRangeVariableSyntax).NameEquals.Identifier, VisualBasicSyntaxNode))) 2697Dim x2 = DirectCast(semanticModel.GetDeclaredSymbol(node2.Parent), RangeVariableSymbol) 2702Dim symbolInfo = semanticModel.GetSymbolInfo(DirectCast(node2.Parent, ExpressionRangeVariableSyntax)) 2709Dim x3 = semanticModel.GetDeclaredSymbol(node3.Parent) 2734Dim k1 = DirectCast(semanticModel.GetDeclaredSymbol(node4.Parent.Parent), RangeVariableSymbol) 2738Assert.Same(k1, semanticModel.GetDeclaredSymbol(DirectCast(node4.Parent.Parent, ExpressionRangeVariableSyntax).NameEquals.Identifier)) 2739Assert.Same(k1, semanticModel.GetDeclaredSymbol(DirectCast(DirectCast(node4.Parent.Parent, ExpressionRangeVariableSyntax).NameEquals.Identifier, VisualBasicSyntaxNode))) 2748Dim w2 = DirectCast(semanticModel.GetDeclaredSymbol(node5.Parent), RangeVariableSymbol) 2753symbolInfo = semanticModel.GetSymbolInfo(DirectCast(node5.Parent, ExpressionRangeVariableSyntax)) 2760Dim w3 = semanticModel.GetDeclaredSymbol(node6.Parent) 2791Dim k2 = DirectCast(semanticModel.GetDeclaredSymbol(node8.Parent.Parent), RangeVariableSymbol) 2794Assert.Same(k2, semanticModel.GetDeclaredSymbol(DirectCast(node8.Parent.Parent, AggregationRangeVariableSyntax))) 2923Assert.Same(x4, semanticModel.GetDeclaredSymbol(DirectCast(node8.Parent.Parent, AggregationRangeVariableSyntax))) 2924Assert.Same(x4, semanticModel.GetDeclaredSymbol(node8.Parent.Parent)) 3302Assert.Same(s1, semanticModel.GetDeclaredSymbol(node1.Parent)) 3303Assert.Same(s1, semanticModel.GetDeclaredSymbol(DirectCast(node1.Parent, CollectionRangeVariableSyntax))) 3317Assert.Same(x1, semanticModel.GetDeclaredSymbol(DirectCast(node3.Parent.Parent, AggregationRangeVariableSyntax))) 3318Assert.Same(x1, semanticModel.GetDeclaredSymbol(node3.Parent.Parent)) 3506Assert.Same(s1, semanticModel.GetDeclaredSymbol(node1.Parent)) 3507Assert.Same(s1, semanticModel.GetDeclaredSymbol(DirectCast(node1.Parent, CollectionRangeVariableSyntax))) 3521Assert.Same(x1, semanticModel.GetDeclaredSymbol(DirectCast(node3.Parent.Parent, AggregationRangeVariableSyntax))) 3522Assert.Same(x1, semanticModel.GetDeclaredSymbol(node3.Parent.Parent))
Microsoft.CodeAnalysis.VisualBasic.Symbol.UnitTests (26)
DocumentationComments\DocCommentTests.vb (7)
5463DirectCast(names(0).Parent, ExpressionSyntax), 5466CheckSymbolInfoOnly(model, DirectCast(names(1).Parent, ExpressionSyntax)) 5469DirectCast(names(2).Parent, ExpressionSyntax), 5472CheckSymbolInfoOnly(model, DirectCast(names(3).Parent, ExpressionSyntax)) 5475DirectCast(names(4).Parent, ExpressionSyntax), 5479CheckSymbolInfoOnly(model, DirectCast(names(5).Parent, ExpressionSyntax)) 11981node = node.Parent
SymbolsTests\AnonymousTypes\AnonymousTypesSemanticsTests.vb (6)
323tree.GetRoot().FindToken(sub2).Parent.Parent.GetLocation, 333tree.GetRoot().FindToken(sub4).Parent.Parent.GetLocation, 390tree.GetRoot().FindToken(sub1).Parent.Parent.GetLocation, 401tree.GetRoot().FindToken(sub2).Parent.Parent.GetLocation, 1855Dim mainBlock = DirectCast(mainSyntax.Parent, MethodBlockSyntax) 1905Dim mainBlock = DirectCast(mainSyntax.Parent, MethodBlockSyntax)
SymbolsTests\Source\BindingsTests.vb (3)
35node = node.Parent 38While (TypeOf node.Parent Is TypeSyntax) 39node = node.Parent
SymbolsTests\Source\GroupClassTests.vb (9)
3275Assert.Equal("= DefaultInstanceTest1", node1.Parent.ToString()) 3284Assert.Equal("= DefaultInstanceTest2", node2.Parent.ToString()) 3356Assert.Equal("= DefaultInstanceTest2", node2.Parent.ToString()) 3762Assert.Equal("Form1.M1", node1.Parent.ToString()) 3770Assert.Equal("Form1.Close", node2.Parent.ToString()) 3778Assert.Equal("f1 = Form1", node3.Parent.Parent.ToString()) 3786Assert.Equal("= Form1(2)", node4.Parent.Parent.ToString())
SymbolsTests\Source\OperatorsTests.vb (1)
255node = node.Parent
Microsoft.CodeAnalysis.VisualBasic.Syntax.UnitTests (13)
Parser\ParseExpression.vb (1)
1161Dim lambda = DirectCast(subKeyword.Parent.Parent, MultiLineLambdaExpressionSyntax)
Parser\ParseIteratorTests.vb (1)
423Return IsIteratorMethod(DirectCast(yieldStatement.Parent, MethodBlockBaseSyntax))
TestSyntaxNodes.vb (11)
59Assert.Null(simpleTree.Parent) 60Assert.Equal(simpleTree, CType(simpleTree, BinaryExpressionSyntax).Left.Parent) 61Assert.Equal(simpleTree, CType(simpleTree, BinaryExpressionSyntax).Right.Parent) 66Assert.Equal(argList, argList.Arguments(0).Parent) 67Assert.Equal(argList, argList.Arguments(1).Parent) 629Assert.Null(sepList(1).Parent) 650Assert.Equal(statement, sepList(1).Parent) 1817Dim foundDocComment = result.Parent.Parent.Parent.Parent 1818Assert.Equal(Nothing, foundDocComment.Parent)
Microsoft.CodeAnalysis.VisualBasic.Test.Utilities (18)
CompilationTestUtils.vb (6)
513node = node.Parent 681node = node.Parent 1090node = node.Parent 1104node = node.Parent 1118node = node.Parent 1144node = node.Parent
ParserTestUtilities.vb (9)
135Dim parent = triviaStructure.Parent 151Dim parent = triviaStructure.Parent 402If node.Parent IsNot Nothing Then 403VerifyContainsErrors(node.Parent, tree, tree.GetDiagnostics(node).ToXml) 451If node.Parent IsNot Nothing Then 452Assert.True(node.SpanStart >= node.Parent.SpanStart AndAlso 453node.Span.End <= node.Parent.Span.End, "Span of child (" & 456node.Parent.Kind.ToString & node.Parent.Span.ToString & ")")
SemanticModelTestBase.vb (3)
37node = node.Parent 78node = node.Parent 107node = node.Parent
Microsoft.CodeAnalysis.VisualBasic.Workspaces (425)
CaseCorrection\VisualBasicCaseCorrectionService.Rewriter.vb (3)
130Dim nameColonEquals = TryCast(token.Parent?.Parent, NameColonEqualsSyntax) 131If nameColonEquals IsNot Nothing AndAlso TypeOf nameColonEquals.Parent?.Parent Is TupleExpressionSyntax Then
Classification\ClassificationHelpers.vb (16)
219ElseIf TypeOf parent?.Parent Is CatchStatementSyntax AndAlso DirectCast(parent.Parent, CatchStatementSyntax).IdentifierName.Identifier = identifier Then 233Dim parent = identifierSyntax.Parent 236parent = parent.Parent 252parent = parent.Parent?.Parent 283If TypeOf node.Parent Is ParameterSyntax Then 288If TypeOf node.Parent IsNot VariableDeclaratorSyntax Then 292If TypeOf node.Parent.Parent Is LocalDeclarationStatementSyntax Then 293Dim localDeclaration = DirectCast(node.Parent.Parent, LocalDeclarationStatementSyntax) 298If TypeOf node.Parent.Parent Is FieldDeclarationSyntax Then 299Dim localDeclaration = DirectCast(node.Parent.Parent, FieldDeclarationSyntax)
Classification\SyntaxClassification\ImportAliasClauseSyntaxClassifier.vb (1)
30Dim symbolInfo = semanticModel.GetTypeInfo(DirectCast(node.Parent, SimpleImportsClauseSyntax).Name, cancellationToken)
Classification\SyntaxClassification\NameSyntaxClassifier.vb (3)
247modifiedIdentifier.Parent.IsParentKind(SyntaxKind.FieldDeclaration) Then 249If DirectCast(modifiedIdentifier.Parent, VariableDeclaratorSyntax).AsClause Is Nothing AndAlso 250DirectCast(modifiedIdentifier.Parent, VariableDeclaratorSyntax).Initializer Is Nothing Then
Classification\Worker.DocumentationCommentClassifier.vb (2)
150If TypeOf node.Parent Is BaseXmlAttributeSyntax Then 152ElseIf TypeOf node.Parent Is XmlProcessingInstructionSyntax Then
Classification\Worker.XmlClassifier.vb (6)
233If TypeOf element.Parent Is XmlAttributeSyntax AndAlso 234DirectCast(element.Parent, XmlAttributeSyntax).Name Is element Then 236ElseIf TypeOf element.Parent Is XmlMemberAccessExpressionSyntax AndAlso 237element.Parent.Kind = SyntaxKind.XmlAttributeAccessExpression AndAlso 238DirectCast(element.Parent, XmlMemberAccessExpressionSyntax).Name Is element Then 258Dim parent = name.Parent
CodeCleanup\Providers\AddMissingTokensCodeCleanupProvider.vb (3)
69If name Is Nothing OrElse TypeOf name.Parent Is NameSyntax Then 86If TypeOf name.Parent Is MemberAccessExpressionSyntax OrElse 87TypeOf name.Parent Is TupleElementSyntax OrElse
CodeCleanup\Providers\FixIncorrectTokensCodeCleanupProvider.vb (1)
114Dim parent = TryCast(node.Parent, QualifiedNameSyntax)
CodeCleanup\Providers\RemoveUnnecessaryLineContinuationCodeCleanupProvider.vb (1)
267node = node.Parent
CodeCleanup\VisualBasicCodeCleanerService.vb (1)
110Return GetMultiLineContainer(node.Parent)
CodeGeneration\VisualBasicSyntaxGenerator.vb (31)
1826If IsChildOf(declaration.Parent, SyntaxKind.FieldDeclaration) And GetDeclarationCount(declaration.Parent.Parent) > 1 Then 1828ElseIf IsChildOf(declaration.Parent, SyntaxKind.LocalDeclarationStatement) And GetDeclarationCount(declaration.Parent.Parent) > 1 Then 1833Dim list = TryCast(declaration.Parent, AttributeListSyntax) 1894Return GetFullDeclaration(declaration.Parent) 1898Return declaration.Parent 1901If declaration.Parent IsNot Nothing Then 1902Return declaration.Parent 1906If declaration.Parent IsNot Nothing Then 1907Return declaration.Parent 1922Dim list = TryCast(declaration.Parent, AttributeListSyntax) 1928Dim stmt = TryCast(declaration.Parent, ImportsStatementSyntax) 2107Dim vd = TryCast(declaration.Parent, VariableDeclaratorSyntax) 2190Dim vd = TryCast(declaration.Parent, VariableDeclaratorSyntax) 3421Return AreSimilarExceptForSubDeclarations(decl1.Parent, decl2.Parent) 3451Return SyntaxFactory.AreEquivalent(vd1.AsClause, vd2.AsClause) AndAlso SyntaxFactory.AreEquivalent(vd2.Initializer, vd1.Initializer) AndAlso AreSimilarExceptForSubDeclarations(decl1.Parent, decl2.Parent) 3614Dim vd = TryCast(node.Parent, VariableDeclaratorSyntax) 3620If IsChildOfVariableDeclaration(node) AndAlso GetDeclarationCount(node.Parent) = 1 Then 3622Return RemoveNodeInternal(root, node.Parent, options) 3626Dim attrStmt = TryCast(attrList.Parent, AttributesStatementSyntax) 3632Dim attrList = TryCast(node.Parent, AttributeListSyntax) 3638If IsChildOf(node, SyntaxKind.ArgumentList) AndAlso IsChildOf(node.Parent, SyntaxKind.Attribute) Then 3639Dim argList = DirectCast(node.Parent, ArgumentListSyntax) 3647Dim imps = DirectCast(node.Parent, ImportsStatementSyntax) 3650Return RemoveNodeInternal(root, node.Parent, options) 3653Dim parent = node.Parent
FindSymbols\VisualBasicDeclaredSymbolInfoFactoryService.vb (3)
380If Not parameterCount.HasValue OrElse parameterCount.Value = 0 OrElse TypeOf node.Parent?.Parent IsNot ModuleBlockSyntax Then 402Return TypeOf node.Parent Is TypeBlockSyntax
Formatting\DefaultOperationProvider.vb (12)
84If previousToken.Parent.Parent IsNot Nothing AndAlso TypeOf previousToken.Parent.Parent Is ParameterSyntax Then 95currentToken.Parent.Parent IsNot Nothing AndAlso TypeOf currentToken.Parent.Parent Is ParameterSyntax Then 137Dim [imports] = DirectCast(previousImports.Parent, CompilationUnitSyntax).Imports 185TypeOf xmlDeclaration.Parent Is XmlDocumentSyntax AndAlso 186Not TypeOf xmlDeclaration.Parent.Parent Is XmlNodeSyntax Then 193TypeOf startTag.Parent Is XmlElementSyntax AndAlso 194Not TypeOf startTag.Parent.Parent Is XmlNodeSyntax Then 201Not TypeOf emptyTag.Parent Is XmlNodeSyntax Then
Formatting\FormattingHelpers.vb (6)
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) 278If token.Parent.Parent Is Nothing Then
Formatting\Rules\ElasticTriviaFormattingRule.vb (7)
116currentToken.Parent.Parent.Kind = SyntaxKind.ObjectCollectionInitializer Then 150previousToken.Parent.Parent.Kind = SyntaxKind.ObjectCollectionInitializer Then 158previousToken.Parent.Parent.Kind = SyntaxKind.ObjectCollectionInitializer Then 166currentToken.Parent.Parent.Kind = SyntaxKind.CollectionInitializer Then 179currentToken.Parent.Parent.Kind = SyntaxKind.ObjectCollectionInitializer Then 187If attributeNode IsNot Nothing AndAlso TypeOf attributeNode.Parent Is StatementSyntax AndAlso 257Return TryCast(node, TStatement) IsNot Nothing AndAlso TryCast(node.Parent, TBlock) IsNot Nothing
Formatting\Rules\NodeBasedFormattingRule.vb (6)
208outerBlock = outerBlock.Parent 229If Not TypeOf node.Parent Is XmlNodeSyntax Then 244If Not TypeOf xmlNode.Parent Is XmlNodeSyntax Then 249If Not TypeOf xmlNode.Parent Is XmlNodeSyntax Then 255If TypeOf xmlNode.Parent Is XmlEmbeddedExpressionSyntax Then 267Dim element = TryCast(xmlNode.Parent, XmlElementSyntax)
ReassignedVariable\VisualBasicReassignedVariableService.vb (3)
37Return TryCast(variable.Parent, VariableDeclaratorSyntax)?.Initializer IsNot Nothing 47current = current.Parent 51Return current.Parent
Rename\VisualBasicRenameRewriterLanguageService.vb (2)
254Dim parent = DirectCast(node.Parent, MultiLineLambdaExpressionSyntax) 401If TypeOf token.Parent Is SimpleNameSyntax AndAlso token.Kind <> SyntaxKind.GlobalKeyword AndAlso token.Parent.Parent.IsKind(SyntaxKind.QualifiedName, SyntaxKind.QualifiedCrefOperatorReference) Then
SemanticModelReuse\VisualBasicSemanticModelReuseLanguageService.vb (2)
29Dim container = accessor.Parent 50node = node.Parent
Simplification\Reducers\VisualBasicInferredMemberNameReducer.Rewriter.vb (2)
54parentNode:=node.Parent, 67parentNode:=node.Parent,
Simplification\Reducers\VisualBasicMiscellaneousReducer.Rewriter.vb (1)
42parentNode:=node.Parent,
Simplification\Reducers\VisualBasicVariableDeclaratorReducer.vb (2)
60Not variableDeclarator.Parent.IsKind( 72Dim parent = variableDeclarator.Parent
Simplification\Simplifiers\AbstractVisualBasicSimplifier.vb (3)
156Dim nameofValueOpt = semanticModel.GetConstantValue(node.Parent.Parent.Parent)
Simplification\Simplifiers\ExpressionSimplifier.vb (2)
278Dim symbolForMemberAccess = semanticModel.GetSymbolInfo(DirectCast(memberAccess.Parent, MemberAccessExpressionSyntax), cancellationToken).Symbol 283Dim parent = DirectCast(memberAccess.Parent, MemberAccessExpressionSyntax)
Simplification\Simplifiers\NameSimplifier.vb (11)
156Not name.Parent.IsKind(SyntaxKind.QualifiedName) AndAlso 157Not name.Parent.IsKind(SyntaxKind.NameOfExpression) Then 270nextNode = nextNode.Parent 315Return TypeOf expression.Parent Is ImportsClauseSyntax AndAlso 326Dim symbolForName = semanticModel.GetSymbolInfo(DirectCast(name.Parent, QualifiedNameSyntax), cancellationToken).Symbol 339Dim parent = DirectCast(name.Parent, QualifiedNameSyntax) 369If name.Parent.Kind = SyntaxKind.Attribute OrElse name.IsRightSideOfDot() Then 438(name.IsParentKind(SyntaxKind.QualifiedName) AndAlso name.Parent?.IsParentKind(SyntaxKind.CrefReference)) OrElse ' cref="System.Nullable(Of T)" 439(name.IsParentKind(SyntaxKind.QualifiedName) AndAlso If(name.Parent?.IsParentKind(SyntaxKind.QualifiedName), False) AndAlso name.Parent.Parent?.IsParentKind(SyntaxKind.CrefReference)) Then ' cref="System.Nullable(Of T).Value"
Simplification\VisualBasicSimplificationService.Expander.vb (3)
301Dim tuple = TryCast(node.Parent, TupleExpressionSyntax) 612Dim parent = originalSimpleName.Parent 750Dim parent = originalNode.Parent
Simplification\VisualBasicSimplificationService.NodesAndTokensToReduceComputer.vb (2)
80node.Parent IsNot Nothing AndAlso node.Parent.Kind() = SyntaxKind.FieldDeclaration
Simplification\VisualBasicSimplificationService.vb (3)
86originalNode.Parent.Kind() = SyntaxKind.FieldDeclaration Then 156Return node IsNot Nothing AndAlso node.Parent IsNot Nothing AndAlso 158TypeOf node.Parent Is FieldDeclarationSyntax
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Extensions\ArgumentSyntaxExtensions.vb (2)
30Dim argumentList = TryCast(argument.Parent, ArgumentListSyntax) 36Dim symbolInfo = semanticModel.GetSymbolInfo(argumentList.Parent, cancellationToken)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Extensions\DirectiveSyntaxExtensions.vb (3)
26While node IsNot Nothing AndAlso (node.Parent IsNot Nothing OrElse TypeOf node Is StructuredTriviaSyntax) 27If node.Parent IsNot Nothing Then 28node = node.Parent
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Extensions\ExpressionSyntaxExtensions.vb (33)
16expression = DirectCast(expression.Parent, ExpressionSyntax) 38(expression.IsParentKind(SyntaxKind.QualifiedName) AndAlso DirectCast(expression.Parent, QualifiedNameSyntax).Left Is expression) OrElse 39(expression.IsParentKind(SyntaxKind.SimpleMemberAccessExpression) AndAlso DirectCast(expression.Parent, MemberAccessExpressionSyntax).Expression Is expression) 59DirectCast(expression.Parent, MemberAccessExpressionSyntax).Name Is expression 64Return TypeOf expression?.Parent Is MemberAccessExpressionSyntax AndAlso 65DirectCast(expression.Parent, MemberAccessExpressionSyntax).Name Is expression 81DirectCast(expression.Parent, QualifiedNameSyntax).Right Is expression 87DirectCast(expression.Parent, QualifiedNameSyntax).Left Is expression 156Dim unaryParent = TryCast(expression.WalkUpParentheses().Parent, UnaryExpressionSyntax) 279Dim simpleArgument = TryCast(expression?.Parent, SimpleArgumentSyntax) 290Dim argumentList = TryCast(simpleArgument.Parent, ArgumentListSyntax) 293Dim parent = argumentList.Parent 328expression = TryCast(expression.Parent, ExpressionSyntax) 337Dim assignmentStatement = DirectCast(expression.Parent, AssignmentStatementSyntax) 344expression.Parent.IsParentKind(SyntaxKind.SimpleArgument) Then 372expression = TryCast(expression.Parent, ExpressionSyntax) 380If TypeOf expression.Parent Is AssignmentStatementSyntax Then 381Dim assignmentStatement = DirectCast(expression.Parent, AssignmentStatementSyntax) 392If TypeOf expression.Parent Is MemberAccessExpressionSyntax Then 393Dim memberAccess = DirectCast(expression.Parent, MemberAccessExpressionSyntax) 498If TypeOf expression.Parent Is InvocationExpressionSyntax Then 551If TypeOf expression.Parent Is BinaryExpressionSyntax OrElse 552TypeOf expression.Parent Is AssignmentStatementSyntax OrElse 553TypeOf expression.Parent Is WhileOrUntilClauseSyntax OrElse 554TypeOf expression.Parent Is SingleLineLambdaExpressionSyntax OrElse 555TypeOf expression.Parent Is AwaitExpressionSyntax Then 572If TypeOf expression.Parent Is ExpressionRangeVariableSyntax AndAlso 573TypeOf expression.Parent.Parent Is QueryClauseSyntax Then 574Dim rangeVariable = DirectCast(expression.Parent, ExpressionRangeVariableSyntax) 575Dim selectClause = TryCast(rangeVariable.Parent, SelectClauseSyntax) 584Dim queryExpression = TryCast(selectClause.Parent, QueryExpressionSyntax) 589Dim aggregateClause = TryCast(selectClause.Parent, AggregateClauseSyntax)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Extensions\InvocationExpressionSyntaxExtensions.vb (1)
60Return DirectCast(invocationExpression.Parent, ConditionalAccessExpressionSyntax).Expression
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Extensions\MemberAccessExpressionSyntaxExtensions.vb (8)
50If TypeOf memberAccess.Parent Is InvocationExpressionSyntax Then 51statement = memberAccess.Parent.Parent 54statement = memberAccess.Parent 60DirectCast(statement.Parent, ConstructorBlockSyntax).Statements.First() Is statement 111TypeOf current.Parent Is ObjectCreationExpressionSyntax Then 112Return DirectCast(current.Parent, ExpressionSyntax) 115current = current.Parent
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Extensions\ParenthesizedExpressionSyntaxExtensions.vb (22)
139Dim interpolation = DirectCast(node.Parent, InterpolationSyntax) 158If node.Parent.IsParentKind(SyntaxKind.ObjectCollectionInitializer) AndAlso 159DirectCast(node.Parent.Parent, ObjectCollectionInitializerSyntax).Initializer Is node.Parent Then 166If node.Parent.IsParentKind(SyntaxKind.CollectionInitializer) AndAlso 167node.Parent.Parent.IsParentKind(SyntaxKind.ObjectCollectionInitializer) AndAlso 168DirectCast(node.Parent.Parent.Parent, ObjectCollectionInitializerSyntax).Initializer Is node.Parent.Parent Then 280If TypeOf node.Parent Is ArgumentSyntax Then 284Dim argument = DirectCast(node.Parent, ArgumentSyntax) 301Dim parentInvocation = DirectCast(node.Parent, InvocationExpressionSyntax) 353Dim parentExpression = TryCast(node.Parent, ExpressionSyntax) 453If (node.Parent.Kind = SyntaxKind.InvocationExpression OrElse 454node.Parent.Kind = SyntaxKind.IsExpression OrElse 455node.Parent.Kind = SyntaxKind.TypeOfIsExpression OrElse 456node.Parent.Kind = SyntaxKind.TypeOfIsNotExpression) Then 466node.Parent.Kind = SyntaxKind.XmlEmbeddedExpression Then
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Extensions\SemanticModelExtensions.vb (55)
113type.Parent.IsParentKind(SyntaxKind.VariableDeclarator) Then 114If type.Parent.Parent.IsParentKind(SyntaxKind.FieldDeclaration) OrElse 115type.Parent.Parent.IsParentKind(SyntaxKind.EventStatement) Then 116Dim variableDeclarator = DirectCast(type.Parent.Parent, VariableDeclaratorSyntax) 127type.Parent.IsParentKind(SyntaxKind.AsNewClause) AndAlso 128type.Parent.Parent.IsParentKind(SyntaxKind.VariableDeclarator) Then 129If type.Parent.Parent.Parent.IsParentKind(SyntaxKind.FieldDeclaration) OrElse 130type.Parent.Parent.Parent.IsParentKind(SyntaxKind.EventStatement) Then 131Dim variableDeclarator = DirectCast(type.Parent.Parent.Parent, VariableDeclaratorSyntax) 140If type.Parent.IsParentKind(SyntaxKind.DelegateFunctionStatement) OrElse 141type.Parent.IsParentKind(SyntaxKind.FunctionStatement) OrElse 142type.Parent.IsParentKind(SyntaxKind.PropertyStatement) OrElse 143type.Parent.IsParentKind(SyntaxKind.EventStatement) OrElse 144type.Parent.IsParentKind(SyntaxKind.OperatorStatement) Then 146type.Parent.Parent, cancellationToken).DeclaredAccessibility 151type.Parent.IsParentKind(SyntaxKind.Parameter) AndAlso 152type.Parent.Parent.IsParentKind(SyntaxKind.ParameterList) Then 153If type.Parent.Parent.Parent.IsParentKind(SyntaxKind.DelegateFunctionStatement) OrElse 154type.Parent.Parent.Parent.IsParentKind(SyntaxKind.FunctionStatement) OrElse 155type.Parent.Parent.Parent.IsParentKind(SyntaxKind.PropertyStatement) OrElse 156type.Parent.Parent.Parent.IsParentKind(SyntaxKind.OperatorStatement) OrElse 157type.Parent.Parent.Parent.IsParentKind(SyntaxKind.SubNewStatement) OrElse 158type.Parent.Parent.Parent.IsParentKind(SyntaxKind.SubStatement) Then 160type.Parent.Parent.Parent.Parent, cancellationToken).DeclaredAccessibility 232If TypeOf topExpression.Parent Is ArgumentSyntax Then 233Dim argument = DirectCast(topExpression.Parent, ArgumentSyntax) 240Dim argumentList = TryCast(argument.Parent, ArgumentListSyntax) 243Dim member = TryCast(semanticModel.GetSymbolInfo(argumentList.Parent, cancellationToken).Symbol, IMethodSymbol)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Extensions\StatementSyntaxExtensions.vb (1)
745DirectCast(statement.Parent, ConstructorBlockSyntax).Statements.FirstOrDefault() Is statement Then
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Extensions\SyntaxNodeExtensions.vb (24)
19node.Parent.IsKind(kind) 25IsKind(node.Parent, kind1, kind2) 31IsKind(node.Parent, kind1, kind2, kind3) 681singleLineIf = DirectCast(executableBlock.Parent, SingleLineIfStatementSyntax) 730current = singleLineIf.Parent 788DirectCast(node.Parent, AssignmentStatementSyntax).Left Is node 794node.Parent.IsAnyAssignmentStatement() AndAlso 795DirectCast(node.Parent, AssignmentStatementSyntax).Left Is node 807node.Parent.IsCompoundAssignmentStatement() AndAlso 808DirectCast(node.Parent, AssignmentStatementSyntax).Left Is node 986node = DirectCast(node.Parent, ExpressionSyntax) 995TypeOf node.Parent IsNot ConditionalAccessExpressionSyntax 997node = TryCast(node.Parent, ExpressionSyntax) 1027If TypeOf node?.Parent Is ConditionalAccessExpressionSyntax AndAlso 1028DirectCast(node.Parent, ConditionalAccessExpressionSyntax).Expression Is node Then 1030node = DirectCast(node.Parent, ExpressionSyntax) 1033If TypeOf node?.Parent Is ConditionalAccessExpressionSyntax AndAlso 1034DirectCast(node.Parent, ConditionalAccessExpressionSyntax).WhenNotNull Is node Then 1036node = DirectCast(node.Parent, ExpressionSyntax) 1053While TypeOf node?.Parent Is ConditionalAccessExpressionSyntax 1054Dim conditionalParent = DirectCast(node.Parent, ConditionalAccessExpressionSyntax) 1098current = current.Parent 1221Dim parent As SyntaxNode = node.Parent 1262Dim parent As SyntaxNode = node.Parent
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Extensions\SyntaxTreeExtensions.vb (2)
71current = current.Parent 92node = node.Parent
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Extensions\VariableDeclaratorSyntaxExtensions.vb (1)
54Not DirectCast(variableDeclarator.Parent, FieldDeclarationSyntax).Modifiers.Any(SyntaxKind.ConstKeyword) Then
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Services\SemanticFacts\VisualBasicSemanticFacts.vb (5)
244TypeOf argument.Parent Is ArgumentListSyntax AndAlso 245TypeOf argument.Parent.Parent Is AttributeSyntax Then 314Dim parent As SyntaxNode = node.Parent 324parent = current.Parent
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Services\SyntaxFacts\VisualBasicAccessibilityFacts.vb (5)
65Not declaration.Parent.IsKind(SyntaxKind.ModuleBlock) 69CanHaveAccessibility(declaration.Parent), 74CanHaveAccessibility(declaration.Parent), 160Return GetModifierTokens(declaration.Parent) 166Return GetModifierTokens(declaration.Parent)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Services\SyntaxFacts\VisualBasicBlockFacts.vb (2)
24Return If(IsExecutableBlock(statement.Parent), statement.Parent, Nothing)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Services\SyntaxFacts\VisualBasicSyntaxFacts.vb (47)
164Dim memberAccess = TryCast(node?.Parent, MemberAccessExpressionSyntax) 195DirectCast(node.Parent, SimpleImportsClauseSyntax).Name Is node 232Return firstStatement.Parent Is secondStatement.Parent 249Dim memberAccess = TryCast(token.Parent.Parent, MemberAccessExpressionSyntax) 258Dim memberAccess = TryCast(token.Parent.Parent, MemberAccessExpressionSyntax) 625identifierName.Parent.IsParentKind(SyntaxKind.SimpleArgument) AndAlso 626identifierName.Parent.Parent.IsParentKind(SyntaxKind.ArgumentList) AndAlso 627identifierName.Parent.Parent.Parent.IsParentKind(SyntaxKind.Attribute) 642Dim parent = node.Parent 649node = node.Parent 664initializedInstance = identifier.Parent.Parent.Parent 673If TypeOf node.Parent Is ArrayCreationExpressionSyntax Then 674creationExpression = node.Parent 676ElseIf TypeOf node.Parent Is ObjectCollectionInitializerSyntax AndAlso 677TypeOf node.Parent.Parent Is ObjectCreationExpressionSyntax Then 678creationExpression = node.Parent.Parent 702If TypeOf node Is MethodBlockBaseSyntax AndAlso Not TypeOf node.Parent Is PropertyBlockSyntax Then 706If TypeOf node Is MethodBaseSyntax AndAlso Not TypeOf node.Parent Is MethodBlockBaseSyntax Then 710If TypeOf node Is PropertyStatementSyntax AndAlso Not TypeOf node.Parent Is PropertyBlockSyntax Then 714If TypeOf node Is EventStatementSyntax AndAlso Not TypeOf node.Parent Is EventBlockSyntax Then 735If TypeOf node Is MethodBlockBaseSyntax AndAlso Not TypeOf node.Parent Is PropertyBlockSyntax Then 739If TypeOf node Is MethodBaseSyntax AndAlso Not TypeOf node.Parent Is MethodBlockBaseSyntax Then 767node = node.Parent 780If TypeOf node Is MethodStatementSyntax AndAlso Not TypeOf node.Parent Is MethodBlockBaseSyntax Then 784If TypeOf node Is SubNewStatementSyntax AndAlso Not TypeOf node.Parent Is MethodBlockBaseSyntax Then 788If TypeOf node Is OperatorStatementSyntax AndAlso Not TypeOf node.Parent Is MethodBlockBaseSyntax Then 792If TypeOf node Is PropertyStatementSyntax AndAlso Not TypeOf node.Parent Is PropertyBlockSyntax Then 796If TypeOf node Is EventStatementSyntax AndAlso Not TypeOf node.Parent Is EventBlockSyntax Then 944Dim parent = node.Parent 947parent = parent.Parent 955parent = parent.Parent 1078Dim parent = node.Parent 1202Return IsLeftSideOfDot(node) AndAlso TryCast(node.Parent.Parent, ImplementsClauseSyntax) IsNot Nothing 1328If (node.Parent.IsKind(SyntaxKind.FieldDeclaration)) Then 1454Return node IsNot Nothing AndAlso TryCast(node.Parent, ForEachStatementSyntax)?.Expression Is node 1534Return node IsNot Nothing AndAlso TryCast(node.Parent, PropertyStatementSyntax)?.Initializer Is node 1659Return node.Parent IsNot Nothing AndAlso node.Parent.IsKind(kind)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Simplification\VisualBasicInferredMemberNameSimplifier.vb (2)
20If RemovalCausesAmbiguity(DirectCast(node.Parent, TupleExpressionSyntax).Arguments, node) Then 35Dim parentMemberInitializer As ObjectMemberInitializerSyntax = DirectCast(node.Parent, ObjectMemberInitializerSyntax)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Utilities\CastAnalyzer.vb (4)
35Dim argument = TryCast(_castNode.WalkUpParentheses().Parent, ArgumentSyntax) 59Dim parent = expression.Parent 75Dim returnedType = AsTypeInVariableDeclarator(parentEqualsValue.Parent, semanticModel) 362Dim parentNode = expression.Parent
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Utilities\SpeculationAnalyzer.vb (2)
339Debug.Assert(previousOriginalNode Is Nothing OrElse previousOriginalNode.Parent Is currentOriginalNode) 340Debug.Assert(previousReplacedNode Is Nothing OrElse previousReplacedNode.Parent Is currentReplacedNode)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\CodeGeneration\VisualBasicCodeGenerationHelpers.vb (2)
216Dim variableDeclarator = TryCast(modifiedIdentifierNode.Parent, VariableDeclaratorSyntax) 218Dim fieldDecl = TryCast(variableDeclarator.Parent, FieldDeclarationSyntax)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\CodeGeneration\VisualBasicDeclarationComparer.vb (3)
325declaration = declaration.Parent 328Dim node = declaration.Parent 345node = node.Parent
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\CodeRefactorings\VisualBasicRefactoringHelpersService.vb (9)
76Yield node.Parent 81If TypeOf node Is ForEachStatementSyntax And TypeOf node.Parent Is ForEachBlockSyntax Then 83Yield foreachStatement.Parent 86If TypeOf node Is ForStatementSyntax And TypeOf node.Parent Is ForBlockSyntax Then 88Yield forStatement.Parent 93If TypeOf declarator.Parent Is LocalDeclarationStatementSyntax Then 94Dim localDeclarationStatement = CType(declarator.Parent, LocalDeclarationStatementSyntax) 105Return (TypeOf node Is ModifiedIdentifierSyntax) AndAlso (TypeOf node.Parent Is ParameterSyntax) AndAlso (CType(node.Parent, ParameterSyntax).Identifier Is node)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\Extensions\ContextQuery\SyntaxTreeExtensions.vb (7)
323TypeOf targetToken.Parent.Parent Is NewExpressionSyntax Then 325Dim symbolInfo = semanticModel.GetSymbolInfo(DirectCast(targetToken.Parent.Parent, NewExpressionSyntax).Type(), cancellationToken) 444TypeOf targetToken.Parent.Parent Is LambdaHeaderSyntax Then 471targetToken.Parent.Parent.IsKind(SyntaxKind.Attribute) Then 691ancestor = ancestor.Parent.Parent 709ancestor = ancestor.Parent
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\Extensions\ContextQuery\VisualBasicSyntaxContext.vb (10)
144Dim methodStatement = TryCast(asClause?.Parent, MethodBaseSyntax) 213If TypeOf collectionRange.Parent Is FromClauseSyntax AndAlso TypeOf collectionRange.Parent.Parent Is QueryExpressionSyntax Then 214Dim fromClause = DirectCast(collectionRange.Parent, FromClauseSyntax) 215Dim queryExpression = DirectCast(collectionRange.Parent.Parent, QueryExpressionSyntax) 220If fromClause.Variables.FirstOrDefault() Is collectionRange AndAlso queryExpression.Clauses.FirstOrDefault() Is collectionRange.Parent Then 223ElseIf TypeOf collectionRange.Parent Is SimpleJoinClauseSyntax OrElse TypeOf collectionRange.Parent Is GroupJoinClauseSyntax Then
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\Extensions\ExpressionSyntaxExtensions.vb (3)
201Return DirectCast(statement.Parent, ConstructorBlockSyntax).Statements(0) Is statement 206Dim simpleArgument = TryCast(expression.Parent, SimpleArgumentSyntax) 253Return TypeOf expression?.Parent Is MemberAccessExpressionSyntax
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\Extensions\ParameterSyntaxExtensions.vb (2)
16parameter.Parent.Parent.IsKind(SyntaxKind.FunctionLambdaHeader, SyntaxKind.SubLambdaHeader) Then
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\Extensions\SimpleNameSyntaxExtensions.vb (3)
15Return DirectCast(name.Parent, MemberAccessExpressionSyntax).Expression 17Return DirectCast(name.Parent, QualifiedNameSyntax).Left 37Dim invocationExpression = DirectCast(simpleName.Parent, InvocationExpressionSyntax)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\Indentation\VisualBasicIndentationService.vb (2)
105currentNode = currentNode.Parent 115currentNode = currentNode.Parent
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\LanguageServices\InitializeParameter\VisualBasicInitializeParameterService.vb (1)
29Return TryCast(TryCast(reference, AccessorStatementSyntax)?.Parent, AccessorBlockSyntax)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\LanguageServices\VisualBasicTypeInferenceService.TypeInferrer.vb (26)
57Dim parent = node.Parent 158Function(nameColonEquals As NameColonEqualsSyntax) InferTypeInArgumentList(TryCast(nameColonEquals.Parent.Parent, ArgumentListSyntax), DirectCast(nameColonEquals.Parent, ArgumentSyntax)), 177Return If(parameterList.Parent IsNot Nothing, 178InferTypeInLambda(TryCast(parameterList.Parent.Parent, LambdaExpressionSyntax)), 184If TypeOf argument.Parent Is ArgumentListSyntax Then 186DirectCast(argument.Parent, ArgumentListSyntax), argument, previousToken) 189If TypeOf argument.Parent Is TupleExpressionSyntax Then 191DirectCast(argument.Parent, TupleExpressionSyntax), 231If argumentList.Parent IsNot Nothing Then 236Dim invocation = TryCast(argumentList.Parent, InvocationExpressionSyntax) 274ElseIf invocation.Parent.IsKind(SyntaxKind.ConditionalAccessExpression) Then 275targetExpression = DirectCast(invocation.Parent, ConditionalAccessExpressionSyntax).Expression 291Dim creation = TryCast(argumentList.Parent, ObjectCreationExpressionSyntax) 316Dim attribute = TryCast(argumentList.Parent, AttributeSyntax) 602Dim variableDeclarator = DirectCast(equalsValue.Parent, VariableDeclaratorSyntax) 626Dim propertySyntax = CType(equalsValue.Parent, PropertyStatementSyntax) 798If TypeOf switchStatementSyntax.Parent Is SelectBlockSyntax Then 799Dim firstCase = DirectCast(switchStatementSyntax.Parent, SelectBlockSyntax).CaseBlocks.SelectMany(Function(c) c.CaseStatement.Cases).OfType(Of SimpleCaseClauseSyntax).FirstOrDefault() 912memberAccessExpression.Parent.IsParentKind(SyntaxKind.AwaitExpression) Then 913Return InferTypes(DirectCast(memberAccessExpression.Parent, ExpressionSyntax)) 932Dim invocation = DirectCast(memberAccessExpression.Parent, InvocationExpressionSyntax) 1064Dim objectInitializer = TryCast(collectionInitializer.Parent, ObjectCollectionInitializerSyntax) 1065Dim objectCreation = TryCast(objectInitializer?.Parent, ObjectCreationExpressionSyntax)
Microsoft.CodeAnalysis.Workspaces (80)
Differencing\AbstractSyntaxComparer.cs (2)
67parent = node.Parent; 70parent = parent.Parent;
Editing\SyntaxGenerator.cs (2)
94node = node.Parent; 112node = node.Parent;
FindSymbols\FindReferences\Finders\AbstractReferenceFinder.cs (11)
607while (syntaxFacts.IsQualifiedName(topNameNode.Parent)) 608topNameNode = topNameNode.Parent; 610var isInNamespaceNameContext = syntaxFacts.IsBaseNamespaceDeclaration(topNameNode.Parent); 631while (syntaxFacts.IsQualifiedName(node.Parent)) 632node = node.Parent; 634if (syntaxFacts.IsTypeArgumentList(node.Parent)) 638else if (syntaxFacts.IsTypeConstraint(node.Parent)) 642else if (syntaxFacts.IsBaseTypeList(node.Parent) || 643syntaxFacts.IsBaseTypeList(node.Parent?.Parent)) 744return syntaxFacts.IsLeftSideOfDot(node.Parent);
FindSymbols\FindReferences\Finders\AbstractReferenceFinder_GlobalSuppressions.cs (3)
184var attributeArgument = token.Parent?.Parent; 190var attributeNode = attributeArgument!.Parent?.Parent;
FindSymbols\FindReferences\Finders\AbstractTypeParameterSymbolReferenceFinder.cs (3)
51syntaxFacts.IsObjectCreationExpression(token.Parent.Parent); 61Contract.ThrowIfNull(token.Parent?.Parent); 62var typeInfo = state.SemanticModel.GetTypeInfo(token.Parent.Parent, cancellationToken);
FindSymbols\FindReferences\Finders\ParameterSymbolReferenceFinder.cs (1)
171for (var current = parameterNode; current != null; current = current.Parent)
Recommendations\AbstractRecommendationServiceRunner.cs (9)
84if (!(syntaxFactsService.IsArgument(lambdaSyntax.Parent) && 85syntaxFactsService.IsInvocationExpression(lambdaSyntax.Parent.Parent.Parent))) 90var invocationExpression = lambdaSyntax.Parent.Parent.Parent; 92var argumentName = syntaxFactsService.GetNameForArgument(lambdaSyntax.Parent); 93var ordinalInInvocation = arguments.IndexOf(lambdaSyntax.Parent);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SyntaxNodeExtensions.cs (6)
24=> node.Parent ?? throw new InvalidOperationException("Node's parent was null"); 34var current = node.Parent; 47var current = node.Parent; 62var current = node.Parent; 131if (node?.Parent is not T parentNode) 794var parent = node.Parent;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\BottomUpBaseIndentationFinder.cs (4)
242current = current.Parent; 261currentNode = currentNode.Parent; 272currentNode = currentNode.Parent; 295currentNode = currentNode.Parent;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Context\FormattingContext.InitialContextFinder.cs (2)
101node = node.Parent; 164currentIndentationNode = currentIndentationNode.Parent;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\FormattingExtensions.cs (4)
24if (node.Parent == null) 29if (node.Parent.Span != node.Span) 31return node.Parent; 34return GetParentWithBiggerSpan(node.Parent);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\BlockFacts\IBlockFactsExtensions.cs (3)
15for (var current = node; current is not null; current = current.Parent) 17if (blockFacts.IsStatementContainer(current.Parent)) 18return current.Parent;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\SelectedMembers\AbstractSelectedMembers.cs (2)
69.Where(m => m.Parent is TTypeDeclarationSyntax) 82var containingType = (TTypeDeclarationSyntax)firstMember.Parent;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\SyntaxFacts\ISyntaxFactsExtensions.cs (10)
300while (syntaxFacts.IsParenthesizedExpression(node?.Parent)) 301node = node.Parent; 612var parent = node?.Parent; 621var parent = node?.Parent; 631var parent = node?.Parent; 641if (!syntaxFacts.IsAttribute(node?.Parent)) 644syntaxFacts.GetPartsOfAttribute(node.Parent, out var name, out _); 650var parent = node?.Parent; 660var parent = node?.Parent; 670var parent = node?.Parent;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\AbstractSpeculationAnalyzer.cs (6)
543RoslynDebug.AssertNotNull(currentOriginalNode.Parent); 544RoslynDebug.AssertNotNull(currentReplacedNode.Parent); 548currentOriginalNode = currentOriginalNode.Parent; 549currentReplacedNode = currentReplacedNode.Parent; 573Debug.Assert(previousOriginalNode == null || previousOriginalNode.Parent == currentOriginalNode); 574Debug.Assert(previousReplacedNode == null || previousReplacedNode.Parent == currentReplacedNode);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\CommonFormattingHelpers.cs (1)
341node = node.Parent;
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeRefactorings\AbstractRefactoringHelpersService.cs (8)
284leftNode = leftNode?.Parent; 323rightNode = rightNode?.Parent; 378selectionNode = selectionNode.Parent; 409if (syntaxFacts.IsLocalDeclarationStatement(node) || syntaxFacts.IsLocalDeclarationStatement(node.Parent)) 411var localDeclarationStatement = syntaxFacts.IsLocalDeclarationStatement(node) ? node : node.Parent!; 471if (syntaxFacts.IsExpressionStatement(node.Parent)) 473yield return node.Parent; 554ancestor = ancestor.Parent;
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\SyntaxEditorExtensions.cs (2)
206n.Parent == null, 214n.Parent == null,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\LanguageServices\AddImports\AbstractAddImportsService.cs (1)
198var node = usingDirective != null ? usingDirective.Parent! : contextNode;
Microsoft.CodeAnalysis.Workspaces.UnitTests (1)
SymbolKeyTests.cs (1)
1558node = node.Parent;
Microsoft.DotNet.CodeAnalysis (3)
Analyzers\AppContextDefaultsAnalyzer.cs (3)
88if (!(containingIfStatement.Parent.IsKind(SyntaxKind.SwitchSection) || 89containingIfStatement.Parent.Parent.IsKind(SyntaxKind.SwitchSection)))
Microsoft.DotNet.GenFacades (15)
NotSupportedAssemblyGenerator.cs (5)
201if (node.Parent is NamespaceDeclarationSyntax parentNamespace) 207parent = GetFullyQualifiedName((TypeDeclarationSyntax)node.Parent); 215private string GetMethodDefinition(MethodDeclarationSyntax node) => GetFullyQualifiedName((TypeDeclarationSyntax)node.Parent) + "." + node.Identifier.ValueText; 217private string GetPropertyDefinition(PropertyDeclarationSyntax node) => GetFullyQualifiedName((TypeDeclarationSyntax)node.Parent) + "." + node.Identifier.ValueText; 219private string GetEventDefinition(EventDeclarationSyntax node) => GetFullyQualifiedName((TypeDeclarationSyntax)node.Parent) + "." + node.Identifier.ValueText;
TypeParser.cs (10)
79if (item.Parent is NamespaceDeclarationSyntax parent) 85fullyQualifiedName = GetFullyQualifiedName((BaseTypeDeclarationSyntax)item.Parent, item.Identifier.ValueText.Trim()); 96if (node.Parent is NamespaceDeclarationSyntax parent) 102return GetFullyQualifiedName((BaseTypeDeclarationSyntax)node.Parent, string.IsNullOrEmpty(nested) ? typeName : typeName + "." + nested); 155if (token.Parent == null || token.Parent is NamespaceDeclarationSyntax) 158return HasPublicModifier(token.Modifiers) && HasPublicModifier((BaseTypeDeclarationSyntax)(token.Parent)); 163if (token.Parent == null || token.Parent is NamespaceDeclarationSyntax) 166return HasPublicModifier(token.Modifiers) && HasPublicModifier((BaseTypeDeclarationSyntax)(token.Parent));
Microsoft.Extensions.Logging.Generators (6)
LoggerMessageGenerator.Parser.cs (5)
502SyntaxNode? potentialNamespaceParent = classDec.Parent; 510potentialNamespaceParent = potentialNamespaceParent.Parent; 522namespaceParent = namespaceParent.Parent as NamespaceDeclarationSyntax; 544var parentLoggerClass = (classDec.Parent as TypeDeclarationSyntax); 562parentLoggerClass = (parentLoggerClass.Parent as TypeDeclarationSyntax);
LoggerMessageGenerator.Roslyn3.11.cs (1)
86return methodDeclarationSyntax.Parent as ClassDeclarationSyntax;
Microsoft.Extensions.Options.SourceGeneration (2)
Parser.cs (2)
126var parent = syntax.Parent as TypeDeclarationSyntax; 131parent = parent.Parent as TypeDeclarationSyntax;
Microsoft.Gen.ComplianceReports (2)
src\Generators\Shared\GeneratorUtilities.cs (2)
113var node = attributeSyntax.Parent?.Parent;
Microsoft.Gen.ContextualOptions (2)
src\Generators\Shared\GeneratorUtilities.cs (2)
113var node = attributeSyntax.Parent?.Parent;
Microsoft.Gen.Logging (9)
LoggingGenerator.cs (2)
22(syntaxNode, _) => syntaxNode.Parent is TypeDeclarationSyntax, 23(context, _) => (TypeDeclarationSyntax)context.TargetNode.Parent!);
Parsing\Parser.cs (5)
289SyntaxNode? potentialNamespaceParent = typeDec.Parent; 294potentialNamespaceParent = potentialNamespaceParent.Parent; 303namespaceParent = namespaceParent.Parent as NamespaceDeclarationSyntax; 329var parentLoggerClass = typeDec.Parent as TypeDeclarationSyntax; 348parentLoggerClass = parentLoggerClass.Parent as TypeDeclarationSyntax;
src\Generators\Shared\GeneratorUtilities.cs (2)
113var node = attributeSyntax.Parent?.Parent;
Microsoft.Gen.Metrics (8)
MetricsGenerator.cs (1)
28GeneratorUtilities.Initialize(context, _attributeNames, m => m.Parent as TypeDeclarationSyntax, HandleAnnotatedTypes);
Parser.cs (5)
107SyntaxNode? potentialNamespaceParent = typeDeclaration.Parent; 112potentialNamespaceParent = potentialNamespaceParent.Parent; 121ns = ns.Parent as NamespaceDeclarationSyntax; 146var parentMetricClass = typeDeclaration.Parent as TypeDeclarationSyntax; 169parentMetricClass = parentMetricClass.Parent as TypeDeclarationSyntax;
src\Generators\Shared\GeneratorUtilities.cs (2)
113var node = attributeSyntax.Parent?.Parent;
Microsoft.Gen.MetricsReports (7)
src\Generators\Microsoft.Gen.Metrics\Parser.cs (5)
107SyntaxNode? potentialNamespaceParent = typeDeclaration.Parent; 112potentialNamespaceParent = potentialNamespaceParent.Parent; 121ns = ns.Parent as NamespaceDeclarationSyntax; 146var parentMetricClass = typeDeclaration.Parent as TypeDeclarationSyntax; 169parentMetricClass = parentMetricClass.Parent as TypeDeclarationSyntax;
src\Generators\Shared\GeneratorUtilities.cs (2)
113var node = attributeSyntax.Parent?.Parent;
Microsoft.Interop.ComInterfaceGenerator (4)
src\libraries\System.Runtime.InteropServices\gen\Common\ConvertToSourceGeneratedInteropFixer.cs (2)
234for (SyntaxNode? node = syntax.Parent; node is not null; node = node.Parent)
VtableIndexStubGenerator.cs (2)
404for (SyntaxNode? parentNode = methodSyntax.Parent; parentNode is TypeDeclarationSyntax typeDecl; parentNode = parentNode.Parent)
Microsoft.Interop.JavaScript.JSImportGenerator (4)
JSExportGenerator.cs (2)
348for (SyntaxNode? parentNode = methodSyntax.Parent; parentNode is TypeDeclarationSyntax typeDecl; parentNode = parentNode.Parent)
JSImportGenerator.cs (2)
227for (SyntaxNode? parentNode = methodSyntax.Parent; parentNode is TypeDeclarationSyntax typeDecl; parentNode = parentNode.Parent)
Microsoft.Interop.LibraryImportGenerator (12)
Analyzers\ConvertToLibraryImportFixer.cs (9)
303{ Parent: InvocationExpressionSyntax invocationInScope } => invocationInScope, 304{ Parent: MemberAccessExpressionSyntax { Parent: InvocationExpressionSyntax invocationOnType } } => invocationOnType, 322else if (invocation.Parent.IsKind(SyntaxKind.ExpressionStatement)) 342else if (invocation.Parent.IsKind(SyntaxKind.EqualsValueClause)) 375else if (invocation.Parent.IsKind(SyntaxKind.SimpleAssignmentExpression) && invocation.Parent.Parent.IsKind(SyntaxKind.ExpressionStatement)) 377editor.ReplaceNode(invocation.Parent,
LibraryImportGenerator.cs (1)
554if (methodSyntax.Parent is TypeDeclarationSyntax typeDecl && !typeDecl.IsInPartialContext(out var nonPartialIdentifier))
src\libraries\System.Runtime.InteropServices\gen\Common\ConvertToSourceGeneratedInteropFixer.cs (2)
234for (SyntaxNode? node = syntax.Parent; node is not null; node = node.Parent)
Microsoft.Interop.LibraryImportGenerator.Downlevel (1)
DownlevelLibraryImportGenerator.cs (1)
424if (methodSyntax.Parent is TypeDeclarationSyntax typeDecl && !typeDecl.IsInPartialContext(out var nonPartialIdentifier))
Microsoft.Interop.SourceGeneration (4)
ContainingSyntaxContext.cs (3)
53for (SyntaxNode? parent = memberDeclaration.Parent; parent is TypeDeclarationSyntax typeDeclaration; parent = parent.Parent) 69for (SyntaxNode? parent = memberDeclaration.FirstAncestorOrSelf<BaseNamespaceDeclarationSyntax>(); parent is BaseNamespaceDeclarationSyntax ns; parent = parent.Parent)
SyntaxExtensions.cs (1)
122for (SyntaxNode? parentNode = syntax; parentNode is TypeDeclarationSyntax typeDecl; parentNode = parentNode.Parent)
Microsoft.ML.InternalCodeAnalyzer (12)
ContractsCheckAnalyzer.cs (2)
165node = node.Parent; 209if (isExcept && invocation.Parent.IsKind(SyntaxKind.ExpressionStatement))
ContractsCheckNameofFixProvider.cs (9)
50Debug.Assert(nameArg.Parent.Parent.IsKind(SyntaxKind.InvocationExpression)); 51var invokeExp = (InvocationExpressionSyntax)nameArg.Parent.Parent; 56var argList = (ArgumentListSyntax)nameArg.Parent; 78var pk = node.Parent.Kind(); 81var parentAccess = (MemberAccessExpressionSyntax)node.Parent; 89candidate = SyntaxFactory.ParseExpression(node.Parent.ToString()); 109temp = temp.Parent;
SingleVariableDeclarationAnalyzer.cs (1)
44if (vars.Count <= 1 || node.Parent.IsKind(SyntaxKind.ForStatement))
Microsoft.VisualStudio.LanguageServices (2)
Progression\GraphNodeIdCreation.cs (1)
529currentNode = currentNode.Parent;
Venus\ContainedDocument.cs (1)
863current = current.Parent;
Microsoft.VisualStudio.LanguageServices.CSharp (35)
CodeModel\CSharpCodeModelService.cs (23)
142node.Parent != null) 261return MatchesScope(node.Parent!, scope); 338return GetAttributeNodes(parent.Parent!); 1161if (member.Parent is (kind: SyntaxKind.InterfaceDeclaration or SyntaxKind.EnumDeclaration)) 1177if (!(member.Parent is BaseTypeDeclarationSyntax) && 1671RoslynDebug.Assert(attributeNode.Parent is AttributeListSyntax); 1673return (AttributeListSyntax)attributeNode.Parent; 1679RoslynDebug.Assert(attributeNode.Parent is AttributeListSyntax); 1681var attributeList = (AttributeListSyntax)attributeNode.Parent; 1758Contract.ThrowIfNull(node.Parent); 1759return node.Parent; 1845: usingDirective.Parent; 1930var parameterList = (ParameterListSyntax)parameter.Parent!; 2016if (member.Parent is InterfaceDeclarationSyntax) 2035if (member.Parent is InterfaceDeclarationSyntax) 2254if (member.Parent is InterfaceDeclarationSyntax) 2275if (member.Parent is InterfaceDeclarationSyntax) 2286if (member.Parent is ClassDeclarationSyntax) 2288var parentFlags = ((ClassDeclarationSyntax)member.Parent).GetModifierFlags(); 2770var enumDeclaration = (EnumDeclarationSyntax)node.Parent!; 3081var attributeDeclaration = (AttributeListSyntax)attribute.Parent!; 3451return InsertAttributeListIntoContainer(index, list, container.Parent!); 3580if (methodDeclaration?.Parent is not ClassDeclarationSyntax classDecl ||
CodeModel\CSharpCodeModelService.NodeLocator.cs (1)
1170return new VirtualTreePoint(fileScopedNamespace.SyntaxTree, text, fileScopedNamespace.Parent.Span.End);
LanguageService\CSharpHelpContextService.cs (10)
248if (token.Parent.Parent.IsKind(SyntaxKind.Parameter)) 253else if (token.Parent.Parent.IsKind(SyntaxKind.PropertyDeclaration)) 258else if (token.Parent.Parent.IsKind(SyntaxKind.EnumMemberDeclaration)) 263else if (token.Parent.Parent.IsKind(SyntaxKind.VariableDeclarator)) 271if (token.Parent.Parent.IsKind(SyntaxKind.AnonymousObjectMemberDeclarator)) 276else if (token.Parent.Parent.IsKind(SyntaxKind.UsingDirective)) 281else if (token.Parent.Parent.IsKind(SyntaxKind.AttributeArgument)) 412if (token.Parent is IdentifierNameSyntax { Parent: TypeConstraintSyntax { Parent: TypeParameterConstraintClauseSyntax } }) 525token.Parent?.Parent is VariableDeclarationSyntax declaration && token.Parent == declaration.Type)
Utilities\BlankLineInGeneratedMethodFormattingRule.cs (1)
28currentToken.Parent.Parent.Kind() == SyntaxKind.MethodDeclaration)
Microsoft.VisualStudio.LanguageServices.VisualBasic (70)
CodeModel\VisualBasicCodeModelService.CodeModelEventCollector.vb (15)
137If member.Parent.IsKind(SyntaxKind.CompilationUnit, SyntaxKind.NamespaceBlock) AndAlso 820Dim oldVariableDeclarator = DirectCast(oldModifiedIdentifier.Parent, VariableDeclaratorSyntax) 821Dim newVariableDeclarator = DirectCast(newModifiedIdentifier.Parent, VariableDeclaratorSyntax) 828Dim oldField = DirectCast(oldVariableDeclarator.Parent, FieldDeclarationSyntax) 829Dim newField = DirectCast(newVariableDeclarator.Parent, FieldDeclarationSyntax) 1109TypeOf node.Parent Is TypeBlockSyntax Then 1111Return node.Parent 1115TypeOf node.Parent Is EnumBlockSyntax Then 1117Return node.Parent 1121TypeOf node.Parent Is MethodBlockBaseSyntax Then 1123Return node.Parent 1127TypeOf node.Parent Is PropertyBlockSyntax Then 1129Return node.Parent 1133TypeOf node.Parent Is EventBlockSyntax Then 1135Return node.Parent
CodeModel\VisualBasicCodeModelService.NodeLocator.vb (18)
51Return GetTypeBlockStartPoint(text, options, DirectCast(node.Parent, TypeBlockSyntax), part) 53Return GetEnumBlockStartPoint(text, options, DirectCast(node.Parent, EnumBlockSyntax), part) 71Return GetMethodBlockStartPoint(text, options, DirectCast(node.Parent, MethodBlockBaseSyntax), part) 74If TypeOf node.Parent Is MethodBlockBaseSyntax Then 75Return GetMethodBlockStartPoint(text, options, DirectCast(node.Parent, MethodBlockBaseSyntax), part) 100Return GetNamespaceBlockStartPoint(text, options, DirectCast(node.Parent, NamespaceBlockSyntax), part) 115Return GetImportsStatementStartPoint(text, DirectCast(node.Parent, ImportsStatementSyntax), part) 141Return GetTypeBlockEndPoint(text, DirectCast(node.Parent, TypeBlockSyntax), part) 143Return GetEnumBlockEndPoint(text, DirectCast(node.Parent, EnumBlockSyntax), part) 161Return GetMethodBlockEndPoint(text, DirectCast(node.Parent, MethodBlockBaseSyntax), part) 164If TypeOf node.Parent Is MethodBlockBaseSyntax Then 165Return GetMethodBlockEndPoint(text, DirectCast(node.Parent, MethodBlockBaseSyntax), part) 190Return GetNamespaceBlockEndPoint(text, DirectCast(node.Parent, NamespaceBlockSyntax), part) 205Return GetImportsStatementEndPoint(text, DirectCast(node.Parent, ImportsStatementSyntax), part) 766DirectCast(propertyStatement.Parent, PropertyBlockSyntax).EndPropertyStatement.Span.End, 775DirectCast(propertyStatement.Parent, PropertyBlockSyntax).EndPropertyStatement.SpanStart, 889DirectCast(eventStatement.Parent, EventBlockSyntax).EndEventStatement.Span.End, 897DirectCast(eventStatement.Parent, EventBlockSyntax).EndEventStatement.SpanStart,
CodeModel\VisualBasicCodeModelService.vb (24)
170node.Parent IsNot Nothing Then 230If Not TypeOf node.Parent Is EventBlockSyntax Then 242If Not TypeOf node.Parent Is PropertyBlockSyntax Then 281If node.Parent.Kind <> SyntaxKind.Parameter Then 285Return MatchesScope(node.Parent, scope) 403Return GetAttributeNodes(node.Parent) 1519If member.Parent.Kind = SyntaxKind.InterfaceBlock OrElse 1520member.Parent.Kind = SyntaxKind.EnumBlock Then 1531If Not TypeOf member.Parent Is TypeBlockSyntax AndAlso 1596Dim attributeBlock = DirectCast(attribute.Parent, AttributeListSyntax) 1637Dim importsStatement = DirectCast(importsClause.Parent, ImportsStatementSyntax) 1680Dim fieldDeclaration = DirectCast(variableDeclarator.Parent, FieldDeclarationSyntax) 1857Return node.Parent 2113If member.Parent.Kind = SyntaxKind.InterfaceBlock Then 2653If member.Parent.Kind = SyntaxKind.InterfaceBlock Then 2717If TypeOf memberNode.Parent Is ModuleBlockSyntax OrElse 2718TypeOf memberNode.Parent Is InterfaceBlockSyntax OrElse 2719TypeOf memberNode.Parent Is PropertyBlockSyntax OrElse 2720TypeOf memberNode.Parent Is PropertyStatementSyntax Then 2921Dim parentType = TryCast(member.Parent, DeclarationStatementSyntax) 3510Dim variableDeclarator = DirectCast(modifiedIdentifier.Parent, VariableDeclaratorSyntax) 4061Dim parentTypeBlock = TryCast(method.Parent, TypeBlockSyntax) 4089Dim parentTypeBlock = TryCast(method.Parent, TypeBlockSyntax) 4200Not TypeOf node.Parent Is InterfaceBlockSyntax
CodeModel\VisualBasicCodeModelService_Prototype.vb (1)
127Dim variableDeclarator = TryCast(modifiedIdentifier.Parent, VariableDeclaratorSyntax)
Help\VisualBasicHelpContextService.Visitor.vb (12)
46Visit(node.Parent) 54Visit(node.Parent) 138If TypeOf (node.Parent) Is ArrayCreationExpressionSyntax Then 139Visit(node.Parent) 377node.Parent.Parent.Kind() = SyntaxKind.ModuleBlock AndAlso 434If Not TypeOf node.Parent Is InheritsOrImplementsStatementSyntax Then 435If TypeOf node.Parent Is DeclarationStatementSyntax OrElse TypeOf node.Parent Is FieldDeclarationSyntax Then 553If node.Parent.Kind() <> SyntaxKind.PropertyBlock Then 617If Not node.Parent.IsKind(SyntaxKind.AnonymousObjectCreationExpression) Then 925If node.Parent.IsKind(SyntaxKind.GroupJoinClause) Then
System.Private.CoreLib.Generators (3)
EventSourceGenerator.Parser.cs (3)
22NamespaceDeclarationSyntax? ns = classDef.Parent as NamespaceDeclarationSyntax; 25if (classDef.Parent is not CompilationUnitSyntax) 86ns = ns.Parent as NamespaceDeclarationSyntax;
System.Text.Json.SourceGeneration (1)
JsonSourceGenerator.Parser.cs (1)
173for (TypeDeclarationSyntax? currentType = contextClassSyntax; currentType != null; currentType = currentType.Parent as TypeDeclarationSyntax)
System.Text.RegularExpressions.Generator (3)
RegexGenerator.Parser.cs (3)
50TypeDeclarationSyntax? typeDec = memberSyntax.Parent as TypeDeclarationSyntax; 228var parent = typeDec.Parent as TypeDeclarationSyntax; 238parent = parent.Parent as TypeDeclarationSyntax;