Share via


SyntaxNodeExtensions.InsertTokensAfter<TRoot> Method

Definition

Creates a new tree of nodes with new tokens inserted after the specified token.

public:
generic <typename TRoot>
 where TRoot : Microsoft::CodeAnalysis::SyntaxNode[System::Runtime::CompilerServices::Extension]
 static TRoot InsertTokensAfter(TRoot root, Microsoft::CodeAnalysis::SyntaxToken tokenInList, System::Collections::Generic::IEnumerable<Microsoft::CodeAnalysis::SyntaxToken> ^ newTokens);
public static TRoot InsertTokensAfter<TRoot>(this TRoot root, Microsoft.CodeAnalysis.SyntaxToken tokenInList, System.Collections.Generic.IEnumerable<Microsoft.CodeAnalysis.SyntaxToken> newTokens) where TRoot : Microsoft.CodeAnalysis.SyntaxNode;
static member InsertTokensAfter : 'Root * Microsoft.CodeAnalysis.SyntaxToken * seq<Microsoft.CodeAnalysis.SyntaxToken> -> 'Root (requires 'Root :> Microsoft.CodeAnalysis.SyntaxNode)
<Extension()>
Public Function InsertTokensAfter(Of TRoot As SyntaxNode) (root As TRoot, tokenInList As SyntaxToken, newTokens As IEnumerable(Of SyntaxToken)) As TRoot

Type Parameters

TRoot

The type of the root node.

Parameters

root
TRoot

The root of the tree of nodes.

tokenInList
SyntaxToken

The token to insert after. This must be a direct element of a SyntaxTokenList (such as a modifier in a list of modifiers), and a descendant of the root node. The new tokens will be inserted after this token in that list. If the token is not part of a SyntaxTokenList, an InvalidOperationException will be thrown.

newTokens
IEnumerable<SyntaxToken>

A sequence of tokens to insert into the tree immediately after the specified token.

Returns

TRoot

Exceptions

Thrown when tokenInList is not an element of a SyntaxTokenList.

Applies to