Class LuaSyntaxTree
The parsed representation of a Lua source document.
Inherited Members
Namespace: Loretta.CodeAnalysis.Lua
Assembly: cs.temp.dll.dll
Syntax
public abstract class LuaSyntaxTree : SyntaxTree
Properties
Options
The options used by the parser to produce the syntax tree.
Declaration
public abstract LuaParseOptions Options { get; }
Property Value
| Type | Description |
|---|---|
| LuaParseOptions |
Methods
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. |
Create(LuaSyntaxNode, LuaParseOptions, String, Nullable<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.Nullable<Encoding> | encoding |
Returns
| Type | Description |
|---|---|
| SyntaxTree |
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 |
Returns
| Type | Description |
|---|---|
| IList<TextSpan> |
Overrides
Remarks
The list is pessimistic because it may claim more or larger regions than actually changed.
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 |
Returns
| Type | Description |
|---|---|
| IList<TextChange> |
Overrides
Remarks
The list of changes may be different than the original changes that produced this tree.
GetCompilationUnitRoot(CancellationToken)
Gets the root of the syntax tree statically typed as
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.
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> |
Overrides
Remarks
This method does not filter diagnostics based on #pragmas and compiler options
like /nowarn, /warnaserror etc.
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
Remarks
This method does not filter diagnostics based on #pragmas and compiler options
like /nowarn, /warnaserror etc.
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
Remarks
This method does not filter diagnostics based on #pragmas and compiler options
like /nowarn, /warnaserror etc.
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
Remarks
This method does not filter diagnostics based on #pragmas and compiler options
like /nowarn, /warnaserror etc.
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
Remarks
This method does not filter diagnostics based on #pragmas and compiler options
like /nowarn, /warnaserror etc.
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. |
Overrides
Remarks
The values are not affected by line mapping directives (#line).
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
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 |
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).
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
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 |
ParseText(String, LuaParseOptions, String, Nullable<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.Nullable<Encoding> | encoding | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| SyntaxTree |
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 |
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
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.