Search Results for

    Show / Hide Table of Contents

    Class SyntaxTree

    The parsed representation of a source document.

    Inheritance
    System.Object
    SyntaxTree
    LuaSyntaxTree
    Inherited Members
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    Namespace: Loretta.CodeAnalysis
    Assembly: Loretta.CodeAnalysis.dll
    Syntax
    public abstract class SyntaxTree

    Properties

    | Improve this Doc View Source

    Encoding

    The text encoding of the source document.

    Declaration
    public abstract Encoding Encoding { get; }
    Property Value
    Type Description
    System.Text.Encoding
    | Improve this Doc View Source

    FilePath

    The path of the source document file.

    Declaration
    public abstract string FilePath { get; }
    Property Value
    Type Description
    System.String
    Remarks

    If this syntax tree is not associated with a file, this value can be empty. The path shall not be null.

    The file doesn't need to exist on disk. The path is opaque to the compiler.

    | Improve this Doc View Source

    HasCompilationUnitRoot

    Returns true if this syntax tree has a root with SyntaxKind "CompilationUnit".

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

    Length

    The length of the text of the syntax tree.

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

    Options

    The options used by the parser to produce the syntax tree.

    Declaration
    public ParseOptions Options { get; }
    Property Value
    Type Description
    ParseOptions

    Methods

    | Improve this Doc View Source

    GetChangedSpans(SyntaxTree)

    Returns a list of the changed regions between this tree and the specified tree. The list is conservative for performance reasons. It may return larger regions than what has actually changed.

    Declaration
    public abstract IList<TextSpan> GetChangedSpans(SyntaxTree syntaxTree)
    Parameters
    Type Name Description
    SyntaxTree syntaxTree
    Returns
    Type Description
    IList<TextSpan>
    | Improve this Doc View Source

    GetChanges(SyntaxTree)

    Gets a list of text changes that when applied to the old tree produce this tree.

    Declaration
    public abstract IList<TextChange> GetChanges(SyntaxTree oldTree)
    Parameters
    Type Name Description
    SyntaxTree oldTree

    The old tree.

    Returns
    Type Description
    IList<TextChange>
    Remarks

    The list of changes may be different than the original changes that produced this tree.

    | Improve this Doc View Source

    GetDiagnostics(CancellationToken)

    Gets a list of all the diagnostics in the syntax tree. This method does not filter diagnostics based on #pragmas and compiler options like nowarn, warnaserror etc.

    Declaration
    public abstract IEnumerable<Diagnostic> GetDiagnostics(CancellationToken cancellationToken = null)
    Parameters
    Type Name Description
    CancellationToken cancellationToken
    Returns
    Type Description
    IEnumerable<Diagnostic>
    | Improve this Doc View Source

    GetDiagnostics(SyntaxNode)

    Gets a list of all the diagnostics in the sub tree that has the specified node as its root. This method does not filter diagnostics based on #pragmas and compiler options like nowarn, warnaserror etc.

    Declaration
    public abstract IEnumerable<Diagnostic> GetDiagnostics(SyntaxNode node)
    Parameters
    Type Name Description
    SyntaxNode node
    Returns
    Type Description
    IEnumerable<Diagnostic>
    | Improve this Doc View Source

    GetDiagnostics(SyntaxNodeOrToken)

    Gets a list of all the diagnostics in either the sub tree that has the specified node as its root or associated with the token and its related trivia. This method does not filter diagnostics based on #pragmas and compiler options like nowarn, warnaserror etc.

    Declaration
    public abstract IEnumerable<Diagnostic> GetDiagnostics(SyntaxNodeOrToken nodeOrToken)
    Parameters
    Type Name Description
    SyntaxNodeOrToken nodeOrToken
    Returns
    Type Description
    IEnumerable<Diagnostic>
    | Improve this Doc View Source

    GetDiagnostics(SyntaxToken)

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

    Declaration
    public abstract IEnumerable<Diagnostic> GetDiagnostics(SyntaxToken token)
    Parameters
    Type Name Description
    SyntaxToken token
    Returns
    Type Description
    IEnumerable<Diagnostic>
    | Improve this Doc View Source

    GetDiagnostics(SyntaxTrivia)

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

    Declaration
    public abstract IEnumerable<Diagnostic> GetDiagnostics(SyntaxTrivia trivia)
    Parameters
    Type Name Description
    SyntaxTrivia trivia
    Returns
    Type Description
    IEnumerable<Diagnostic>
    | Improve this Doc View Source

    GetLineSpan(TextSpan, CancellationToken)

    Gets the location in terms of path, line and column for a given span.

    Declaration
    public abstract FileLinePositionSpan GetLineSpan(TextSpan span, CancellationToken cancellationToken = null)
    Parameters
    Type Name Description
    TextSpan span

    Span within the tree.

    CancellationToken cancellationToken

    Cancellation token.

    Returns
    Type Description
    FileLinePositionSpan

    A valid FileLinePositionSpan that contains path, line and column information. The values are not affected by line mapping directives (#line).

    | Improve this Doc View Source

    GetLocation(TextSpan)

    Gets a location for the specified text span.

    Declaration
    public abstract Location GetLocation(TextSpan span)
    Parameters
    Type Name Description
    TextSpan span
    Returns
    Type Description
    Location
    | Improve this Doc View Source

    GetReference(SyntaxNode)

    Gets a SyntaxReference for a specified syntax node. SyntaxReferences can be used to regain access to a syntax node without keeping the entire tree and source text in memory.

    Declaration
    public abstract SyntaxReference GetReference(SyntaxNode node)
    Parameters
    Type Name Description
    SyntaxNode node
    Returns
    Type Description
    SyntaxReference
    | Improve this Doc View Source

    GetRoot(CancellationToken)

    Gets the root node of the syntax tree, causing computation if necessary.

    Declaration
    public SyntaxNode GetRoot(CancellationToken cancellationToken = null)
    Parameters
    Type Name Description
    CancellationToken cancellationToken
    Returns
    Type Description
    SyntaxNode
    | Improve this Doc View Source

    GetRootAsync(CancellationToken)

    Gets the root node of the syntax tree asynchronously.

    Declaration
    public Task<SyntaxNode> GetRootAsync(CancellationToken cancellationToken = null)
    Parameters
    Type Name Description
    CancellationToken cancellationToken
    Returns
    Type Description
    Task<SyntaxNode>
    | Improve this Doc View Source

    GetText(CancellationToken)

    Gets the text of the source document.

    Declaration
    public abstract SourceText GetText(CancellationToken cancellationToken = null)
    Parameters
    Type Name Description
    CancellationToken cancellationToken
    Returns
    Type Description
    SourceText
    | Improve this Doc View Source

    GetTextAsync(CancellationToken)

    Gets the text of the source document asynchronously.

    Declaration
    public virtual Task<SourceText> GetTextAsync(CancellationToken cancellationToken = null)
    Parameters
    Type Name Description
    CancellationToken cancellationToken
    Returns
    Type Description
    Task<SourceText>
    Remarks

    By default, the work associated with this method will be executed immediately on the current thread. Implementations that wish to schedule this work differently should override GetTextAsync(CancellationToken).

    | Improve this Doc View Source

    IsEquivalentTo(SyntaxTree, Boolean)

    Determines if two trees are the same, disregarding trivia differences.

    Declaration
    public abstract bool IsEquivalentTo(SyntaxTree tree, bool topLevel = false)
    Parameters
    Type Name Description
    SyntaxTree tree

    The tree to compare against.

    System.Boolean topLevel

    If true then the trees are equivalent if the contained nodes and tokens declaring metadata visible symbolic information are equivalent, ignoring any differences of nodes inside method bodies or initializer expressions, otherwise all nodes and tokens must be equivalent.

    Returns
    Type Description
    System.Boolean
    | Improve this Doc View Source

    ToString()

    Returns a System.String that represents the entire source text of this SyntaxTree.

    Declaration
    public override string ToString()
    Returns
    Type Description
    System.String
    Overrides
    System.Object.ToString()
    | Improve this Doc View Source

    TryGetRoot(out SyntaxNode)

    Gets the root of the syntax tree if it is available.

    Declaration
    public bool TryGetRoot(out SyntaxNode root)
    Parameters
    Type Name Description
    SyntaxNode root
    Returns
    Type Description
    System.Boolean
    | Improve this Doc View Source

    TryGetText(out SourceText)

    Gets the syntax tree's text if it is available.

    Declaration
    public abstract bool TryGetText(out SourceText text)
    Parameters
    Type Name Description
    SourceText text
    Returns
    Type Description
    System.Boolean
    | Improve this Doc View Source

    WithChangedText(SourceText)

    Create a new syntax tree based off this tree using a new source text.

    If the new source text is a minor change from the current source text an incremental parse will occur reusing most of the current syntax tree internal data. Otherwise, a full parse will occur using the new source text.

    Declaration
    public abstract SyntaxTree WithChangedText(SourceText newText)
    Parameters
    Type Name Description
    SourceText newText
    Returns
    Type Description
    SyntaxTree
    | Improve this Doc View Source

    WithFilePath(String)

    Returns a new tree whose FilePath is the specified node and other properties are copied from the current tree.

    Declaration
    public abstract SyntaxTree WithFilePath(string path)
    Parameters
    Type Name Description
    System.String path
    Returns
    Type Description
    SyntaxTree
    | Improve this Doc View Source

    WithRootAndOptions(SyntaxNode, ParseOptions)

    Returns a new tree whose root and options are as specified and other properties are copied from the current tree.

    Declaration
    public abstract SyntaxTree WithRootAndOptions(SyntaxNode root, ParseOptions options)
    Parameters
    Type Name Description
    SyntaxNode root
    ParseOptions options
    Returns
    Type Description
    SyntaxTree

    Extension Methods

    LuaExtensions.GetCompilationUnitRoot(SyntaxTree, CancellationToken)
    • Improve this Doc
    • View Source
    ☀
    ☾
    In This Article
    Back to top

    Copyright (c) LorettaDevs

    Generated by DocFX

    ☀
    ☾