Skip to main content

Crate gdscript_scene

Crate gdscript_scene 

Source
Expand description

gdscript-scene — a .tscn/.tres text parser for scene-aware analysis (Phase 4).

Godot’s text scene format is INI-like: bracketed section headers ([node …], [ext_resource …], …) followed by key = value property lines. This crate parses that structure — node names, types, parent paths, attached scripts, unique_name_in_owner, and instanced sub-scenes — into a SceneModel with byte spans, so the type layer (Phase-4 M1+) can resolve $Path / %Unique / get_node("…") to a node’s real Control/Node subclass instead of bare Node — intelligence the Godot editor’s own LSP produces only in-editor and never flows into inference.

M0 scope: the pure, wasm-clean parse_scene (&str -> SceneModel) + the model + byte spans. It records the typing inputs (type=/script=/instance=); it does not resolve a Ty (M1), recurse into instanced sub-scenes, build the project-wide script↔scene index, or cache via salsa (M1+). See plans/PHASE-4-M0-PLAYBOOK.md.

Invariant: the parser is strictly additive and never fails — every binary/malformed/ unknown form degrades to an empty-or-partial model + a SceneProblem, never a panic or Err. The floor is always parity with the engine’s Node-everywhere baseline.

Portability: a core crate — wasm32-clean (no std::fs, no Instant, no threads); .tscn text is injected via the VFS exactly like .gd.

Structs§

ExtId
An ext_resource/sub_resource id — the opaque, quoted-string key as written ("1", "1_app", "StyleBoxFlat_x"). A 3.x bare-int id is normalized to its string form.
ExtResource
An [ext_resource …] declaration.
NodeIdx
Index of a node into SceneModel::nodes.
SceneModel
One parsed .tscn/.tres. Produced by crate::parse_scene; never an Err — every malformed/binary/unknown form degrades to an empty-or-partial model plus a SceneProblem. PartialEq/Eq so it can be a backdated salsa query result (Arc<SceneModel>) in M1.
SceneNode
One [node …] section: its header attributes + the two body properties we read.
SubResource
A [sub_resource …] declaration (type only — the value body is skipped).

Enums§

NodePathResolution
The reason a node path did (not) resolve — for the INVALID_NODE_PATH decision (M2).
SceneKind
Whether the parsed file is a .tscn scene (gd_scene) or a .tres resource (gd_resource).
SceneProblem
A non-fatal problem found during parsing. The parser records these and keeps going — the floor is always parity with the engine’s Node-everywhere baseline.

Functions§

parse_scene
Parse .tscn/.tres text into a SceneModel. Pure, never panics, never returns Err.