Skip to main content

Crate ruitl_lsp

Crate ruitl_lsp 

Source
Expand description

RUITL Language Server — core backend.

The Backend type owns a document store (DashMap<Url, String>), runs the RUITL parser on every change, and publishes textDocument/publishDiagnostics messages. The binary in src/main.rs wires this to stdio via tower_lsp::LspService.

v0.1 capabilities:

  • textDocument/didOpen | didChange | didSave | didClose
  • textDocument/publishDiagnostics (parser errors only; codegen errors reported at save time too)
  • Incremental sync is advertised but we recompute from full text each tick — simplest thing that works for a regex-derived parser with O(template-size) complexity.

Out of scope for v0.1:

  • Completion (T14 in roadmap)
  • Go-to-definition for @Component references
  • Format on save (needs AST → .ruitl pretty-printer)

Structs§

Backend
LSP backend. Client is the outbound handle for server→editor notifications (diagnostics, log messages); documents keeps the latest full text for each open file; index maps each URI to its component metadata for completion / hover / go-to-definition.
IndexedComponent
One component’s declaration metadata as known by the LSP. Enough to answer completion, hover, and go-to-definition queries without re-parsing the source document every time.

Functions§

active_component_invocation
If the cursor at pos is inside an @Component(...) argument list, return the component’s name. Walks backward from the cursor character by character until it finds either an unmatched ( (match!) or hits a structural boundary ({, }, ;, newline-outside-arglist, or the start of the buffer).
diagnose
Run the full pipeline (parse + codegen) and translate each error into an LSP Diagnostic. Separated from the async backend so unit tests can drive it without a Client.
token_at_position
Return the identifier token at pos. If prefix is Some('@'), the token must be preceded by @ (i.e. a component-invocation reference or a @Name in a component declaration is NOT matched, only the invocation form). Returns None if no identifier covers pos.

Type Aliases§

DocumentIndex
Per-document index entry: every component declared in that document. A DashMap keyed by document URI gives us a simple workspace-wide index — reconstructed on every parse, so it’s always in sync with the latest buffer contents.