ShellSyntaxNode Class

The base of every node in a shell tree.

public abstract class ShellSyntaxNode : SyntaxNode

Example

var tree = ShellSyntaxTree.ParseText("ls -l", ShellDialect.Bash);

var kinds = new List<SyntaxKind>();
foreach (var node in tree.GetRoot().DescendantNodes())
{
    kinds.Add(node.Kind());
}

Assert.Equal([SyntaxKind.StatementList, SyntaxKind.Command, SyntaxKind.Word, SyntaxKind.LiteralWordPart, SyntaxKind.Word, SyntaxKind.LiteralWordPart], kinds);
Inheritance
SyntaxNode ShellSyntaxNode

Properties

NameDescription
DialectGets the dialect the node was read as, or null when it belongs to no tree.
ParentGets the node this one is a child of, or null when it is the root of its tree.

Gets the dialect the node was read as, or null when it belongs to no tree.

public ShellDialect? Dialect { get; }

Property value

ShellDialect?

Gets the node this one is a child of, or null when it is the root of its tree.

public ShellSyntaxNode? Parent { get; }

Property value

ShellSyntaxNode?

Methods

NameDescription
Accept(ShellSyntaxVisitor)Calls the method of visitor that matches this node.
Accept<TResult>(ShellSyntaxVisitor<TResult>)Calls the method of visitor that matches this node.
DescendantComments()Returns every comment in this node, in source order.
Kind()Gets what kind of node this is.

Accept overloads

Accept(ShellSyntaxVisitor)

Calls the method of visitor that matches this node.

public abstract void Accept(ShellSyntaxVisitor visitor)
Parameters
visitor ShellSyntaxVisitor
Exceptions
ArgumentNullException
visitor is null.

Accept<TResult>(ShellSyntaxVisitor<TResult>)

Calls the method of visitor that matches this node.

public abstract TResult? Accept<TResult>(ShellSyntaxVisitor<TResult> visitor)
Type parameters
TResult
Parameters
visitor ShellSyntaxVisitor<TResult>
Returns

TResult?

Exceptions
ArgumentNullException
visitor is null.

DescendantComments()

ShellSyntaxNode.cs

Returns every comment in this node, in source order.

public IEnumerable<SyntaxTrivia> DescendantComments()

Gets what kind of node this is.

public SyntaxKind Kind()

Returns

SyntaxKind