TomlSyntaxRewriter Class
Builds a new tree by visiting an old one and returning replacements.
public class TomlSyntaxRewriter : TomlSyntaxVisitor<SyntaxNode?>Remarks
A node whose parts all come back unchanged is returned as it was, so rewriting a tree and changing nothing in it costs nothing and keeps every node.
Example
private sealed class DoubleIntegers : TomlSyntaxRewriter
{
public override SyntaxNode? VisitTomlInteger(TomlIntegerSyntax node) => node.WithValue(node.Value * 2);
}- Inheritance
TomlSyntaxVisitor<SyntaxNode?>TomlSyntaxRewriter
Constructors
| Name | Description |
|---|---|
| TomlSyntaxRewriter() |
TomlSyntaxRewriter()
public TomlSyntaxRewriter()No documentation is available.
Methods
VisitList overloads
VisitList(SyntaxTokenList)
TomlSyntaxRewriter.cspublic virtual SyntaxTokenList VisitList(SyntaxTokenList list)No documentation is available.
VisitList(SyntaxTriviaList)
TomlSyntaxRewriter.csRewrites each trivium of a list, dropping the ones a rewrite turned into the default trivium.
public virtual SyntaxTriviaList VisitList(SyntaxTriviaList list)VisitList<TNode>(SeparatedSyntaxList<TNode>)
TomlSyntaxRewriter.csRewrites the elements of a separated list and its separators.
public virtual SeparatedSyntaxList<TNode> VisitList<TNode>(SeparatedSyntaxList<TNode> list) where TNode : TomlSyntaxNodeType parameters
TNode
Parameters
Returns
Exceptions
InvalidOperationException- The rewrite returned a node that cannot take the place of the one it rewrote.
Remarks
An element the rewrite returns null for is removed, together with the separator after it, or the one before it when it is the last element, and the trivia they hold.
VisitList<TNode>(SyntaxList<TNode>)
TomlSyntaxRewriter.csRewrites each node of a list, dropping the ones the rewrite returns null for.
public virtual SyntaxList<TNode> VisitList<TNode>(SyntaxList<TNode> list) where TNode : TomlSyntaxNodeType parameters
TNode
Parameters
listSyntaxList<TNode>
Returns
Exceptions
InvalidOperationException- The rewrite returned a node that cannot take the place of the one it rewrote.
VisitRequired<TNode>(TNode)
TomlSyntaxRewriter.csRewrites a node that has to be there, keeping it when the rewrite returns null.
protected TNode VisitRequired<TNode>(TNode node) where TNode : TomlSyntaxNodeType parameters
TNode
Parameters
nodeTNode
Returns
TNode
Exceptions
InvalidOperationException- The rewrite returned a node that cannot take the place of
node.
VisitToken(SyntaxToken)
TomlSyntaxRewriter.csRewrites a token, putting the trivia around it through TomlSyntaxRewriter.VisitTrivia.
public virtual SyntaxToken VisitToken(SyntaxToken token)VisitTomlArray(TomlArraySyntax)
TomlSyntaxRewriter.cspublic override SyntaxNode? VisitTomlArray(TomlArraySyntax node)Parameters
nodeTomlArraySyntax
Returns
Exceptions
InsufficientExecutionStackException- The value is nested too deeply to rewrite.
VisitTomlBoolean(TomlBooleanSyntax)
TomlSyntaxRewriter.cspublic override SyntaxNode? VisitTomlBoolean(TomlBooleanSyntax node)No documentation is available.
VisitTomlDateTime(TomlDateTimeSyntax)
TomlSyntaxRewriter.cspublic override SyntaxNode? VisitTomlDateTime(TomlDateTimeSyntax node)No documentation is available.
VisitTomlDocument(TomlDocumentSyntax)
TomlSyntaxRewriter.cspublic override SyntaxNode? VisitTomlDocument(TomlDocumentSyntax node)No documentation is available.
VisitTomlFloat(TomlFloatSyntax)
TomlSyntaxRewriter.cspublic override SyntaxNode? VisitTomlFloat(TomlFloatSyntax node)No documentation is available.
VisitTomlInlineTable(TomlInlineTableSyntax)
TomlSyntaxRewriter.cspublic override SyntaxNode? VisitTomlInlineTable(TomlInlineTableSyntax node)Parameters
Returns
Exceptions
InsufficientExecutionStackException- The value is nested too deeply to rewrite.
VisitTomlInteger(TomlIntegerSyntax)
TomlSyntaxRewriter.cspublic override SyntaxNode? VisitTomlInteger(TomlIntegerSyntax node)No documentation is available.
VisitTomlKey(TomlKeySyntax)
TomlSyntaxRewriter.cspublic override SyntaxNode? VisitTomlKey(TomlKeySyntax node)No documentation is available.
VisitTomlProperty(TomlPropertySyntax)
TomlSyntaxRewriter.cspublic override SyntaxNode? VisitTomlProperty(TomlPropertySyntax node)No documentation is available.
VisitTomlSkippedText(TomlSkippedTextSyntax)
TomlSyntaxRewriter.cspublic override SyntaxNode? VisitTomlSkippedText(TomlSkippedTextSyntax node)No documentation is available.
VisitTomlSkippedValue(TomlSkippedValueSyntax)
TomlSyntaxRewriter.cspublic override SyntaxNode? VisitTomlSkippedValue(TomlSkippedValueSyntax node)No documentation is available.
VisitTomlString(TomlStringSyntax)
TomlSyntaxRewriter.cspublic override SyntaxNode? VisitTomlString(TomlStringSyntax node)No documentation is available.
VisitTomlTable(TomlTableSyntax)
TomlSyntaxRewriter.cspublic override SyntaxNode? VisitTomlTable(TomlTableSyntax node)No documentation is available.
VisitTrivia(SyntaxTrivia)
TomlSyntaxRewriter.cspublic virtual SyntaxTrivia VisitTrivia(SyntaxTrivia trivia)No documentation is available.