Question about using just the basename of the file in Merlin
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: https://github.com/ocaml/merlin/blob/be3451817c034ca24ae4d151dab05a796763c5ea/src/kernel/mconfig.ml#L828-L833):
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.
Hi @jonahbeckford !
The parser is configured to use the "filename" here:
https://github.com/ocaml/merlin/blob/874de7e42bd6c64793c8520d0d2a955e9c555595/src/kernel/mocaml.ml#L39
I would expect that to corresponds to the content of the -filename argument, which is indeed not the case since query.filename = File.basename filename.
It does feel like we should use Filename.concat t.query.directory t.query.filename here, but I am a bit worried of the potential downstream implications. Feel free to try it and open a PR, I will try to think more about it.