Search Results for

    Show / Hide Table of Contents

    Struct SyntaxNodeOrToken

    A wrapper for either a syntax node (SyntaxNode) or a syntax token (SyntaxToken).

    Implements
    IEquatable<SyntaxNodeOrToken>
    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 SyntaxNodeOrToken
    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.

    Properties

    | Improve this Doc View Source

    ContainsAnnotations

    Determines whether this node or token (or any sub node, token or trivia) as annotations.

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

    ContainsDiagnostics

    Determines whether the underlying node or token or any of its descendant nodes, tokens or 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 the underlying node or 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 the underlying node or 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 the underlying node or token has any leading trivia.

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

    HasTrailingTrivia

    Determines whether the underlying node or 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 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.

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

    IsNode

    Determines whether this SyntaxNodeOrToken is wrapping a node.

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

    IsToken

    Determines whether this SyntaxNodeOrToken is wrapping a token.

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

    Language

    The language name that this node or token is syntax of.

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

    Parent

    The node that contains the underlying node or 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 the underlying node or token.

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

    Span

    The absolute span of the underlying node or 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

    SyntaxTree which contains current SyntaxNodeOrToken.

    Declaration
    public readonly SyntaxTree SyntaxTree { get; }
    Property Value
    Type Description
    SyntaxTree

    Methods

    | Improve this Doc View Source

    AsNode()

    Returns the underlying node if this SyntaxNodeOrToken is wrapping a node.

    Declaration
    public readonly SyntaxNode AsNode()
    Returns
    Type Description
    SyntaxNode

    The underlying node if this SyntaxNodeOrToken is wrapping a node.

    | Improve this Doc View Source

    AsToken()

    Returns the underlying token if this SyntaxNodeOrToken is wrapping a token.

    Declaration
    public readonly SyntaxToken AsToken()
    Returns
    Type Description
    SyntaxToken

    The underlying token if this SyntaxNodeOrToken is wrapping a token.

    | Improve this Doc View Source

    ChildNodesAndTokens()

    The list of child nodes and tokens of the underlying node or token.

    Declaration
    public readonly ChildSyntaxList ChildNodesAndTokens()
    Returns
    Type Description
    ChildSyntaxList
    | Improve this Doc View Source

    Equals(SyntaxNodeOrToken)

    Determines whether the supplied SyntaxNodeOrToken is equal to this SyntaxNodeOrToken.

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

    Equals(Object)

    Determines whether the supplied SyntaxNodeOrToken is equal to this SyntaxNodeOrToken.

    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

    GetAnnotations(IEnumerable<String>)

    Gets all 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 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

    GetDiagnostics()

    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.

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

    GetFirstChildIndexSpanningPosition(SyntaxNode, Int32)

    Returns the index of the first child of the provided node that contains the provided position.

    Declaration
    public static int GetFirstChildIndexSpanningPosition(SyntaxNode node, int position)
    Parameters
    Type Name Description
    SyntaxNode node
    System.Int32 position
    Returns
    Type Description
    System.Int32
    | Improve this Doc View Source

    GetHashCode()

    Serves as hash function for SyntaxNodeOrToken.

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

    GetLeadingTrivia()

    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.

    Declaration
    public readonly SyntaxTriviaList GetLeadingTrivia()
    Returns
    Type Description
    SyntaxTriviaList
    | Improve this Doc View Source

    GetLocation()

    Get the location of this node or token.

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

    GetNextSibling()

    Returns the sibling to the right of this node or token.

    Declaration
    public readonly SyntaxNodeOrToken GetNextSibling()
    Returns
    Type Description
    SyntaxNodeOrToken
    | Improve this Doc View Source

    GetPreviousSibling()

    Returns the sibling to the left of this node or token.

    Declaration
    public readonly SyntaxNodeOrToken GetPreviousSibling()
    Returns
    Type Description
    SyntaxNodeOrToken
    | Improve this Doc View Source

    GetTrailingTrivia()

    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.

    Declaration
    public readonly SyntaxTriviaList GetTrailingTrivia()
    Returns
    Type Description
    SyntaxTriviaList
    | Improve this Doc View Source

    HasAnnotation(SyntaxAnnotation)

    Determines if this node or token has the specific 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(IEnumerable<String>)

    Determines whether this node or token has annotations of the specified kind.

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

    HasAnnotations(String)

    Determines whether this node or token has annotations of the specified 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

    IsEquivalentTo(SyntaxNodeOrToken)

    Determines if the two nodes or tokens are equivalent.

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

    IsIncrementallyIdenticalTo(SyntaxNodeOrToken)

    See IsIncrementallyIdenticalTo(SyntaxNode) and IsIncrementallyIdenticalTo(SyntaxToken).

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

    ToFullString()

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

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

    The full string representation of this node or 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 node or token, not including its leading and trailing trivia.

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

    The string representation of this node or 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>)

    Creates a new node or token identical to this one with the specified annotations.

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

    WithAdditionalAnnotations(SyntaxAnnotation[])

    Creates a new node or token identical to this one with the specified annotations.

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

    WithLeadingTrivia(IEnumerable<SyntaxTrivia>)

    Returns this SyntaxNode or SyntaxToken with the provided leading trivia.

    Declaration
    public readonly SyntaxNodeOrToken WithLeadingTrivia(IEnumerable<SyntaxTrivia> trivia)
    Parameters
    Type Name Description
    IEnumerable<SyntaxTrivia> trivia
    Returns
    Type Description
    SyntaxNodeOrToken
    | Improve this Doc View Source

    WithLeadingTrivia(SyntaxTrivia[])

    Returns this SyntaxNode or SyntaxToken with the provided leading trivia.

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

    WithoutAnnotations(IEnumerable<SyntaxAnnotation>)

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

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

    WithoutAnnotations(SyntaxAnnotation[])

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

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

    WithoutAnnotations(String)

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

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

    WithTrailingTrivia(IEnumerable<SyntaxTrivia>)

    Returns this SyntaxNode or SyntaxToken with the provided trailing trivia.

    Declaration
    public readonly SyntaxNodeOrToken WithTrailingTrivia(IEnumerable<SyntaxTrivia> trivia)
    Parameters
    Type Name Description
    IEnumerable<SyntaxTrivia> trivia
    Returns
    Type Description
    SyntaxNodeOrToken
    | Improve this Doc View Source

    WithTrailingTrivia(SyntaxTrivia[])

    Returns this SyntaxNode or SyntaxToken with the provided trailing trivia.

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

    WriteTo(TextWriter)

    Writes the full text of this node or token to the specified TextWriter.

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

    Operators

    | Improve this Doc View Source

    Equality(SyntaxNodeOrToken, SyntaxNodeOrToken)

    Determines whether two SyntaxNodeOrTokens are equal.

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

    Explicit(SyntaxNodeOrToken to SyntaxNode)

    Returns the underlying node wrapped by the supplied SyntaxNodeOrToken.

    Declaration
    public static explicit operator SyntaxNode(SyntaxNodeOrToken nodeOrToken)
    Parameters
    Type Name Description
    SyntaxNodeOrToken nodeOrToken

    The input SyntaxNodeOrToken.

    Returns
    Type Description
    SyntaxNode

    The underlying node wrapped by the supplied SyntaxNodeOrToken.

    | Improve this Doc View Source

    Explicit(SyntaxNodeOrToken to SyntaxToken)

    Returns the underlying token wrapped by the supplied SyntaxNodeOrToken.

    Declaration
    public static explicit operator SyntaxToken(SyntaxNodeOrToken nodeOrToken)
    Parameters
    Type Name Description
    SyntaxNodeOrToken nodeOrToken

    The input SyntaxNodeOrToken.

    Returns
    Type Description
    SyntaxToken

    The underlying token wrapped by the supplied SyntaxNodeOrToken.

    | Improve this Doc View Source

    Implicit(SyntaxNode to SyntaxNodeOrToken)

    Returns a new SyntaxNodeOrToken that wraps the supplied node.

    Declaration
    public static implicit operator SyntaxNodeOrToken(SyntaxNode node)
    Parameters
    Type Name Description
    SyntaxNode node

    The input node.

    Returns
    Type Description
    SyntaxNodeOrToken

    A SyntaxNodeOrToken that wraps the supplied node.

    | Improve this Doc View Source

    Implicit(SyntaxToken to SyntaxNodeOrToken)

    Returns a new SyntaxNodeOrToken that wraps the supplied token.

    Declaration
    public static implicit operator SyntaxNodeOrToken(SyntaxToken token)
    Parameters
    Type Name Description
    SyntaxToken token

    The input token.

    Returns
    Type Description
    SyntaxNodeOrToken

    A SyntaxNodeOrToken that wraps the supplied token.

    | Improve this Doc View Source

    Inequality(SyntaxNodeOrToken, SyntaxNodeOrToken)

    Determines whether two SyntaxNodeOrTokens are unequal.

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

    Implements

    IEquatable<>

    Extension Methods

    LuaExtensions.IsKind(SyntaxNodeOrToken, SyntaxKind)
    LuaExtensions.Kind(SyntaxNodeOrToken)
    • Improve this Doc
    • View Source
    ☀
    ☾
    In This Article
    Back to top

    Copyright (c) LorettaDevs

    Generated by DocFX

    ☀
    ☾