Search Results for

    Show / Hide Table of Contents

    Class LuaSyntaxTree

    The parsed representation of a Lua source document.

    Inheritance
    System.Object
    SyntaxTree
    LuaSyntaxTree
    Inherited Members
    SyntaxTree.FilePath
    SyntaxTree.HasCompilationUnitRoot
    SyntaxTree.Length
    SyntaxTree.TryGetText(SourceText)
    SyntaxTree.GetText(CancellationToken)
    SyntaxTree.Encoding
    SyntaxTree.GetTextAsync(CancellationToken)
    SyntaxTree.TryGetRoot(SyntaxNode)
    SyntaxTree.GetReference(SyntaxNode)
    SyntaxTree.WithRootAndOptions(SyntaxNode, ParseOptions)
    SyntaxTree.WithFilePath(String)
    SyntaxTree.ToString()
    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.Lua
    Assembly: Loretta.CodeAnalysis.Lua.dll
    Syntax
    public abstract class LuaSyntaxTree : SyntaxTree

    Properties

    | Improve this Doc View Source

    Options

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

    Declaration
    public abstract LuaParseOptions Options { get; }
    Property Value
    Type Description
    LuaParseOptions

    Methods

    | Improve this Doc View Source

    CloneNodeAsRoot<T>(T)

    Produces a clone of a LuaSyntaxNode which will have current syntax tree as its parent.

    Caller must guarantee that if the same instance of LuaSyntaxNode makes multiple calls to this function, only one result is observable.

    Declaration
    protected T CloneNodeAsRoot<T>(T node)
        where T : LuaSyntaxNode
    Parameters
    Type Name Description
    T node

    The original syntax node.

    Returns
    Type Description
    T

    A clone of the original syntax node that has current LuaSyntaxTree as its parent.

    Type Parameters
    Name Description
    T

    Type of the syntax node.

    | Improve this Doc View Source

    Create(LuaSyntaxNode, LuaParseOptions, String, Encoding)

    Creates a new syntax tree from a syntax node.

    Declaration
    public static SyntaxTree Create(LuaSyntaxNode root, LuaParseOptions options = null, string path = "", Encoding encoding = null)
    Parameters
    Type Name Description
    LuaSyntaxNode root
    LuaParseOptions options
    System.String path
    System.Text.Encoding encoding
    Returns
    Type Description
    SyntaxTree
    | Improve this Doc View Source

    GetChangedSpans(SyntaxTree)

    Produces a pessimistic list of spans that denote the regions of text in this tree that are changed from the text of the old tree.

    Declaration
    public override IList<TextSpan> GetChangedSpans(SyntaxTree oldTree)
    Parameters
    Type Name Description
    SyntaxTree oldTree

    The old tree. Cannot be null.

    Returns
    Type Description
    IList<TextSpan>
    Overrides
    SyntaxTree.GetChangedSpans(SyntaxTree)
    Remarks

    The list is pessimistic because it may claim more or larger regions than actually changed.

    | 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 override IList<TextChange> GetChanges(SyntaxTree oldTree)
    Parameters
    Type Name Description
    SyntaxTree oldTree

    The old tree. Cannot be null.

    Returns
    Type Description
    IList<TextChange>
    Overrides
    SyntaxTree.GetChanges(SyntaxTree)
    Remarks

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

    | Improve this Doc View Source

    GetCompilationUnitRoot(CancellationToken)

    Gets the root of the syntax tree statically typed as CompilationUnitSyntax.

    Declaration
    public CompilationUnitSyntax GetCompilationUnitRoot(CancellationToken cancellationToken = null)
    Parameters
    Type Name Description
    CancellationToken cancellationToken
    Returns
    Type Description
    CompilationUnitSyntax
    Remarks

    Ensure that HasCompilationUnitRoot is true for this tree prior to invoking this method.

    | Improve this Doc View Source

    GetDiagnostics(CancellationToken)

    Gets a list of all the diagnostics in the syntax tree.

    Declaration
    public override IEnumerable<Diagnostic> GetDiagnostics(CancellationToken cancellationToken = null)
    Parameters
    Type Name Description
    CancellationToken cancellationToken
    Returns
    Type Description
    IEnumerable<Diagnostic>
    Remarks

    This method does not filter diagnostics based on #pragmas and compiler options like /nowarn, /warnaserror etc.

    | 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.

    Declaration
    public override IEnumerable<Diagnostic> GetDiagnostics(SyntaxNode node)
    Parameters
    Type Name Description
    SyntaxNode node
    Returns
    Type Description
    IEnumerable<Diagnostic>
    Overrides
    SyntaxTree.GetDiagnostics(SyntaxNode)
    Remarks

    This method does not filter diagnostics based on #pragmas and compiler options like /nowarn, /warnaserror etc.

    | 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.

    Declaration
    public override IEnumerable<Diagnostic> GetDiagnostics(SyntaxNodeOrToken nodeOrToken)
    Parameters
    Type Name Description
    SyntaxNodeOrToken nodeOrToken
    Returns
    Type Description
    IEnumerable<Diagnostic>
    Overrides
    SyntaxTree.GetDiagnostics(SyntaxNodeOrToken)
    Remarks

    This method does not filter diagnostics based on #pragmas and compiler options like /nowarn, /warnaserror etc.

    | Improve this Doc View Source

    GetDiagnostics(SyntaxToken)

    Gets a list of all the diagnostics associated with the token and any related trivia.

    Declaration
    public override IEnumerable<Diagnostic> GetDiagnostics(SyntaxToken token)
    Parameters
    Type Name Description
    SyntaxToken token
    Returns
    Type Description
    IEnumerable<Diagnostic>
    Overrides
    SyntaxTree.GetDiagnostics(SyntaxToken)
    Remarks

    This method does not filter diagnostics based on #pragmas and compiler options like /nowarn, /warnaserror etc.

    | Improve this Doc View Source

    GetDiagnostics(SyntaxTrivia)

    Gets a list of all the diagnostics associated with the trivia.

    Declaration
    public override IEnumerable<Diagnostic> GetDiagnostics(SyntaxTrivia trivia)
    Parameters
    Type Name Description
    SyntaxTrivia trivia
    Returns
    Type Description
    IEnumerable<Diagnostic>
    Overrides
    SyntaxTree.GetDiagnostics(SyntaxTrivia)
    Remarks

    This method does not filter diagnostics based on #pragmas and compiler options like /nowarn, /warnaserror etc.

    | Improve this Doc View Source

    GetLineSpan(TextSpan, CancellationToken)

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

    Declaration
    public override 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

    FileLinePositionSpan that contains path, line and column information.

    Remarks

    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 override Location GetLocation(TextSpan span)
    Parameters
    Type Name Description
    TextSpan span
    Returns
    Type Description
    Location
    Overrides
    SyntaxTree.GetLocation(TextSpan)
    | Improve this Doc View Source

    GetRoot(CancellationToken)

    Gets the root node of the syntax tree.

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

    GetRootAsync(CancellationToken)

    Gets the root node of the syntax tree asynchronously.

    Declaration
    public virtual Task<LuaSyntaxNode> GetRootAsync(CancellationToken cancellationToken = null)
    Parameters
    Type Name Description
    CancellationToken cancellationToken
    Returns
    Type Description
    Task<LuaSyntaxNode>
    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 GetRootAsync(CancellationToken).

    | Improve this Doc View Source

    IsEquivalentTo(SyntaxTree, Boolean)

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

    Declaration
    public override 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
    Overrides
    SyntaxTree.IsEquivalentTo(SyntaxTree, Boolean)
    | Improve this Doc View Source

    ParseText(SourceText, LuaParseOptions, String, CancellationToken)

    Produces a syntax tree by parsing the source text.

    Declaration
    public static SyntaxTree ParseText(SourceText text, LuaParseOptions options = null, string path = "", CancellationToken cancellationToken = null)
    Parameters
    Type Name Description
    SourceText text
    LuaParseOptions options
    System.String path
    CancellationToken cancellationToken
    Returns
    Type Description
    SyntaxTree
    | Improve this Doc View Source

    ParseText(String, LuaParseOptions, String, Encoding, CancellationToken)

    Produces a syntax tree by parsing the source text.

    Declaration
    public static SyntaxTree ParseText(string text, LuaParseOptions options = null, string path = "", Encoding encoding = null, CancellationToken cancellationToken = null)
    Parameters
    Type Name Description
    System.String text
    LuaParseOptions options
    System.String path
    System.Text.Encoding encoding
    CancellationToken cancellationToken
    Returns
    Type Description
    SyntaxTree
    | Improve this Doc View Source

    TryGetRoot(out LuaSyntaxNode)

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

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

    WithChangedText(SourceText)

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

    Declaration
    public override SyntaxTree WithChangedText(SourceText newText)
    Parameters
    Type Name Description
    SourceText newText
    Returns
    Type Description
    SyntaxTree
    Overrides
    SyntaxTree.WithChangedText(SourceText)
    Remarks

    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.

    Extension Methods

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

    Copyright (c) LorettaDevs

    Generated by DocFX

    ☀
    ☾