/// <summary>
/// Creates a new list with the specified separator token replaced with the new separator.
/// </summary>
/// <param name="separatorToken">The separator token to be replaced.</param>
/// <param name="newSeparator">The new separator token.</param>
public SeparatedSyntaxList <TNode> ReplaceSeparator(SyntaxToken separatorToken, SyntaxToken newSeparator)
{
SyntaxNodeOrTokenList nodesWithSeps = this.GetWithSeparators();
int index = nodesWithSeps.IndexOf(separatorToken);
if (index < 0)
{
throw new ArgumentException("separatorToken");
}
if (newSeparator.RawKind != nodesWithSeps[index].RawKind ||
newSeparator.Language != nodesWithSeps[index].Language)
{
throw new ArgumentException("newSeparator");
}
return(new SeparatedSyntaxList <TNode>(nodesWithSeps.Replace(separatorToken, newSeparator)));
}