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
@Componentreferences - Format on save (needs AST → .ruitl pretty-printer)
Structs§
- Backend
- LSP backend.
Clientis the outbound handle for server→editor notifications (diagnostics, log messages);documentskeeps the latest full text for each open file;indexmaps each URI to its component metadata for completion / hover / go-to-definition. - Indexed
Component - 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
posis 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 aClient. - token_
at_ position - Return the identifier token at
pos. IfprefixisSome('@'), the token must be preceded by@(i.e. a component-invocation reference or a@Namein a component declaration is NOT matched, only the invocation form). Returns None if no identifier coverspos.
Type Aliases§
- Document
Index - 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.