Skip to content

Commit

Permalink
address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
leostera committed Nov 25, 2023
1 parent bcc2048 commit 43ef436
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
15 changes: 15 additions & 0 deletions src/lib/uTop_compat.ml
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,18 @@ let visible_paths_for_cmt_infos (cmt_infos: Cmt_format.cmt_infos) =
#else
cmt_infos.cmt_loadpath
#endif

let add_cmi_hook f =
let default_load = !Persistent_env.Persistent_signature.load in
#if OCAML_VERSION >= (5, 2, 0)
let load ~allow_hidden ~unit_name =
let res = default_load ~unit_name ~allow_hidden in
#else
let load ~unit_name =
let res = default_load ~unit_name in
#endif
(match res with None -> () | Some x -> f x.cmi);
res
in
Persistent_env.Persistent_signature.load := load

2 changes: 1 addition & 1 deletion src/lib/uTop_complete.ml
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ let visible_modules () =
(Sys.readdir (if dir = "" then Filename.current_dir_name else dir))
with Sys_error _ ->
acc)
String_set.empty @@ (UTop_compat.get_load_path ())
String_set.empty @@ UTop_compat.get_load_path ()
)

let field_name { ld_id = id } = Ident.name id
Expand Down
15 changes: 1 addition & 14 deletions src/lib/uTop_main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -335,20 +335,7 @@ end = struct

let scan_cmis =
let new_cmis = ref [] in
let default_load = !Persistent_env.Persistent_signature.load in

#if OCAML_VERSION >= (5, 2, 0)
let load ~allow_hidden ~unit_name =
let res = default_load ~unit_name ~allow_hidden in
#else
let load ~unit_name =
let res = default_load ~unit_name in
#endif
(match res with None -> () | Some x -> new_cmis := x.cmi :: !new_cmis);
res
in
Persistent_env.Persistent_signature.load := load;

UTop_compat.add_cmi_hook (fun cmi -> new_cmis := cmi :: !new_cmis );
fun pp ->
List.iter (fun (cmi : Cmi_format.cmi_infos) ->
walk_sig pp ~path:(Longident.Lident cmi.cmi_name) cmi.cmi_sign
Expand Down

0 comments on commit 43ef436

Please sign in to comment.