Skip to main content

SyntaxExtensions.FirstAncestor<TNode>(SyntaxNode, Func<TNode, Boolean>, Boolean) Method

Containing Type: SyntaxExtensions

Assembly: Roslynator.Core.dll

Returns the first node of type TNode that matches the predicate.

public static TNode? FirstAncestor<TNode>(this Microsoft.CodeAnalysis.SyntaxNode node, Func<TNode, bool>? predicate = null, bool ascendOutOfTrivia = true) where TNode : Microsoft.CodeAnalysis.SyntaxNode

Type Parameters

TNode

Parameters

node SyntaxNode

predicate Func<TNode, Boolean>

ascendOutOfTrivia Boolean

Returns

TNode