SyntaxNodeOrToken Struct

Either a node or a token, as they appear side by side among the children of a node.

public readonly struct SyntaxNodeOrToken : IEquatable<SyntaxNodeOrToken>

Remarks

default is the token that is not there, matching SyntaxToken.None.

Implements

Properties

NameDescription
ContainsAnnotations
ContainsDiagnostics
ContainsSkippedText
FullSpan
IsMissing
IsNode
IsToken
ParentGets the node this one is a child of.
RawKindGets the language-specific kind as a plain integer.
Span
SpanStart

ContainsAnnotations

SyntaxNodeOrToken.cs
public bool ContainsAnnotations { get; }

Property value

bool

No documentation is available.

ContainsDiagnostics

SyntaxNodeOrToken.cs
public bool ContainsDiagnostics { get; }

Property value

bool

No documentation is available.

ContainsSkippedText

SyntaxNodeOrToken.cs
public bool ContainsSkippedText { get; }

Property value

bool

No documentation is available.

public TextSpan FullSpan { get; }

Property value

TextSpan

No documentation is available.

public bool IsMissing { get; }

Property value

bool

No documentation is available.

public bool IsNode { get; }

Property value

bool

No documentation is available.

public bool IsToken { get; }

Property value

bool

No documentation is available.

Gets the node this one is a child of.

public SyntaxNode? Parent { get; }

Property value

SyntaxNode?

Gets the language-specific kind as a plain integer.

public int RawKind { get; }

Property value

int

public TextSpan Span { get; }

Property value

TextSpan

No documentation is available.

public int SpanStart { get; }

Property value

int

No documentation is available.

Methods

NameDescription
AsNode()Returns the node, or null when this is a token.
AsNode(SyntaxNode?)Returns whether this is a node, and the node itself when it is.
AsToken()Returns the token, or SyntaxToken.None when this is a node.
AsToken(SyntaxToken)Returns whether this is a token, and the token itself when it is.
ChildNodesAndTokens()Gets the children of the node, or nothing when this is a token.
Equals(SyntaxNodeOrToken)
Equals(object?)
FromNode(SyntaxNode)Returns this as a node or token, for callers that cannot use the implicit conversion.
FromToken(SyntaxToken)Returns this as a node or token, for callers that cannot use the implicit conversion.
GetHashCode()
GetLeadingTrivia()
GetTrailingTrivia()
IsEquivalentTo(SyntaxNodeOrToken)Determines whether the two have the same structure and text, ignoring their positions.
ToFullString()
ToString()
WriteTo(TextWriter)

AsNode overloads

Returns the node, or null when this is a token.

public SyntaxNode? AsNode()

AsNode(SyntaxNode?)

SyntaxNodeOrToken.cs

Returns whether this is a node, and the node itself when it is.

public bool AsNode(out SyntaxNode? node)
Parameters
node SyntaxNode?
Returns

bool

AsToken overloads

Returns the token, or SyntaxToken.None when this is a node.

public SyntaxToken AsToken()

AsToken(SyntaxToken)

SyntaxNodeOrToken.cs

Returns whether this is a token, and the token itself when it is.

public bool AsToken(out SyntaxToken token)
Parameters
token SyntaxToken
Returns

bool

ChildNodesAndTokens()

SyntaxNodeOrToken.cs

Gets the children of the node, or nothing when this is a token.

public ChildSyntaxList ChildNodesAndTokens()

Equals overloads

Equals(SyntaxNodeOrToken)

SyntaxNodeOrToken.cs
public bool Equals(SyntaxNodeOrToken other)
Parameters
other SyntaxNodeOrToken
Returns

bool

No documentation is available.

Equals(object?)

SyntaxNodeOrToken.cs
public override bool Equals(object? obj)
Parameters
obj object?
Returns

bool

No documentation is available.

FromNode(SyntaxNode)

SyntaxNodeOrToken.cs

Returns this as a node or token, for callers that cannot use the implicit conversion.

public static SyntaxNodeOrToken FromNode(SyntaxNode node)

Parameters

node SyntaxNode

Returns

SyntaxNodeOrToken

FromToken(SyntaxToken)

SyntaxNodeOrToken.cs

Returns this as a node or token, for callers that cannot use the implicit conversion.

public static SyntaxNodeOrToken FromToken(SyntaxToken token)

Parameters

token SyntaxToken

Returns

SyntaxNodeOrToken

public override int GetHashCode()

Returns

int

No documentation is available.

GetLeadingTrivia()

SyntaxNodeOrToken.cs
public SyntaxTriviaList GetLeadingTrivia()

No documentation is available.

GetTrailingTrivia()

SyntaxNodeOrToken.cs
public SyntaxTriviaList GetTrailingTrivia()

No documentation is available.

IsEquivalentTo(SyntaxNodeOrToken)

SyntaxNodeOrToken.cs

Determines whether the two have the same structure and text, ignoring their positions.

public bool IsEquivalentTo(SyntaxNodeOrToken other)

Parameters

other SyntaxNodeOrToken

Returns

bool

ToFullString()

SyntaxNodeOrToken.cs
public string ToFullString()

Returns

string

No documentation is available.

public override string ToString()

Returns

string

No documentation is available.

WriteTo(TextWriter)

SyntaxNodeOrToken.cs
public void WriteTo(TextWriter writer)

Parameters

writer TextWriter

Exceptions

ArgumentNullException
writer is null.

Operators

NameDescription
operator ==(SyntaxNodeOrToken, SyntaxNodeOrToken)
explicit operator SyntaxNode?(SyntaxNodeOrToken)
explicit operator SyntaxToken(SyntaxNodeOrToken)
implicit operator SyntaxNodeOrToken(SyntaxNode)
implicit operator SyntaxNodeOrToken(SyntaxToken)
operator !=(SyntaxNodeOrToken, SyntaxNodeOrToken)

operator ==(SyntaxNodeOrToken, SyntaxNodeOrToken)

SyntaxNodeOrToken.cs
public static bool operator ==(SyntaxNodeOrToken left, SyntaxNodeOrToken right)

Parameters

left SyntaxNodeOrToken
right SyntaxNodeOrToken

Returns

bool

No documentation is available.

op_Explicit overloads

explicit operator SyntaxNode?(SyntaxNodeOrToken)

SyntaxNodeOrToken.cs
public static explicit operator SyntaxNode?(SyntaxNodeOrToken nodeOrToken)
Parameters
nodeOrToken SyntaxNodeOrToken
Returns

SyntaxNode?

No documentation is available.

explicit operator SyntaxToken(SyntaxNodeOrToken)

SyntaxNodeOrToken.cs
public static explicit operator SyntaxToken(SyntaxNodeOrToken nodeOrToken)
Parameters
nodeOrToken SyntaxNodeOrToken
Returns

SyntaxToken

No documentation is available.

op_Implicit overloads

implicit operator SyntaxNodeOrToken(SyntaxNode)

SyntaxNodeOrToken.cs
public static implicit operator SyntaxNodeOrToken(SyntaxNode node)
Parameters
node SyntaxNode
Returns

SyntaxNodeOrToken

No documentation is available.

implicit operator SyntaxNodeOrToken(SyntaxToken)

SyntaxNodeOrToken.cs
public static implicit operator SyntaxNodeOrToken(SyntaxToken token)
Parameters
token SyntaxToken
Returns

SyntaxNodeOrToken

No documentation is available.

operator !=(SyntaxNodeOrToken, SyntaxNodeOrToken)

SyntaxNodeOrToken.cs
public static bool operator !=(SyntaxNodeOrToken left, SyntaxNodeOrToken right)

Parameters

left SyntaxNodeOrToken
right SyntaxNodeOrToken

Returns

bool

No documentation is available.