235 references to FirstAncestorOrSelf
ILLink.RoslynAnalyzer (1)
TrimAnalysis\TrimDataFlowAnalysis.cs (1)
96 var method = op.Syntax.FirstAncestorOrSelf<MethodDeclarationSyntax> ();
Microsoft.AspNetCore.App.Analyzers (4)
RouteEmbeddedLanguage\FrameworkParametersCompletionProvider.cs (3)
171(previous.IsKind(SyntaxKind.CloseBracketToken) && previous.GetRequiredParent().FirstAncestorOrSelf<AttributeListSyntax>() != null) || 172(previous.IsKind(SyntaxKind.LessThanToken) && previous.GetRequiredParent().FirstAncestorOrSelf<GenericNameSyntax>() != null)) 190var methodSyntax = container.FirstAncestorOrSelf<MethodDeclarationSyntax>();
RouteEmbeddedLanguage\Infrastructure\RouteStringSyntaxDetector.cs (1)
99var statement = container.FirstAncestorOrSelf<SyntaxNode>(n => n is StatementSyntax);
Microsoft.AspNetCore.App.CodeFixes (2)
Kestrel\ListenOnIPv6AnyFixer.cs (1)
40var argumentSyntax = root.FindNode(diagnostic.Location.SourceSpan).FirstAncestorOrSelf<ArgumentSyntax>();
PublicPartialProgramClassFixer.cs (1)
39.FirstAncestorOrSelf<ClassDeclarationSyntax>();
Microsoft.AspNetCore.Mvc.Api.Analyzers (1)
AddResponseTypeAttributeCodeFixAction.cs (1)
132var methodSyntax = diagnosticNode.FirstAncestorOrSelf<MethodDeclarationSyntax>();
Microsoft.CodeAnalysis.CodeStyle (10)
src\Analyzers\Core\Analyzers\NewLines\ConsecutiveStatementPlacement\AbstractConsecutiveStatementPlacementDiagnosticAnalyzer.cs (1)
85var nextTokenContainingStatement = nextToken.Parent?.FirstAncestorOrSelf<TExecutableStatementSyntax>();
src\Analyzers\Core\Analyzers\UseAutoProperty\AbstractUseAutoPropertyAnalyzer.cs (2)
219if (!shouldAnalyze && analysisRoot.FirstAncestorOrSelf<SyntaxNode>(node => node is TPropertyDeclaration or TFieldDeclaration) == null) 638=> nodes.Where(n => n.FirstAncestorOrSelf<TConstructorDeclaration>() is null);
src\Analyzers\Core\Analyzers\UseCollectionInitializer\AbstractObjectCreationExpressionAnalyzer.cs (1)
103var statement = rootExpression.FirstAncestorOrSelf<TStatementSyntax>()!;
src\Analyzers\Core\Analyzers\UseCollectionInitializer\AbstractUseCollectionInitializerDiagnosticAnalyzer.cs (1)
158var containingStatement = objectCreationExpression.FirstAncestorOrSelf<TStatementSyntax>();
src\Analyzers\Core\Analyzers\UseCollectionInitializer\UpdateExpressionState.cs (1)
68ContainingStatement = startExpression.FirstAncestorOrSelf<TStatementSyntax>()!;
src\Analyzers\Core\Analyzers\UseObjectInitializer\AbstractUseObjectInitializerDiagnosticAnalyzer.cs (1)
112var containingStatement = objectCreationExpression.FirstAncestorOrSelf<TStatementSyntax>();
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SyntaxNodeExtensions.cs (1)
202=> nodes.FindInnermostCommonNode()?.FirstAncestorOrSelf(predicate);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SyntaxTokenExtensions.cs (1)
19=> token.Parent?.FirstAncestorOrSelf(predicate);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Helpers\RemoveUnnecessaryImports\AbstractUnnecessaryImportsProvider.cs (1)
33if (node.FirstAncestorOrSelf<TSyntaxNode>() is null)
Microsoft.CodeAnalysis.CodeStyle.Fixes (8)
src\Analyzers\Core\CodeFixes\DocumentationComments\AbstractAddDocCommentNodesCodeFixProvider.cs (1)
33var parentMethod = root.FindNode(context.Span).FirstAncestorOrSelf<TMemberDeclarationSyntax>();
src\Analyzers\Core\CodeFixes\DocumentationComments\AbstractRemoveDocCommentNodeCodeFixProvider.cs (1)
56return paramNode.FirstAncestorOrSelf<TXmlElementSyntax>();
src\Analyzers\Core\CodeFixes\MakeFieldReadonly\AbstractMakeFieldReadonlyCodeFixProvider.cs (2)
50declarators.Add(root.FindNode(diagnosticSpan, getInnermostNodeForTie: true).FirstAncestorOrSelf<TSymbolSyntax>()!); 60var declaratorsByField = declarators.GroupBy(g => g.FirstAncestorOrSelf<TFieldDeclarationSyntax>()!);
src\Analyzers\Core\CodeFixes\RemoveUnusedMembers\AbstractRemoveUnusedMembersCodeFixProvider.cs (1)
71var fieldDeclarator = node.FirstAncestorOrSelf<TFieldDeclarationSyntax>();
src\Analyzers\Core\CodeFixes\RemoveUnusedParametersAndValues\AbstractRemoveUnusedValuesCodeFixProvider.cs (2)
402var expressionStatement = root.FindNode(diagnostic.Location.SourceSpan).FirstAncestorOrSelf<TExpressionStatementSyntax>(); 496var variableDeclarator = node.FirstAncestorOrSelf<TVariableDeclaratorSyntax>();
src\Analyzers\Core\CodeFixes\UseObjectInitializer\AbstractUseObjectInitializerCodeFixProvider.cs (1)
76var statement = objectCreation.FirstAncestorOrSelf<TStatementSyntax>();
Microsoft.CodeAnalysis.CSharp (12)
Compilation\CSharpCompilation.cs (1)
2664Parent!.FirstAncestorOrSelf<ExternAliasDirectiveSyntax>();
Compilation\SpeculativeSemanticModelWithMemberModel.cs (2)
60attributedNode = attributedNode?.FirstAncestorOrSelf<AttributeListSyntax>()?.Parent; 150var attributeOrParameter = node.FirstAncestorOrSelf<SyntaxNode>(static n => n.Kind() is SyntaxKind.Attribute or SyntaxKind.Parameter);
Compilation\SyntaxTreeSemanticModel.cs (1)
1042return node.FirstAncestorOrSelf(s_isMemberDeclarationFunction);
Lowering\Instrumentation\CodeCoverageInstrumenter.cs (1)
440var whenClause = original.Syntax.FirstAncestorOrSelf<WhenClauseSyntax>();
Lowering\Instrumentation\DebugInfoInjector.cs (1)
439WhenClauseSyntax? whenClause = original.Syntax.FirstAncestorOrSelf<WhenClauseSyntax>();
Lowering\Instrumentation\Instrumenter.cs (1)
282Debug.Assert(original.Syntax.FirstAncestorOrSelf<WhenClauseSyntax>() != null);
Lowering\LocalRewriter\LocalRewriter_FixedStatement.cs (3)
255VariableDeclaratorSyntax? declarator = fixedInitializer.Syntax.FirstAncestorOrSelf<VariableDeclaratorSyntax>(); 316VariableDeclaratorSyntax? declarator = fixedInitializer.Syntax.FirstAncestorOrSelf<VariableDeclaratorSyntax>(); 447VariableDeclaratorSyntax? declarator = fixedInitializer.Syntax.FirstAncestorOrSelf<VariableDeclaratorSyntax>();
Symbols\Source\SourceLabelSymbol.cs (1)
100node = _identifierNodeOrToken.AsNode()!.FirstAncestorOrSelf<SwitchLabelSyntax>();
Symbols\Symbol.cs (1)
516CSharpSyntaxNode node = token.Parent.FirstAncestorOrSelf<TNode>();
Microsoft.CodeAnalysis.CSharp.CodeStyle (8)
src\Analyzers\CSharp\Analyzers\InlineDeclaration\CSharpInlineDeclarationDiagnosticAnalyzer.cs (1)
123var containingStatement = argumentExpression.FirstAncestorOrSelf<StatementSyntax>();
src\Analyzers\CSharp\Analyzers\RemoveUnreachableCode\CSharpRemoveUnreachableCodeDiagnosticAnalyzer.cs (1)
74var firstUnreachableStatement = node.FirstAncestorOrSelf<StatementSyntax>();
src\Analyzers\CSharp\Analyzers\RemoveUnusedParametersAndValues\CSharpRemoveUnusedParametersAndValuesDiagnosticAnalyzer.cs (1)
69var statementAncestor = unusedSymbolWriteOperation.Syntax.FirstAncestorOrSelf<StatementSyntax>()?.Parent;
src\Analyzers\CSharp\Analyzers\UseCollectionExpression\UseCollectionExpressionHelpers.cs (1)
540var containingBlock = declarator.FirstAncestorOrSelf<BlockSyntax>();
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\ExpressionSyntaxExtensions.cs (1)
905=> expression.FirstAncestorOrSelf<XmlCrefAttributeSyntax>() != null;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\ILocalSymbolExtensions.cs (1)
18var localFunctionStatement = destinationBlock.FirstAncestorOrSelf<LocalFunctionStatementSyntax>();
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\FormattingRangeHelper.cs (1)
447return token.Parent.FirstAncestorOrSelf<MemberDeclarationSyntax>();
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\TypeStyle\CSharpTypeStyleHelper.cs (1)
62if (typeName?.FirstAncestorOrSelf<SyntaxNode>(a => a.Kind() is SyntaxKind.DeclarationExpression or SyntaxKind.VariableDeclaration or SyntaxKind.ForEachStatement) is not { } declaration)
Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes (2)
src\Analyzers\CSharp\CodeFixes\MakeTypeAbstract\CSharpMakeTypeAbstractCodeFixProvider.cs (1)
49var enclosingType = node.FirstAncestorOrSelf<TypeDeclarationSyntax>();
src\Analyzers\CSharp\CodeFixes\UseConditionalExpression\MultiLineConditionalExpressionFormattingRule.cs (1)
54var statement = conditional.FirstAncestorOrSelf<StatementSyntax>();
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (3)
Diagnostics\GetDiagnosticsTests.cs (2)
1014if (node.FirstAncestorOrSelf<BasePropertyDeclarationSyntax>() is { } basePropertyDecl) 1024else if (node.FirstAncestorOrSelf<BaseMethodDeclarationSyntax>() is { } baseMethodDecl)
Semantics\PatternMatchingTestBase.cs (1)
323var dataFlowParent = designation.FirstAncestorOrSelf<ExpressionSyntax>();
Microsoft.CodeAnalysis.CSharp.Features (14)
Completion\CompletionProviders\CrefCompletionProvider.cs (1)
187var typeDeclaration = token.Parent?.FirstAncestorOrSelf<TypeDeclarationSyntax>();
Completion\KeywordRecommenders\InKeywordRecommender.cs (1)
120var joinClause = token.Parent?.FirstAncestorOrSelf<JoinClauseSyntax>();
DecompiledSource\CSharpDecompiledSourceFormattingRule.cs (2)
38var previousStatement = previousToken.Parent.FirstAncestorOrSelf<StatementSyntax>(); 39var nextStatement = currentToken.Parent.FirstAncestorOrSelf<StatementSyntax>();
EditAndContinue\CSharpEditAndContinueAnalyzer.cs (2)
937=> node is CompilationUnitSyntax ? null : node.Parent!.FirstAncestorOrSelf<BaseTypeDeclarationSyntax>(); 1501=> node.FirstAncestorOrSelf<QueryExpressionSyntax>();
ExtractMethod\CSharpMethodExtractor.CSharpCodeGenerator.cs (1)
730var enclosingMethod = returnOperationSyntax.FirstAncestorOrSelf<SyntaxNode>(n => n switch
ReplaceMethodWithProperty\CSharpReplaceMethodWithPropertyService.cs (1)
369var invocation = nameNode?.FirstAncestorOrSelf<InvocationExpressionSyntax>();
src\Analyzers\CSharp\Analyzers\InlineDeclaration\CSharpInlineDeclarationDiagnosticAnalyzer.cs (1)
123var containingStatement = argumentExpression.FirstAncestorOrSelf<StatementSyntax>();
src\Analyzers\CSharp\Analyzers\RemoveUnreachableCode\CSharpRemoveUnreachableCodeDiagnosticAnalyzer.cs (1)
74var firstUnreachableStatement = node.FirstAncestorOrSelf<StatementSyntax>();
src\Analyzers\CSharp\Analyzers\RemoveUnusedParametersAndValues\CSharpRemoveUnusedParametersAndValuesDiagnosticAnalyzer.cs (1)
69var statementAncestor = unusedSymbolWriteOperation.Syntax.FirstAncestorOrSelf<StatementSyntax>()?.Parent;
src\Analyzers\CSharp\Analyzers\UseCollectionExpression\UseCollectionExpressionHelpers.cs (1)
540var containingBlock = declarator.FirstAncestorOrSelf<BlockSyntax>();
src\Analyzers\CSharp\CodeFixes\MakeTypeAbstract\CSharpMakeTypeAbstractCodeFixProvider.cs (1)
49var enclosingType = node.FirstAncestorOrSelf<TypeDeclarationSyntax>();
src\Analyzers\CSharp\CodeFixes\UseConditionalExpression\MultiLineConditionalExpressionFormattingRule.cs (1)
54var statement = conditional.FirstAncestorOrSelf<StatementSyntax>();
Microsoft.CodeAnalysis.CSharp.Features.UnitTests (1)
EditAndContinue\BreakpointSpansTests.cs (1)
77var declarationNode = root.FindToken(position).Parent.FirstAncestorOrSelf<TDeclaration>();
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (13)
Compilation\GetSemanticInfoTests.cs (1)
4757var parameterSyntax = trueLiteral.FirstAncestorOrSelf<ParameterSyntax>();
Compilation\SemanticModelAPITests.cs (1)
3751var expr = identifier.FirstAncestorOrSelf<ArgumentSyntax>().Parent.Parent;
Symbols\Source\DeclaringSyntaxNodeTests.cs (6)
140var node = tree.GetRoot().FindToken(position).Parent.FirstAncestorOrSelf<TNode>(); 155var node = tree.GetCompilationUnitRoot().FindToken(position).Parent.FirstAncestorOrSelf<TNode>(); 263var declaratorA1 = tree.GetCompilationUnitRoot().FindToken(posA1).Parent.FirstAncestorOrSelf<VariableDeclaratorSyntax>(); 307var declaratorQ = tree.GetCompilationUnitRoot().FindToken(posQ).Parent.FirstAncestorOrSelf<VariableDeclaratorSyntax>(); 314var declaratorX = tree.GetCompilationUnitRoot().FindToken(posX).Parent.FirstAncestorOrSelf<VariableDeclaratorSyntax>(); 321var declaratorZ = tree.GetCompilationUnitRoot().FindToken(posZ).Parent.FirstAncestorOrSelf<VariableDeclaratorSyntax>();
Symbols\StaticAbstractMembersInInterfacesTests.cs (5)
19565var declaredSymbol = model.GetDeclaredSymbol(node.FirstAncestorOrSelf<OperatorDeclarationSyntax>()); 19648var declaredSymbol = model.GetDeclaredSymbol(node.FirstAncestorOrSelf<OperatorDeclarationSyntax>()); 19740var declaredSymbol = model.GetDeclaredSymbol(node.FirstAncestorOrSelf<OperatorDeclarationSyntax>()); 19829var declaredSymbol = model.GetDeclaredSymbol(node.FirstAncestorOrSelf<OperatorDeclarationSyntax>()); 28778var declaredSymbol = model.GetDeclaredSymbol(node.FirstAncestorOrSelf<ConversionOperatorDeclarationSyntax>());
Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests (17)
Syntax\SyntaxNodeTests.cs (17)
124var firstParens = e.FirstAncestorOrSelf<ExpressionSyntax>(n => n.Kind() == SyntaxKind.ParenthesizedExpression); 2479var b = expr.DescendantTokens().Where(t => t.Text == "b").Select(t => t.Parent.FirstAncestorOrSelf<ArgumentSyntax>()).FirstOrDefault(); 2494var b = expr.DescendantTokens().Where(t => t.Text == "b").Select(t => t.Parent.FirstAncestorOrSelf<ArgumentSyntax>()).FirstOrDefault(); 2510var b = expr.DescendantTokens().Where(t => t.Text == "b").Select(t => t.Parent.FirstAncestorOrSelf<ArgumentSyntax>()).FirstOrDefault(); 2527var b = expr.DescendantTokens().Where(t => t.Text == "b").Select(t => t.Parent.FirstAncestorOrSelf<ArgumentSyntax>()).FirstOrDefault(); 2548var b = expr.DescendantTokens().Where(t => t.Text == "b").Select(t => t.Parent.FirstAncestorOrSelf<ArgumentSyntax>()).FirstOrDefault(); 2567var b = expr.DescendantTokens().Where(t => t.Text == "b").Select(t => t.Parent.FirstAncestorOrSelf<ArgumentSyntax>()).FirstOrDefault(); 2583var b = expr.DescendantTokens().Where(t => t.Text == "b").Select(t => t.Parent.FirstAncestorOrSelf<ArgumentSyntax>()).FirstOrDefault(); 2599var b = expr.DescendantTokens().Where(t => t.Text == "b").Select(t => t.Parent.FirstAncestorOrSelf<ArgumentSyntax>()).FirstOrDefault(); 2615var b = expr.DescendantTokens().Where(t => t.Text == "b").Select(t => t.Parent.FirstAncestorOrSelf<ArgumentSyntax>()).FirstOrDefault(); 2635var b = expr.DescendantTokens().Where(t => t.Text == "b").Select(t => t.Parent.FirstAncestorOrSelf<ArgumentSyntax>()).FirstOrDefault(); 2652var n = expr.DescendantTokens().Where(t => t.Text == "a").Select(t => t.Parent.FirstAncestorOrSelf<ArgumentSyntax>()).FirstOrDefault(); 2666var n = expr.DescendantTokens().Where(t => t.Text == "a").Select(t => t.Parent.FirstAncestorOrSelf<ArgumentSyntax>()).FirstOrDefault(); 2680var n = expr.DescendantTokens().Where(t => t.Text == "c").Select(t => t.Parent.FirstAncestorOrSelf<ArgumentSyntax>()).FirstOrDefault(); 2694var b = expr.DescendantTokens().Where(t => t.Text == "b").Select(t => t.Parent.FirstAncestorOrSelf<StatementSyntax>()).FirstOrDefault(); 2708var b = expr.DescendantTokens().Where(t => t.Text == "b").Select(t => t.Parent.FirstAncestorOrSelf<StatementSyntax>()).FirstOrDefault(); 3845var firstParens = e.FirstAncestorOrSelf<ExpressionSyntax>(n => n.Kind() == SyntaxKind.ParenthesizedExpression);
Microsoft.CodeAnalysis.CSharp.Workspaces (12)
Classification\ClassificationHelpers.cs (1)
469var fromClause = token.Parent.FirstAncestorOrSelf<FromClauseSyntax>();
Rename\CSharpRenameRewriterLanguageService.cs (1)
755var enclosingMemberDeclaration = expression.FirstAncestorOrSelf<MemberDeclarationSyntax>();
Simplification\CSharpSimplificationService.Expander.cs (1)
139var parentLambda = node.FirstAncestorOrSelf<LambdaExpressionSyntax>();
Simplification\Reducers\CSharpMiscellaneousReducer.cs (1)
48var oldLambda = parameterSyntax.FirstAncestorOrSelf<ParenthesizedLambdaExpressionSyntax>();
Simplification\Simplifiers\AbstractCSharpSimplifier.cs (1)
385var nameOfInvocationExpr = expression.FirstAncestorOrSelf<InvocationExpressionSyntax>(
Simplification\Simplifiers\ExpressionSimplifier.cs (1)
369var ancestorInvocation = memberAccess.FirstAncestorOrSelf<InvocationExpressionSyntax>();
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\ExpressionSyntaxExtensions.cs (1)
905=> expression.FirstAncestorOrSelf<XmlCrefAttributeSyntax>() != null;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\ILocalSymbolExtensions.cs (1)
18var localFunctionStatement = destinationBlock.FirstAncestorOrSelf<LocalFunctionStatementSyntax>();
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\FormattingRangeHelper.cs (1)
447return token.Parent.FirstAncestorOrSelf<MemberDeclarationSyntax>();
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\TypeStyle\CSharpTypeStyleHelper.cs (1)
62if (typeName?.FirstAncestorOrSelf<SyntaxNode>(a => a.Kind() is SyntaxKind.DeclarationExpression or SyntaxKind.VariableDeclaration or SyntaxKind.ForEachStatement) is not { } declaration)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpTypeInferenceService.TypeInferrer.cs (2)
1971var declaration = yieldStatement.FirstAncestorOrSelf<SyntaxNode>(n => n.IsReturnableConstruct()); 2012var ancestor = returnStatement.FirstAncestorOrSelf<SyntaxNode>(n => n.IsReturnableConstruct());
Microsoft.CodeAnalysis.EditorFeatures (1)
InlineRename\AbstractEditorInlineRenameService.cs (1)
58var targetNode = containingNode.FirstAncestorOrSelf<T>() ?? containingNode;
Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities (1)
Structure\AbstractSyntaxNodeStructureProviderTests.cs (1)
27var node = token.Parent.FirstAncestorOrSelf<TSyntaxNode>();
Microsoft.CodeAnalysis.EditorFeatures.UnitTests (2)
CodeGeneration\CodeGenerationTests.cs (2)
556var declarationNode = taggedNode.FirstAncestorOrSelf<T>(); 576var declarationNode = testContext.GetDestinationNode().FirstAncestorOrSelf<T>();
Microsoft.CodeAnalysis.Features (22)
AddDebuggerDisplay\AbstractAddDebuggerDisplayCodeRefactoringProvider.cs (1)
91var typeDecl = method.FirstAncestorOrSelf<TTypeDeclarationSyntax>();
ExtractMethod\MethodExtractor.VariableSymbol.cs (1)
281var declStatement = identifier.Parent.FirstAncestorOrSelf<T>();
InitializeParameter\AbstractAddParameterCheckCodeRefactoringProvider.cs (1)
139var functionDeclaration = firstParameterNode.FirstAncestorOrSelf<SyntaxNode>(IsFunctionDeclaration);
InitializeParameter\AbstractInitializeParameterCodeRefactoringProvider.cs (1)
71var functionDeclaration = selectedParameter.FirstAncestorOrSelf<SyntaxNode>(IsFunctionDeclaration);
MoveToNamespace\AbstractMoveToNamespaceService.cs (3)
94var declarationSyntax = node.FirstAncestorOrSelf<TNamespaceDeclarationSyntax>(); 159=> namedTypeSyntax.FirstAncestorOrSelf<TNamespaceDeclarationSyntax>(); 267syntaxNode ??= container.FirstAncestorOrSelf<TNamespaceDeclarationSyntax>() ?? syntaxRoot;
Snippets\SnippetProviders\AbstractConsoleSnippetProvider.cs (1)
96var nearestExpression = closestNode.FirstAncestorOrSelf<TExpressionSyntax>(static exp => exp.Parent is TExpressionStatementSyntax or TLambdaExpressionSyntax);
Snippets\SnippetProviders\AbstractInlineStatementSnippetProvider.cs (1)
77return closestNode.FirstAncestorOrSelf<TStatementSyntax>();
SplitOrMergeIfStatements\AbstractMergeIfStatementsCodeRefactoringProvider.cs (1)
83return innerMatch?.FirstAncestorOrSelf<SyntaxNode>(
src\Analyzers\Core\Analyzers\NewLines\ConsecutiveStatementPlacement\AbstractConsecutiveStatementPlacementDiagnosticAnalyzer.cs (1)
85var nextTokenContainingStatement = nextToken.Parent?.FirstAncestorOrSelf<TExecutableStatementSyntax>();
src\Analyzers\Core\Analyzers\UseAutoProperty\AbstractUseAutoPropertyAnalyzer.cs (1)
638=> nodes.Where(n => n.FirstAncestorOrSelf<TConstructorDeclaration>() is null);
src\Analyzers\Core\Analyzers\UseCollectionInitializer\AbstractObjectCreationExpressionAnalyzer.cs (1)
103var statement = rootExpression.FirstAncestorOrSelf<TStatementSyntax>()!;
src\Analyzers\Core\Analyzers\UseCollectionInitializer\AbstractUseCollectionInitializerDiagnosticAnalyzer.cs (1)
158var containingStatement = objectCreationExpression.FirstAncestorOrSelf<TStatementSyntax>();
src\Analyzers\Core\Analyzers\UseCollectionInitializer\UpdateExpressionState.cs (1)
68ContainingStatement = startExpression.FirstAncestorOrSelf<TStatementSyntax>()!;
src\Analyzers\Core\Analyzers\UseObjectInitializer\AbstractUseObjectInitializerDiagnosticAnalyzer.cs (1)
112var containingStatement = objectCreationExpression.FirstAncestorOrSelf<TStatementSyntax>();
src\Analyzers\Core\CodeFixes\DocumentationComments\AbstractRemoveDocCommentNodeCodeFixProvider.cs (1)
56return paramNode.FirstAncestorOrSelf<TXmlElementSyntax>();
src\Analyzers\Core\CodeFixes\MakeFieldReadonly\AbstractMakeFieldReadonlyCodeFixProvider.cs (1)
60var declaratorsByField = declarators.GroupBy(g => g.FirstAncestorOrSelf<TFieldDeclarationSyntax>()!);
src\Analyzers\Core\CodeFixes\RemoveUnusedParametersAndValues\AbstractRemoveUnusedValuesCodeFixProvider.cs (3)
402var expressionStatement = root.FindNode(diagnostic.Location.SourceSpan).FirstAncestorOrSelf<TExpressionStatementSyntax>(); 496var variableDeclarator = node.FirstAncestorOrSelf<TVariableDeclaratorSyntax>(); 695var insertionNode = node.FirstAncestorOrSelf<SyntaxNode>(
src\Analyzers\Core\CodeFixes\UseObjectInitializer\AbstractUseObjectInitializerCodeFixProvider.cs (1)
76var statement = objectCreation.FirstAncestorOrSelf<TStatementSyntax>();
Microsoft.CodeAnalysis.Test.Utilities (1)
MarkedSource\SourceWithMarkedNodes.cs (1)
128var nodeOfKind = node.FirstAncestorOrSelf<SyntaxNode>(n => n.RawKind == marker.SyntaxKind);
Microsoft.CodeAnalysis.VisualBasic (2)
Compilation\SemanticModel.vb (1)
3564Dim fieldDecl = declaringSyntax.FirstAncestorOrSelf(Of FieldDeclarationSyntax)()
Symbols\Symbol.vb (1)
375Dim node As VisualBasicSyntaxNode = token.Parent.FirstAncestorOrSelf(Of TNode)()
Microsoft.CodeAnalysis.VisualBasic.CodeStyle (9)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Extensions\ExpressionSyntaxExtensions.vb (1)
520Dim nextStatement = expression.FirstAncestorOrSelf(Of NextStatementSyntax)()
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Extensions\ParenthesizedExpressionSyntaxExtensions.vb (4)
14Dim query = token.Parent.FirstAncestorOrSelf(Of QueryExpressionSyntax)() 18Dim invocationAtLast = token.Parent.FirstAncestorOrSelf(Of InvocationExpressionSyntax)() 29Dim variableDeclarator = token.Parent.FirstAncestorOrSelf(Of VariableDeclaratorSyntax)() 35Dim lambda = token.Parent.FirstAncestorOrSelf(Of SingleLineLambdaExpressionSyntax)()
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Extensions\StatementSyntaxExtensions.vb (1)
731Return nextToken.Parent.FirstAncestorOrSelf(Of StatementSyntax)()
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Extensions\SyntaxTreeExtensions.vb (1)
361Dim statement = token.Parent.FirstAncestorOrSelf(Of StatementSyntax)()
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Services\SemanticFacts\VisualBasicSemanticFacts.vb (1)
272Return node.FirstAncestorOrSelf(Of NameOfExpressionSyntax) IsNot Nothing
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Utilities\CastAnalyzer.vb (1)
162Dim parentStatement = parentExpression.FirstAncestorOrSelf(Of ExecutableStatementSyntax)()
Microsoft.CodeAnalysis.VisualBasic.CodeStyle.Fixes (8)
src\Analyzers\VisualBasic\CodeFixes\UseCollectionInitializer\VisualBasicUseCollectionInitializerCodeFixProvider.vb (1)
51Dim statement = objectCreation.FirstAncestorOrSelf(Of StatementSyntax)
src\Analyzers\VisualBasic\CodeFixes\UseConditionalExpression\MultiLineConditionalExpressionFormattingRule.vb (1)
58Dim statement = conditional.FirstAncestorOrSelf(Of StatementSyntax)()
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\Extensions\ContextQuery\SyntaxTreeExtensions.vb (3)
722If targetToken.Parent.FirstAncestorOrSelf(Of AggregateClauseSyntax)() Is Nothing AndAlso 723targetToken.Parent.FirstAncestorOrSelf(Of GroupByClauseSyntax)() Is Nothing AndAlso 724targetToken.Parent.FirstAncestorOrSelf(Of GroupJoinClauseSyntax)() Is Nothing Then
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\Extensions\ExpressionSyntaxExtensions.vb (2)
192Dim statement = expression.FirstAncestorOrSelf(Of StatementSyntax)() 247Dim crefAttribute = expression.FirstAncestorOrSelf(Of XmlCrefAttributeSyntax)()
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\Extensions\ParameterSyntaxExtensions.vb (1)
20Dim oldLambda = parameter.FirstAncestorOrSelf(Of LambdaExpressionSyntax)()
Microsoft.CodeAnalysis.VisualBasic.EditorFeatures (1)
EndConstructGeneration\EndConstructStatementVisitor_Properties.vb (1)
16Dim interfaceBlock = node.FirstAncestorOrSelf(Of InterfaceBlockSyntax)()
Microsoft.CodeAnalysis.VisualBasic.Features (10)
CodeFixes\CorrectNextControlVariable\CorrectNextControlVariableCodeFixProvider.vb (1)
40Dim nextStatement = node.FirstAncestorOrSelf(Of NextStatementSyntax)()
Completion\CompletionProviders\CrefCompletionProvider.vb (1)
125token.Parent?.FirstAncestorOrSelf(Of XmlCrefAttributeSyntax)() IsNot Nothing
EditAndContinue\VisualBasicEditAndContinueAnalyzer.vb (2)
482Return node.Parent.FirstAncestorOrSelf(Of TypeBlockSyntax)() ' TODO: EnbumBlock? 1008Return node.FirstAncestorOrSelf(Of QueryExpressionSyntax)
ExtractMethod\Extensions.vb (2)
118Dim argument = node.FirstAncestorOrSelf(Of ArgumentSyntax)() 126Dim invocation = argument.FirstAncestorOrSelf(Of InvocationExpressionSyntax)()
MetadataAsSource\VisualBasicMetadataAsSourceService.vb (2)
94Dim member1 = token1.Parent.FirstAncestorOrSelf(Of DeclarationStatementSyntax)() 95Dim member2 = token2.Parent.FirstAncestorOrSelf(Of DeclarationStatementSyntax)()
src\Analyzers\VisualBasic\CodeFixes\UseCollectionInitializer\VisualBasicUseCollectionInitializerCodeFixProvider.vb (1)
51Dim statement = objectCreation.FirstAncestorOrSelf(Of StatementSyntax)
src\Analyzers\VisualBasic\CodeFixes\UseConditionalExpression\MultiLineConditionalExpressionFormattingRule.vb (1)
58Dim statement = conditional.FirstAncestorOrSelf(Of StatementSyntax)()
Microsoft.CodeAnalysis.VisualBasic.Semantic.UnitTests (6)
DeclaringSyntaxNodeTests.vb (3)
107Dim node = token.Parent.FirstAncestorOrSelf(Of TNode)() 121Dim node = token.Parent.FirstAncestorOrSelf(Of TNode)() 131Dim node = tree.GetCompilationUnitRoot().FindToken(position).Parent.FirstAncestorOrSelf(Of TNode)()
Diagnostics\GetDiagnosticsTests.vb (3)
657Dim propertyBlock = node.FirstAncestorOrSelf(Of PropertyBlockSyntax) 661Dim eventBlock = node.FirstAncestorOrSelf(Of EventBlockSyntax) 665Dim methodBlock = node.FirstAncestorOrSelf(Of MethodBlockBaseSyntax)
Microsoft.CodeAnalysis.VisualBasic.Symbol.UnitTests (12)
SymbolsTests\AnonymousTypes\AnonymousTypesSemanticsTests.vb (12)
109Dim declaratorQ = tree.GetRoot().FindToken(posQ).Parent.FirstAncestorOrSelf(Of VariableDeclaratorSyntax)() 116Dim declaratorX = tree.GetRoot().FindToken(posX).Parent.FirstAncestorOrSelf(Of VariableDeclaratorSyntax)() 123Dim declaratorZ = tree.GetRoot().FindToken(posZ).Parent.FirstAncestorOrSelf(Of VariableDeclaratorSyntax)() 245Dim declaratorW = tree.GetRoot().FindToken(posW).Parent.FirstAncestorOrSelf(Of VariableDeclaratorSyntax)() 250Dim declaratorZF = tree.GetRoot().FindToken(posZF).Parent.FirstAncestorOrSelf(Of VariableDeclaratorSyntax)() 260Dim declaratorZL = tree.GetRoot().FindToken(posZL).Parent.FirstAncestorOrSelf(Of VariableDeclaratorSyntax)() 316Dim declaratorT = tree.GetRoot().FindToken(posT).Parent.FirstAncestorOrSelf(Of VariableDeclaratorSyntax)() 321Dim declaratorA = tree.GetRoot().FindToken(posA).Parent.FirstAncestorOrSelf(Of VariableDeclaratorSyntax)() 331Dim declaratorB = tree.GetRoot().FindToken(posB).Parent.FirstAncestorOrSelf(Of VariableDeclaratorSyntax)() 383Dim declaratorT = tree.GetRoot().FindToken(posT).Parent.FirstAncestorOrSelf(Of VariableDeclaratorSyntax)() 388Dim declaratorA = tree.GetRoot().FindToken(posA).Parent.FirstAncestorOrSelf(Of VariableDeclaratorSyntax)() 398Dim declaratorB = tree.GetRoot().FindToken(posB).Parent.FirstAncestorOrSelf(Of VariableDeclaratorSyntax)()
Microsoft.CodeAnalysis.VisualBasic.Workspaces (18)
Recommendations\VisualBasicRecommendationServiceRunner.vb (2)
436token.Parent?.FirstAncestorOrSelf(Of InheritsStatementSyntax) IsNot Nothing 445token.Parent?.FirstAncestorOrSelf(Of ImplementsStatementSyntax) IsNot Nothing
Simplification\Simplifiers\AbstractVisualBasicSimplifier.vb (1)
190Dim nameOfExpression = expr.FirstAncestorOrSelf(Of NameOfExpressionSyntax)()
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Extensions\ExpressionSyntaxExtensions.vb (1)
520Dim nextStatement = expression.FirstAncestorOrSelf(Of NextStatementSyntax)()
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Extensions\ParenthesizedExpressionSyntaxExtensions.vb (4)
14Dim query = token.Parent.FirstAncestorOrSelf(Of QueryExpressionSyntax)() 18Dim invocationAtLast = token.Parent.FirstAncestorOrSelf(Of InvocationExpressionSyntax)() 29Dim variableDeclarator = token.Parent.FirstAncestorOrSelf(Of VariableDeclaratorSyntax)() 35Dim lambda = token.Parent.FirstAncestorOrSelf(Of SingleLineLambdaExpressionSyntax)()
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Extensions\StatementSyntaxExtensions.vb (1)
731Return nextToken.Parent.FirstAncestorOrSelf(Of StatementSyntax)()
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Extensions\SyntaxTreeExtensions.vb (1)
361Dim statement = token.Parent.FirstAncestorOrSelf(Of StatementSyntax)()
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Services\SemanticFacts\VisualBasicSemanticFacts.vb (1)
272Return node.FirstAncestorOrSelf(Of NameOfExpressionSyntax) IsNot Nothing
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Utilities\CastAnalyzer.vb (1)
162Dim parentStatement = parentExpression.FirstAncestorOrSelf(Of ExecutableStatementSyntax)()
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\Extensions\ContextQuery\SyntaxTreeExtensions.vb (3)
722If targetToken.Parent.FirstAncestorOrSelf(Of AggregateClauseSyntax)() Is Nothing AndAlso 723targetToken.Parent.FirstAncestorOrSelf(Of GroupByClauseSyntax)() Is Nothing AndAlso 724targetToken.Parent.FirstAncestorOrSelf(Of GroupJoinClauseSyntax)() Is Nothing Then
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\Extensions\ExpressionSyntaxExtensions.vb (2)
192Dim statement = expression.FirstAncestorOrSelf(Of StatementSyntax)() 247Dim crefAttribute = expression.FirstAncestorOrSelf(Of XmlCrefAttributeSyntax)()
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\Extensions\ParameterSyntaxExtensions.vb (1)
20Dim oldLambda = parameter.FirstAncestorOrSelf(Of LambdaExpressionSyntax)()
Microsoft.CodeAnalysis.Workspaces (3)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SyntaxNodeExtensions.cs (1)
202=> nodes.FindInnermostCommonNode()?.FirstAncestorOrSelf(predicate);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SyntaxTokenExtensions.cs (1)
19=> token.Parent?.FirstAncestorOrSelf(predicate);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Helpers\RemoveUnnecessaryImports\AbstractUnnecessaryImportsProvider.cs (1)
33if (node.FirstAncestorOrSelf<TSyntaxNode>() is null)
Microsoft.Interop.LibraryImportGenerator (1)
Analyzers\ConvertToLibraryImportFixer.cs (1)
344LocalDeclarationStatementSyntax declaration = invocation.FirstAncestorOrSelf<LocalDeclarationStatementSyntax>();
Microsoft.Interop.SourceGeneration (1)
ContainingSyntaxContext.cs (1)
69for (SyntaxNode? parent = memberDeclaration.FirstAncestorOrSelf<BaseNamespaceDeclarationSyntax>(); parent is BaseNamespaceDeclarationSyntax ns; parent = parent.Parent)
Microsoft.ML.InternalCodeAnalyzer (1)
ContractsCheckNameofFixProvider.cs (1)
44var nameArg = root.FindToken(diagnosticSpan.Start).Parent.FirstAncestorOrSelf<ArgumentSyntax>();
Microsoft.VisualStudio.LanguageServices.CSharp (10)
CodeModel\CSharpCodeModelService.cs (8)
115return node.FirstAncestorOrSelf<BaseFieldDeclarationSyntax>() != null; 571var baseFieldDeclaration = node.FirstAncestorOrSelf<BaseFieldDeclarationSyntax>(); 624var eventFieldDeclaration = node.FirstAncestorOrSelf<EventFieldDeclarationSyntax>(); 2423var containingType = member.FirstAncestorOrSelf<TypeDeclarationSyntax>(); 2750var fieldDeclaration = node.FirstAncestorOrSelf<BaseFieldDeclarationSyntax>(); 2790var attributeList = node.FirstAncestorOrSelf<AttributeListSyntax>(); 2817var argumentList = node.FirstAncestorOrSelf<AttributeArgumentListSyntax>(); 2827var parameterList = node.FirstAncestorOrSelf<ParameterListSyntax>();
CodeModel\CSharpCodeModelService.NodeLocator.cs (2)
680var field = node.FirstAncestorOrSelf<BaseFieldDeclarationSyntax>(); 1260var field = node.FirstAncestorOrSelf<BaseFieldDeclarationSyntax>();
Microsoft.VisualStudio.LanguageServices.VisualBasic (18)
CodeModel\VisualBasicCodeModelService.NodeLocator.vb (6)
473Dim propertyBlock = methodBlock.FirstAncestorOrSelf(Of PropertyBlockSyntax)() 483Dim eventBlock = methodBlock.FirstAncestorOrSelf(Of EventBlockSyntax)() 633Dim propertyBlock = methodBlock.FirstAncestorOrSelf(Of PropertyBlockSyntax)() 643Dim eventBlock = methodBlock.FirstAncestorOrSelf(Of EventBlockSyntax)() 1070Dim fieldDeclaration = variable.FirstAncestorOrSelf(Of FieldDeclarationSyntax)() 1127Dim fieldDeclaration = variable.FirstAncestorOrSelf(Of FieldDeclarationSyntax)()
CodeModel\VisualBasicCodeModelService.vb (12)
131Return node.FirstAncestorOrSelf(Of AttributeSyntax) IsNot Nothing 134Return node.FirstAncestorOrSelf(Of FieldDeclarationSyntax)() IsNot Nothing 138Return node.FirstAncestorOrSelf(Of EventBlockSyntax)() Is Nothing 142Return node.FirstAncestorOrSelf(Of PropertyBlockSyntax)() Is Nothing 146Return node.FirstAncestorOrSelf(Of MethodBlockSyntax)() Is Nothing 191node.FirstAncestorOrSelf(Of MethodBlockSyntax)() Is Nothing Then 1324Dim declarator = node.FirstAncestorOrSelf(Of VariableDeclaratorSyntax)() 1337Dim declaration = node.FirstAncestorOrSelf(Of FieldDeclarationSyntax)() 1350Dim attributeList = node.FirstAncestorOrSelf(Of AttributeListSyntax)() 1371Dim argumentList = node.FirstAncestorOrSelf(Of ArgumentListSyntax)() 1378Dim parameterList = node.FirstAncestorOrSelf(Of ParameterListSyntax)() 3714variableNode.FirstAncestorOrSelf(Of FieldDeclarationSyntax)(),