Skip to content
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

Support "Find occurrences" at whole project scale, not just inside the current file #377

Closed
UnixJunkie opened this issue Mar 20, 2015 · 14 comments

Comments

@UnixJunkie
Copy link

merlin-locate is project-wise
merlin-occurrences is just current-buffer
Can't we have a merlin-occurrences that is project-wise?

@let-def
Copy link
Contributor

let-def commented Mar 20, 2015

I started work on this a few weeks ago, but I don't have time for it right now…
I hope to release it in a few more weeks.

@let-def let-def self-assigned this Mar 20, 2015
@UnixJunkie
Copy link
Author

Thanks! 👍

@sir4ur0n
Copy link

Hi,

I feel always a bit bad when reviving a 4 year old issue 😅 but I found this issue while looking for a way to find project-wise occurrences (currently limited to the current file).

The issue #156 is kind of misleading, one has to read carefully through the thread to understand it only works in the current file.

I propose this issue is renamed to better reflect the feature request: Support "Find occurrences" in the project, not just in the current file. What do you think?


6 years later, does someone have any idea if this feature is:

  • feasible?
  • easy or difficult to implement?

I have the secret (though probably unrealistic 😁 ) hope that current knowledge would make this implementation easier than it was back then 🤞

As a recent OCaml developer, this would be an amazing feature to work on medium to large projects (where grepping gives too many false-positives) 🙏

Project-wise renaming would be the cherry on top, but finding occurrences alone would be an amazing step forward already.

@UnixJunkie
Copy link
Author

@sir4ur0n there is ocp-grep, if you are really dying for something.

@UnixJunkie UnixJunkie changed the title incoherence between merlin-locate and merlin-occurrences Support "Find occurrences" at whole project scale, not just inside the current file Feb 25, 2021
@sir4ur0n
Copy link

sir4ur0n commented Mar 4, 2021

So I gave a serious shot to ocp-grep, thanks for mentioning that @UnixJunkie , I wasn't aware of it!

Unfortunately there are several shortcomings to this tool:

  • It seems to miss some occurrences (returns less than all valid occurrences)
  • I could not make it work to find occurrences of operators (but maybe it's possible)
  • The Emacs command tries to find the identifier at point to pass it to ocp-grep, unfortunately it fails on 90% of my tries, and I have to manually find and type the identifier myself.
  • I hoped I could compose it with some Merlin command to get the identifier at point, unfortunately the Merlin API provides no such thing.
  • Merely no documentation (or I miserably failed to find it)

I don't mean to be unfair to ocp-grep (nor its maintainers) though: when it works, it works rather well, this is a net improvement over the current status quo of grepping an OCaml codebase as it removes many false positives in the result list.

As Merlin seems to be the standard OCaml development tool, I think it would make sense to add this "Find occurrences" feature.

What do the maintainers think about this?

  • "Makes sense, we will work on it (assuming we have time, etc.) / are already working on it"
  • "Makes sense, but we don't have time/energy/motivation/other to do it ourselves. Contributions are welcome though" (in that case, could we get pointers please?)
  • "No, this is a bad idea/doesn't make sense (in Merlin) because ..."
  • Other

I just want to thank again the maintainers because what Merlin currently does, it does really well (I am often baffled by how well it keeps working below lines that don't compile) 🙇

@ulugbekna
Copy link
Contributor

Re: find occurrences in merlin

I was recently onboarded to work on editor experience for OCaml projects. I find "occurrences" as important as you do especially when working with new projects. There are some other tasks that I will need to complete before however, including work on other aspects of occurrences.

So, if you want the feature asap and anyone wants to point you in the right direction (I can't since I'm new to merlin codebase myself), then it may be indeed a good idea to give it a try yourself.

@emillon
Copy link
Contributor

emillon commented Mar 29, 2021

Hi,

The answer is definitely "Makes sense, we will work on it (assuming we have time, etc.) / are already working on it" :)

Historically Merlin has been supporting a wide range of versions and this has made this kind of feature difficult to support. Now that a given version of merlin only support the latest compiler, it can leverage more precise compiler information.

For example, finding where a value comes from can be a tricky question to define. It used to be tracked by source location, but this is not always a 1:1 mapping (for example with generated code). With things like ocaml/ocaml#8934 merged in the compiler it means that merlin can have a more precise view of how definitions, declarations and usage are linked.

All of these features (more precise jumps, cross-module uses, better renaming) are on merlin's roadmap so you should be able to see some improvements later this year.

@HyunggyuJang
Copy link

Any progress?

@trefis
Copy link
Contributor

trefis commented Apr 15, 2022

Yes, we've progressed by at least one more (significant) step with some recent changes that were made to the compiler ( https://github.com/ocaml/ocaml/blob/trunk/Changes#L658 ).

At this point everything we would need from the compiler for a project-wide "find occurences" functionality is present in 4.14. What we need is to build the actual tooling around it; which implies merlin but also some cooperation from dune and other build systems.
@voodoos has started working on this recently.

We have no ETA for the finished feature yet, but the work is progressing steadily.

@sidkshatriya
Copy link
Contributor

sidkshatriya commented Nov 4, 2022

The ability to search for occurrences of a symbol across a project is very useful.

I was wondering if any more progress had been made on this @voodoos @trefis

I am willing to work on this feature to make it happen. However, I don't know Merlin internals but I'm willing to learn. Let me know if it would be efficient to be guided to build this feature and I can volunteer.

@voodoos
Copy link
Collaborator

voodoos commented Nov 6, 2022

I was wondering if any more progress had been made on this @voodoos @trefis

Yes, it is actually in the works :-)
Your testing will be very much welcome when we will have our first prototype !

@sidkshatriya
Copy link
Contributor

Very exciting!

If there is a public branch available to check this out do let us know :-) !

@7h3kk1d
Copy link

7h3kk1d commented Oct 8, 2024

For anyone looking this seems to work using LSP in the most recent version https://discuss.ocaml.org/t/ann-project-wide-occurrences-in-merlin-and-lsp/14847/1

Requires a dune build @ocaml-index

@voodoos
Copy link
Collaborator

voodoos commented Oct 8, 2024

Indeed, since Merlin 5.2-502 one can perform project-wide usages searches !

Meta-issue tracking bugs and future work related to that feature: #1780

@voodoos voodoos closed this as completed Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests