Click or drag to resize

SyntaxNodeOrToken Class



A wrapper for either a syntax node (SyntaxNode) or a syntax token (SyntaxToken).
Inheritance Hierarchy
SystemValueType
  Microsoft.CodeAnalysisSyntaxNodeOrToken

Namespace:  Microsoft.CodeAnalysis
Assembly:  Microsoft.CodeAnalysis (in Microsoft.CodeAnalysis.dll) Version: 2.3.0-dev-56735-00. Commit Hash: <developer build>
Syntax
public sealed class SyntaxNodeOrToken : ValueType, 
	IEquatable

The SyntaxNodeOrToken type exposes the following members.

Properties
  NameDescription
Public propertyContainsAnnotations
Determines whether this node or token (or any sub node, token or trivia) as annotations.
Public propertyContainsDiagnostics
Determines whether the underlying node or token or any of its descendant nodes, tokens or trivia have any diagnostics on them.
Public propertyContainsDirectives
Determines whether the underlying node or token has any descendant preprocessor directives.
Public propertyFullSpan
The absolute span of the underlying node or token in characters, including its leading and trailing trivia.
Public propertyHasLeadingTrivia
Determines whether the underlying node or token has any leading trivia.
Public propertyHasTrailingTrivia
Determines whether the underlying node or token has any trailing trivia.
Public propertyIsMissing
Determines whether the underlying node or token represents a language construct that was actually parsed from source code. Missing nodes and tokens are typically generated by the parser in error scenarios to represent constructs that should have been present in the source code for the source code to compile successfully but were actually missing.
Public propertyIsNode
Determines whether this SyntaxNodeOrToken is wrapping a node.
Public propertyIsToken
Determines whether this SyntaxNodeOrToken is wrapping a token.
Public propertyLanguage
The language name that this node or token is syntax of.
Public propertyParent
The node that contains the underlying node or token in its Children collection.
Public propertyRawKind
An integer representing the language specific kind of the underlying node or token.
Public propertySpan
The absolute span of the underlying node or token in characters, not including its leading and trailing trivia.
Public propertySpanStart
Same as accessing Start on Span.
Public propertySyntaxTree
SyntaxTree which contains current SyntaxNodeOrToken.
Top
Methods
  NameDescription
Public methodAsNode
Returns the underlying node if this SyntaxNodeOrToken is wrapping a node.
Public methodAsToken
Returns the underlying token if this SyntaxNodeOrToken is wrapping a token.
Public methodChildNodesAndTokens
The list of child nodes and tokens of the underlying node or token.
Public methodEquals(Object)
Determines whether the supplied SyntaxNodeOrToken is equal to this SyntaxNodeOrToken.
Public methodEquals(SyntaxNodeOrToken)
Determines whether the supplied SyntaxNodeOrToken is equal to this SyntaxNodeOrToken.
Public methodGetAnnotations(Void)
Public methodGetDiagnostics
Gets a list of all the diagnostics in either the sub tree that has this node as its root or associated with this token and its related trivia. This method does not filter diagnostics based on #pragmas and compiler options like nowarn, warnaserror etc.
Public methodStatic memberGetFirstChildIndexSpanningPosition
Public methodGetHashCode
Serves as hash function for SyntaxNodeOrToken.
Public methodGetLeadingTrivia
The list of trivia that appear before the underlying node or token in the source code and are attached to a token that is a descendant of the underlying node or token.
Public methodGetLocation
Get the location of this node or token.
Public methodGetNextSibling
Public methodGetPreviousSibling
Public methodGetTrailingTrivia
The list of trivia that appear after the underlying node or token in the source code and are attached to a token that is a descendant of the underlying node or token.
Public methodHasAnnotation
Determines if this node or token has the specific annotation.
Public methodHasAnnotations(IEnumerableT)
Public methodHasAnnotations(String)
Determines whether this node or token has annotations of the specified kind.
Public methodIsEquivalentTo
Determines if the two nodes or tokens are equivalent.
Public methodToFullString
Returns the full string representation of this node or token including its leading and trailing trivia.
Public methodToString
Returns the string representation of this node or token, not including its leading and trailing trivia.
Public methodWithAdditionalAnnotations(IEnumerableT)
Public methodWithAdditionalAnnotations(SyntaxAnnotation)
Creates a new node or token identical to this one with the specified annotations.
Public methodWithLeadingTrivia(IEnumerableT)
Public methodWithLeadingTrivia(SyntaxTrivia)
Public methodWithoutAnnotations(IEnumerableT)
Public methodWithoutAnnotations(String)
Creates a new node or token identical to this one without annotations of the specified kind.
Public methodWithoutAnnotations(SyntaxAnnotation)
Creates a new node or token identical to this one without the specified annotations.
Public methodWithTrailingTrivia(IEnumerableT)
Public methodWithTrailingTrivia(SyntaxTrivia)
Public methodWriteTo
Writes the full text of this node or token to the specified TextWriter.
Top
Operators
  NameDescription
Public operatorStatic memberEquality
Determines whether two SyntaxNodeOrTokens are equal.
Public operatorStatic member(SyntaxNodeOrToken to SyntaxToken)
Returns the underlying token wrapped by the supplied SyntaxNodeOrToken.
Public operatorStatic member(SyntaxNodeOrToken to SyntaxNode)
Returns the underlying node wrapped by the supplied SyntaxNodeOrToken.
Public operatorStatic member(SyntaxNode to SyntaxNodeOrToken)
Returns a new SyntaxNodeOrToken that wraps the supplied node.
Public operatorStatic member(SyntaxToken to SyntaxNodeOrToken)
Returns a new SyntaxNodeOrToken that wraps the supplied token.
Public operatorStatic memberInequality
Determines whether two SyntaxNodeOrTokens are unequal.
Top
Extension Methods
  NameDescription
Public Extension MethodIsKind(SyntaxKind)Overloaded.
Determines if a SyntaxNodeOrToken is a specified kind.
(Defined by VisualBasicExtensions.)
Public Extension MethodIsKind(SyntaxKind)Overloaded. (Defined by CSharpExtensions.)
Public Extension MethodKindOverloaded.
Returns SyntaxKind for SyntaxNodeOrToken from RawKind property.
(Defined by VisualBasicExtensions.)
Public Extension MethodKindOverloaded. (Defined by CSharpExtensions.)
Top
Remarks
Note that we do not store the token directly, we just store enough information to reconstruct it. This allows us to reuse nodeOrToken as a token's parent.
See Also