79 references to GetAncestorOrThis
Microsoft.CodeAnalysis.CSharp.EditorFeatures (1)
Interactive\CSharpSendToInteractiveSubmissionProvider.cs (1)
93SyntaxNode? candidate = node.GetAncestorOrThis<StatementSyntax>();
Microsoft.CodeAnalysis.CSharp.Features (28)
ChangeSignature\CSharpChangeSignatureService.cs (1)
167: matchingNode.GetAncestorOrThis<InvocationExpressionSyntax>()?.ArgumentList;
Completion\KeywordRecommenders\TypeVarKeywordRecommender.cs (3)
27var type = typeParameters.GetAncestorOrThis<TypeDeclarationSyntax>(); 34var @delegate = typeParameters.GetAncestorOrThis<DelegateDeclarationSyntax>(); 40var method = typeParameters.GetAncestorOrThis<MethodDeclarationSyntax>();
Completion\KeywordRecommenders\WhereKeywordRecommender.cs (1)
48var decl = typeParameters.GetAncestorOrThis<TypeDeclarationSyntax>();
ConvertLinq\CSharpConvertLinqQueryToForEachProvider.cs (2)
389var parentStatement = invocationExpression.GetAncestorOrThis<StatementSyntax>(); 542var parentStatement = _source.GetAncestorOrThis<StatementSyntax>();
CSharpAddExplicitCastCodeFixProvider.cs (2)
79if (spanNode.GetAncestorOrThis<ArgumentSyntax>() is ArgumentSyntax targetArgument 87else if (spanNode.GetAncestorOrThis<AttributeArgumentSyntax>() is AttributeArgumentSyntax targetAttributeArgument
CSharpQualifyMemberAccessDiagnosticAnalyzer.cs (2)
32if (node.GetAncestorOrThis<AttributeSyntax>() != null) 37if (node.GetAncestorOrThis<ConstructorInitializerSyntax>() != null)
Debugging\CSharpProximityExpressionsService.Worker.cs (2)
62if (_parentStatement.GetAncestorOrThis<AccessorDeclarationSyntax>() is (kind: 75var memberDeclaration = _parentStatement.GetAncestorOrThis<MemberDeclarationSyntax>();
Debugging\LocationInfoGetter.cs (1)
62var accessor = memberDeclaration.GetAncestorOrThis<AccessorDeclarationSyntax>();
ExtractMethod\CSharpSelectionResult.ExpressionResult.cs (2)
46var scope = firstToken.GetCommonRoot(lastToken).GetAncestorOrThis<ExpressionSyntax>(); 65var variableDeclExpression = node.GetAncestorOrThis<VariableDeclarationSyntax>();
GenerateType\CSharpGenerateTypeService.cs (1)
150var usingDirectiveSyntax = simpleName.GetAncestorOrThis<UsingDirectiveSyntax>();
IntroduceVariable\CSharpIntroduceVariableService.cs (7)
49return expression.GetAncestorOrThis<VariableDeclaratorSyntax>() 50.GetAncestorOrThis<FieldDeclarationSyntax>() != null; 54=> expression.GetAncestorOrThis<EqualsValueClauseSyntax>().IsParentKind(SyntaxKind.Parameter); 57=> expression.GetAncestorOrThis<ConstructorInitializerSyntax>() != null; 60=> expression.GetAncestorOrThis<EqualsValueClauseSyntax>().IsParentKind(SyntaxKind.PropertyDeclaration); 86var attributeArgument = expression.GetAncestorOrThis<AttributeArgumentSyntax>(); 94var attributeDecl = attributeArgument.GetAncestorOrThis<AttributeListSyntax>();
IntroduceVariable\CSharpIntroduceVariableService_IntroduceField.cs (1)
28var oldTypeDeclaration = expression.GetAncestorOrThis<TypeDeclarationSyntax>();
MetadataAsSource\CSharpMetadataAsSourceService.cs (1)
134return annotatedChildren.Any(n => n.GetAncestorOrThis<AttributeSyntax>() == null);
Snippets\AbstractCSharpAutoPropertySnippetProvider.cs (1)
93return node.GetAncestorOrThis<PropertyDeclarationSyntax>();
Snippets\AbstractCSharpTypeSnippetProvider.cs (1)
87return node.GetAncestorOrThis<BaseTypeDeclarationSyntax>();
Microsoft.CodeAnalysis.CSharp.Workspaces (9)
J\s\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxNodeExtensions.cs\SyntaxNodeExtensions.cs (2)
378return node.GetAncestorOrThis<CompilationUnitSyntax>()!.Usings 386return node.GetAncestorOrThis<CompilationUnitSyntax>()!.Externs
J\s\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTreeExtensions.cs\SyntaxTreeExtensions.cs (2)
1199var method = tokenOnLeftOfPosition.Parent.GetAncestorOrThis<MethodDeclarationSyntax>(); 1200var typeDecl = method.GetAncestorOrThis<TypeDeclarationSyntax>();
LanguageServices\FixAllSpanMappingService\CSharpFixAllSpanMappingService.cs (1)
33if (node.GetAncestorOrThis<GlobalStatementSyntax>() is null)
Recommendations\CSharpRecommendationServiceRunner.cs (2)
336var declarationSyntax = name.GetAncestorOrThis<BaseNamespaceDeclarationSyntax>(); 347var usingDirective = name.GetAncestorOrThis<UsingDirectiveSyntax>();
Simplification\Simplifiers\AbstractCSharpSimplifier.cs (2)
348var usingDirective = startNode.GetAncestorOrThis<UsingDirectiveSyntax>(); 357var @namespace = startNode.GetAncestorOrThis<BaseNamespaceDeclarationSyntax>();
Microsoft.CodeAnalysis.CSharp.Workspaces.UnitTests (1)
CodeGeneration\SyntaxGeneratorTests.cs (1)
3836Generator.ReplaceNode(declC, declX.GetAncestorOrThis<VariableDeclaratorSyntax>(), SyntaxFactory.VariableDeclarator("Q")),
Microsoft.CodeAnalysis.Features (7)
ExtractMethod\SelectionResult.cs (1)
98return containingScope.GetAncestorOrThis<TNode>();
ExtractMethod\SelectionValidator.cs (2)
110var commonRoot = token1.GetCommonRoot(token2).GetAncestorOrThis<T>() ?? root; 170var commonRoot = token1.GetCommonRoot(token2).GetAncestorOrThis<T>() ?? root;
Fixer.cs (1)
211if (newRoot.FindNode(targetNode.Span).GetAncestorOrThis<TArgumentListSyntax>() is TArgumentListSyntax newArgumentList)
ImplementAbstractClass\AbstractImplementAbstractClassCodeFixProvider.cs (1)
37var classNode = token.Parent.GetAncestorOrThis<TClassNode>();
IntroduceVariable\AbstractIntroduceVariableService.State.cs (1)
292if (Expression.GetAncestorOrThis<TTypeDeclarationSyntax>() != null)
RemoveUnusedVariable\AbstractRemoveUnusedVariableCodeFixProvider.cs (1)
124var localDeclaration = node.GetAncestorOrThis<TLocalDeclarationStatement>();
Microsoft.CodeAnalysis.VisualBasic.Features (21)
ChangeSignature\VisualBasicChangeSignatureService.vb (1)
142Dim invocation = matchingNode.GetAncestorOrThis(Of InvocationExpressionSyntax)
Completion\CompletionProviders\ImportCompletionProvider\TypeImportCompletionProvider.vb (1)
54Return node.GetAncestorOrThis(Of CompilationUnitSyntax).Imports.SelectMany(Function(import) import.ImportsClauses).OfType(Of SimpleImportsClauseSyntax).ToImmutableArray()
Debugging\ProximityExpressionsGetter.Worker.vb (3)
136Dim methodBlock = Me._parentStatement.GetAncestorOrThis(Of MethodBlockBaseSyntax)() 141Dim propertyBlock = Me._parentStatement.GetAncestorOrThis(Of PropertyBlockSyntax)() 146Dim typeBlock = Me._parentStatement.GetAncestorOrThis(Of TypeBlockSyntax)()
ExtractMethod\VisualBasicSelectionResult.vb (1)
125Dim scope = first.GetCommonRoot(last).GetAncestorOrThis(Of ExpressionSyntax)()
ExtractMethod\VisualBasicSelectionValidator.vb (2)
138If commonNode.GetAncestorOrThis(Of WithBlockSyntax)() IsNot Nothing Then 195Dim expression = GetFinalTokenCommonRoot(selectionInfo).GetAncestorOrThis(Of ExpressionSyntax)()
IntroduceVariable\VisualBasicIntroduceVariableService.vb (9)
32If expression.GetAncestorOrThis(Of ArgumentSyntax)() Is Nothing Then 36If expression.GetAncestorOrThis(Of AttributeSyntax)() Is Nothing Then 45Dim attributeBlock = expression.GetAncestorOrThis(Of AttributeListSyntax)() 63If expression.GetAncestorOrThis(Of LambdaExpressionSyntax)() IsNot Nothing Then 95If expression.GetAncestorOrThis(Of VariableDeclaratorSyntax)().GetAncestorOrThis(Of FieldDeclarationSyntax)() IsNot Nothing Then 118Return expression.GetAncestorOrThis(Of EqualsValueSyntax)().IsParentKind(SyntaxKind.Parameter) 122Dim propertyStatement = expression.GetAncestorOrThis(Of PropertyStatementSyntax)() 123Dim equalsValueStatement = expression.GetAncestorOrThis(Of EqualsValueSyntax)
IntroduceVariable\VisualBasicIntroduceVariableService_IntroduceField.vb (1)
22Dim oldTypeDeclaration = expression.GetAncestorOrThis(Of TypeBlockSyntax)()
IntroduceVariable\VisualBasicIntroduceVariableService_IntroduceLocal.vb (1)
143Dim innermostStatements = New HashSet(Of StatementSyntax)(matches.Select(Function(expr) expr.GetAncestorOrThis(Of StatementSyntax)()))
VisualBasicQualifyMemberAccessDiagnosticAnalyzer.vb (1)
28If node.GetAncestorOrThis(Of AttributeSyntax) IsNot Nothing Then
VisualBasicRemoveUnnecessaryCastCodeFixProvider.vb (1)
130Dim containingStatement = n.GetAncestorOrThis(Of StatementSyntax)
Microsoft.CodeAnalysis.VisualBasic.Workspaces (7)
CompilationUnitSyntaxExtensions.vb (1)
27Dim root = contextNode.GetAncestorOrThis(Of CompilationUnitSyntax)()
J\s\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\Extensions\ExpressionSyntaxExtensions.vb\ExpressionSyntaxExtensions.vb (1)
277Dim attribute = originalName.GetAncestorOrThis(Of AttributeSyntax)()
SemanticModelExtensions.vb (1)
84From u In location.GetAncestorOrThis(Of CompilationUnitSyntax).Imports
SyntaxNodeExtensions.vb (1)
88Dim containingType = node.GetAncestorOrThis(Of TypeBlockSyntax)()
VisualBasicIndentationService.Indenter.vb (1)
224Dim containingStatement = node.GetAncestorOrThis(Of StatementSyntax)()
VisualBasicTypeInferenceService.TypeInferrer.vb (2)
732If returnStatement.GetAncestorOrThis(Of MethodBlockBaseSyntax) Is Nothing Then 763If yieldStatement.GetAncestorOrThis(Of MethodBlockBaseSyntax) Is Nothing Then
Microsoft.CodeAnalysis.VisualBasic.Workspaces.UnitTests (1)
CodeGeneration\SyntaxGeneratorTests.vb (1)
3581Generator.ReplaceNode(declC, declX.GetAncestorOrThis(Of ModifiedIdentifierSyntax), SyntaxFactory.ModifiedIdentifier("Q")),
Microsoft.CodeAnalysis.Workspaces (1)
AbstractAddImportsService.cs (1)
204(SyntaxNode?)node.GetAncestorOrThis<TCompilationUnitSyntax>();
Microsoft.VisualStudio.LanguageServices.CSharp (3)
LanguageService\CSharpHelpContextService.cs (3)
371if (token.Parent.GetAncestorOrThis<MethodDeclarationSyntax>() != null) 376else if (token.Parent.GetAncestorOrThis<TypeDeclarationSyntax>() != null) 385text = token.Parent.GetAncestorOrThis<TypeParameterConstraintClauseSyntax>() != null