Repository navigation
Generate the .idp schema from core's table of config.idp keys - #37
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #31. Also closes the part of #22 that #31 absorbed.
core#292 is merged:
comline.idpSchema.revpins its merge commit (4d5b19c), and the generated file is the same bytes it was at the PR's head.Problem
src/idpSchema.tswas a hand-written mirror of core'sconfig.idpreader, and the language server leaves.idpkey completion and hover outsidesettingsto the client, so a key missing here was missing in the editor. It had drifted: noid,handshake,settings,unverified,encodingsor dependencyaccept_unverified;wirenameddatagram@2the default;specification_versionwas called a "schema format version".Fix: the schema is generated from core, not written
Core keeps a table of every key its reader takes (
package::config::keys), with types, allowed values, defaults and prose, and commits it asschemas/config-idp.json. Its tests hold the table to the reader in both directions, so a key added to the reader without the table fails there (core#292). The values come from where core declares them (official encodings,comline@2's parameters, the editions, the guarantees), so there is one copy of each.src/idpSchema.generated.json: that file, byte for byte, at the core commitcomline.idpSchema.revpins inpackage.json, next tocomline.languageServer.rev.scripts/sync-idp-schema.mjs: checks the committed copy against the pin (--writerefreshes it,--revtries another commit), as the docs repo does forcomline.toml's schema (sync-comline-toml-schema.py). Node built-ins only.Config schema: runs the script, so it fails when the committed copy is not what the pin generates, or the pin is not on GitHub.src/idpSchema.ts: the 200 lines of keys are gone. The engine stays (comment stripping, key path at the cursor, schema walk). It gains the shapes core writes:choice(a string from a closed set, with its default),list,oneOf(handshakeandunverifiedare a name or a dictionary,publish_registriesentries a string or a dictionary) andsettings, and arequiredflag. A version it doesn't know is an error, so a bump of the file's shape in core can't be read as the old one.code_generation.languagesstays the CLI's live list of targets (ensureTargetsLoaded), because its keys are checked against the generators the configured CLI has; core describes it as a map and the extension replaces it, with one sentence added to core's description saying so. Nothing else.choiceshows its values ("packed@1" | "json@1" | "msgpack@1"), an either-or shows both ("comline@1" | "comline@2" | "none" | dictionary), and hover onhandshake,unverifiedor an entry lists the dictionary's fields, withrequired.ahead of the ones a dictionary needs.#31, item by item
specification_version: described as the edition, with the editions core knows.wire:formatispacked@1(default),json@1ormsgpack@1;framingisdatagram@3(default),datagram@2,datagram@1orjsonrpc@1; a namespaced name declared underencodingsis allowed too.handshake: the name (comline@1,comline@2,none) or the dictionary,nameandcomline@2's four parameters, defaults first:scopeprotocol|package,newer_consumerdegrade|refuse,same_version_differsrefuse|warn,exchangeoffer|symmetric.id,settings,unverified(a reason, or one per guarantee),encodings(kind,profile,mapper language withtype,package,version).accept_unverified: protocol names to lists of guarantees.group: not here; core#284 hasn't landed, and it appears by bumping the pin.Tests
src/idpSchema.test.ts, inyarn test: the engine against core's shapes (a name or a dictionary, a map's entry names,settingsleft to the language server, a version it doesn't read), and what #31 found missing, by key. It doesn't list the whole schema, so a bump doesn't break it.Not here
comline.idpSchema.rev: a bump needs--writein the same pull request, which Renovate can't do. Instead, an advisory CI step (The pin should be current) warns when core'sschemas/config-idp.jsonon its default branch differs from the pinned copy, like the language-server pin's check.wire = { format = | }offering the formats): the schema now has the values, the completion provider still offers keys only..idpitself, which makes this copy unnecessary.