Skip to main content

SyntaxExtensions.FirstAncestorOrSelf Method

Containing Type: SyntaxExtensions

Assembly: Roslynator.CSharp.dll

Overloads

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

FirstAncestorOrSelf(SyntaxNode, Func<SyntaxNode, Boolean>, Boolean)

Gets the first ancestor that matches the predicate.

public static Microsoft.CodeAnalysis.SyntaxNode? FirstAncestorOrSelf(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

FirstAncestorOrSelf(SyntaxNode, SyntaxKind, Boolean)

Gets the first ancestor of the specified kind.

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

Parameters

node SyntaxNode

kind SyntaxKind

ascendOutOfTrivia Boolean

Returns

SyntaxNode

FirstAncestorOrSelf(SyntaxNode, SyntaxKind, SyntaxKind, Boolean)

Gets the first ancestor of the specified kinds.

public static Microsoft.CodeAnalysis.SyntaxNode? FirstAncestorOrSelf(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

FirstAncestorOrSelf(SyntaxNode, SyntaxKind, SyntaxKind, SyntaxKind, Boolean)

Gets the first ancestor of the specified kinds.

public static Microsoft.CodeAnalysis.SyntaxNode? FirstAncestorOrSelf(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