Skip to content

add DocumentLink support - #69

Open
srivastava-diya wants to merge 3 commits into
hyperjump-io:mainfrom
srivastava-diya:links
Open

add DocumentLink support#69
srivastava-diya wants to merge 3 commits into
hyperjump-io:mainfrom
srivastava-diya:links

Conversation

@srivastava-diya

@srivastava-diya srivastava-diya commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

Description

Adds documentLink support, scoped to what this language server actually owns, the document's own $schema declaration.

  • 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 %3A that doesn't match the unencoded form produced when resolving $schema.

@srivastava-diya

Copy link
Copy Markdown
Collaborator Author

I thought of using @hyperjump/browser's get() as the primary resolution mechanism, I used this same approach for my JRef Qualification task, but it turns out not to be effective here. SchemaStore already owns the single global application/json media-type, so get() gives back schema-compiler internals, not the plain JSON content of the file. I confirmed this by using step() on a .json file which returned {}

Registering a second application/json plugin isn't an option either.

Given all that, i added manual resolution.

@jdesrosiers jdesrosiers left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.

@srivastava-diya

Copy link
Copy Markdown
Collaborator Author

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",

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants