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

Question about using just the basename of the file in Merlin #1871

Open
jonahbeckford opened this issue Dec 3, 2024 · 0 comments
Open

Question about using just the basename of the file in Merlin #1871

jonahbeckford opened this issue Dec 3, 2024 · 0 comments

Comments

@jonahbeckford
Copy link
Contributor

I was a bit surprised that when I inspected Location.input_name it was always a basename rather than the full path.

For example:

... | ocamlmerlin.exe single dump-configuration -filename src\SonicScout_Setup\AndroidStudio.ml

will returns evidence Merlin knows the full path:

    "query": {
      "filename": "AndroidStudio.ml",
      "directory": "Y:\\source\\scoutapps\\src\\SonicScout_Setup",
      "printer_width": 0,
      "verbosity": "lvl 0"
    }

But when I output Location.input_file as an error node in a FLG -ppx and look at it with:

... | ocamlmerlin.exe single errors -filename src\SonicScout_Setup\AndroidStudio.ml

that returns evidence Merlin is throwing the path away:

{
  "class": "return",
  "value": [
    {
      "start": {
        "line": 1,
        "col": 0
      },
      "end": {
        "line": 66,
        "col": 73
      },
      "type": "typer",
      "sub": [],
      "valid": true,
      "message": ".... Work dir is\nY:\\source\\scoutapps.\nLocation.input_name is AndroidStudio.ml.\n..."
    },

I think this behavior is because of the several places in the code that do Misc.unitname t.query.filename. Example:

let basename = Misc.unitname t.query.filename in
begin
match t.merlin.wrapping_prefix with
| Some prefix -> prefix ^ basename
| None -> basename
end
):


I can patch this but why does Merlin not pass Filename.concat t.query.directory t.query.filename as the Location.input_file to PPX-es?

I need the path for my MlFront/DkCoder scripting tool (adds a Java-like packaging system onto OCaml). It is straightforward to convert each source code path into a package identifier (just like Java), and it would not be great if Merlin confuses MyLibrary_One/A/Modul.ml and MyLibrary_Two/A/Modul.ml.

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant