-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Labels
Description
/// <summary>
/// Same as DocumentEditor.ReplaceNode but nicer types.
/// </summary>
/// <typeparam name="T">The type of the node.</typeparam>
/// <param name="editor">The <see cref="DocumentEditor"/>.</param>
/// <param name="node">The <see cref="SyntaxNode"/>.</param>
/// <param name="replacement">The replacement factory.</param>
/// <returns>The <see cref="DocumentEditor"/> that was passed in.</returns>
public static DocumentEditor ReplaceNode<T>(this DocumentEditor editor, T node, Func<T, SyntaxNode> replacement)
where T : SyntaxNode
{
if (editor is null)
{
throw new ArgumentNullException(nameof(editor));
}
if (node is null)
{
throw new ArgumentNullException(nameof(node));
}
if (replacement is null)
{
throw new ArgumentNullException(nameof(replacement));
}
editor.ReplaceNode(node, (x, _) => replacement((T)x));
return editor;
}