Search Results for

    Show / Hide Table of Contents

    Struct SyntaxToken

    Represents a token in the syntax tree.

    Implements
    IEquatable<SyntaxToken>
    Inherited Members
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetType()
    System.Object.ReferenceEquals(System.Object, System.Object)
    Namespace: Loretta.CodeAnalysis
    Assembly: Loretta.CodeAnalysis.dll
    Syntax
    public readonly struct SyntaxToken

    Properties

    | Improve this Doc View Source

    ContainsAnnotations

    True if this token or its trivia has any annotations.

    Declaration
    public readonly bool ContainsAnnotations { get; }
    Property Value
    Type Description
    System.Boolean
    | Improve this Doc View Source

    ContainsDiagnostics

    Determines whether this token or any of its descendant trivia have any diagnostics on them.

    Declaration
    public readonly bool ContainsDiagnostics { get; }
    Property Value
    Type Description
    System.Boolean
    | Improve this Doc View Source

    ContainsDirectives

    Determines whether this token has any descendant preprocessor directives.

    Declaration
    public readonly bool ContainsDirectives { get; }
    Property Value
    Type Description
    System.Boolean
    | Improve this Doc View Source

    FullSpan

    The absolute span of this token in characters, including its leading and trailing trivia.

    Declaration
    public readonly TextSpan FullSpan { get; }
    Property Value
    Type Description
    TextSpan
    | Improve this Doc View Source

    HasLeadingTrivia

    Determines whether this token has any leading trivia.

    Declaration
    public readonly bool HasLeadingTrivia { get; }
    Property Value
    Type Description
    System.Boolean
    | Improve this Doc View Source

    HasStructuredTrivia

    Determines whether any of this token's trivia is structured.

    Declaration
    public readonly bool HasStructuredTrivia { get; }
    Property Value
    Type Description
    System.Boolean
    | Improve this Doc View Source

    HasTrailingTrivia

    Determines whether this token has any trailing trivia.

    Declaration
    public readonly bool HasTrailingTrivia { get; }
    Property Value
    Type Description
    System.Boolean
    | Improve this Doc View Source

    IsMissing

    Determines whether this token represents a language construct that was actually parsed from source code. Missing 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.

    Declaration
    public readonly bool IsMissing { get; }
    Property Value
    Type Description
    System.Boolean
    | Improve this Doc View Source

    Language

    The language name that this token is syntax of.

    Declaration
    public readonly string Language { get; }
    Property Value
    Type Description
    System.String
    | Improve this Doc View Source

    LeadingTrivia

    The list of trivia that appear before this token in the source code.

    Declaration
    public readonly SyntaxTriviaList LeadingTrivia { get; }
    Property Value
    Type Description
    SyntaxTriviaList
    | Improve this Doc View Source

    Parent

    The node that contains this token in its Children collection.

    Declaration
    public readonly SyntaxNode Parent { get; }
    Property Value
    Type Description
    SyntaxNode
    | Improve this Doc View Source

    RawKind

    An integer representing the language specific kind of this token.

    Declaration
    public readonly int RawKind { get; }
    Property Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    Span

    The absolute span of this token in characters, not including its leading and trailing trivia.

    Declaration
    public readonly TextSpan Span { get; }
    Property Value
    Type Description
    TextSpan
    | Improve this Doc View Source

    SpanStart

    Same as accessing Start on Span.

    Declaration
    public readonly int SpanStart { get; }
    Property Value
    Type Description
    System.Int32
    Remarks

    Slight performance improvement.

    | Improve this Doc View Source

    SyntaxTree

    The SyntaxTree that contains this token.

    Declaration
    public readonly SyntaxTree SyntaxTree { get; }
    Property Value
    Type Description
    SyntaxTree
    | Improve this Doc View Source

    Text

    The token's text.

    Declaration
    public readonly string Text { get; }
    Property Value
    Type Description
    System.String
    | Improve this Doc View Source

    TrailingTrivia

    The list of trivia that appear after this token in the source code and are attached to this token or any of its descendants.

    Declaration
    public readonly SyntaxTriviaList TrailingTrivia { get; }
    Property Value
    Type Description
    SyntaxTriviaList
    | Improve this Doc View Source

    Value

    Returns the value of the token. For example, if the token represents an integer literal, then this property would return the actual integer.

    Declaration
    public readonly object Value { get; }
    Property Value
    Type Description
    System.Object
    | Improve this Doc View Source

    ValueText

    Returns the text representation of the value of the token. For example, if the token represents an integer literal, then this property would return a string representing the integer.

    Declaration
    public readonly string ValueText { get; }
    Property Value
    Type Description
    System.String

    Methods

    | Improve this Doc View Source

    CopyAnnotationsTo(SyntaxToken)

    Copies all SyntaxAnnotations, if any, from this SyntaxToken instance and attaches them to a new instance based on token.

    Declaration
    public readonly SyntaxToken CopyAnnotationsTo(SyntaxToken token)
    Parameters
    Type Name Description
    SyntaxToken token
    Returns
    Type Description
    SyntaxToken
    Remarks

    If no annotations are copied, just returns token.

    | Improve this Doc View Source

    Equals(SyntaxToken)

    Determines whether the supplied SyntaxToken is equal to this SyntaxToken.

    Declaration
    public readonly bool Equals(SyntaxToken other)
    Parameters
    Type Name Description
    SyntaxToken other
    Returns
    Type Description
    System.Boolean
    | Improve this Doc View Source

    Equals(Object)

    Determines whether the supplied SyntaxToken is equal to this SyntaxToken.

    Declaration
    public override readonly bool Equals(object obj)
    Parameters
    Type Name Description
    System.Object obj
    Returns
    Type Description
    System.Boolean
    Overrides
    System.ValueType.Equals(System.Object)
    | Improve this Doc View Source

    GetAllTrivia()

    Gets a list of all the trivia (both leading and trailing) for this token.

    Declaration
    public readonly IEnumerable<SyntaxTrivia> GetAllTrivia()
    Returns
    Type Description
    IEnumerable<SyntaxTrivia>
    | Improve this Doc View Source

    GetAnnotations(IEnumerable<String>)

    Gets all the annotations of the specified annotation kind.

    Declaration
    public readonly IEnumerable<SyntaxAnnotation> GetAnnotations(IEnumerable<string> annotationKinds)
    Parameters
    Type Name Description
    IEnumerable<System.String> annotationKinds
    Returns
    Type Description
    IEnumerable<SyntaxAnnotation>
    | Improve this Doc View Source

    GetAnnotations(String)

    Gets all the annotations of the specified annotation kind.

    Declaration
    public readonly IEnumerable<SyntaxAnnotation> GetAnnotations(string annotationKind)
    Parameters
    Type Name Description
    System.String annotationKind
    Returns
    Type Description
    IEnumerable<SyntaxAnnotation>
    | Improve this Doc View Source

    GetAnnotations(String[])

    Gets all the annotations of the specified annotation kind.

    Declaration
    public readonly IEnumerable<SyntaxAnnotation> GetAnnotations(params string[] annotationKinds)
    Parameters
    Type Name Description
    System.String[] annotationKinds
    Returns
    Type Description
    IEnumerable<SyntaxAnnotation>
    | Improve this Doc View Source

    GetDiagnostics()

    Gets a list of all the diagnostics associated with this token and any related trivia. This method does not filter diagnostics based on #pragmas and compiler options like nowarn, warnaserror etc.

    Declaration
    public readonly IEnumerable<Diagnostic> GetDiagnostics()
    Returns
    Type Description
    IEnumerable<Diagnostic>
    | Improve this Doc View Source

    GetHashCode()

    Serves as hash function for SyntaxToken.

    Declaration
    public override readonly int GetHashCode()
    Returns
    Type Description
    System.Int32
    Overrides
    System.ValueType.GetHashCode()
    | Improve this Doc View Source

    GetLocation()

    Gets the location for this token.

    Declaration
    public readonly Location GetLocation()
    Returns
    Type Description
    Location
    | Improve this Doc View Source

    GetNextToken(Boolean, Boolean, Boolean, Boolean)

    Gets the token that follows this token in the syntax tree.

    Declaration
    public readonly SyntaxToken GetNextToken(bool includeZeroWidth = false, bool includeSkipped = false, bool includeDirectives = false, bool includeDocumentationComments = false)
    Parameters
    Type Name Description
    System.Boolean includeZeroWidth
    System.Boolean includeSkipped
    System.Boolean includeDirectives
    System.Boolean includeDocumentationComments
    Returns
    Type Description
    SyntaxToken

    The token that follows this token in the syntax tree.

    | Improve this Doc View Source

    GetPreviousToken(Boolean, Boolean, Boolean, Boolean)

    Gets the token that precedes this token in the syntax tree.

    Declaration
    public readonly SyntaxToken GetPreviousToken(bool includeZeroWidth = false, bool includeSkipped = false, bool includeDirectives = false, bool includeDocumentationComments = false)
    Parameters
    Type Name Description
    System.Boolean includeZeroWidth
    System.Boolean includeSkipped
    System.Boolean includeDirectives
    System.Boolean includeDocumentationComments
    Returns
    Type Description
    SyntaxToken

    The next token that follows this token in the syntax tree.

    | Improve this Doc View Source

    HasAnnotation(SyntaxAnnotation)

    True if this token has the specified annotation.

    Declaration
    public readonly bool HasAnnotation(SyntaxAnnotation annotation)
    Parameters
    Type Name Description
    SyntaxAnnotation annotation
    Returns
    Type Description
    System.Boolean
    | Improve this Doc View Source

    HasAnnotations(String)

    True if this token has annotations of the specified annotation kind.

    Declaration
    public readonly bool HasAnnotations(string annotationKind)
    Parameters
    Type Name Description
    System.String annotationKind
    Returns
    Type Description
    System.Boolean
    | Improve this Doc View Source

    HasAnnotations(String[])

    True if this token has annotations of the specified annotation kinds.

    Declaration
    public readonly bool HasAnnotations(params string[] annotationKinds)
    Parameters
    Type Name Description
    System.String[] annotationKinds
    Returns
    Type Description
    System.Boolean
    | Improve this Doc View Source

    IsEquivalentTo(SyntaxToken)

    Determines if this token is equivalent to the specified token.

    Declaration
    public readonly bool IsEquivalentTo(SyntaxToken token)
    Parameters
    Type Name Description
    SyntaxToken token
    Returns
    Type Description
    System.Boolean
    | Improve this Doc View Source

    IsIncrementallyIdenticalTo(SyntaxToken)

    Returns true if these two tokens are considered "incrementally identical". An incrementally identical token occurs when a SyntaxTree is incrementally parsed using WithChangedText(SourceText) and the incremental parser is able to take the token from the original tree and use it in its entirety in the new tree. In this case, the ToFullString() of each token will be the same, though they could have different parents, and may occur at different positions in the respective trees. If two tokens are incrementally identical, all trivial of each node will be incrementally identical as well.

    Declaration
    public readonly bool IsIncrementallyIdenticalTo(SyntaxToken token)
    Parameters
    Type Name Description
    SyntaxToken token
    Returns
    Type Description
    System.Boolean
    Remarks

    Incrementally identical tokens can also appear within the same syntax tree, or syntax trees that did not arise from WithChangedText(SourceText). This can happen as the parser is allowed to construct parse trees using shared tokens for efficiency. In all these cases though, it will still remain true that the incrementally identical tokens could have different parents and may occur at different positions in their respective trees.

    | Improve this Doc View Source

    IsPartOfStructuredTrivia()

    Determines whether this token is a descendant of a structured trivia.

    Declaration
    public readonly bool IsPartOfStructuredTrivia()
    Returns
    Type Description
    System.Boolean
    | Improve this Doc View Source

    ToFullString()

    Returns the full string representation of this token including its leading and trailing trivia.

    Declaration
    public readonly string ToFullString()
    Returns
    Type Description
    System.String

    The full string representation of this token including its leading and trailing trivia.

    Remarks

    The length of the returned string is always the same as FullSpan.Length

    | Improve this Doc View Source

    ToString()

    Returns the string representation of this token, not including its leading and trailing trivia.

    Declaration
    public override readonly string ToString()
    Returns
    Type Description
    System.String

    The string representation of this token, not including its leading and trailing trivia.

    Overrides
    System.ValueType.ToString()
    Remarks

    The length of the returned string is always the same as Span.Length

    | Improve this Doc View Source

    WithAdditionalAnnotations(IEnumerable<SyntaxAnnotation>)

    Adds this annotation to a given syntax token, creating a new syntax token of the same type with the annotation on it.

    Declaration
    public readonly SyntaxToken WithAdditionalAnnotations(IEnumerable<SyntaxAnnotation> annotations)
    Parameters
    Type Name Description
    IEnumerable<SyntaxAnnotation> annotations
    Returns
    Type Description
    SyntaxToken
    | Improve this Doc View Source

    WithAdditionalAnnotations(SyntaxAnnotation[])

    Adds this annotation to a given syntax token, creating a new syntax token of the same type with the annotation on it.

    Declaration
    public readonly SyntaxToken WithAdditionalAnnotations(params SyntaxAnnotation[] annotations)
    Parameters
    Type Name Description
    SyntaxAnnotation[] annotations
    Returns
    Type Description
    SyntaxToken
    | Improve this Doc View Source

    WithLeadingTrivia(SyntaxTrivia[])

    Creates a new token from this token with the leading trivia specified..

    Declaration
    public readonly SyntaxToken WithLeadingTrivia(params SyntaxTrivia[] trivia)
    Parameters
    Type Name Description
    SyntaxTrivia[] trivia
    Returns
    Type Description
    SyntaxToken
    | Improve this Doc View Source

    WithLeadingTrivia(SyntaxTriviaList)

    Creates a new token from this token with the leading trivia specified.

    Declaration
    public readonly SyntaxToken WithLeadingTrivia(SyntaxTriviaList trivia)
    Parameters
    Type Name Description
    SyntaxTriviaList trivia
    Returns
    Type Description
    SyntaxToken
    | Improve this Doc View Source

    WithLeadingTrivia(Nullable<IEnumerable<SyntaxTrivia>>)

    Creates a new token from this token with the leading trivia specified.

    Declaration
    public readonly SyntaxToken WithLeadingTrivia(IEnumerable<SyntaxTrivia>? trivia)
    Parameters
    Type Name Description
    System.Nullable<IEnumerable<SyntaxTrivia>> trivia
    Returns
    Type Description
    SyntaxToken
    | Improve this Doc View Source

    WithoutAnnotations(IEnumerable<SyntaxAnnotation>)

    Creates a new syntax token identical to this one without the specified annotations.

    Declaration
    public readonly SyntaxToken WithoutAnnotations(IEnumerable<SyntaxAnnotation> annotations)
    Parameters
    Type Name Description
    IEnumerable<SyntaxAnnotation> annotations
    Returns
    Type Description
    SyntaxToken
    | Improve this Doc View Source

    WithoutAnnotations(SyntaxAnnotation[])

    Creates a new syntax token identical to this one without the specified annotations.

    Declaration
    public readonly SyntaxToken WithoutAnnotations(params SyntaxAnnotation[] annotations)
    Parameters
    Type Name Description
    SyntaxAnnotation[] annotations
    Returns
    Type Description
    SyntaxToken
    | Improve this Doc View Source

    WithoutAnnotations(String)

    Creates a new syntax token identical to this one without annotations of the specified kind.

    Declaration
    public readonly SyntaxToken WithoutAnnotations(string annotationKind)
    Parameters
    Type Name Description
    System.String annotationKind
    Returns
    Type Description
    SyntaxToken
    | Improve this Doc View Source

    WithTrailingTrivia(SyntaxTrivia[])

    Creates a new token from this token with the trailing trivia specified.

    Declaration
    public readonly SyntaxToken WithTrailingTrivia(params SyntaxTrivia[] trivia)
    Parameters
    Type Name Description
    SyntaxTrivia[] trivia
    Returns
    Type Description
    SyntaxToken
    | Improve this Doc View Source

    WithTrailingTrivia(SyntaxTriviaList)

    Creates a new token from this token with the trailing trivia specified.

    Declaration
    public readonly SyntaxToken WithTrailingTrivia(SyntaxTriviaList trivia)
    Parameters
    Type Name Description
    SyntaxTriviaList trivia
    Returns
    Type Description
    SyntaxToken
    | Improve this Doc View Source

    WithTrailingTrivia(Nullable<IEnumerable<SyntaxTrivia>>)

    Creates a new token from this token with the trailing trivia specified.

    Declaration
    public readonly SyntaxToken WithTrailingTrivia(IEnumerable<SyntaxTrivia>? trivia)
    Parameters
    Type Name Description
    System.Nullable<IEnumerable<SyntaxTrivia>> trivia
    Returns
    Type Description
    SyntaxToken
    | Improve this Doc View Source

    WithTriviaFrom(SyntaxToken)

    Creates a new token from this token with the leading and trailing trivia from the specified token.

    Declaration
    public readonly SyntaxToken WithTriviaFrom(SyntaxToken token)
    Parameters
    Type Name Description
    SyntaxToken token
    Returns
    Type Description
    SyntaxToken
    | Improve this Doc View Source

    WriteTo(TextWriter)

    Writes the full text of this token to the specified writer.

    Declaration
    public readonly void WriteTo(TextWriter writer)
    Parameters
    Type Name Description
    System.IO.TextWriter writer

    Operators

    | Improve this Doc View Source

    Equality(SyntaxToken, SyntaxToken)

    Determines whether two SyntaxTokens are equal.

    Declaration
    public static bool operator ==(SyntaxToken left, SyntaxToken right)
    Parameters
    Type Name Description
    SyntaxToken left
    SyntaxToken right
    Returns
    Type Description
    System.Boolean
    | Improve this Doc View Source

    Inequality(SyntaxToken, SyntaxToken)

    Determines whether two SyntaxTokens are unequal.

    Declaration
    public static bool operator !=(SyntaxToken left, SyntaxToken right)
    Parameters
    Type Name Description
    SyntaxToken left
    SyntaxToken right
    Returns
    Type Description
    System.Boolean

    Implements

    IEquatable<>

    Extension Methods

    SyntaxNodeExtensions.WithoutTrivia(SyntaxToken)
    LuaExtensions.IsKind(SyntaxToken, SyntaxKind)
    LuaExtensions.Kind(SyntaxToken)
    LuaExtensions.IsKeyword(SyntaxToken)
    LuaExtensions.IsVerbatimStringLiteral(SyntaxToken)
    LuaExtensions.ReplaceTrivia(SyntaxToken, IEnumerable<SyntaxTrivia>, Func<SyntaxTrivia, SyntaxTrivia, SyntaxTrivia>)
    LuaExtensions.ReplaceTrivia(SyntaxToken, SyntaxTrivia, SyntaxTrivia)
    SyntaxExtensions.NormalizeWhitespace(SyntaxToken, String, Boolean)
    SyntaxExtensions.NormalizeWhitespace(SyntaxToken, String, String, Boolean)
    • Improve this Doc
    • View Source
    ☀
    ☾
    In This Article
    Back to top

    Copyright (c) LorettaDevs

    Generated by DocFX

    ☀
    ☾