Skip to content

Commit 0eed693

Browse files
committed
Review changes in locate.ml
1 parent 740f5f5 commit 0eed693

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

src/analysis/locate.ml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,7 @@ module Utils = struct
449449

450450
let find_file_with_path ~config ?(with_fallback = false) file path =
451451
let title = "find_file_with_path" in
452+
452453
let filename = File.name file in
453454
log ~title "Try find %S" filename;
454455
if File.is_source file && filename = Mconfig.unitname config then
@@ -464,6 +465,7 @@ module Utils = struct
464465
else None
465466
in
466467
let fname = File.with_ext ~src_suffix_pair file in
468+
log ~title "Trying %S" fname;
467469
try Some (Misc.find_in_path_normalized ?fallback path fname)
468470
with Not_found -> None
469471
in
@@ -776,6 +778,7 @@ let find_source ~config loc path =
776778
doesn't know which is the right one: %s"
777779
matches)
778780

781+
(* CR: Is there something better to do to avoid the assertions? *)
779782
let rec unbox_uid = function
780783
| Shape.Uid.Unboxed_version uid -> unbox_uid uid
781784
| uid -> uid
@@ -861,13 +864,14 @@ let get_linked_uids ~config ~comp_unit decl_uid =
861864
| Ok (_pos_fname, artifact) ->
862865
log ~title "Cmt successfully loaded, looking for %a" Logger.fmt (fun fmt ->
863866
Shape.Uid.print fmt decl_uid);
864-
List.filter_map ~f:(function
865-
| Cmt_format.Definition_to_declaration, def, decl when decl = decl_uid ->
866-
Some def
867-
| Cmt_format.Definition_to_declaration, def, decl when def = decl_uid ->
868-
Some decl
869-
| _ -> None)
870-
@@ Artifact.declaration_dependencies artifact
867+
List.filter_map
868+
~f:(function
869+
| Cmt_format.Definition_to_declaration, def, decl when decl = decl_uid
870+
-> Some def
871+
| Cmt_format.Definition_to_declaration, def, decl when def = decl_uid ->
872+
Some decl
873+
| _ -> None)
874+
(Artifact.declaration_dependencies artifact)
871875
| _ ->
872876
log ~title "Failed to load the cmt file";
873877
[]

src/analysis/locate.mli

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,6 @@ end
6666
val uid_of_result :
6767
traverse_aliases:bool -> Shape_reduce.result -> Shape.Uid.t option * bool
6868

69-
(* val lookup_uid_decl :
70-
config:Mconfig.t -> Shape.Uid.t -> Typedtree.item_declaration option *)
71-
7269
(** Lookup the declaration of the given Uid in the appropriate cmt file *)
7370
val lookup_uid_loc_of_decl :
7471
config:Mconfig.t -> Shape.Uid.t -> string Location.loc option

0 commit comments

Comments
 (0)