Class Script
A script containing one or more files.
Inheritance
Inherited Members
Namespace: Loretta.CodeAnalysis.Lua
Assembly: Loretta.CodeAnalysis.Lua.dll
Syntax
public sealed class Script
Constructors
| Improve this Doc View SourceScript()
Initializes an empty script.
Declaration
public Script()
Script(ImmutableArray<SyntaxTree>)
Initializes a new script.
Declaration
public Script(ImmutableArray<SyntaxTree> syntaxTrees)
Parameters
Type | Name | Description |
---|---|---|
ImmutableArray<SyntaxTree> | syntaxTrees |
Properties
| Improve this Doc View SourceEmpty
An empty script with no syntax trees.
Declaration
public static Script Empty { get; }
Property Value
Type | Description |
---|---|
Script |
RootScope
The root scope of the script.
Declaration
public IScope RootScope { get; }
Property Value
Type | Description |
---|---|
IScope |
SyntaxTrees
The syntax trees contained in this script.
Declaration
public ImmutableArray<SyntaxTree> SyntaxTrees { get; }
Property Value
Type | Description |
---|---|
ImmutableArray<SyntaxTree> |
Methods
| Improve this Doc View SourceFindScope(SyntaxNode, ScopeKind)
Attempts to find the outermost scope of the provided kind (or a more generic one).
Declaration
public IScope FindScope(SyntaxNode node, ScopeKind kind = ScopeKind.Block)
Parameters
Type | Name | Description |
---|---|---|
SyntaxNode | node | The node to search from. |
ScopeKind | kind | The kind to search for. |
Returns
Type | Description |
---|---|
IScope |
Remarks
If the tree that contains the provided node does not have a CompilationUnitSyntax, statements on the file root will not have a scope.
The kind parameter searches for a scope of the provided kind or a more generic one as in the following list:
GetLabel(SyntaxNode)
Get the goto label for the provided node.
Declaration
public IGotoLabel GetLabel(SyntaxNode node)
Parameters
Type | Name | Description |
---|---|---|
SyntaxNode | node |
Returns
Type | Description |
---|---|
IGotoLabel |
GetScope(SyntaxNode)
Get the scope for the provided node.
Declaration
public IScope GetScope(SyntaxNode node)
Parameters
Type | Name | Description |
---|---|---|
SyntaxNode | node |
Returns
Type | Description |
---|---|
IScope |
GetVariable(SyntaxNode)
Get the variable for the provided node.
Declaration
public IVariable GetVariable(SyntaxNode node)
Parameters
Type | Name | Description |
---|---|---|
SyntaxNode | node |
Returns
Type | Description |
---|---|
IVariable |
RenameVariable(IVariable, String)
Attempts to rename the provided variable with the new provided name.
Declaration
public Result<Script, IEnumerable<RenameError>> RenameVariable(IVariable variable, string newName)
Parameters
Type | Name | Description |
---|---|---|
IVariable | variable | The variable to rename. |
System.String | newName | The new variable's name. |
Returns
Type | Description |
---|---|
Tsu.Result<Script, IEnumerable<RenameError>> | An Ok(Script) if the rename was successful or an Err(IEnumerable<RenameError>) if there were errors while renaming the variable. |