69 references to Ancestors
Microsoft.Analyzers.Local (2)
InternalReferencedInPublicDocAnalyzer.cs (2)
26var documentationComment = crefNode.Ancestors(ascendOutOfTrivia: false).OfType<DocumentationCommentTriviaSyntax>().FirstOrDefault(); 34var symbolNode = crefNode.Ancestors().OfType<MemberDeclarationSyntax>().FirstOrDefault();
Microsoft.CodeAnalysis.CodeStyle (4)
src\Analyzers\Core\Analyzers\MatchFolderAndNamespace\AbstractMatchFolderAndNamespaceDiagnosticAnalyzer.cs (1)
98if (namespaceDeclaration.Ancestors().OfType<TNamespaceSyntax>().Any())
src\Analyzers\Core\Analyzers\UseAutoProperty\AbstractUseAutoPropertyAnalyzer.cs (3)
552if (!ineligibleFieldUsages.All(loc => loc.Ancestors().Contains(result.PropertyDeclaration))) 572NonConstructorLocations(writeLocations1).Any(loc => !loc.Ancestors().Contains(result.PropertyDeclaration))) 585NonConstructorLocations(writeLocations2).Any(loc => !loc.Ancestors().Contains(result.PropertyDeclaration)))
Microsoft.CodeAnalysis.CodeStyle.Fixes (2)
src\Analyzers\Core\CodeFixes\GenerateMember\AbstractGenerateMemberService.cs (1)
160var propertyPatternClause = expression.Ancestors().FirstOrDefault(syntaxFacts.IsPropertyPatternClause);
src\Analyzers\Core\CodeFixes\GenerateVariable\AbstractGenerateVariableService.State.cs (1)
338var assignmentStatement = simpleName.Ancestors().FirstOrDefault(syntaxFacts.IsSimpleAssignmentStatement);
Microsoft.CodeAnalysis.CSharp (1)
Symbols\Source\SourceLocalSymbol.cs (1)
175Contains(nodeToBind.Ancestors().OfType<StatementSyntax>().First().Kind()) ||
Microsoft.CodeAnalysis.CSharp.CodeStyle (3)
src\Analyzers\CSharp\Analyzers\UsePatternMatching\CSharpAsAndNullCheckDiagnosticAnalyzer.Analyzer.cs (1)
98foreach (var current in _comparison.Ancestors())
src\Analyzers\CSharp\Analyzers\UseUtf8StringLiteral\UseUtf8StringLiteralDiagnosticAnalyzer.cs (1)
82if (arrayCreationOperation.Syntax.Ancestors().OfType<AttributeSyntax>().Any())
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\ElasticTriviaFormattingRule.cs (1)
121if (previousToken.Parent.Ancestors().OfType<TypeParameterConstraintClauseSyntax>().Any())
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (10)
Semantics\OutVarTests.cs (8)
1078var typeofExpression = decl.Ancestors().OfType<TypeOfExpressionSyntax>().FirstOrDefault(); 1277if ((forStatement = decl.Ancestors().OfType<ForStatementSyntax>().FirstOrDefault()) != null && 1284var containingStatement = decl.Ancestors().OfType<StatementSyntax>().FirstOrDefault(); 1302reference.Ancestors().OfType<DoStatementSyntax>().Join( 1303decl.Ancestors().OfType<DoStatementSyntax>(), d => d, d => d, (d1, d2) => true).Any()))) 20954Assert.True(decl.Ancestors().OfType<VariableDeclaratorSyntax>().First().ArgumentList.Contains(decl)); 32707var declarator = decl.Ancestors().OfType<VariableDeclaratorSyntax>().FirstOrDefault(); 35616var statementBefore = identifierBefore.Ancestors().OfType<StatementSyntax>().First();
Semantics\PatternMatchingTestBase.cs (2)
291var declarator = designation.Ancestors().OfType<VariableDeclaratorSyntax>().FirstOrDefault(); 350Assert.True(decl.Ancestors().OfType<VariableDeclaratorSyntax>().First().ArgumentList.Contains(decl));
Microsoft.CodeAnalysis.CSharp.Features (5)
CodeRefactorings\AddAwait\CSharpAddAwaitCodeRefactoringProvider.cs (1)
32foreach (var current in node.Ancestors())
Debugging\CSharpProximityExpressionsService.Worker.cs (1)
220var statementAncestor = _parentStatement.Ancestors().OfType<StatementSyntax>().FirstOrDefault(node => !node.IsKind(SyntaxKind.Block));
IntroduceVariable\CSharpIntroduceVariableService_IntroduceLocal.cs (1)
35var containerToGenerateInto = expression.Ancestors().FirstOrDefault(s =>
src\Analyzers\CSharp\Analyzers\UsePatternMatching\CSharpAsAndNullCheckDiagnosticAnalyzer.Analyzer.cs (1)
98foreach (var current in _comparison.Ancestors())
src\Analyzers\CSharp\Analyzers\UseUtf8StringLiteral\UseUtf8StringLiteralDiagnosticAnalyzer.cs (1)
82if (arrayCreationOperation.Syntax.Ancestors().OfType<AttributeSyntax>().Any())
Microsoft.CodeAnalysis.CSharp.IOperation.UnitTests (1)
IOperation\IOperationTests.cs (1)
589var methodDeclSyntax = literal.Ancestors().OfType<MethodDeclarationSyntax>().Single();
Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests (12)
Semantics\LambdaTests.cs (3)
6511.Where(i => i.Ancestors().Any(a => a.IsKind(SyntaxKind.Attribute) || a.IsKind(SyntaxKind.DefaultExpression) || a.IsKind(SyntaxKind.InvocationExpression))) 6821.Where(i => i.Ancestors().Any(a => a.IsKind(SyntaxKind.InvocationExpression))) 6850.Where(i => i.Ancestors().Any(a => a.IsKind(SyntaxKind.InvocationExpression)))
Semantics\LocalFunctionTests.cs (4)
7641.Where(i => i.Ancestors().Any(a => a.Kind() is SyntaxKind.Attribute or SyntaxKind.TypeConstraint or SyntaxKind.DefaultExpression or SyntaxKind.InvocationExpression or SyntaxKind.EqualsValueClause)) 8686.Where(i => i.Ancestors().Any(a => a.IsKind(SyntaxKind.Attribute) || a.IsKind(SyntaxKind.TypeConstraint) || a.IsKind(SyntaxKind.DefaultExpression) || a.IsKind(SyntaxKind.InvocationExpression))) 9554.Where(i => i.Ancestors().Any(a => a.IsKind(SyntaxKind.Attribute))) 10174.Where(i => i.Ancestors().Any(a => a.IsKind(SyntaxKind.Attribute)))
Semantics\TopLevelStatementsTests.cs (4)
497Assert.DoesNotContain(declSymbol, model1.AnalyzeDataFlow(localDecl.Ancestors().OfType<StatementSyntax>().First()).DataFlowsOut); 589Assert.Contains(declSymbol, model1.AnalyzeDataFlow(localDecl.Ancestors().OfType<StatementSyntax>().First()).DataFlowsOut); 2925model1.GetDiagnostics(nameRef.Ancestors().OfType<StatementSyntax>().First().Span).Verify( 2947model2.GetDiagnostics(nameRef.Ancestors().OfType<StatementSyntax>().First().Span).Verify(
Semantics\UnsafeTests.cs (1)
7274var declaredSymbol = model.GetDeclaredSymbol(syntax.Ancestors().OfType<VariableDeclaratorSyntax>().First());
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (1)
DocumentationComments\CrefTests.cs (1)
4559Assert.Equal(SyntaxKind.EndOfFileToken, crefSyntax.Ancestors().First(n => n.IsStructuredTrivia).ParentTrivia.Token.Kind());
Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests (1)
Syntax\SyntaxNodeTests.cs (1)
87var nodes = e.Ancestors().ToList();
Microsoft.CodeAnalysis.CSharp.Test.Utilities (1)
CompilationTestUtils.cs (1)
464var annotationsByMethod = allAnnotations.GroupBy(annotation => annotation.Expression.Ancestors().OfType<BaseMethodDeclarationSyntax>().First()).ToArray();
Microsoft.CodeAnalysis.CSharp.Workspaces (3)
Simplification\CSharpSimplificationService.Expander.cs (1)
789var invocationExpression = originalSimpleName.Ancestors().OfType<InvocationExpressionSyntax>().FirstOrDefault();
Simplification\Simplifiers\ExpressionSimplifier.cs (1)
393var constructor = memberAccess.Ancestors().OfType<ConstructorDeclarationSyntax>().SingleOrDefault();
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\ElasticTriviaFormattingRule.cs (1)
121if (previousToken.Parent.Ancestors().OfType<TypeParameterConstraintClauseSyntax>().Any())
Microsoft.CodeAnalysis.Features (9)
ConvertAutoPropertyToFullProperty\AbstractConvertAutoPropertyToFullPropertyCodeRefactoringProvider.cs (1)
112if (property.Ancestors().Contains(typeBlock))
InitializeParameter\AbstractInitializeMemberFromParameterCodeRefactoringProviderMemberCreation.cs (1)
556if (symbolSyntax.Ancestors().Contains(typeDeclaration))
InvertIf\AbstractInvertIfCodeRefactoringProvider.cs (2)
363foreach (var node in ifNode.Ancestors()) 404foreach (var node in ifNode.Ancestors())
src\Analyzers\Core\Analyzers\MatchFolderAndNamespace\AbstractMatchFolderAndNamespaceDiagnosticAnalyzer.cs (1)
98if (namespaceDeclaration.Ancestors().OfType<TNamespaceSyntax>().Any())
src\Analyzers\Core\Analyzers\UseAutoProperty\AbstractUseAutoPropertyAnalyzer.cs (2)
572NonConstructorLocations(writeLocations1).Any(loc => !loc.Ancestors().Contains(result.PropertyDeclaration))) 585NonConstructorLocations(writeLocations2).Any(loc => !loc.Ancestors().Contains(result.PropertyDeclaration)))
src\Analyzers\Core\CodeFixes\GenerateMember\AbstractGenerateMemberService.cs (1)
160var propertyPatternClause = expression.Ancestors().FirstOrDefault(syntaxFacts.IsPropertyPatternClause);
src\Analyzers\Core\CodeFixes\GenerateVariable\AbstractGenerateVariableService.State.cs (1)
338var assignmentStatement = simpleName.Ancestors().FirstOrDefault(syntaxFacts.IsSimpleAssignmentStatement);
Microsoft.CodeAnalysis.VisualBasic.EditorFeatures (2)
LineCommit\ContainingStatementInfo.vb (1)
145For Each ancestor In node.Ancestors()
Utilities\NavigationPointHelpers.vb (1)
60Dim indents = beginStatement.Ancestors().Count() - 1
Microsoft.CodeAnalysis.VisualBasic.Features (4)
CodeRefactorings\AddAwait\VisualBasicAddAwaitCodeRefactoringProvider.vb (1)
30For Each current In node.Ancestors()
CodeRefactorings\InlineTemporary\VisualBasicInlineTemporaryCodeRefactoringProvider.vb (2)
81.Ancestors() _ 161localDeclaration.Ancestors().OfType(Of ExpressionSyntax).Last().FirstAncestorOrSelf(Of StatementSyntax)(),
Wrapping\SeparatedSyntaxList\VisualBasicArgumentWrapper.vb (1)
76If token.Parent.Ancestors().Contains(listSyntax) Then
Microsoft.CodeAnalysis.VisualBasic.Workspaces (1)
Simplification\Simplifiers\ExpressionSimplifier.vb (1)
242Dim isInCref = left.Ancestors(ascendOutOfTrivia:=True).OfType(Of CrefReferenceSyntax)().Any()
Microsoft.DotNet.CodeAnalysis (1)
Analyzers\AppContextDefaultsAnalyzer.cs (1)
80var containingIfStatement = call.Ancestors().FirstOrDefault(n => n.IsKind(SyntaxKind.IfStatement)) as IfStatementSyntax;
Microsoft.VisualStudio.LanguageServices.CSharp (1)
CodeModel\CSharpCodeModelService.cs (1)
1662var attribute = (AttributeSyntax)argument.Ancestors().First(n => n.Kind() == SyntaxKind.Attribute);
Microsoft.VisualStudio.LanguageServices.VisualBasic (1)
CodeModel\VisualBasicCodeModelService.vb (1)
1865Dim attribute = DirectCast(argument.Ancestors.FirstOrDefault(Function(n) n.Kind = SyntaxKind.Attribute), AttributeSyntax)
System.Text.RegularExpressions.Generator (3)
UpgradeToGeneratedRegexCodeFixer.cs (3)
102SyntaxNode? typeDeclarationOrCompilationUnit = nodeToFix.Ancestors().OfType<TypeDeclarationSyntax>().FirstOrDefault(); 127nodeToFix.Ancestors().OfType<TypeDeclarationSyntax>(), 148nodeToFix.Ancestors().OfType<TypeDeclarationSyntax>().FirstOrDefault() :
System.Windows.Forms.Analyzers.CSharp (1)
System\Windows\Forms\CSharp\Generators\ApplicationConfiguration\ApplicationConfigurationGenerator.cs (1)
63.Ancestors()