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

NameDescription
TomlSyntaxRewriter()

TomlSyntaxRewriter()

public TomlSyntaxRewriter()

No documentation is available.

Methods

NameDescription
VisitList(SyntaxTokenList)
VisitList(SyntaxTriviaList)Rewrites each trivium of a list, dropping the ones a rewrite turned into the default trivium.
VisitList<TNode>(SeparatedSyntaxList<TNode>)Rewrites the elements of a separated list and its separators.
VisitList<TNode>(SyntaxList<TNode>)Rewrites each node of a list, dropping the ones the rewrite returns null for.
VisitRequired<TNode>(TNode)Rewrites a node that has to be there, keeping it when the rewrite returns null.
VisitToken(SyntaxToken)Rewrites a token, putting the trivia around it through TomlSyntaxRewriter.VisitTrivia.
VisitTomlArray(TomlArraySyntax)
VisitTomlBoolean(TomlBooleanSyntax)
VisitTomlDateTime(TomlDateTimeSyntax)
VisitTomlDocument(TomlDocumentSyntax)
VisitTomlFloat(TomlFloatSyntax)
VisitTomlInlineTable(TomlInlineTableSyntax)
VisitTomlInteger(TomlIntegerSyntax)
VisitTomlKey(TomlKeySyntax)
VisitTomlProperty(TomlPropertySyntax)
VisitTomlSkippedText(TomlSkippedTextSyntax)
VisitTomlSkippedValue(TomlSkippedValueSyntax)
VisitTomlString(TomlStringSyntax)
VisitTomlTable(TomlTableSyntax)
VisitTrivia(SyntaxTrivia)

VisitList overloads

VisitList(SyntaxTokenList)

TomlSyntaxRewriter.cs
public virtual SyntaxTokenList VisitList(SyntaxTokenList list)
Parameters
list SyntaxTokenList
Returns

SyntaxTokenList

No documentation is available.

VisitList(SyntaxTriviaList)

TomlSyntaxRewriter.cs

Rewrites each trivium of a list, dropping the ones a rewrite turned into the default trivium.

public virtual SyntaxTriviaList VisitList(SyntaxTriviaList list)
Parameters
list SyntaxTriviaList
Returns

SyntaxTriviaList

VisitList<TNode>(SeparatedSyntaxList<TNode>)

TomlSyntaxRewriter.cs

Rewrites the elements of a separated list and its separators.

public virtual SeparatedSyntaxList<TNode> VisitList<TNode>(SeparatedSyntaxList<TNode> list) where TNode : TomlSyntaxNode
Type parameters
TNode
Parameters
list SeparatedSyntaxList<TNode>
Returns

SeparatedSyntaxList<TNode>

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.cs

Rewrites each node of a list, dropping the ones the rewrite returns null for.

public virtual SyntaxList<TNode> VisitList<TNode>(SyntaxList<TNode> list) where TNode : TomlSyntaxNode
Type parameters
TNode
Parameters
list SyntaxList<TNode>
Returns

SyntaxList<TNode>

Exceptions
InvalidOperationException
The rewrite returned a node that cannot take the place of the one it rewrote.

VisitRequired<TNode>(TNode)

TomlSyntaxRewriter.cs

Rewrites a node that has to be there, keeping it when the rewrite returns null.

protected TNode VisitRequired<TNode>(TNode node) where TNode : TomlSyntaxNode

Type parameters

TNode

Parameters

node TNode

Returns

TNode

Exceptions

InvalidOperationException
The rewrite returned a node that cannot take the place of node.

VisitToken(SyntaxToken)

TomlSyntaxRewriter.cs

Rewrites a token, putting the trivia around it through TomlSyntaxRewriter.VisitTrivia.

public virtual SyntaxToken VisitToken(SyntaxToken token)

Parameters

token SyntaxToken

Returns

SyntaxToken

VisitTomlArray(TomlArraySyntax)

TomlSyntaxRewriter.cs
public override SyntaxNode? VisitTomlArray(TomlArraySyntax node)

Parameters

node TomlArraySyntax

Returns

SyntaxNode?

Exceptions

InsufficientExecutionStackException
The value is nested too deeply to rewrite.

VisitTomlBoolean(TomlBooleanSyntax)

TomlSyntaxRewriter.cs
public override SyntaxNode? VisitTomlBoolean(TomlBooleanSyntax node)

Parameters

node TomlBooleanSyntax

Returns

SyntaxNode?

No documentation is available.

VisitTomlDateTime(TomlDateTimeSyntax)

TomlSyntaxRewriter.cs
public override SyntaxNode? VisitTomlDateTime(TomlDateTimeSyntax node)

Parameters

node TomlDateTimeSyntax

Returns

SyntaxNode?

No documentation is available.

VisitTomlDocument(TomlDocumentSyntax)

TomlSyntaxRewriter.cs
public override SyntaxNode? VisitTomlDocument(TomlDocumentSyntax node)

Parameters

node TomlDocumentSyntax

Returns

SyntaxNode?

No documentation is available.

VisitTomlFloat(TomlFloatSyntax)

TomlSyntaxRewriter.cs
public override SyntaxNode? VisitTomlFloat(TomlFloatSyntax node)

Parameters

node TomlFloatSyntax

Returns

SyntaxNode?

No documentation is available.

VisitTomlInlineTable(TomlInlineTableSyntax)

TomlSyntaxRewriter.cs
public override SyntaxNode? VisitTomlInlineTable(TomlInlineTableSyntax node)

Parameters

node TomlInlineTableSyntax

Returns

SyntaxNode?

Exceptions

InsufficientExecutionStackException
The value is nested too deeply to rewrite.

VisitTomlInteger(TomlIntegerSyntax)

TomlSyntaxRewriter.cs
public override SyntaxNode? VisitTomlInteger(TomlIntegerSyntax node)

Parameters

node TomlIntegerSyntax

Returns

SyntaxNode?

No documentation is available.

VisitTomlKey(TomlKeySyntax)

TomlSyntaxRewriter.cs
public override SyntaxNode? VisitTomlKey(TomlKeySyntax node)

Parameters

node TomlKeySyntax

Returns

SyntaxNode?

No documentation is available.

VisitTomlProperty(TomlPropertySyntax)

TomlSyntaxRewriter.cs
public override SyntaxNode? VisitTomlProperty(TomlPropertySyntax node)

Parameters

node TomlPropertySyntax

Returns

SyntaxNode?

No documentation is available.

VisitTomlSkippedText(TomlSkippedTextSyntax)

TomlSyntaxRewriter.cs
public override SyntaxNode? VisitTomlSkippedText(TomlSkippedTextSyntax node)

Parameters

node TomlSkippedTextSyntax

Returns

SyntaxNode?

No documentation is available.

VisitTomlSkippedValue(TomlSkippedValueSyntax)

TomlSyntaxRewriter.cs
public override SyntaxNode? VisitTomlSkippedValue(TomlSkippedValueSyntax node)

Parameters

node TomlSkippedValueSyntax

Returns

SyntaxNode?

No documentation is available.

VisitTomlString(TomlStringSyntax)

TomlSyntaxRewriter.cs
public override SyntaxNode? VisitTomlString(TomlStringSyntax node)

Parameters

node TomlStringSyntax

Returns

SyntaxNode?

No documentation is available.

VisitTomlTable(TomlTableSyntax)

TomlSyntaxRewriter.cs
public override SyntaxNode? VisitTomlTable(TomlTableSyntax node)

Parameters

node TomlTableSyntax

Returns

SyntaxNode?

No documentation is available.

VisitTrivia(SyntaxTrivia)

TomlSyntaxRewriter.cs
public virtual SyntaxTrivia VisitTrivia(SyntaxTrivia trivia)

Parameters

trivia SyntaxTrivia

Returns

SyntaxTrivia

No documentation is available.