SyntaxNode Class
Base class used to define a TOML Syntax tree.
public abstract class SyntaxNode : SyntaxNodeBase- Inheritance
SyntaxNodeBaseSyntaxNode
Constructors
| Name | Description |
|---|---|
| SyntaxNode(SyntaxKind) | Initializes a new instance of the SyntaxNode class. |
SyntaxNode(SyntaxKind)
SyntaxNode.csInitializes a new instance of the SyntaxNode class.
protected SyntaxNode(SyntaxKind kind)Parameters
kindSyntaxKind- The kind of syntax node.
Properties
| Name | Description |
|---|---|
| ChildrenCount | Gets the number of children. |
| Kind | Gets the type of node. |
| LeadingTrivia | Gets the leading trivia attached to this node. Might be null if no leading trivias. |
| TrailingTrivia | Gets the trailing trivia attached to this node. Might be null if no trailing trivias. |
ChildrenCount
Kind
SyntaxNode.csLeadingTrivia
SyntaxNode.csGets the leading trivia attached to this node. Might be null if no leading trivias.
public List<SyntaxTrivia>? LeadingTrivia { get; set; }Property value
TrailingTrivia
SyntaxNode.csGets the trailing trivia attached to this node. Might be null if no trailing trivias.
public List<SyntaxTrivia>? TrailingTrivia { get; set; }Property value
Methods
| Name | Description |
|---|---|
| GetChild(int) | Gets a child at the specified index. |
| GetChildImpl(int) | Gets a child at the specified index. |
| ParentToThis<TSyntaxNode>(TSyntaxNode?, TSyntaxNode?) | Helper method to deparent/parent a node to this instance. |
| ParentToThis<TSyntaxNode>(TSyntaxNode?, TSyntaxNode?, TokenKind) | Helper method to deparent/parent a SyntaxToken to this instance with an expected kind of token. |
| ParentToThis<TSyntaxNode>(TSyntaxNode?, TSyntaxNode?, TokenKind, TokenKind) | Helper method to deparent/parent a SyntaxToken to this instance with an expected kind of token. |
| ParentToThis<TSyntaxNode, TExpected>(TSyntaxNode?, TSyntaxNode?, bool, TExpected) | Helper method to deparent/parent a SyntaxToken to this instance with an expected kind of token condition. |
| ToString() | Returns a string that represents the current object. |
| WriteTo(TextWriter) | Writes this node to a textual TOML representation |
GetChild(int)
SyntaxNode.csGets a child at the specified index.
public SyntaxNode? GetChild(int index)GetChildImpl(int)
Gets a child at the specified index.
protected abstract SyntaxNode? GetChildImpl(int index)Parameters
indexint- Index of the child
Returns
SyntaxNode? A child at the specified index
Remarks
The index is safe to use
ParentToThis overloads
ParentToThis<TSyntaxNode>(TSyntaxNode?, TSyntaxNode?)
SyntaxNode.csHelper method to deparent/parent a node to this instance.
protected void ParentToThis<TSyntaxNode>(ref TSyntaxNode? set, TSyntaxNode? node) where TSyntaxNode : SyntaxNodeType parameters
TSyntaxNode- Type of the node
Parameters
setTSyntaxNode?- The previous child node parented to this instance
nodeTSyntaxNode?- The new child node to parent to this instance
ParentToThis<TSyntaxNode>(TSyntaxNode?, TSyntaxNode?, TokenKind)
SyntaxNode.csHelper method to deparent/parent a SyntaxToken to this instance with an expected kind of token.
protected void ParentToThis<TSyntaxNode>(ref TSyntaxNode? set, TSyntaxNode? node, TokenKind expectedKind) where TSyntaxNode : SyntaxTokenType parameters
TSyntaxNode- Type of the node
Parameters
setTSyntaxNode?- The previous child node parented to this instance
nodeTSyntaxNode?- The new child node to parent to this instance
expectedKindTokenKind- The expected kind of token
ParentToThis<TSyntaxNode>(TSyntaxNode?, TSyntaxNode?, TokenKind, TokenKind)
SyntaxNode.csHelper method to deparent/parent a SyntaxToken to this instance with an expected kind of token.
protected void ParentToThis<TSyntaxNode>(ref TSyntaxNode? set, TSyntaxNode? node, TokenKind expectedKind1, TokenKind expectedKind2) where TSyntaxNode : SyntaxTokenParentToThis<TSyntaxNode, TExpected>(TSyntaxNode?, TSyntaxNode?, bool, TExpected)
SyntaxNode.csHelper method to deparent/parent a SyntaxToken to this instance with an expected kind of token condition.
protected void ParentToThis<TSyntaxNode, TExpected>(ref TSyntaxNode? set, TSyntaxNode? node, bool expectedKindSuccess, TExpected expectedMessage) where TSyntaxNode : SyntaxTokenType parameters
TSyntaxNode- Type of the node
TExpected- The type of message
Parameters
setTSyntaxNode?- The previous child node parented to this instance
nodeTSyntaxNode?- The new child node to parent to this instance
expectedKindSuccessbool- true if kind is matching, false otherwise
expectedMessageTExpected- The message to display if the kind is not matching
ToString()
SyntaxNode.csWriteTo(TextWriter)
SyntaxNode.csWrites this node to a textual TOML representation
public void WriteTo(TextWriter writer)Parameters
writerTextWriter- A writer to receive the TOML output