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§
- Explain
Params - The
bynk/explainrequest payload: just the diagnostic code. - Wire
Explanation - The
bynk/explainresponse for a curated code.
Constants§
- CLIENT_
CAPABILITY - The
ClientCapabilities.experimentalkey a client sets totrueto say it implementsEXPLAIN_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 intersectsrequested(the same keying rule ascrate::code_actions::quick_fixes). In diagnostic order. - explanation_
for - The explanation for
code, orNonewhen the compiler curates none (an uncurated real code, or not a code at all).