Skip to content

Commit 05d214b

Browse files
author
Yogthos
committed
LSP Phase 3: file lifecycle + push diagnostic state + wait API
src/lsp/client.rs (LspClient wrapping RpcClient) - notify_open(path): reads file, sends textDocument/didOpen on first contact or textDocument/didChange (with bumped version) thereafter. Returns the version sent so callers can correlate later push events. - diagnostics_for(path): merged + deduped push/pull diagnostics for one file. dedupe key: range + severity + code + source + message (matches opencode). Code is load-bearing — same-line same-message diagnostics with distinct clippy codes (needless_clone vs redundant_clone) must NOT collapse. - all_diagnostics(): aggregate across every tracked file; empty entries pruned. - wait_for_push(path, after, timeout): blocks until a fresh push for path arrives strictly after the given Instant. Subscribes to a watch channel that the publishDiagnostics handler bumps on every push; re-checks state under each wake. Stale pushes (already in state at call time) do NOT satisfy the wait — only fresh arrivals count. - Push state populated by an internally-registered textDocument/publishDiagnostics handler. URIs decoded back to PathBufs via percent_decode so we round-trip cleanly with path_to_file_uri_string. 15 tests including regressions: - notify_open second call sends didChange (not another didOpen) with bumped version - dedupe preserves entries with distinct fields - wait_for_push ignores stale arrivals (rejects pushes before ) - merged_diagnostics dedupes identical entries Code review fixes applied before push: - Dedupe key was missing — added with regression test. - Doc-noted blocking std::fs I/O in notify_open for Phase 4 to revisit. Phase 1: 29, Phase 2: 31, Phase 3: +15 → 75 LSP tests. Suite: 365 -> 380.
1 parent 80356d0 commit 05d214b

2 files changed

Lines changed: 696 additions & 0 deletions

File tree

0 commit comments

Comments
 (0)