Re: automatically resolving open?
Kenichi Asai <[email protected]> Thu, 24 Apr 2025 22:06:54 +0900
| Newsgroups | gmane.comp.lang.caml.inria |
|---|---|
| Message-ID | <[email protected]> |
Thank you all for the information. I realize the problem is much harder than I first thought. But the refactor open of Merlin appears to be the closest to what I wanted. I confirmed that I can add and remove module names in emacs and VS Code. Can I do the same thing using a stand-alone command line tool? If not, can I do it from the VS Code extension programatically? > 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. In my environment, I could do both direction. Sincerely, -- Kenichi Asai On Thu, Apr 24, 2025 at 11:16:36AM +0200, Ulysse Gérard wrote: > 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,