add DocumentLink support - #69
Conversation
|
I thought of using Registering a second application/json plugin isn't an option either. Given all that, i added manual resolution. |
jdesrosiers
left a comment
There was a problem hiding this comment.
I consider this to be out of scope. This is a language server for JSON files. It uses JSON Schema, for validating JSON, but it's not intended to be a language server for editing JSON Schema files. It should treat JSON Schema files as plain JSON files, which means it doesn't know that $ref is a link. It should be treated as just a string. DocumentLinks for $ref is for the JSON Schema language server to implement.
The only thing we should be creating document links for in this language server is $schema. If $schema points to a schema in the workspace (rather than from SchemaStore.org), we can make it clickable.
sure and my bad for not thinking through this before, i'll change the implementation accordingly. |
|
|
||
| const link: DocumentLink = { | ||
| target: schemaUri, | ||
| tooltip: "Click to open schema file", |
There was a problem hiding this comment.
Added a custom tooltip so that user will know that this specific link opens the associated schema, because the default tooltip text ("Follow link") is generic and opens any external link, so this distinguishes our link from theirs.
Description
Adds
documentLinksupport, scoped to what this language server actually owns, the document's own$schemadeclaration.If a JSON document's top-level $schema value resolves to a schema file inside an open workspace folder, that value becomes a clickable link to the schema file.
Links are not created for $schema values that resolve to a SchemaStore.org URL (or any non-workspace location).
Workspace folder URIs are normalized before comparison against the resolved $schema URI, since VS Code sends them with a
%3Athat doesn't match the unencoded form produced when resolving $schema.