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

Fix issue 1388 #1419

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions src/dot-merlin/dot_merlin_reader.ml
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ let postprocess cfg =
; List.concat_map pkg_paths ~f:(fun p -> [ `B p; `S p ])
; ppx
; List.map failures ~f:(fun s -> `ERROR_MSG s)
; Option.to_list cfg.stdlib |> List.map ~f:(fun std -> `STDLIB std)
]

let load dot_merlin_file =
Expand Down
30 changes: 11 additions & 19 deletions src/kernel/mconfig.ml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ let canonicalize_filename path =
let marg_path f =
Marg.param "path" (fun path acc -> f (canonicalize_filename path) acc)

let marg_path_no_canon f =
Marg.param "path" (fun path acc -> f path acc)

let marg_commandline f =
Marg.param "command"
(fun workval acc -> f {workdir = unsafe_get_cwd (); workval} acc)
Expand Down Expand Up @@ -413,7 +416,7 @@ let ocaml_alert_spec =
let ocaml_flags = [
(
"-I",
marg_path (fun dir ocaml ->
marg_path_no_canon (fun dir ocaml ->
{ocaml with include_dirs = dir :: ocaml.include_dirs}),
"<dir> Add <dir> to the list of include directories"
);
Expand Down Expand Up @@ -691,7 +694,7 @@ let source_path config =
config.merlin.source_path]
|> List.filter_dup

let build_path config = (
let include_dirs ~stdlib config =
let dirs =
match config.ocaml.threads with
| `None -> config.ocaml.include_dirs
Expand All @@ -703,10 +706,12 @@ let build_path config = (
config.merlin.build_path @
dirs
in
List.map dirs ~f:(fun dir -> Misc.expand_directory stdlib dir
|> Misc.canonicalize_filename)

let build_path config = (
let stdlib = stdlib config in
let exp_dirs =
List.map ~f:(Misc.expand_directory stdlib) dirs
in
let exp_dirs = include_dirs ~stdlib config in
let stdlib = if config.ocaml.no_std_include then [] else [stdlib] in
let dirs = List.rev_append exp_dirs stdlib in
let result =
Expand All @@ -721,21 +726,8 @@ let build_path config = (
)

let cmt_path config = (
let dirs =
match config.ocaml.threads with
| `None -> config.ocaml.include_dirs
| `Threads -> "+threads" :: config.ocaml.include_dirs
| `Vmthreads -> "+vmthreads" :: config.ocaml.include_dirs
in
let dirs =
config.merlin.cmt_path @
config.merlin.build_path @
dirs
in
let stdlib = stdlib config in
let exp_dirs =
List.map ~f:(Misc.expand_directory stdlib) dirs
in
let exp_dirs = include_dirs ~stdlib config in
let stdlib = if config.ocaml.no_std_include then [] else [stdlib] in
config.query.directory :: List.rev_append exp_dirs stdlib
)
Expand Down
31 changes: 31 additions & 0 deletions tests/test-dirs/config/issue1388.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
$ cat >.merlin <<EOF
> STDLIB /my/std
> FLG -I +../cerberus/flags
> S +../cerberus/source
> B +../cerberus/build
> EOF

$ echo "" | $MERLIN single dump-configuration -filename test.ml | \
> grep -A2 'include_dirs\|source_path\|build_path'
"include_dirs": [
"+../cerberus/flags"
],
--
"build_path": [
"/my/cerberus/build"
],
"source_path": [
"/my/cerberus/source"
],

$ echo "" | $MERLIN single dump -what paths -filename test.ml
{
"class": "return",
"value": [
"$TESTCASE_ROOT",
"/my/cerberus/flags",
"/my/cerberus/build",
"/my/std"
],
"notifications": []
}