Skip to main content

Module resolve

Module resolve 

Source
Expand description

Name & type resolution (Playbook §3.2/§3.5): the resolve_external Phase-3 seam, the GDScript source-annotation → Ty resolver, base-class resolution, the per-class ClassScope (the class-member tier of the binder), and global resolution.

The binder’s lookup order (local → class member → inherited → global) is driven by crate::infer; this module supplies the class-member and global tiers plus the type resolution all tiers share. Everything here is a pure function of the item tree + the Arc-shared EngineApi — no body, no cross-file state.

Structs§

ClassScope
The class-member tier of the binder (Playbook §3.2 step 2): this file’s own members + the resolved base type. Anonymous-enum variants are flattened in as int constants.

Enums§

ClassItem
What a class-level name resolves to within ClassScope.
ExternalRef
A reference that would require another file to resolve — the Phase-3 boundary. Phase 2 never reaches across files, so every variant resolves to the same non-cascading Ty::Unknown; Phase 3 reimplements only resolve_external, leaving every inference body unchanged (Playbook §0 — “the biggest enabler in the whole phase; protect it”).
GlobalDef
What a bare global name resolves to (Playbook §3.2 step 4). The caller (crate::infer) decides how to use it given the syntactic context (bare value vs. call vs. .-access).

Functions§

anchor_res_path
Anchor a preload/extends resource path to an absolute res:///user:// path the way Godot does (reduce_preload: script_path.get_base_dir().path_join(p).simplify_path()): an already- absolute path passes through unchanged; a RELATIVE path is joined to importing’s directory and simplified (./.. collapsed). None only when the path is relative and importing carries no resource anchor — the conservative seam (never a false resolution).
layer_to_ty
Map a coarse engine-layer LayerTy (used by the hand-authored GDScript layer, which predates the loaded model’s real ids) to a Ty.
resolve_base
Resolve a file’s (or inner class’s) base type from its extends. A bare engine-class name resolves to Object(id); a script-path / dotted / unknown base goes through the seam to Unknown. With no extends, a script implicitly extends RefCounted.
resolve_external
The Phase-3 seam. Resolve a cross-file reference. In Phase 2 this is always Ty::Unknown — a type that never warns, never cascades a diagnostic, and is elided from hover. Funnel every “would need another file” path through here so Phase 3 has exactly one function to reimplement.
resolve_global
Resolve a bare global identifier. Order is deliberate: pseudo-constants and singletons take precedence over the same-named type (bare Input is the singleton instance, not the class).
resolve_type_name
Resolve a bare type name (no type arguments) — for callers that only have a string (completion detail, inlay display).
resolve_type_ref
Resolve a GDScript source type annotation (a TypeRef CST node) to a Ty. Handles void/Variant, builtins, engine classes, Array/Array[T], Dictionary/ Dictionary[K, V], global enums, and Class.Enum; an unknown bare name is treated as a (cross-file) class_name and funneled through the resolve_external seam.