Skip to main content

Module editor_contract

Module editor_contract 

Source
Expand description

The editor contract: the compiler-owned facts a language-client extension must stay in step with, as one JSON document.

The VS Code extension keeps a TextMate grammar (it highlights by keyword list) and declares the custom semantic-token types the server emits. Both must follow the compiler, and both used to be checked by Rust tests that read the extension’s files from a sibling directory (legend_drift, textmate_keywords). That only worked while the extension lived in this repository. This document is the same data, published: the extension checks itself against the contract of the server release it pins (see design/vscode-extension-extraction.md, §4).

Besides the keywords and legend it carries the two JSON documents the extension parses and keeps a fixture copy of: bynk doctor --json and bynk status --json, as their golden files pin them. The extension checks its fixtures equal the released ones, so a change to either output shape fails there instead of surfacing as a runtime parse error in the editor.

Two forms:

  • the snapshot, committed at SNAPSHOT_PATH. It omits the version, so a release bump never makes it stale; a change to the keywords or legend shows up as a diff in the compiler PR that makes it, which is the signal that the extension needs a matching change. tests/editor_contract.rs fails when it is stale;
  • the release asset bynk-editor-contract-<tag>.json, the snapshot plus the release’s version (render_release).

Constants§

SNAPSHOT_PATH
Where the snapshot is committed, relative to the repo root.

Functions§

generate
The contract without a version.
render
The snapshot as committed: pretty-printed, with a trailing newline.
render_release
The release asset: the snapshot plus the release tag.
write
Write the snapshot to SNAPSHOT_PATH under root.