Lens
loreline.Lens (Class)
Utility class for analyzing Loreline scripts without executing them.
Provides methods for finding nodes, variables, references, etc.
Instance Members
Gets the node at the given position
| Name |
Type |
Description |
pos |
Position |
Position to check |
| Returns |
Description |
| Null<Node> |
Most specific node at that position, or null if none found |
Gets the closest node before or at the given position
| Name |
Type |
Description |
pos |
Position |
Position to check |
| Returns |
Description |
| Null<Node> |
Most specific node at that position or before, or null if none found |
getNodesOfType(nodeType: Class<getNodesOfType.T>, ?includeImported: Bool = false): Array<getNodesOfType.T>
Gets all nodes of a specific type
| Name |
Type |
Default |
Description |
nodeType |
Class<getNodesOfType.T> |
|
Class type to find |
includeImported |
Bool |
false |
|
| Returns |
Description |
| Array<getNodesOfType.T> |
Array of matching nodes |
Gets the parent node of a given node
| Name |
Type |
Description |
node |
Node |
Child node |
| Returns |
Description |
| Null<Node> |
Parent node or null if none found |
getFirstParentOfType(node: Node, type: Class<getFirstParentOfType.T>): Null<getFirstParentOfType.T>
Gets the first parent node matching the given type
| Name |
Type |
Description |
node |
Node |
Child node |
type |
Class<getFirstParentOfType.T> |
|
| Returns |
Description |
| Null<getFirstParentOfType.T> |
Parent node or null if none found |
Resolves an identifier access to its corresponding node in the AST.
Resolution follows the same priority order as the interpreter:
- State fields in current scope and parent beats
- Top-level state fields
- Top-level character declarations
- Beat declarations
| Name |
Type |
Description |
access |
NAccess |
The access expression to resolve |
| Returns |
Description |
| Null<Node> |
The referenced node if found, null otherwise |
Finds and returns the beat declaration referenced by the given call.
This method searches through the beat declarations to find a match based on the call's fields.
| Returns |
Description |
| Null<NBeatDecl> |
The referenced beat declaration if found, null otherwise |
Finds and returns the beat declaration referenced by the given transition.
This method searches through the beat declarations to find a match based on the transition's fields.
| Name |
Type |
Description |
transition |
NTransition |
The transition object containing the reference to search for |
| Returns |
Description |
| Null<NBeatDecl> |
The referenced beat declaration if found, null otherwise |
Finds and returns the beat declaration referenced by the given insertion.
This method searches through the beat declarations to find a match based on the insertion's fields.
| Name |
Type |
Description |
insertion |
NInsertion |
The insertion object containing the reference to search for |
| Returns |
Description |
| Null<NBeatDecl> |
The referenced beat declaration if found, null otherwise |
Finds and returns the character declaration referenced by the given dialogue statement.
This method searches through the character declarations to find a match based on the
dialogue's character name.
| Name |
Type |
Description |
dialogue |
NDialogueStatement |
The dialogue statement containing the character reference |
| Returns |
Description |
| Null<NCharacterDecl> |
The referenced character declaration if found, null otherwise |
Gets all state fields visible from a given position.
This includes fields from both temporary and permanent states.
Gets all beat declarations available from a given position.
This includes both top-level beats and nested beats that are in scope.
Gets all unique tags used in the script.
| Returns |
Description |
| Array<String> |
Array of unique tag strings |
Count every occurence of tags
| Returns |
Description |
| Map |
Map of tag counts |
Find all beats that can be reached from a given beat through transitions or calls.
| Name |
Type |
Description |
beatDecl |
NBeatDecl |
The beat declaration to analyze |
Finds all nodes that reference a specific beat declaration.
| Name |
Type |
Description |
beatDecl |
NBeatDecl |
The beat declaration to find references to |
Finds all state fields that are modified within a given beat
| Name |
Type |
Description |
beatDecl |
NBeatDecl |
The beat declaration to analyze |
Finds all state fields that are read/accessed within a given beat
| Name |
Type |
Description |
beatDecl |
NBeatDecl |
The beat declaration to analyze |
Find all characters that have a presence in a given beat through:
- Field access to character state
- Dialogue statements
| Name |
Type |
Description |
beatDecl |
NBeatDecl |
The beat declaration to analyze |
Finds all character fields that are modified within a given beat
| Name |
Type |
Description |
beatDecl |
NBeatDecl |
The beat declaration to analyze |
Finds all character fields that are read/accessed within a given beat
| Name |
Type |
Description |
beatDecl |
NBeatDecl |
The beat declaration to analyze |
traverse(node: Node, callback: Function): Void
| Name |
Type |
node |
Node |
callback |
Function |
Private Members
The script being analyzed
Map of all nodes by their unique ID
Map of node IDs to their parent nodes
Map of node IDs to their child nodes
Initialize all the lookups and analysis data
Find the state field being accessed by a field access expression
| Name |
Type |
Description |
access |
NAccess |
The field access to analyze |