Skip to main content

Module analysis

Module analysis 

Source

Structs§

AnalysisResult
Result of running scope building and validation.
AnalyzeOptions
Options for running analysis (single entry point for program or document).
ClassDeclInfo
Info extracted from a NodeClassDecl (name and optional super class).
FunctionDeclInfo
Info extracted from a NodeFunctionDecl (name and parameter counts).
Scope
Single scope: variables and optional main-only data.
ScopeBuilder
Builds scope tree by walking the syntax tree; maintains a stack of scope IDs. Records the sequence of scope IDs pushed (in walk order) so Validator can use the same IDs.
ScopeId
Identifies a scope in the scope store (used for parent chain).
ScopeStore
Store for all scopes; root is at index 0.
SigMeta
Documentation and complexity metadata for a root function or global (from .sig).
TypeChecker
Tracks inferred types and runs arity checks. Runs after scope building and validation.
Validator
Collects diagnostics and maintains scope stack (replaying scope structure from first pass). Uses the same scope ID sequence as ScopeBuilder so resolve() looks up the correct scope.
VarDeclInfo
Info extracted from a NodeVarDecl (var/global/const/let or typed).
VariableInfo
Variable binding: local, global, or parameter.

Enums§

AnalysisError
Error codes for semantic validation (mirroring leekscript-java Error enum).
MemberVisibility
Visibility of a class member. Properties and methods are public by default when no modifier is given.
ResolvedSymbol
ScopeKind
Kind of a scope block (determines what can be declared and how lookup works).
TypeExprResult
Result of parsing a type expression: either a type or an error span.
VarDeclKind
Declaration kind for a variable declaration node.
VariableKind

Functions§

analyze
Build scope from the tree and run validation. Returns diagnostics and the scope store.
analyze_with_include_tree
Analyze the main file of an include tree: seed scope from included files and signatures, then analyze the main AST.
analyze_with_options
Run analysis with the given options. Dispatches to analyze, analyze_with_signatures, or analyze_with_include_tree as appropriate.
analyze_with_signatures
Analyze the program with the root scope pre-seeded from signature files (e.g. stdlib constants and functions). This allows references to global constants and built-in functions to resolve without errors. Also seeds built-in type/class names (e.g. Class, bool) so that common LeekScript code validates.
binary_expr_rhs
Returns the right-hand side expression of a NodeBinaryExpr. Prefers the named field “rhs” when present; otherwise uses the last node child. When the grammar labels RHS, it may wrap it in NodeExpr; we unwrap so the returned node is the inner expression.
build_scope_extents
Build list of (ScopeId, extent) where extent is (start_byte, end_byte). Root scope (ScopeId(0)) is always first with extent (0, source_len). Remaining entries are in walk order, matching scope_id_sequence.
call_argument_count
Number of argument expressions in a NodeCallExpr. Used for type inference so the call is inferred as the function’s return type. The grammar uses lparen, optional(expr, zero_or_more(comma, expr)), rparen; the optional may be one node (with 0, 1, or more children) or optional + zero_or_more as siblings.
call_argument_node
Returns the syntax node for the i-th argument expression of a NodeCallExpr (0-based), for error spans.
class_decl_info
Returns class name and optional super class from a NodeClassDecl.
class_field_info
Field name, optional declared type, and whether it’s static from a NodeClassField. Returns (name, type, is_static) where type is None if the field has no type annotation.
class_member_visibility
Visibility of a class member from the preceding modifier. Public by default when no modifier. The modifier that applies is the last visibility keyword before this member that is not “consumed” by another member (i.e. no other member’s range contains that keyword).
complexity_display_string
Display string for complexity code 1–13 from .sig @complexity N.
find_type_expr_child
Find a child node of parent that is NodeTypeExpr (for var decl, param, etc.).
function_decl_info
Returns name and parameter counts from a NodeFunctionDecl. For default parameters, min_arity is the number of required params; max_arity is total.
member_expr_member_name
Returns the member name (identifier after the dot) from a NodeMemberExpr.
member_expr_receiver_name
Returns the receiver name (identifier or keyword before the dot) from a NodeMemberExpr. For Cell.getCell returns Some("Cell"), for this.update returns Some("this").
param_name
Parameter name and span from a NodeParam (for scope building).
parse_type_expr
Parse a NodeTypeExpr node into a Type. Works for both program and signature grammar.
primary_expr_new_constructor
If this primary is a new ClassName(...) constructor call, returns Some((class_name, num_args)).
primary_expr_resolvable_name
Name to use for type/scope resolution from a primary expr: identifier, or “this”/“super” when the single token is the corresponding keyword (class methods don’t use the function keyword).
scope_at_offset
Find the innermost scope containing the given byte offset. When extents is empty (e.g. partial state), returns root scope ID so the LSP never panics.
seed_scope_from_program
Seed the root scope from a program AST (top-level classes, functions, globals only). Also registers class fields and methods so member access (e.g. myCell.x) infers types. Used when building scope from included files so the main file sees their declarations.
seed_scope_from_signatures
Seed the root scope from parsed signature file(s). Each element of signature_roots should be the root node returned by parse_signatures() (may be a wrapper or NodeSigFile).
var_decl_info
Returns the declaration kind and name from a NodeVarDecl. For “var x”, “global T x”: name is the first identifier after the keyword. For typed form “Array arr” or “integer? y”: name is the last identifier before “=” (type names come first).

Type Aliases§

TypeMapKey
Key for type map: (span.start, span.end) for exact span lookup.