Skip to main content

Module explain_request

Module explain_request 

Source
Expand description

#2098: bynk/explain — the in-editor, offline explanation of a diagnostic code, and the “Explain …” code action that opens it.

The explanation data is compiled into the toolchain ([bynk_syntax::diagnostics::explain]), so the server already holds the exact text for the code it just emitted: serving it from here is version-matched by construction and needs no network and no bynk on PATH. The content is the same curated blurb, example and Book link that bynk explain <code> prints (bynk/src/explain.rs); this module only re-shapes it as Markdown for a client to render.

Transport (DECISION A). A custom request, bynk/explain { code } → { title, markdown, href } | null, advertised under ServerCapabilities.experimental.explain like the other custom requests. The request is not document-scoped: the params carry only the code, so the client can also look up a code it saw in CI output. null for any code with no curated explanation — a known-but-uncurated code and an unknown one alike; telling those apart (and saying so gracefully) is the client’s job.

Code action (DECISION B). For every diagnostic in the requested range whose code is curated, a quickfix that carries a client-side command (EXPLAIN_COMMAND) rather than an edit. It is appended after every real fix and never marked preferred, so it cannot preempt one. Because the command is executed by the client, the action is only offered to a client that says it implements it — experimental.explainDiagnosticCommand: true in its ClientCapabilities (see client_supports_explain_command). A client that does not would otherwise show a lightbulb entry that does nothing when chosen.

Structs§

ExplainParams
The bynk/explain request payload: just the diagnostic code.
WireExplanation
The bynk/explain response for a curated code.

Constants§

CLIENT_CAPABILITY
The ClientCapabilities.experimental key a client sets to true to say it implements EXPLAIN_COMMAND, and so wants the “Explain …” code action.
EXPLAIN_COMMAND
The client-side command the “Explain …” code action invokes, with the diagnostic code as its single argument. The VS Code extension registers it (vscode-bynk/src/explainView.ts).

Functions§

client_supports_explain_command
Whether the client advertised experimental.explainDiagnosticCommand: true.
explain_actions
One “Explain code” action per distinct curated code among the diagnostics whose span intersects requested (the same keying rule as crate::code_actions::quick_fixes). In diagnostic order.
explanation_for
The explanation for code, or None when the compiler curates none (an uncurated real code, or not a code at all).