Skip to content

Conversation

@voodoos
Copy link
Collaborator

@voodoos voodoos commented Sep 9, 2025

Fixes #1552

Now object method types are correctly shown.

The issue was due to a missing case in the hover filtering logic (cc @awilliambauer).

@coveralls
Copy link

coveralls commented Sep 9, 2025

Pull Request Test Coverage Report for Build 4929

Details

  • 1 of 4 (25.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.02%) to 23.423%

Changes Missing Coverage Covered Lines Changed/Added Lines %
ocaml-lsp-server/src/hover_req.ml 1 4 25.0%
Totals Coverage Status
Change from base Build 4922: 0.02%
Covered Lines: 5991
Relevant Lines: 25577

💛 - Coveralls

Copy link

@trefis trefis left a comment

Choose a reason for hiding this comment

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

Perhaps the "filtering" match could be made non-fragile to avoid such issues in the future (and so every situation is properly considered)?

Side note: I feel like this code kind of duplicates what the browse tree is used for in merlin...

@voodoos
Copy link
Collaborator Author

voodoos commented Sep 9, 2025

Side note: I feel like this code kind of duplicates what the browse tree is used for in merlin...

My feeling is that the goal of that code is distinct from the one of mbrowse. Merlin was designed around a protocol and a set of editors that require a deliberate action from users to call the type-enclosing command: thus, if the user asked, she probably expects an answer. In visual LSP-based editors, such as vscode, type-enclosing is called continuously, everywhere around the code, as soon as the cursor moves. The best effort strategy of Merlin can result in a lot of clutter, and I think it makes sense to rely on stricter filtering before answering. (I do agree that it could be worth investigating how to re-conciliate both usages with the same code paths internally.)

It's also true that the opt-in nature of the current implementation make it sensible to syntax changes, additions (and omissions such as this one). However it is not a trivial task to reverse this behavior, and outside the scope of this PR.

Meanwhile, we might want to check that other parsetree constructions where an ident is not actually represented by a Pexp_ident node are not suffering from the same omission...

For reference, the PR that introduced this filtering is #1245

Copy link
Collaborator

@xvw xvw left a comment

Choose a reason for hiding this comment

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

I agree with the fix
(Even, I think that, in a future, providing hover as part of the Merlin protocol make sense).

@xvw
Copy link
Collaborator

xvw commented Sep 10, 2025

(I guess that just running dune fmt should make the CI happy?)

@voodoos voodoos merged commit d44b27d into ocaml:master Sep 16, 2025
6 checks passed
davesnx added a commit to davesnx/ocaml-lsp that referenced this pull request Oct 3, 2025
…rmat-mlx

* 'master' of github.com:/ocaml/ocaml-lsp:
  Avoid NeoVim error when opening .mll files (ocaml#1557)
  Fix hover on method calls (ocaml#1553)
voodoos added a commit to voodoos/opam-repository that referenced this pull request Oct 3, 2025
CHANGES:

## Fixes

- Fix hover on method calls not showing the type. (ocaml/ocaml-lsp#1553, fixes ocaml/ocaml-lsp#1552)
- Fix error on opening `.mll` files (ocaml/ocaml-lsp#1557)
- Ensure compatibility with both yojson 2.0 and 3.0. (ocaml/ocaml-lsp#1534)
voodoos added a commit to voodoos/opam-repository that referenced this pull request Oct 3, 2025
CHANGES:

## Fixes

- Fix hover on method calls not showing the type. (ocaml/ocaml-lsp#1553, fixes ocaml/ocaml-lsp#1552)
- Fix error on opening `.mll` files (ocaml/ocaml-lsp#1557)
- Ensure compatibility with both yojson 2.0 and 3.0. (ocaml/ocaml-lsp#1534)
davesnx pushed a commit to davesnx/ocaml-lsp that referenced this pull request Nov 26, 2025
* Reproduce issue ocaml#1552

* Add missing Pexp_send case in hover filtering

Fixes ocaml#1552
Now object method types are correctly shown

* Add changelog entry
davesnx pushed a commit to davesnx/ocaml-lsp that referenced this pull request Nov 26, 2025
* Reproduce issue ocaml#1552

* Add missing Pexp_send case in hover filtering

Fixes ocaml#1552
Now object method types are correctly shown

* Add changelog entry
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.

hover on method call replies "No information available"

4 participants