-
Notifications
You must be signed in to change notification settings - Fork 31.7k
[json] support link on $ref for external references #116540
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
Comments
We currently only support the link for local $ref's |
Hello, is this issue currently being worked on? Otherwise I would like to check it out. |
I'm not working on it, if you want to give it a go, that would be fantastic. |
Hi, after investigating for a bit I believe this feature should be added in the JSON language service. Am I correct in assuming that that we need to commit and make a PR for https://github.com/microsoft/vscode-json-languageservice? If so, should this issue be moved to there as well? |
@yarally how did you come to this conclusion? |
@FilipePintoReis For one of my master courses called Software Architecture we are required to learn about and contribute to a open source project. First of all I noticed that turning off the JSON language service makes it so that the support links stop functioning. Then one of my teammates found this file, which we believe handles the links of the $refs. |
Yes, the change needs to be in https://github.com/microsoft/vscode-json-languageservice. We can move the issue there if that's helpful, or just create a PR there. |
Okay thanks! Keeping the issue here is fine. |
Hi I'm a fellow student of @yarally and I am also currently looking into this issue. We think we will be able to implement this by adding a DocumentContext parameter to the findLinks function, similar to how the html-language-service's link finding function works. Currently this is how the html and css language services both implement DocumentContext. Would this approach be correct? |
@Huntervang What you suggest makes sense! |
@aeschli We have an almost working proposal at the moment, but there is one problem that we're unsure how to solve. In order to calculate the ranges for the references, we need the respective TextDocuments. Inside the jsonServer.ts, this is done using the document manager. However, the manager only has references to documents that are currently open. Is there a way to add documents to the managers's memory or to fetch them some other way using the uri? Thanks in advance! if (ref.uri) {
const externalDocument = documents.get(ref.uri);
// externalDocument is undefined if the user has not opened the file first
if (externalDocument) {
// Do stuff
} |
The schema service uses the schemaRequestService and does caching. However, it it currently only caches the object tree, not the locations nor the underlying document. Instead, I would delay the resolving of the $ref location, so we don't need the caching. This can be done with the document link resolve feature from LSP. |
If we were to only resolve the link on click this would result in us not knowing the existence of a target JSON object, and thus not knowing when the link should become a clickable object. We currently have some code which checks if the file exists and in that case creates a link. This results in the current functionality as seen below: Another question we had is what would be a function that gets called when the user clicks a link within the scope of jsonServer.ts? |
I would always render it as a link, if the link is syntactically correct. Even if it points to a non existing file or property. |
In jsonServer you have to add calls to |
I remember in older version that it showed the link.
Does this issue occur when all extensions are disabled?: Yes
The text was updated successfully, but these errors were encountered: