Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure I understand why this change is required, the current implementation does respect the spec in https://github.com/ocaml/ocaml-lsp/blob/master/ocaml-lsp-server/docs/ocamllsp/merlinCallCompatible-specs.md and this change is not coherent with the dual
yojson_of_t
.Looking at the LSP spec, in most places the
TextDocumentIdentifier.t
is usually given a key namedtextDocument
and making this change would be more "LSP idiomatic", however inlining the sole field inTextDocumentIdentifier
is not really "wrong" either...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The clean way to decode would in fact be:
And we should also probably rename the misleading field
text_document
touri
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some change is required, since the current
t_of_yojson
certainly has a bug (TextDocumentIdentifier.t_of_yojson json
is clearly wrong in this context). I think you're correct that the current implementation does not match the spec.It's also awkward that the custom requests are not uniform in whether their parameters inline the URI or contain a
TextDocumentIdentifier.t
. I'd be happy with a bigger change to make them all the same, and use ppx-based converters (which thehoverExtended
request already does).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it was noticed during
ocaml-eglot
implementation (and this is why the current implementation duplicate a fielduri
additionned totextDocumentIdentifier
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just out of curiosity (and because I can't see the issue, sorry!), I can't understand why
TextDocumentIdenfier.t_of_yojson json
is wrong?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you point me to the duplicate
uri
field? I don't see it in the code...Separately, I don't think a duplicate field is a very nice solution—wouldn't it be better to have the URI appear once in the params rather than twice?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here: https://github.com/tarides/ocaml-eglot/blob/main/ocaml-eglot-req.el#L57
but yeah. I made that fix (on ocaml-eglot) with the goal of making a global pass on every query.
But even I totally agree with you about having uniform way to denote
TextDocumentIdentifier
, I do not understand the issue withTextDocumentIdenfier.t_of_yojson json
(maybe I am missing something)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see. I was confused by the fact that the definition of
RequestParams.t
doesn't match the request spec (i.e., the request spec has auri
field, butRequestParams.t
has atextDocument
field).This PR is not needed if I change our internal integration to follow the spec, and not the type definition in the ocaml-lsp code.