SyntaxNodeExtensions.ReplaceNodes<TRoot,TNode> Method

Definition

Creates a new tree of nodes with the specified old node replaced with a new node.

public:
generic <typename TRoot, typename TNode>
 where TRoot : Microsoft::CodeAnalysis::SyntaxNode where TNode : Microsoft::CodeAnalysis::SyntaxNode[System::Runtime::CompilerServices::Extension]
 static TRoot ReplaceNodes(TRoot root, System::Collections::Generic::IEnumerable<TNode> ^ nodes, Func<TNode, TNode, Microsoft::CodeAnalysis::SyntaxNode ^> ^ computeReplacementNode);
public static TRoot ReplaceNodes<TRoot,TNode> (this TRoot root, System.Collections.Generic.IEnumerable<TNode> nodes, Func<TNode,TNode,Microsoft.CodeAnalysis.SyntaxNode> computeReplacementNode) where TRoot : Microsoft.CodeAnalysis.SyntaxNode where TNode : Microsoft.CodeAnalysis.SyntaxNode;
static member ReplaceNodes : 'Root * seq<'Node (requires 'Node :> Microsoft.CodeAnalysis.SyntaxNode)> * Func<'Node, 'Node, Microsoft.CodeAnalysis.SyntaxNode (requires 'Node :> Microsoft.CodeAnalysis.SyntaxNode and 'Node :> Microsoft.CodeAnalysis.SyntaxNode)> -> 'Root (requires 'Root :> Microsoft.CodeAnalysis.SyntaxNode and 'Node :> Microsoft.CodeAnalysis.SyntaxNode)
<Extension()>
Public Function ReplaceNodes(Of TRoot As SyntaxNode, TNode As SyntaxNode) (root As TRoot, nodes As IEnumerable(Of TNode), computeReplacementNode As Func(Of TNode, TNode, SyntaxNode)) As TRoot

Type Parameters

TRoot

The type of the root node.

TNode

The type of the nodes being replaced.

Parameters

root
TRoot

The root node of the tree of nodes.

nodes
IEnumerable<TNode>

The nodes to be replaced; descendants of the root node.

computeReplacementNode
Func<TNode,TNode,SyntaxNode>

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

TRoot

Applies to