Skip to main content

SyntaxNode Class Extensions

Extension MethodSummary
AppendToLeadingTrivia<TNode>(TNode, IEnumerable<SyntaxTrivia>)Creates a new node from this node with the leading trivia replaced with a new trivia where the specified trivia is added at the end of the leading trivia.
AppendToLeadingTrivia<TNode>(TNode, SyntaxTrivia)Creates a new node from this node with the leading trivia replaced with a new trivia where the specified trivia is added at the end of the leading trivia.
AppendToTrailingTrivia<TNode>(TNode, IEnumerable<SyntaxTrivia>)Creates a new node from this node with the trailing trivia replaced with a new trivia where the specified trivia is added at the end of the trailing trivia.
AppendToTrailingTrivia<TNode>(TNode, SyntaxTrivia)Creates a new node from this node with the trailing trivia replaced with a new trivia where the specified trivia is added at the end of the trailing trivia.
ContainsDirectives(SyntaxNode, TextSpan)Returns true if the node contains any preprocessor directives inside the specified span.
ContainsUnbalancedIfElseDirectives(SyntaxNode, TextSpan)Returns true if the specified node contains #if directive but it does not contain related #endif directive.
ContainsUnbalancedIfElseDirectives(SyntaxNode)Returns true if the specified node contains #if directive but it does not contain related #endif directive.
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<TNode>(SyntaxNode, Func<TNode, Boolean>, Boolean)Returns the first node of type TNode that matches the predicate.
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.
FirstDescendant<TNode>(SyntaxNode, Func<SyntaxNode, Boolean>, Boolean)Searches a list of descendant nodes in prefix document order and returns first descendant of type TNode.
FirstDescendant<TNode>(SyntaxNode, TextSpan, Func<SyntaxNode, Boolean>, Boolean)Searches a list of descendant nodes in prefix document order and returns first descendant of type TNode.
FirstDescendantOrSelf<TNode>(SyntaxNode, Func<SyntaxNode, Boolean>, Boolean)Searches a list of descendant nodes (including this node) in prefix document order and returns first descendant of type TNode.
FirstDescendantOrSelf<TNode>(SyntaxNode, TextSpan, Func<SyntaxNode, Boolean>, Boolean)Searches a list of descendant nodes (including this node) in prefix document order and returns first descendant of type TNode.
GetFirstDirective(SyntaxNode, TextSpan, Func<DirectiveTriviaSyntax, Boolean>)Gets the first directive of the tree rooted by this node.
GetLeadingAndTrailingTrivia(SyntaxNode)Returns leading and trailing trivia of the specified node in a single list.
IsDescendantOf(SyntaxNode, SyntaxKind, Boolean)Returns true if a node is a descendant of a node with the specified kind.
IsInExpressionTree(SyntaxNode, SemanticModel, CancellationToken)Determines if the specified node is contained in an expression tree.
IsKind(SyntaxNode, SyntaxKind, SyntaxKind, SyntaxKind, SyntaxKind, SyntaxKind, SyntaxKind)Returns true if a node's kind is one of the specified kinds.
IsKind(SyntaxNode, SyntaxKind, SyntaxKind, SyntaxKind, SyntaxKind, SyntaxKind)Returns true if a node's kind is one of the specified kinds.
IsKind(SyntaxNode, SyntaxKind, SyntaxKind, SyntaxKind, SyntaxKind)Returns true if a node's kind is one of the specified kinds.
IsKind(SyntaxNode, SyntaxKind, SyntaxKind, SyntaxKind)Returns true if a node's kind is one of the specified kinds.
IsKind(SyntaxNode, SyntaxKind, SyntaxKind)Returns true if a node's kind is one of the specified kinds.
IsParentKind(SyntaxNode, SyntaxKind, SyntaxKind, SyntaxKind, SyntaxKind, SyntaxKind, SyntaxKind)Returns true if a node parent's kind is one of the specified kinds.
IsParentKind(SyntaxNode, SyntaxKind, SyntaxKind, SyntaxKind, SyntaxKind, SyntaxKind)Returns true if a node parent's kind is one of the specified kinds.
IsParentKind(SyntaxNode, SyntaxKind, SyntaxKind, SyntaxKind, SyntaxKind)Returns true if a node parent's kind is one of the specified kinds.
IsParentKind(SyntaxNode, SyntaxKind, SyntaxKind, SyntaxKind)Returns true if a node parent's kind is one of the specified kinds.
IsParentKind(SyntaxNode, SyntaxKind, SyntaxKind)Returns true if a node parent's kind is one of the specified kinds.
IsParentKind(SyntaxNode, SyntaxKind)Returns true if a node parent's kind is the specified kind.
PrependToLeadingTrivia<TNode>(TNode, IEnumerable<SyntaxTrivia>)Creates a new node from this node with the leading trivia replaced with a new trivia where the specified trivia is inserted at the beginning of the leading trivia.
PrependToLeadingTrivia<TNode>(TNode, SyntaxTrivia)Creates a new node from this node with the leading trivia replaced with a new trivia where the specified trivia is inserted at the beginning of the leading trivia.
PrependToTrailingTrivia<TNode>(TNode, IEnumerable<SyntaxTrivia>)Creates a new node from this node with the trailing trivia replaced with a new trivia where the specified trivia is inserted at the beginning of the trailing trivia.
PrependToTrailingTrivia<TNode>(TNode, SyntaxTrivia)Creates a new node from this node with the trailing trivia replaced with a new trivia where the specified trivia is inserted at the beginning of the trailing trivia.
RemoveTrivia<TNode>(TNode, TextSpan?)Creates a new node with the trivia removed.
RemoveWhitespace<TNode>(TNode, TextSpan?)Creates a new node with the whitespace removed.
ReplaceWhitespace<TNode>(TNode, SyntaxTrivia, TextSpan?)Creates a new node with the whitespace replaced.
SpanContainsDirectives(SyntaxNode)Returns true if the node's span contains any preprocessor directives.
TrimLeadingTrivia<TNode>(TNode)Removes all leading whitespace from the leading trivia and returns a new node with the new leading trivia. SyntaxKind.WhitespaceTrivia and SyntaxKind.EndOfLineTrivia is considered to be a whitespace. Returns the same node if there is nothing to trim.
TrimTrailingTrivia<TNode>(TNode)Removes all trailing whitespace from the trailing trivia and returns a new node with the new trailing trivia. SyntaxKind.WhitespaceTrivia and SyntaxKind.EndOfLineTrivia is considered to be a whitespace. Returns the same node if there is nothing to trim.
TrimTrivia<TNode>(TNode)Removes all leading whitespace from the leading trivia and all trailing whitespace from the trailing trivia and returns a new node with the new trivia. SyntaxKind.WhitespaceTrivia and SyntaxKind.EndOfLineTrivia is considered to be a whitespace. Returns the same node if there is nothing to trim.
WithFormatterAnnotation<TNode>(TNode)Creates a new node with the Formatter.Annotation attached.
WithSimplifierAnnotation<TNode>(TNode)Creates a new node with the Simplifier.Annotation attached.
WithTriviaFrom<TNode>(TNode, SyntaxToken)Creates a new node from this node with both the leading and trailing trivia of the specified token.