SyntaxNodeExtensions.ReplaceSyntax<TRoot> Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Creates a new tree of nodes with the specified nodes, tokens and trivia replaced.
public:
generic <typename TRoot>
where TRoot : Microsoft::CodeAnalysis::SyntaxNode[System::Runtime::CompilerServices::Extension]
static TRoot ReplaceSyntax(TRoot root, System::Collections::Generic::IEnumerable<Microsoft::CodeAnalysis::SyntaxNode ^> ^ nodes, Func<Microsoft::CodeAnalysis::SyntaxNode ^, Microsoft::CodeAnalysis::SyntaxNode ^, Microsoft::CodeAnalysis::SyntaxNode ^> ^ computeReplacementNode, System::Collections::Generic::IEnumerable<Microsoft::CodeAnalysis::SyntaxToken> ^ tokens, Func<Microsoft::CodeAnalysis::SyntaxToken, Microsoft::CodeAnalysis::SyntaxToken, Microsoft::CodeAnalysis::SyntaxToken> ^ computeReplacementToken, System::Collections::Generic::IEnumerable<Microsoft::CodeAnalysis::SyntaxTrivia> ^ trivia, Func<Microsoft::CodeAnalysis::SyntaxTrivia, Microsoft::CodeAnalysis::SyntaxTrivia, Microsoft::CodeAnalysis::SyntaxTrivia> ^ computeReplacementTrivia);
public static TRoot ReplaceSyntax<TRoot> (this TRoot root, System.Collections.Generic.IEnumerable<Microsoft.CodeAnalysis.SyntaxNode> nodes, Func<Microsoft.CodeAnalysis.SyntaxNode,Microsoft.CodeAnalysis.SyntaxNode,Microsoft.CodeAnalysis.SyntaxNode> computeReplacementNode, System.Collections.Generic.IEnumerable<Microsoft.CodeAnalysis.SyntaxToken> tokens, Func<Microsoft.CodeAnalysis.SyntaxToken,Microsoft.CodeAnalysis.SyntaxToken,Microsoft.CodeAnalysis.SyntaxToken> computeReplacementToken, System.Collections.Generic.IEnumerable<Microsoft.CodeAnalysis.SyntaxTrivia> trivia, Func<Microsoft.CodeAnalysis.SyntaxTrivia,Microsoft.CodeAnalysis.SyntaxTrivia,Microsoft.CodeAnalysis.SyntaxTrivia> computeReplacementTrivia) where TRoot : Microsoft.CodeAnalysis.SyntaxNode;
public static TRoot ReplaceSyntax<TRoot> (this TRoot root, System.Collections.Generic.IEnumerable<Microsoft.CodeAnalysis.SyntaxNode>? nodes, Func<Microsoft.CodeAnalysis.SyntaxNode,Microsoft.CodeAnalysis.SyntaxNode,Microsoft.CodeAnalysis.SyntaxNode>? computeReplacementNode, System.Collections.Generic.IEnumerable<Microsoft.CodeAnalysis.SyntaxToken>? tokens, Func<Microsoft.CodeAnalysis.SyntaxToken,Microsoft.CodeAnalysis.SyntaxToken,Microsoft.CodeAnalysis.SyntaxToken>? computeReplacementToken, System.Collections.Generic.IEnumerable<Microsoft.CodeAnalysis.SyntaxTrivia>? trivia, Func<Microsoft.CodeAnalysis.SyntaxTrivia,Microsoft.CodeAnalysis.SyntaxTrivia,Microsoft.CodeAnalysis.SyntaxTrivia>? computeReplacementTrivia) where TRoot : Microsoft.CodeAnalysis.SyntaxNode;
static member ReplaceSyntax : 'Root * seq<Microsoft.CodeAnalysis.SyntaxNode> * Func<Microsoft.CodeAnalysis.SyntaxNode, Microsoft.CodeAnalysis.SyntaxNode, Microsoft.CodeAnalysis.SyntaxNode> * seq<Microsoft.CodeAnalysis.SyntaxToken> * Func<Microsoft.CodeAnalysis.SyntaxToken, Microsoft.CodeAnalysis.SyntaxToken, Microsoft.CodeAnalysis.SyntaxToken> * seq<Microsoft.CodeAnalysis.SyntaxTrivia> * Func<Microsoft.CodeAnalysis.SyntaxTrivia, Microsoft.CodeAnalysis.SyntaxTrivia, Microsoft.CodeAnalysis.SyntaxTrivia> -> 'Root (requires 'Root :> Microsoft.CodeAnalysis.SyntaxNode)
<Extension()>
Public Function ReplaceSyntax(Of TRoot As SyntaxNode) (root As TRoot, nodes As IEnumerable(Of SyntaxNode), computeReplacementNode As Func(Of SyntaxNode, SyntaxNode, SyntaxNode), tokens As IEnumerable(Of SyntaxToken), computeReplacementToken As Func(Of SyntaxToken, SyntaxToken, SyntaxToken), trivia As IEnumerable(Of SyntaxTrivia), computeReplacementTrivia As Func(Of SyntaxTrivia, SyntaxTrivia, SyntaxTrivia)) As TRoot
Type Parameters
- TRoot
The type of the root node.
Parameters
- root
- TRoot
The root node of the tree of nodes.
- nodes
- IEnumerable<SyntaxNode>
The nodes to be replaced.
- computeReplacementNode
- Func<SyntaxNode,SyntaxNode,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.
- tokens
- IEnumerable<SyntaxToken>
The tokens to be replaced.
- computeReplacementToken
- Func<SyntaxToken,SyntaxToken,SyntaxToken>
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.
- trivia
- IEnumerable<SyntaxTrivia>
The trivia to be replaced.
- computeReplacementTrivia
- Func<SyntaxTrivia,SyntaxTrivia,SyntaxTrivia>
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
Applies to
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈