I am missing the “references” functionality in OCaml LSP that I really like in, say, in the clang C/C++ language server.
Example: Let say in C in while using clang LSP in my favourite editor I invoke “get references” on “somefunc()”. I then get a list of all the usages of the function across the project in various .c files at difference line numbers.
In the OCaml language server the same functionality works in an incomplete way.
Let say I’m looking for references of the function parse. When I “get references” I will get all the references to that function in only the .ml file I am searching.
But this can be defeated very easily. If somewhere else in the same .ml file, the parse function was invoked using SomeModule.parse, the result does not appear even though the function does live in the SomeModule after all.
All in all:
(1) Get references only returns results in a single .ml file
(2) Get references does not tolerate any kind of aliasing – if the function is referred to via an aliased name it will not be found.
One silly workaround is simply rename the function parse to something like _parse and see all the compiler errors that result in the ml file. Of course one can use regexes but a strongly typed language should be able to do search for occurrences quite easily.
I am not so familiar with merlin but am aware that it is the backend for ocaml-lsp-server. Searching for occurrences using merlin seems to behave similarly like it did for ocaml-lsp-server. Maybe I did not use the correct command?
How can I get the references functionality while editing OCaml code?