Skip to content

add DocumentLink support - #69

Open
srivastava-diya wants to merge 1 commit into
hyperjump-io:mainfrom
srivastava-diya:links
Open

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

Conversation

@srivastava-diya

Copy link
Copy Markdown
Collaborator

Description

Adds textDocument/documentLink support: every $ref string in an open JSON/JSON Schema document becomes a clickable link that jumps to the AST node it points to.

  • Resolves plain JSON Pointers (#/definitions/foo, #), $anchor references (#fooAnchor, including the legacy "$id": "#name" form), and embedded schemas identified by $id/id (with an optional JSON Pointer or anchor fragment).

  • Resolves $refs that point to a different file, not just the current document. Already-open files are read from their live, and unsaved editor files that aren't open are read from disk and parsed fresh.

  • Follows chained $refs , if a resolved target is itself {"$ref": "..."}, resolution keeps hopping, including across multiple files, until it lands on a real node. A visited locations guard makes circular $ref chains resolve to "no link" instead of hanging.

  • JsonDocument.findNodeAtPointer gained an optional from parameter defaults to the document root so a pointer can be resolved starting at an arbitrary node , backward compatible, existing call sites unaffected.

@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.

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.

1 participant