SyntaxToken Struct
A terminal of the grammar: the smallest piece of a tree that carries text.
public readonly struct SyntaxToken : IEquatable<SyntaxToken>Remarks
A token is a view rather than an object of its own, so default is a valid, empty token rather than something that throws. Compare against SyntaxToken.None, or test SyntaxToken.RawKind, to detect it.
- Implements
Properties
| Name | Description |
|---|---|
| ContainsAnnotations | |
| ContainsDiagnostics | |
| ContainsSkippedText | |
| FullSpan | Gets the range this token covers, including the trivia on both sides. |
| HasLeadingTrivia | |
| HasTrailingTrivia | |
| IsMissing | Gets a value indicating whether the parser inserted this token rather than reading it from the text. |
| LeadingTrivia | Gets the trivia that comes before this token's text. |
| None | Gets the token that is not there. |
| Parent | Gets the node this token is a child of. |
| RawKind | Gets the language-specific kind of this token as a plain integer. |
| Span | Gets the range the token's own text covers. |
| SpanStart | |
| Text | Gets the token exactly as it was spelled in the source. |
| TrailingTrivia | Gets the trivia that comes after this token's text. |
| Value | Gets the decoded value of the token, which may be a number or another type the language chose. |
| ValueText | Gets the value the text denotes, which is the text itself unless the language decoded something else. |
ContainsAnnotations
SyntaxToken.csContainsDiagnostics
SyntaxToken.csContainsSkippedText
SyntaxToken.csFullSpan
SyntaxToken.csHasLeadingTrivia
SyntaxToken.csHasTrailingTrivia
SyntaxToken.csIsMissing
SyntaxToken.csLeadingTrivia
SyntaxToken.csGets the trivia that comes before this token's text.
public SyntaxTriviaList LeadingTrivia { get; }Property value
None
SyntaxToken.csParent
SyntaxToken.csRawKind
SyntaxToken.csSpan
SyntaxToken.csSpanStart
SyntaxToken.csText
SyntaxToken.csTrailingTrivia
SyntaxToken.csGets the trivia that comes after this token's text.
public SyntaxTriviaList TrailingTrivia { get; }Property value
Value
SyntaxToken.csValueText
SyntaxToken.csMethods
| Name | Description |
|---|---|
| CopyAnnotationsTo(SyntaxToken) | Returns token carrying this token's annotations as well as its own. |
| Equals(SyntaxToken) | |
| Equals(object?) | |
| GetAnnotations() | Gets all the annotations of this token. |
| GetAnnotations(string) | Gets the annotations of this token of the given kind. |
| GetHashCode() | |
| GetNextToken() | Returns the token that comes after this one in the tree, or SyntaxToken.None when there is none. |
| GetPreviousToken() | Returns the token that comes before this one in the tree, or SyntaxToken.None when there is none. |
| HasAnnotation(SyntaxAnnotation?) | Determines whether this token carries annotation. |
| HasAnnotations(string) | Determines whether this token carries an annotation of the given kind. |
| IsEquivalentTo(SyntaxToken) | Determines whether the two tokens have the same kind and text, ignoring the trivia around them. |
| IsIncrementallyIdenticalTo(SyntaxToken) | Determines whether the two tokens are backed by the very same immutable token, which happens when one tree was derived from the other and this token was left untouched. |
| ToFullString() | Returns the text of this token, including its trivia. |
| ToString() | Returns the text of this token, excluding its trivia. |
| WithAdditionalAnnotations(SyntaxAnnotation[]) | Returns this token carrying annotations as well as the ones it already has. |
| WithLeadingTrivia(SyntaxTrivia[]) | Returns this token with trivia in front of its text. |
| WithLeadingTrivia(IEnumerable<SyntaxTrivia>?) | Returns this token with trivia in front of its text. |
| WithTrailingTrivia(SyntaxTrivia[]) | Returns this token with trivia after its text. |
| WithTrailingTrivia(IEnumerable<SyntaxTrivia>?) | Returns this token with trivia after its text. |
| WithTriviaFrom(SyntaxToken) | Returns this token carrying the trivia of token on both sides. |
| WithoutAnnotations(SyntaxAnnotation[]) | Returns this token without annotations. |
| WithoutAnnotations(string) | Returns this token without any annotation of the given kind. |
| WriteTo(TextWriter) |
CopyAnnotationsTo(SyntaxToken)
SyntaxToken.csReturns token carrying this token's annotations as well as its own.
public SyntaxToken CopyAnnotationsTo(SyntaxToken token)Equals overloads
Equals(SyntaxToken)
SyntaxToken.cspublic bool Equals(SyntaxToken other)No documentation is available.
Equals(object?)
SyntaxToken.csGetAnnotations overloads
GetAnnotations()
SyntaxToken.csGets all the annotations of this token.
public IEnumerable<SyntaxAnnotation> GetAnnotations()GetAnnotations(string)
SyntaxToken.csGets the annotations of this token of the given kind.
public IEnumerable<SyntaxAnnotation> GetAnnotations(string annotationKind)GetHashCode()
SyntaxToken.csGetNextToken()
SyntaxToken.csReturns the token that comes after this one in the tree, or SyntaxToken.None when there is none.
public SyntaxToken GetNextToken()Returns
GetPreviousToken()
SyntaxToken.csReturns the token that comes before this one in the tree, or SyntaxToken.None when there is none.
public SyntaxToken GetPreviousToken()Returns
HasAnnotation(SyntaxAnnotation?)
SyntaxToken.csDetermines whether this token carries annotation.
public bool HasAnnotation(SyntaxAnnotation? annotation)HasAnnotations(string)
SyntaxToken.csIsEquivalentTo(SyntaxToken)
SyntaxToken.csDetermines whether the two tokens have the same kind and text, ignoring the trivia around them.
public bool IsEquivalentTo(SyntaxToken token)IsIncrementallyIdenticalTo(SyntaxToken)
SyntaxToken.csDetermines whether the two tokens are backed by the very same immutable token, which happens when one tree was derived from the other and this token was left untouched.
public bool IsIncrementallyIdenticalTo(SyntaxToken token)ToFullString()
SyntaxToken.csToString()
SyntaxToken.csWithAdditionalAnnotations(SyntaxAnnotation[])
SyntaxToken.csReturns this token carrying annotations as well as the ones it already has.
public SyntaxToken WithAdditionalAnnotations(params SyntaxAnnotation[] annotations)WithLeadingTrivia overloads
WithLeadingTrivia(SyntaxTrivia[])
SyntaxToken.csReturns this token with trivia in front of its text.
public SyntaxToken WithLeadingTrivia(params SyntaxTrivia[] trivia)WithLeadingTrivia(IEnumerable<SyntaxTrivia>?)
SyntaxToken.csReturns this token with trivia in front of its text.
public SyntaxToken WithLeadingTrivia(IEnumerable<SyntaxTrivia>? trivia)WithTrailingTrivia overloads
WithTrailingTrivia(SyntaxTrivia[])
SyntaxToken.csReturns this token with trivia after its text.
public SyntaxToken WithTrailingTrivia(params SyntaxTrivia[] trivia)WithTrailingTrivia(IEnumerable<SyntaxTrivia>?)
SyntaxToken.csReturns this token with trivia after its text.
public SyntaxToken WithTrailingTrivia(IEnumerable<SyntaxTrivia>? trivia)WithTriviaFrom(SyntaxToken)
SyntaxToken.csReturns this token carrying the trivia of token on both sides.
public SyntaxToken WithTriviaFrom(SyntaxToken token)WithoutAnnotations overloads
WithoutAnnotations(SyntaxAnnotation[])
SyntaxToken.csReturns this token without annotations.
public SyntaxToken WithoutAnnotations(params SyntaxAnnotation[] annotations)WithoutAnnotations(string)
SyntaxToken.csReturns this token without any annotation of the given kind.
public SyntaxToken WithoutAnnotations(string annotationKind)WriteTo(TextWriter)
SyntaxToken.cspublic void WriteTo(TextWriter writer)Operators
| Name | Description |
|---|---|
| operator ==(SyntaxToken, SyntaxToken) | |
| operator !=(SyntaxToken, SyntaxToken) |
operator ==(SyntaxToken, SyntaxToken)
SyntaxToken.cspublic static bool operator ==(SyntaxToken left, SyntaxToken right)No documentation is available.
operator !=(SyntaxToken, SyntaxToken)
SyntaxToken.cspublic static bool operator !=(SyntaxToken left, SyntaxToken right)No documentation is available.