Skip to main content

Module server

Module server 

Source
Expand description

LSP backend and LanguageServer trait implementation.

Backend holds per-session state: open documents, compiled project metadata (for go-to-definition, hover, completion, and code lens), and workspace configuration.

§State Management

  • documents — Open document contents, updated on every didOpen / didChange.
  • project_cache — Compiled project metadata. Opened lazily on the first successful build; the same handle is reused across rebuilds.
  • parse_diagnostics — Per-keystroke parse-level diagnostics, keyed by URI. Updated on every didOpen / didChange.
  • project_diagnostics — Project-level (validation + typecheck) diagnostics, keyed by URI. Updated on every rebuild_project.
  • root — The workspace root directory.
  • settings / variables — Project and profile configuration, reloaded at startup and on every save.

§Diagnostic Publishing

LSP publishDiagnostics is full-replacement per URI, so the two sources must be merged before publishing or one will overwrite the other. Both diagnostic flows route through Backend::publish_merged, which reads both maps and emits the union.

rebuild_project() runs validation and (on a successful build) typechecking inline. Both are merged into the new project-diagnostic map; every URI that was previously tracked or is newly tracked is republished through Backend::publish_merged so stale project diagnostics clear while parse diagnostics for open documents survive.

Structs§

Backend 🔒
LSP backend holding session state.
BackendInner 🔒

Constants§

IDLE_REBUILD_DEBOUNCE 🔒
How long to wait after the last keystroke before kicking off an idle rebuild. Long enough that rapid typing doesn’t run repeated rebuilds, short enough that the user sees diagnostics promptly after pausing.

Functions§

resolve_lsp_profile_name 🔒
Resolve the active profile for LSP operations.
try_open_project_cache 🔒
Try to open a long-lived ProjectCache (read-only SQLite connection).