CssSyntaxNode Class

The base of every node in a CSS tree.

public abstract class CssSyntaxNode : SyntaxNode

Example

var tree = CssSyntaxTree.ParseText("a { color: red }");

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

Assert.Equal([SyntaxKind.StyleRule, SyntaxKind.SelectorList, SyntaxKind.ComplexSelector, SyntaxKind.ComplexSelectorPart, SyntaxKind.CompoundSelector, SyntaxKind.TypeSelector, SyntaxKind.Block, SyntaxKind.Declaration, SyntaxKind.TokenValue], kinds);
Inheritance
SyntaxNode CssSyntaxNode

Properties

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

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

public CssSyntaxNode? Parent { get; }

Property value

CssSyntaxNode?

Methods

NameDescription
Accept(CssSyntaxVisitor)Calls the method of visitor that matches this node.
Accept<TResult>(CssSyntaxVisitor<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(CssSyntaxVisitor)

Calls the method of visitor that matches this node.

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

Accept<TResult>(CssSyntaxVisitor<TResult>)

Calls the method of visitor that matches this node.

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

TResult?

Exceptions
ArgumentNullException
visitor is null.

DescendantComments()

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