Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add editor support for JSON config schema #4724

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

tobias-tengler
Copy link
Contributor

No description provided.

@tobias-tengler tobias-tengler changed the title (WIP) Add editor support for JSON config schema [WIP] Add editor support for JSON config schema Jun 23, 2024
@captbaritone
Copy link
Contributor

captbaritone commented Jun 25, 2024

I just had another idea. Since the VSCode extension already knows how to invoke the compiler binary, and the compiler binary can construct the json schema, what if we added a separate compiler command to return the schema text on stdout? It seems like that might be simpler. It would also work better for us internally since we don't access the compiler via an NPM module but a separate binary deployment which would be hard to update to also sync a sibling file.

I'll work on a compile diff to add this support.

@tobias-tengler tobias-tengler force-pushed the json-schema-editor-support branch 2 times, most recently from 9c31623 to 0982908 Compare June 28, 2024 19:36
@tobias-tengler tobias-tengler changed the base branch from json-schema to main June 28, 2024 19:37
@tobias-tengler tobias-tengler marked this pull request as ready for review June 28, 2024 19:37
@tobias-tengler tobias-tengler changed the title [WIP] Add editor support for JSON config schema Add editor support for JSON config schema Jun 28, 2024

provideTextDocumentContent(uri: Uri): ProviderResult<string> {
if (uri.authority === PACKAGE_JSON_RELAY_CONFIG_SCHEMA_PATH) {
return `{"properties": { "relay": { "$ref": "${RelayTextDocumentContentProvider.scheme}://${RELAY_CONFIG_SCHEMA_PATH}", "description": "Relay.js configuration" }}}`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This little recursion trick is so clever. Nice.

}

if (uri.authority === RELAY_CONFIG_SCHEMA_PATH) {
this.cachedJsonSchema ||= this.loadConfigJsonSchema();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the user changes their relay binary path in the config file, does this get invalidated correctly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, but you have to restart the extension anyways because the binary information is only loaded once at startup atm.

@tobias-tengler
Copy link
Contributor Author

The Prettier and ESLint rules are conflicting... Nice

@@ -25,6 +25,7 @@ module.exports = {
'operator-linebreak': 'off',
'@typescript-eslint/indent': 'off',
'@typescript-eslint/object-curly-spacing': 'off',
'@typescript-eslint/brace-style': 'off',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants