Expand description
gdscript-db — the input layer for the analyzer.
Holds the virtual file system (FileId → text, always injected — never std::fs), the
project model, and (from Phase 3) the salsa query graph: #[salsa::input]s set via
apply_change, #[salsa::tracked] derived queries, durability tiers. The Phase-0/1/2
plain VFS map + reparse-on-change is being replaced here, localized behind the unchanged
gdscript-ide public API (Playbook §3.M0).
Crate boundary: gdscript-db is the base of the salsa stack — it owns the Db trait,
the inputs, and the parse query (it may depend on gdscript-syntax, never on
gdscript-hir). The higher queries (item_tree, analyze_file) live in gdscript-hir,
which depends on this crate for &dyn Db. This one-way layering is what avoids a
db ↔ hir dependency cycle.
FileId is deliberately not a salsa input. The FileId → FileText mapping is a side
table (Files) the database owns, mirroring rust-analyzer’s base-db: FileIds are
assigned by the client/loader and stay opaque ids, while the salsa input is the text.
Must build for wasm32 (single-threaded; salsa with default-features = false).
Structs§
- Engine
Generation - A generation counter that makes the otherwise-untracked runtime engine model invalidate
correctly. The engine model is a leaked
&'staticside handle (not a salsa input), so a query memoized while it was still absent (engine() == None, onwasm32beforeset_engine_api) would otherwise return that stale empty result forever. Everyengine()read records a dependency on this input;set_engine_apibumps it, recomputing those queries. The value is irrelevant — only that setting it advances the revision. Used onwasm32only (native has the bundled model from the start, so it never changes — no generation tracking, no overhead). - File
Text - The VFS leaf: one file’s UTF-8 text, as a salsa input, plus its
FileId(so a query holding only aFileTextcan recover the id for cross-file resolution) and itsres://path (sopreload/extends "res://…"resolve to the declaring file — M3). - Files
- The
FileId → FileTextside table.Arc-backed so a cheap clone shares the same map — needed to mutate an input (&mut dyn Db) without simultaneously borrowingself.files. - Project
Config - The project’s
project.godot, injected as raw text — the wasm-clean core never reads the filesystem, so the loader pushes the bytes exactly like a.gdfile. The autoload index is a tracked query that parses this text (M4). Held atMEDIUMdurability (project structure, stable across.gdkeystrokes), so a body edit (LOW) never invalidates the autoload registry. - Root
Database - The concrete analyzer database — a salsa
Storageplus theFilesside table. - Source
Root - The project’s file set — a salsa input so project-wide queries (the global
class_nameregistry, M1) iterate the files incrementally. It changes only when a file is added or removed, never on a body edit, and is held at MEDIUM durability — so a keystroke (aLOWchange) never invalidates project-wide derived data.
Traits§
- Db
- The database trait
gdscript-hir/gdscript-idedepend on.#[salsa::db]on the trait makes it a salsa supertrait, so any&dyn Dbupcasts to&dyn salsa::Databaseand every#[salsa::tracked]free function downstream can takedb: &dyn Db.
Functions§
- parse
- Parse a file to its lossless CST. Memoized; re-parses only when the file text changes.