Skip to content

Delegate outline generation to Merlin #1529

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

Merged
merged 4 commits into from
Jun 24, 2025

Conversation

Tim-ats-d
Copy link
Contributor

@Tim-ats-d Tim-ats-d commented May 19, 2025

Replacement of the in-house solution for generating outlines by Merlin.

I had to regenerate the tests because merlin and ocaml-lsp don't calculate the positions of elements in the outline in the same way. Fir instance, the y loc was the enclosing location for ocaml-lsp:

let x = object
  method y = 10
(*^^^^^^^^^^^^^*)  
end

While Merlin indicates the exact position:

let x = object
  method y = 10
      (* ^ *)  
end

The PR diff also indicates that several items kind value have changed from 7 to 13. Indeed, Merlin treats instance variables as Values and not as Property like ocaml-lsp does. This change simply means that the icon displayed on the vscode side will be different

Could you please mark this PR has draft? We have to wait for the next Merlin next because we need this patch ocaml/merlin#1936

@xvw xvw changed the title Delegate outline generation to Merlin Draft: Delegate outline generation to Merlin May 19, 2025
@Tim-ats-d Tim-ats-d changed the title Draft: Delegate outline generation to Merlin Draft:Delegate outline generation to Merlin May 19, 2025
@Tim-ats-d Tim-ats-d changed the title Draft:Delegate outline generation to Merlin Draft: Delegate outline generation to Merlin May 19, 2025
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.

What a nice PR! Thanks!

Comment on lines 389 to 390
"end": { "character": 10, "line": 2 },
"start": { "character": 9, "line": 2 }
Copy link
Collaborator

Choose a reason for hiding this comment

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

Sometime the result spans multiple lines like the previous one for a. But sometimes the only highlight the character like this one for b. Do you know why ?

I expect for most editors this is not an issue since they only use the start position ? But we might want to be a bit more careful about what we return here...

Copy link
Collaborator

Choose a reason for hiding this comment

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

There was more to that in the e2e test. The LSP protocol reports 2 locations for outline items: the location of the entire englobing item and the selectionRange that is used when the user clicks the outlines and should select a meaningful identifier. I updated Merlin and this PR to also report these selection ranges.

@xvw
Copy link
Collaborator

xvw commented May 30, 2025

I guess that the PR can be undrafted yes?

@coveralls
Copy link

Pull Request Test Coverage Report for Build 4862

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 14 of 17 (82.35%) changed or added relevant lines in 1 file are covered.
  • 2 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.08%) to 23.384%

Changes Missing Coverage Covered Lines Changed/Added Lines %
ocaml-lsp-server/src/document_symbol.ml 14 17 82.35%
Files with Coverage Reduction New Missed Lines %
lsp/src/types.ml 2 13.08%
Totals Coverage Status
Change from base Build 4858: -0.08%
Covered Lines: 5979
Relevant Lines: 25569

💛 - Coveralls

@Tim-ats-d Tim-ats-d changed the title Draft: Delegate outline generation to Merlin Delegate outline generation to Merlin Jun 11, 2025
@voodoos voodoos force-pushed the use-merlin-outline branch from 45acabe to 7ed4be3 Compare June 24, 2025 13:41
@voodoos voodoos merged commit f56bb6d into ocaml:master Jun 24, 2025
@Tim-ats-d Tim-ats-d deleted the use-merlin-outline branch June 25, 2025 07:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants