Skip to main content

SyntaxExtensions.FirstAncestor Method

Containing Type: SyntaxExtensions

Assembly: Roslynator.CSharp.dll

Overloads​

MethodSummary
FirstAncestor(SyntaxNode, Func<SyntaxNode, Boolean>, Boolean)Gets the first ancestor that matches the predicate.
FirstAncestor(SyntaxNode, SyntaxKind, Boolean)Gets the first ancestor of the specified kind.
FirstAncestor(SyntaxNode, SyntaxKind, SyntaxKind, Boolean)Gets the first ancestor of the specified kinds.
FirstAncestor(SyntaxNode, SyntaxKind, SyntaxKind, SyntaxKind, Boolean)Gets the first ancestor of the specified kinds.

FirstAncestor(SyntaxNode, Func<SyntaxNode, Boolean>, Boolean)​

Gets the first ancestor that matches the predicate.

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

Parameters​

node   SyntaxNode

predicate   Func<SyntaxNode, Boolean>

ascendOutOfTrivia   Boolean

Returns​

SyntaxNode

FirstAncestor(SyntaxNode, SyntaxKind, Boolean)​

Gets the first ancestor of the specified kind.

public static Microsoft.CodeAnalysis.SyntaxNode? FirstAncestor(this Microsoft.CodeAnalysis.SyntaxNode node, Microsoft.CodeAnalysis.CSharp.SyntaxKind kind, bool ascendOutOfTrivia = true)

Parameters​

node   SyntaxNode

kind   SyntaxKind

ascendOutOfTrivia   Boolean

Returns​

SyntaxNode

FirstAncestor(SyntaxNode, SyntaxKind, SyntaxKind, Boolean)​

Gets the first ancestor of the specified kinds.

public static Microsoft.CodeAnalysis.SyntaxNode? FirstAncestor(this Microsoft.CodeAnalysis.SyntaxNode node, Microsoft.CodeAnalysis.CSharp.SyntaxKind kind1, Microsoft.CodeAnalysis.CSharp.SyntaxKind kind2, bool ascendOutOfTrivia = true)

Parameters​

node   SyntaxNode

kind1   SyntaxKind

kind2   SyntaxKind

ascendOutOfTrivia   Boolean

Returns​

SyntaxNode

FirstAncestor(SyntaxNode, SyntaxKind, SyntaxKind, SyntaxKind, Boolean)​

Gets the first ancestor of the specified kinds.

public static Microsoft.CodeAnalysis.SyntaxNode? FirstAncestor(this Microsoft.CodeAnalysis.SyntaxNode node, Microsoft.CodeAnalysis.CSharp.SyntaxKind kind1, Microsoft.CodeAnalysis.CSharp.SyntaxKind kind2, Microsoft.CodeAnalysis.CSharp.SyntaxKind kind3, bool ascendOutOfTrivia = true)

Parameters​

node   SyntaxNode

kind1   SyntaxKind

kind2   SyntaxKind

kind3   SyntaxKind

ascendOutOfTrivia   Boolean

Returns​

SyntaxNode