Skip to main content

Module queries

Module queries 

Source
Expand description

The salsa-tracked entry points for the semantic layer, layered on gdscript-db’s parse query.

These are the memoized queries the IDE layer drives. The heavy lifting stays in crate::item_tree / crate::infer as plain (parsed file) -> value functions; this module only wraps them so their results are cached per revision and recomputed incrementally. item_tree is the firewall query (Playbook §4): it reads only the parse, never a function body, so an unchanged set of signatures backdates across body edits.

Phase-3 note: cross-file resolution (the resolve_external seam) is still Ty::Unknown here — M1 threads &dyn Db + FileId into inference to light it up. M0 only swaps the cache engine; the single-file results are byte-identical.

Structs§

AutoloadRegistry
The project’s autoload singletons (*-flagged [autoload] entries) — the bare names that resolve as globals in code. Maps each singleton name → its resource path (M4). Non-singleton autoloads are deliberately excluded (loaded-but-not-global). Keyed on ProjectConfig alone (it iterates only the config text), so it backdates across every .gd keystroke.
GlobalRegistry
The project-wide global class_name registry: each registered name → the file declaring it.
SceneAttach
Where a script (.gd) is attached in a scene: the owning scene file + the node carrying the script = ExtResource(...). $Path in that script resolves relative to this node.
SceneContext
The resolved owning-scene context for a script — the scene file, its model, the attach node, and whether the attachment is ambiguous (multi-scene). Returned by scene_context.
ScriptClass
A script class’s own members, by name, plus its resolved extends base — the offset-free projection a cross-file reference resolves against. Reads only item_tree signatures (+ annotation/base resolution), never bodies or byte ranges, so it backdates on body edits (the cross-file firewall). Member lookup walks the base chain (M2): own members here, inherited ones via base.

Enums§

MemberSig
One member of a script class, as a cross-file reference sees it (a resolved type, never a byte range).

Functions§

analyze_file
Whole-file inference for file. With no engine model available (wasm32, until the host wires the fetched blob in) this is an empty result — matching the Phase-2 graceful path.
autoload_registry
The project-wide autoload-singleton registry, parsed from project.godot (M4). Only *-flagged entries become globals; a duplicate name keeps the first (deterministic).
class_name_collisions
The set of global class_names declared by more than one file in root — the shadowing diagnostic’s cross-file half. Mirrors global_registry’s firewall exactly: it reads only the offset-free file_class_name projection of each file (never a body or byte range), so a keystroke never rebuilds it. global_registry keeps the first declarer silently; this query names the duplicates so crate::infer::analyze_file can warn at each colliding declaration.
engine_version
The Godot engine (major, minor) declared by project.godot’s [application] config/features, or None if unspecified. Keyed on ProjectConfig alone (MEDIUM durability), so it backdates across .gd body edits — the same cross-file firewall as autoload_registry.
file_class_name
A file’s class_name, if it declares one — the offset-free projection of its item tree that global_registry depends on. It reads only item_tree(file).class_name (never a byte range), so a body edit re-runs item_tree but this query backdates (its value is unchanged), leaving the registry — and everything cross-file — undisturbed by a keystroke.
global_registry
The project-wide global class_name registry. Keyed on the SourceRoot file-set input and the per-file file_class_name projections. A duplicate class_name keeps the first by FileId order (the file set is sorted), so resolution is deterministic. Collision diagnostics (warning at each duplicate declaration) are the separate class_name_collisions projection.
item_tree
The item tree for file (signatures only — the body-edit firewall). Memoized; recomputes when the parse changes but backdates when the resulting signatures are unchanged.
project_engine_version
Convenience over engine_version: the project’s declared engine (major, minor), or None when there is no project.godot or it declares no version.
res_path_registry
The project-wide res:// path → FileId registry (M3): the map preload("res://x.gd") and extends "res://x.gd" resolve through. Keyed on the SourceRoot file-set input and each file’s res_path salsa-input field. res_path is a separate input field from text (salsa tracks input fields individually), so this registry backdates across body edits exactly like global_registry — a keystroke never rebuilds it. A duplicate path keeps the first by FileId order (the file set is sorted), matching global_registry’s policy.
scene_context
The owning-scene context for the script in file (M1): the scene’s FileId, the parsed scene, and the attach node, so $Path/%Unique/get_node("…") can resolve (and go-to-def can jump into the .tscn). None when the project has no scene attaching this script (the overwhelmingly common single-file / dynamic-UI case → node paths stay Node).
scene_model
The parsed SceneModel for file (M1) — memoized; recomputes only when the file text changes. A non-scene file (a .gd, or no res:// path) yields an empty model (so the query is total). The pure gdscript_scene::parse_scene is the cache body; this just wraps + gates it.
script_class
The member table of the script in file. Member types are resolved against the engine model and the registry (a member typed as another class_name resolves to its ScriptRef).
script_ref_name
The class_name behind a ScriptRef, for display (hover / inlay). Ty::label cannot resolve this on its own — it has only the engine model, not the project registry.
script_scene_index
The project-wide script → owning scene index (M1): each .gd’s res:// path → the (first) scene + node that attaches it. Built by scanning every scene’s ext_resources for a type="Script" reference. Keyed on the SourceRoot file-set + each scene file’s text (via scene_model); a .gd body edit never touches a .tscn text, so this backdates across .gd keystrokes — the firewall (a scene edit correctly invalidates it). A duplicate (one script in many scenes) keeps the first by FileId order (the slice’s single-scene policy).