Class SyntaxNodeExtensions
Extension methods for SyntaxNode.
Inheritance
Inherited Members
Namespace: Loretta.CodeAnalysis
Assembly: Loretta.CodeAnalysis.dll
Syntax
public static class SyntaxNodeExtensions
Methods
| Improve this Doc View SourceGetCurrentNode<TNode>(SyntaxNode, TNode)
Gets the node within the subtree corresponding to the original tracked node. Use TrackNodes to start tracking nodes.
Declaration
public static TNode GetCurrentNode<TNode>(this SyntaxNode root, TNode node)
where TNode : SyntaxNode
Parameters
Type | Name | Description |
---|---|---|
SyntaxNode | root | The root of the subtree containing the current node corresponding to the original tracked node. |
TNode | node | The node instance originally tracked. |
Returns
Type | Description |
---|---|
TNode |
Type Parameters
Name | Description |
---|---|
TNode |
GetCurrentNodes<TNode>(SyntaxNode, TNode)
Gets the nodes within the subtree corresponding to the original tracked node. Use TrackNodes to start tracking nodes.
Declaration
public static IEnumerable<TNode> GetCurrentNodes<TNode>(this SyntaxNode root, TNode node)
where TNode : SyntaxNode
Parameters
Type | Name | Description |
---|---|---|
SyntaxNode | root | The root of the subtree containing the current node corresponding to the original tracked node. |
TNode | node | The node instance originally tracked. |
Returns
Type | Description |
---|---|
IEnumerable<TNode> |
Type Parameters
Name | Description |
---|---|
TNode |
GetCurrentNodes<TNode>(SyntaxNode, IEnumerable<TNode>)
Gets the nodes within the subtree corresponding to the original tracked nodes. Use TrackNodes to start tracking nodes.
Declaration
public static IEnumerable<TNode> GetCurrentNodes<TNode>(this SyntaxNode root, IEnumerable<TNode> nodes)
where TNode : SyntaxNode
Parameters
Type | Name | Description |
---|---|---|
SyntaxNode | root | The root of the subtree containing the current nodes corresponding to the original tracked nodes. |
IEnumerable<TNode> | nodes | One or more node instances originally tracked. |
Returns
Type | Description |
---|---|
IEnumerable<TNode> |
Type Parameters
Name | Description |
---|---|
TNode |
InsertNodesAfter<TRoot>(TRoot, SyntaxNode, IEnumerable<SyntaxNode>)
Creates a new tree of nodes with new nodes inserted after the specified node.
Declaration
public static TRoot InsertNodesAfter<TRoot>(this TRoot root, SyntaxNode nodeInList, IEnumerable<SyntaxNode> newNodes)
where TRoot : SyntaxNode
Parameters
Type | Name | Description |
---|---|---|
TRoot | root | The root of the tree of nodes. |
SyntaxNode | nodeInList | The node to insert after; a descendant of the root node an element of a list member. |
IEnumerable<SyntaxNode> | newNodes | A sequence of nodes to insert into the tree immediately after the specified node. |
Returns
Type | Description |
---|---|
TRoot |
Type Parameters
Name | Description |
---|---|
TRoot | The type of the root node. |
InsertNodesBefore<TRoot>(TRoot, SyntaxNode, IEnumerable<SyntaxNode>)
Creates a new tree of nodes with new nodes inserted before the specified node.
Declaration
public static TRoot InsertNodesBefore<TRoot>(this TRoot root, SyntaxNode nodeInList, IEnumerable<SyntaxNode> newNodes)
where TRoot : SyntaxNode
Parameters
Type | Name | Description |
---|---|---|
TRoot | root | The root of the tree of nodes. |
SyntaxNode | nodeInList | The node to insert before; a descendant of the root node an element of a list member. |
IEnumerable<SyntaxNode> | newNodes | A sequence of nodes to insert into the tree immediately before the specified node. |
Returns
Type | Description |
---|---|
TRoot |
Type Parameters
Name | Description |
---|---|
TRoot | The type of the root node. |
InsertTokensAfter<TRoot>(TRoot, SyntaxToken, IEnumerable<SyntaxToken>)
Creates a new tree of nodes with new tokens inserted after the specified token.
Declaration
public static TRoot InsertTokensAfter<TRoot>(this TRoot root, SyntaxToken tokenInList, IEnumerable<SyntaxToken> newTokens)
where TRoot : SyntaxNode
Parameters
Type | Name | Description |
---|---|---|
TRoot | root | The root of the tree of nodes. |
SyntaxToken | tokenInList | The token to insert after; a descendant of the root node and an element of a list member. |
IEnumerable<SyntaxToken> | newTokens | A sequence of tokens to insert into the tree immediately after the specified token. |
Returns
Type | Description |
---|---|
TRoot |
Type Parameters
Name | Description |
---|---|
TRoot | The type of the root node. |
InsertTokensBefore<TRoot>(TRoot, SyntaxToken, IEnumerable<SyntaxToken>)
Creates a new tree of nodes with new tokens inserted before the specified token.
Declaration
public static TRoot InsertTokensBefore<TRoot>(this TRoot root, SyntaxToken tokenInList, IEnumerable<SyntaxToken> newTokens)
where TRoot : SyntaxNode
Parameters
Type | Name | Description |
---|---|---|
TRoot | root | The root of the tree of nodes. |
SyntaxToken | tokenInList | The token to insert before; a descendant of the root node and an element of a list member. |
IEnumerable<SyntaxToken> | newTokens | A sequence of tokens to insert into the tree immediately before the specified token. |
Returns
Type | Description |
---|---|
TRoot |
Type Parameters
Name | Description |
---|---|
TRoot | The type of the root node. |
InsertTriviaAfter<TRoot>(TRoot, SyntaxTrivia, IEnumerable<SyntaxTrivia>)
Creates a new tree of nodes with new trivia inserted after the specified trivia.
Declaration
public static TRoot InsertTriviaAfter<TRoot>(this TRoot root, SyntaxTrivia trivia, IEnumerable<SyntaxTrivia> newTrivia)
where TRoot : SyntaxNode
Parameters
Type | Name | Description |
---|---|---|
TRoot | root | The root of the tree of nodes. |
SyntaxTrivia | trivia | The trivia to insert after; a descendant of the root node. |
IEnumerable<SyntaxTrivia> | newTrivia | A sequence of trivia to insert into the tree immediately after the specified trivia. |
Returns
Type | Description |
---|---|
TRoot |
Type Parameters
Name | Description |
---|---|
TRoot | The type of the root node. |
InsertTriviaBefore<TRoot>(TRoot, SyntaxTrivia, IEnumerable<SyntaxTrivia>)
Creates a new tree of nodes with new trivia inserted before the specified trivia.
Declaration
public static TRoot InsertTriviaBefore<TRoot>(this TRoot root, SyntaxTrivia trivia, IEnumerable<SyntaxTrivia> newTrivia)
where TRoot : SyntaxNode
Parameters
Type | Name | Description |
---|---|---|
TRoot | root | The root of the tree of nodes. |
SyntaxTrivia | trivia | The trivia to insert before; a descendant of the root node. |
IEnumerable<SyntaxTrivia> | newTrivia | A sequence of trivia to insert into the tree immediately before the specified trivia. |
Returns
Type | Description |
---|---|
TRoot |
Type Parameters
Name | Description |
---|---|
TRoot | The type of the root node. |
NormalizeWhitespace<TNode>(TNode, String, Boolean)
Creates a new syntax node with all whitespace and end of line trivia replaced with regularly formatted trivia.
Declaration
public static TNode NormalizeWhitespace<TNode>(this TNode node, string indentation, bool elasticTrivia)
where TNode : SyntaxNode
Parameters
Type | Name | Description |
---|---|---|
TNode | node | The node to format. |
System.String | indentation | A sequence of whitespace characters that defines a single level of indentation. |
System.Boolean | elasticTrivia | If true the replaced trivia is elastic trivia. |
Returns
Type | Description |
---|---|
TNode |
Type Parameters
Name | Description |
---|---|
TNode | The type of the node. |
NormalizeWhitespace<TNode>(TNode, String, String, Boolean)
Creates a new syntax node with all whitespace and end of line trivia replaced with regularly formatted trivia.
Declaration
public static TNode NormalizeWhitespace<TNode>(this TNode node, string indentation = " ", string eol = "\r\n", bool elasticTrivia = false)
where TNode : SyntaxNode
Parameters
Type | Name | Description |
---|---|---|
TNode | node | The node to format. |
System.String | indentation | An optional sequence of whitespace characters that defines a single level of indentation. |
System.String | eol | An optional sequence of whitespace characters used for end of line. |
System.Boolean | elasticTrivia | If true the replaced trivia is elastic trivia. |
Returns
Type | Description |
---|---|
TNode |
Type Parameters
Name | Description |
---|---|
TNode | The type of the node. |
RemoveNode<TRoot>(TRoot, SyntaxNode, SyntaxRemoveOptions)
Creates a new tree of nodes with the specified node removed.
Declaration
public static TRoot RemoveNode<TRoot>(this TRoot root, SyntaxNode node, SyntaxRemoveOptions options)
where TRoot : SyntaxNode
Parameters
Type | Name | Description |
---|---|---|
TRoot | root | The root node from which to remove a descendant node from. |
SyntaxNode | node | The node to remove. |
SyntaxRemoveOptions | options | Options that determine how the node's trivia is treated. |
Returns
Type | Description |
---|---|
TRoot |
Type Parameters
Name | Description |
---|---|
TRoot | The type of the root node. |
RemoveNodes<TRoot>(TRoot, IEnumerable<SyntaxNode>, SyntaxRemoveOptions)
Creates a new tree of nodes with the specified nodes removed.
Declaration
public static TRoot RemoveNodes<TRoot>(this TRoot root, IEnumerable<SyntaxNode> nodes, SyntaxRemoveOptions options)
where TRoot : SyntaxNode
Parameters
Type | Name | Description |
---|---|---|
TRoot | root | The root node from which to remove a descendant node from. |
IEnumerable<SyntaxNode> | nodes | The nodes to remove. |
SyntaxRemoveOptions | options | Options that determine how the nodes' trivia is treated. |
Returns
Type | Description |
---|---|
TRoot |
Type Parameters
Name | Description |
---|---|
TRoot | The type of the root node. |
ReplaceNode<TRoot>(TRoot, SyntaxNode, IEnumerable<SyntaxNode>)
Creates a new tree of nodes with specified old node replaced with a new nodes.
Declaration
public static TRoot ReplaceNode<TRoot>(this TRoot root, SyntaxNode oldNode, IEnumerable<SyntaxNode> newNodes)
where TRoot : SyntaxNode
Parameters
Type | Name | Description |
---|---|---|
TRoot | root | The root of the tree of nodes. |
SyntaxNode | oldNode | The node to be replaced; a descendant of the root node and an element of a list member. |
IEnumerable<SyntaxNode> | newNodes | A sequence of nodes to use in the tree in place of the old node. |
Returns
Type | Description |
---|---|
TRoot |
Type Parameters
Name | Description |
---|---|
TRoot | The type of the root node. |
ReplaceNode<TRoot>(TRoot, SyntaxNode, SyntaxNode)
Creates a new tree of nodes with the specified old node replaced with a new node.
Declaration
public static TRoot ReplaceNode<TRoot>(this TRoot root, SyntaxNode oldNode, SyntaxNode newNode)
where TRoot : SyntaxNode
Parameters
Type | Name | Description |
---|---|---|
TRoot | root | The root node of the tree of nodes. |
SyntaxNode | oldNode | The node to be replaced; a descendant of the root node. |
SyntaxNode | newNode | The new node to use in the new tree in place of the old node. |
Returns
Type | Description |
---|---|
TRoot |
Type Parameters
Name | Description |
---|---|
TRoot | The type of the root node. |
ReplaceNodes<TRoot, TNode>(TRoot, IEnumerable<TNode>, Func<TNode, TNode, SyntaxNode>)
Creates a new tree of nodes with the specified old node replaced with a new node.
Declaration
public static TRoot ReplaceNodes<TRoot, TNode>(this TRoot root, IEnumerable<TNode> nodes, Func<TNode, TNode, SyntaxNode> computeReplacementNode)
where TRoot : SyntaxNode where TNode : SyntaxNode
Parameters
Type | Name | Description |
---|---|---|
TRoot | root | The root node of the tree of nodes. |
IEnumerable<TNode> | nodes | The nodes to be replaced; descendants of the root node. |
Func<TNode, TNode, SyntaxNode> | computeReplacementNode | A function that computes a replacement node for the argument nodes. The first argument is the original node. The second argument is the same node potentially rewritten with replaced descendants. |
Returns
Type | Description |
---|---|
TRoot |
Type Parameters
Name | Description |
---|---|
TRoot | The type of the root node. |
TNode | The type of the nodes being replaced. |
ReplaceSyntax<TRoot>(TRoot, IEnumerable<SyntaxNode>, Func<SyntaxNode, SyntaxNode, SyntaxNode>, IEnumerable<SyntaxToken>, Func<SyntaxToken, SyntaxToken, SyntaxToken>, IEnumerable<SyntaxTrivia>, Func<SyntaxTrivia, SyntaxTrivia, SyntaxTrivia>)
Creates a new tree of nodes with the specified nodes, tokens and trivia replaced.
Declaration
public static TRoot ReplaceSyntax<TRoot>(this TRoot root, IEnumerable<SyntaxNode> nodes, Func<SyntaxNode, SyntaxNode, SyntaxNode> computeReplacementNode, IEnumerable<SyntaxToken> tokens, Func<SyntaxToken, SyntaxToken, SyntaxToken> computeReplacementToken, IEnumerable<SyntaxTrivia> trivia, Func<SyntaxTrivia, SyntaxTrivia, SyntaxTrivia> computeReplacementTrivia)
where TRoot : SyntaxNode
Parameters
Type | Name | Description |
---|---|---|
TRoot | root | The root node of the tree of nodes. |
IEnumerable<SyntaxNode> | nodes | The nodes to be replaced. |
Func<SyntaxNode, SyntaxNode, SyntaxNode> | computeReplacementNode | A function that computes a replacement node for the argument nodes. The first argument is the original node. The second argument is the same node potentially rewritten with replaced descendants. |
IEnumerable<SyntaxToken> | tokens | The tokens to be replaced. |
Func<SyntaxToken, SyntaxToken, SyntaxToken> | computeReplacementToken | A function that computes a replacement token for the argument tokens. The first argument is the original token. The second argument is the same token potentially rewritten with replaced trivia. |
IEnumerable<SyntaxTrivia> | trivia | The trivia to be replaced. |
Func<SyntaxTrivia, SyntaxTrivia, SyntaxTrivia> | computeReplacementTrivia | A function that computes replacement trivia for the specified arguments. The first argument is the original trivia. The second argument is the same trivia with potentially rewritten sub structure. |
Returns
Type | Description |
---|---|
TRoot |
Type Parameters
Name | Description |
---|---|
TRoot | The type of the root node. |
ReplaceToken<TRoot>(TRoot, SyntaxToken, IEnumerable<SyntaxToken>)
Creates a new tree of nodes with the specified old token replaced with new tokens.
Declaration
public static TRoot ReplaceToken<TRoot>(this TRoot root, SyntaxToken tokenInList, IEnumerable<SyntaxToken> newTokens)
where TRoot : SyntaxNode
Parameters
Type | Name | Description |
---|---|---|
TRoot | root | The root of the tree of nodes. |
SyntaxToken | tokenInList | The token to be replaced; a descendant of the root node and an element of a list member. |
IEnumerable<SyntaxToken> | newTokens | A sequence of tokens to use in the tree in place of the specified token. |
Returns
Type | Description |
---|---|
TRoot |
Type Parameters
Name | Description |
---|---|
TRoot | The type of the root node. |
ReplaceToken<TRoot>(TRoot, SyntaxToken, SyntaxToken)
Creates a new tree of nodes with the specified old token replaced with a new token.
Declaration
public static TRoot ReplaceToken<TRoot>(this TRoot root, SyntaxToken oldToken, SyntaxToken newToken)
where TRoot : SyntaxNode
Parameters
Type | Name | Description |
---|---|---|
TRoot | root | The root node of the tree of nodes. |
SyntaxToken | oldToken | The token to be replaced. |
SyntaxToken | newToken | The new token to use in the new tree in place of the old token. |
Returns
Type | Description |
---|---|
TRoot |
Type Parameters
Name | Description |
---|---|
TRoot | The type of the root node. |
ReplaceTokens<TRoot>(TRoot, IEnumerable<SyntaxToken>, Func<SyntaxToken, SyntaxToken, SyntaxToken>)
Creates a new tree of nodes with the specified old node replaced with a new node.
Declaration
public static TRoot ReplaceTokens<TRoot>(this TRoot root, IEnumerable<SyntaxToken> tokens, Func<SyntaxToken, SyntaxToken, SyntaxToken> computeReplacementToken)
where TRoot : SyntaxNode
Parameters
Type | Name | Description |
---|---|---|
TRoot | root | The root node of the tree of nodes. |
IEnumerable<SyntaxToken> | tokens | The token to be replaced; descendants of the root node. |
Func<SyntaxToken, SyntaxToken, SyntaxToken> | computeReplacementToken | A function that computes a replacement token for the argument tokens. The first argument is the original token. The second argument is the same token potentially rewritten with replaced trivia. |
Returns
Type | Description |
---|---|
TRoot |
Type Parameters
Name | Description |
---|---|
TRoot | The type of the root node. |
ReplaceTrivia<TRoot>(TRoot, IEnumerable<SyntaxTrivia>, Func<SyntaxTrivia, SyntaxTrivia, SyntaxTrivia>)
Creates a new tree of nodes with the specified trivia replaced with new trivia.
Declaration
public static TRoot ReplaceTrivia<TRoot>(this TRoot root, IEnumerable<SyntaxTrivia> trivia, Func<SyntaxTrivia, SyntaxTrivia, SyntaxTrivia> computeReplacementTrivia)
where TRoot : SyntaxNode
Parameters
Type | Name | Description |
---|---|---|
TRoot | root | The root node of the tree of nodes. |
IEnumerable<SyntaxTrivia> | trivia | The trivia to be replaced; descendants of the root node. |
Func<SyntaxTrivia, SyntaxTrivia, SyntaxTrivia> | computeReplacementTrivia | A function that computes replacement trivia for the specified arguments. The first argument is the original trivia. The second argument is the same trivia with potentially rewritten sub structure. |
Returns
Type | Description |
---|---|
TRoot |
Type Parameters
Name | Description |
---|---|
TRoot | The type of the root node. |
ReplaceTrivia<TRoot>(TRoot, SyntaxTrivia, IEnumerable<SyntaxTrivia>)
Creates a new tree of nodes with the specified old trivia replaced with new trivia.
Declaration
public static TRoot ReplaceTrivia<TRoot>(this TRoot root, SyntaxTrivia oldTrivia, IEnumerable<SyntaxTrivia> newTrivia)
where TRoot : SyntaxNode
Parameters
Type | Name | Description |
---|---|---|
TRoot | root | The root of the tree of nodes. |
SyntaxTrivia | oldTrivia | The trivia to be replaced; a descendant of the root node. |
IEnumerable<SyntaxTrivia> | newTrivia | A sequence of trivia to use in the tree in place of the specified trivia. |
Returns
Type | Description |
---|---|
TRoot |
Type Parameters
Name | Description |
---|---|
TRoot | The type of the root node. |
ReplaceTrivia<TRoot>(TRoot, SyntaxTrivia, SyntaxTrivia)
Creates a new tree of nodes with the specified trivia replaced with new trivia.
Declaration
public static TRoot ReplaceTrivia<TRoot>(this TRoot root, SyntaxTrivia trivia, SyntaxTrivia newTrivia)
where TRoot : SyntaxNode
Parameters
Type | Name | Description |
---|---|---|
TRoot | root | The root node of the tree of nodes. |
SyntaxTrivia | trivia | The trivia to be replaced. |
SyntaxTrivia | newTrivia | The new trivia to use in the new tree in place of the old trivia. |
Returns
Type | Description |
---|---|
TRoot |
Type Parameters
Name | Description |
---|---|
TRoot | The type of the root node. |
TrackNodes<TRoot>(TRoot, IEnumerable<SyntaxNode>)
Creates a new tree of nodes with the specified nodes being tracked.
Use GetCurrentNode on the subtree resulting from this operation, or any transformation of it, to get the current node corresponding to the original tracked node.
Declaration
public static TRoot TrackNodes<TRoot>(this TRoot root, IEnumerable<SyntaxNode> nodes)
where TRoot : SyntaxNode
Parameters
Type | Name | Description |
---|---|---|
TRoot | root | The root of the subtree containing the nodes to be tracked. |
IEnumerable<SyntaxNode> | nodes | One or more nodes that are descendants of the root node. |
Returns
Type | Description |
---|---|
TRoot |
Type Parameters
Name | Description |
---|---|
TRoot |
TrackNodes<TRoot>(TRoot, SyntaxNode[])
Creates a new tree of nodes with the specified nodes being tracked.
Use GetCurrentNode on the subtree resulting from this operation, or any transformation of it, to get the current node corresponding to the original tracked node.
Declaration
public static TRoot TrackNodes<TRoot>(this TRoot root, params SyntaxNode[] nodes)
where TRoot : SyntaxNode
Parameters
Type | Name | Description |
---|---|---|
TRoot | root | The root of the subtree containing the nodes to be tracked. |
SyntaxNode[] | nodes | One or more nodes that are descendants of the root node. |
Returns
Type | Description |
---|---|
TRoot |
Type Parameters
Name | Description |
---|---|
TRoot |
WithLeadingTrivia<TSyntax>(TSyntax, SyntaxTrivia[])
Creates a new node from this node with the leading trivia replaced.
Declaration
public static TSyntax WithLeadingTrivia<TSyntax>(this TSyntax node, params SyntaxTrivia[] trivia)
where TSyntax : SyntaxNode
Parameters
Type | Name | Description |
---|---|---|
TSyntax | node | |
SyntaxTrivia[] | trivia |
Returns
Type | Description |
---|---|
TSyntax |
Type Parameters
Name | Description |
---|---|
TSyntax |
WithLeadingTrivia<TSyntax>(TSyntax, SyntaxTriviaList)
Creates a new node from this node with the leading trivia replaced.
Declaration
public static TSyntax WithLeadingTrivia<TSyntax>(this TSyntax node, SyntaxTriviaList trivia)
where TSyntax : SyntaxNode
Parameters
Type | Name | Description |
---|---|---|
TSyntax | node | |
SyntaxTriviaList | trivia |
Returns
Type | Description |
---|---|
TSyntax |
Type Parameters
Name | Description |
---|---|
TSyntax |
WithLeadingTrivia<TSyntax>(TSyntax, Nullable<IEnumerable<SyntaxTrivia>>)
Creates a new node from this node with the leading trivia replaced.
Declaration
public static TSyntax WithLeadingTrivia<TSyntax>(this TSyntax node, IEnumerable<SyntaxTrivia>? trivia)
where TSyntax : SyntaxNode
Parameters
Type | Name | Description |
---|---|---|
TSyntax | node | |
System.Nullable<IEnumerable<SyntaxTrivia>> | trivia |
Returns
Type | Description |
---|---|
TSyntax |
Type Parameters
Name | Description |
---|---|
TSyntax |
WithoutLeadingTrivia<TSyntax>(TSyntax)
Creates a new node from this node with the leading trivia removed.
Declaration
public static TSyntax WithoutLeadingTrivia<TSyntax>(this TSyntax node)
where TSyntax : SyntaxNode
Parameters
Type | Name | Description |
---|---|---|
TSyntax | node |
Returns
Type | Description |
---|---|
TSyntax |
Type Parameters
Name | Description |
---|---|
TSyntax |
WithoutTrailingTrivia<TSyntax>(TSyntax)
Creates a new node from this node with the trailing trivia removed.
Declaration
public static TSyntax WithoutTrailingTrivia<TSyntax>(this TSyntax node)
where TSyntax : SyntaxNode
Parameters
Type | Name | Description |
---|---|---|
TSyntax | node |
Returns
Type | Description |
---|---|
TSyntax |
Type Parameters
Name | Description |
---|---|
TSyntax |
WithoutTrivia(SyntaxToken)
Creates a new token from this token without leading or trailing trivia.
Declaration
public static SyntaxToken WithoutTrivia(this SyntaxToken token)
Parameters
Type | Name | Description |
---|---|---|
SyntaxToken | token |
Returns
Type | Description |
---|---|
SyntaxToken |
WithoutTrivia<TSyntax>(TSyntax)
Creates a new node from this node without leading or trailing trivia.
Declaration
public static TSyntax WithoutTrivia<TSyntax>(this TSyntax syntax)
where TSyntax : SyntaxNode
Parameters
Type | Name | Description |
---|---|---|
TSyntax | syntax |
Returns
Type | Description |
---|---|
TSyntax |
Type Parameters
Name | Description |
---|---|
TSyntax |
WithTrailingTrivia<TSyntax>(TSyntax, SyntaxTrivia[])
Creates a new node from this node with the trailing trivia replaced.
Declaration
public static TSyntax WithTrailingTrivia<TSyntax>(this TSyntax node, params SyntaxTrivia[] trivia)
where TSyntax : SyntaxNode
Parameters
Type | Name | Description |
---|---|---|
TSyntax | node | |
SyntaxTrivia[] | trivia |
Returns
Type | Description |
---|---|
TSyntax |
Type Parameters
Name | Description |
---|---|
TSyntax |
WithTrailingTrivia<TSyntax>(TSyntax, SyntaxTriviaList)
Creates a new node from this node with the trailing trivia replaced.
Declaration
public static TSyntax WithTrailingTrivia<TSyntax>(this TSyntax node, SyntaxTriviaList trivia)
where TSyntax : SyntaxNode
Parameters
Type | Name | Description |
---|---|---|
TSyntax | node | |
SyntaxTriviaList | trivia |
Returns
Type | Description |
---|---|
TSyntax |
Type Parameters
Name | Description |
---|---|
TSyntax |
WithTrailingTrivia<TSyntax>(TSyntax, Nullable<IEnumerable<SyntaxTrivia>>)
Creates a new node from this node with the trailing trivia replaced.
Declaration
public static TSyntax WithTrailingTrivia<TSyntax>(this TSyntax node, IEnumerable<SyntaxTrivia>? trivia)
where TSyntax : SyntaxNode
Parameters
Type | Name | Description |
---|---|---|
TSyntax | node | |
System.Nullable<IEnumerable<SyntaxTrivia>> | trivia |
Returns
Type | Description |
---|---|
TSyntax |
Type Parameters
Name | Description |
---|---|
TSyntax |
WithTriviaFrom<TSyntax>(TSyntax, SyntaxNode)
Creates a new node from this node with both the leading and trailing trivia of the specified node.
Declaration
public static TSyntax WithTriviaFrom<TSyntax>(this TSyntax syntax, SyntaxNode node)
where TSyntax : SyntaxNode
Parameters
Type | Name | Description |
---|---|---|
TSyntax | syntax | |
SyntaxNode | node |
Returns
Type | Description |
---|---|
TSyntax |
Type Parameters
Name | Description |
---|---|
TSyntax |