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§
- Autoload
Registry - 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 onProjectConfigalone (it iterates only the config text), so it backdates across every.gdkeystroke. - Global
Registry - The project-wide global
class_nameregistry: each registered name → the file declaring it. - Scene
Attach - Where a script (
.gd) is attached in a scene: the owning scene file + the node carrying thescript = ExtResource(...).$Pathin that script resolves relative to this node. - Scene
Context - 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. - Script
Class - A script class’s own members, by name, plus its resolved
extendsbase — the offset-free projection a cross-file reference resolves against. Reads onlyitem_treesignatures (+ 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 viabase.
Enums§
- Member
Sig - 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 inroot— the shadowing diagnostic’s cross-file half. Mirrorsglobal_registry’s firewall exactly: it reads only the offset-freefile_class_nameprojection of each file (never a body or byte range), so a keystroke never rebuilds it.global_registrykeeps the first declarer silently; this query names the duplicates socrate::infer::analyze_filecan warn at each colliding declaration. - engine_
version - The Godot engine
(major, minor)declared byproject.godot’s[application]config/features, orNoneif unspecified. Keyed onProjectConfigalone (MEDIUM durability), so it backdates across.gdbody edits — the same cross-file firewall asautoload_registry. - file_
class_ name - A file’s
class_name, if it declares one — the offset-free projection of its item tree thatglobal_registrydepends on. It reads onlyitem_tree(file).class_name(never a byte range), so a body edit re-runsitem_treebut 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_nameregistry. Keyed on theSourceRootfile-set input and the per-filefile_class_nameprojections. A duplicateclass_namekeeps the first byFileIdorder (the file set is sorted), so resolution is deterministic. Collision diagnostics (warning at each duplicate declaration) are the separateclass_name_collisionsprojection. - 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), orNonewhen there is noproject.godotor it declares no version. - res_
path_ registry - The project-wide
res:// path → FileIdregistry (M3): the mappreload("res://x.gd")andextends "res://x.gd"resolve through. Keyed on theSourceRootfile-set input and each file’sres_pathsalsa-input field.res_pathis a separate input field fromtext(salsa tracks input fields individually), so this registry backdates across body edits exactly likeglobal_registry— a keystroke never rebuilds it. A duplicate path keeps the first byFileIdorder (the file set is sorted), matchingglobal_registry’s policy. - scene_
context - The owning-scene context for the script in
file(M1): the scene’sFileId, the parsed scene, and the attach node, so$Path/%Unique/get_node("…")can resolve (and go-to-def can jump into the.tscn).Nonewhen the project has no scene attaching this script (the overwhelmingly common single-file / dynamic-UI case → node paths stayNode). - scene_
model - The parsed
SceneModelforfile(M1) — memoized; recomputes only when the file text changes. A non-scene file (a.gd, or nores://path) yields an empty model (so the query is total). The puregdscript_scene::parse_sceneis 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 anotherclass_nameresolves to itsScriptRef). - script_
ref_ name - The
class_namebehind aScriptRef, for display (hover / inlay).Ty::labelcannot 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’sres://path → the (first) scene + node that attaches it. Built by scanning every scene’sext_resourcesfor atype="Script"reference. Keyed on theSourceRootfile-set + each scene file’s text (viascene_model); a.gdbody edit never touches a.tscntext, so this backdates across.gdkeystrokes — the firewall (a scene edit correctly invalidates it). A duplicate (one script in many scenes) keeps the first byFileIdorder (the slice’s single-scene policy). - suppression_
map - The per-file
@warning_ignore[_start|_restore]suppression map (Workstream 1). Keyed on the file’s parse — CST byte ranges are stable across incremental edits — so it recomputes only when the file text changes, never on a warning-setting edit. - warning_
settings - The project’s resolved warning settings, parsed from
project.godot’sdebug/gdscript/warnings/*(Workstream 1). Keyed onProjectConfigalone (MEDIUM durability) and reads no.gdbody, so editing a warning level invalidates only this query + the downstream gate, neveranalyze_file/item_tree/infer— the salsa-cacheability invariant the gating seam depends on (W1 §3.4/§6).