M3.3: engine wiring for Phpactor and diagnostics

- One Phpactor per open project on its own session thread, started when
  the toolchain is ready; ordered document sync from buffer.edit and the
  pump; lspStatus, diagnosticsChanged, diagnostics.list, lsp.status,
  lsp.restart; app.quit stops the server synchronously.
- Phpactor 2026.06.25.0 on Windows: keep-alive $/lutra/tick (its event
  loop only runs on stdin input), in-process diagnostics and a polling
  watcher through initializationOptions (amphp subprocesses fail), 500 ms
  shutdown timeout.
- Editor lint extension (underlines, gutter dots, hover; tokens only) and
  a Problems tab in the bottom panel; problems.open Mod+Alt+P.
- Tests: engine tests against the fake server (incl. sync proptest), an
  ignored real-Phpactor test, a TCP test, Vitest for lint and Problems.
- Docs: architecture, gaps G6, parity (Inspections 4% est.), ui-parity,
  roadmap, ROADMAP.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
danny 2026-10-21 18:58:32 +02:00
parent 65c6966588
commit 13c76d3046
34 changed files with 3562 additions and 37 deletions

View file

@ -197,6 +197,12 @@ pub enum Event {
/// PHP or Phpactor changed: `{php, phpactor}` as `toolchain.status`
/// returns it.
ToolchainChanged(crate::cmd::toolchain::ToolchainStatus),
/// The language server's state changed: `{state, message?}` with state
/// `starting`, `ready`, `restarting`, `failed` or `stopped`.
LspStatus(crate::lsp::LspStatus),
/// The diagnostics of one file changed: `{path, items}`; empty items
/// mean the file has none any more. Fetch all with `diagnostics.list`.
DiagnosticsChanged(crate::lsp::FileDiagnostics),
/// Terminal events (`terminalOutput`, `terminalExited`), see [`crate::cmd::terminal`].
#[serde(untagged)]
Terminal(crate::cmd::terminal::TerminalEvent),
@ -382,4 +388,40 @@ mod tests {
json!({"kind": "outlineChanged", "id": 4})
);
}
#[test]
fn lsp_shapes() {
use crate::lsp::{
DiagnosticItem, DiagnosticSeverity, FileDiagnostics, LineRange, LspState, LspStatus,
};
let e = Event::LspStatus(LspStatus {
state: LspState::Restarting,
message: Some("exit code 7".into()),
});
assert_eq!(
serde_json::to_value(e).unwrap(),
json!({"kind": "lspStatus", "state": "restarting", "message": "exit code 7"})
);
let range = LineRange {
start: lutra_text::Position::new(1, 2).into(),
end: lutra_text::Position::new(1, 5).into(),
};
let e = Event::DiagnosticsChanged(FileDiagnostics {
path: "src/a.php".into(),
items: vec![DiagnosticItem {
range,
severity: DiagnosticSeverity::Info,
message: "unused".into(),
source: None,
code: Some("X1".into()),
}],
});
assert_eq!(
serde_json::to_value(e).unwrap(),
json!({"kind": "diagnosticsChanged", "path": "src/a.php", "items": [{
"range": {"start": {"line": 1, "column": 2}, "end": {"line": 1, "column": 5}},
"severity": "info", "message": "unused", "code": "X1"
}]})
);
}
}