-
Notifications
You must be signed in to change notification settings - Fork 8
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
Better LSP hover interaction in stack-or-heap #116
Conversation
Signed-off-by: David Vulakh <[email protected]>
Signed-off-by: David Vulakh <[email protected]>
gated behind [-lsp-compat] flag Signed-off-by: David Vulakh <[email protected]>
report the entire value binding when not in the lsp-compat regime also move all the lsp-compat tests to a separate file to group them together Signed-off-by: David Vulakh <[email protected]>
clean up some artifacts of intermediate states to make the total PR diff cleaner Signed-off-by: David Vulakh <[email protected]>
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.
Has an lsp dev has verified that the new functionality interacts well with the lsp? If so, lgtm
let[@tail_mod_cons] rec tails = function | ||
| hd :: tl -> (hd, tl) :: tails tl | ||
| [] -> [] | ||
in |
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.
This function seems a bit more general than necessary - I think it might be a bit clearer if it were something like:
let[@tail_mod_cons] rec with_parents = function
| hd :: next :: tl -> (hd, Some next) :: tails (next :: tl)
| [ hd ] -> [hd, None]
| [] -> []
Signed-off-by: David Vulakh <[email protected]>
Signed-off-by: David Vulakh <[email protected]>
This PR adds some special cases to
stack-or-heap
so that it more consistently reports the same location as atype-enclosing
query at the same position (even if that location less accurately describes the allocating expression). Once the locations coincide in more cases, it will be easier to exposestack-or-heap
in a hover-based interface via the LSP.This less precise location reporting is gated behind the
-lsp-compat true
command-line flag, so editors that query thestack-or-heap
RPC directly can still get the maximally descriptive ranges.Here are the two special cases we consider:
stack-or-heap
of a (non-polymorphic variant) constructor now reports the location of just the constructor (not the constructed expression) when-lsp-compat true
is passed. This better matches the behavior oftype-enclosing
, which e.g. reports'a -> 'a option
for the type ofSome
inSome 5
. Polymorphic variants don't have this behavior intype-enclosing
, so we also don't special-case them instack-or-heap
.stack-or-heap
of an identifier pattern that is the left-hand side of a function binding reports thestack-or-heap
of that function. The associated location is the entire binding, unless-lsp-compat true
is passed, in which case it is just the identifier.The new test file
lsp_compat.ml
demonstrates these special cases and how the-lps-compat
flag affects their treatment.