Re: automatically resolving open?
Ulysse Gérard <[email protected]> Thu, 24 Apr 2025 11:16:36 +0200
| Newsgroups | gmane.comp.lang.caml.inria |
|---|---|
| Message-ID | <[email protected]> |
Refactor open is actually a feature of Merlin which have long been exposed in the custom protocol: https://github.com/ocaml/merlin/blob/main/doc/dev/PROTOCOL.md#refactor-open--postion-position--action-qualifyunqualify - In the merlin.el mode the commands are: `merlin-refactor-open` and `merlin-refactor-open-qualify`. - In the vim plugin it is `merlin#RefactorOpen`. - In LSP based plugins, such as `ocaml-eglot` for emacs and `vscode-ocaml-platform`, it is available as a code action. It appears to be working in only one direction however: from the `open` statement it is possible to qualifying all identifiers coming from that statement. As for other solutions, potential shadowing is not checked. This is a fairly obscur command of Merlin, please open an issue if you encounter any issue. Additionally, if someone wants to step in to improve the feature in LSP we will be happy to welcome their contribution :-) Ulysse > On 24 Apr 2025, at 08:39, Virgile Prevosto <[email protected]> wrote: > > Hello, > > this is one of the built-in transformations offered by the recently advertised `ocamlmig` tool: > https://github.com/v-gb/ocamlmig/blob/main/doc/using.md#removing-opens > However, it comes with caveats, including that "when identifiers are requalified, not all possible shadowings are taken into account" (and I've checked that indeed in François' example we end up with a `List.map` below the `module List = struct end`...) > > Best regards,