@@ -353,48 +353,6 @@ let uid_of_path ~config ~env ~ml_or_mli ~decl_uid path ns =
353353 Logger. fmt (fun fmt -> Shape. print fmt r);
354354 r.uid
355355
356- (* * [module_aliasing] iterates on a typedtree to check if the provided uid
357- corresponds to a module alias. If it does the function returns the uid of the
358- aliased module. If not it returns None.
359- The intended use of this function is to traverse dune-generated aliases. *)
360- let module_aliasing ~(bin_annots : Cmt_format.binary_annots ) uid =
361- let exception Found of Path. t * Env. t in
362- let iterator env = { Tast_iterator. default_iterator with
363- module_binding = (fun sub mb ->
364- begin match mb with
365- | { mb_id = Some id; mb_expr = { mod_desc = Tmod_ident (path, _); _ }; _ }
366- ->
367- let md = Env. find_module (Pident id) env in
368- if Shape.Uid. equal uid md.md_uid then
369- raise (Found (path, env))
370- | _ -> () end ;
371- Tast_iterator. default_iterator.module_binding sub mb)
372- }
373- in
374- try
375- begin match bin_annots with
376- | Interface s ->
377- let sig_final_env = Envaux. env_of_only_summary s.sig_final_env in
378- let iterator = iterator sig_final_env in
379- iterator.signature iterator { s with sig_final_env }
380- | Implementation str ->
381- let str_final_env = Envaux. env_of_only_summary str.str_final_env in
382- let iterator = iterator str_final_env in
383- iterator.structure iterator { str with str_final_env }
384- | _ -> () end ;
385- None
386- with Found (path , env ) ->
387- let namespace = Shape.Sig_component_kind. Module in
388- let shape = Env. shape_of_path ~namespace env path in
389- log ~title: " locate" " Uid %a corresponds to an alias of %a
390- which has the shape %a and the uid %a"
391- Logger. fmt (fun fmt -> Shape.Uid. print fmt uid)
392- Logger. fmt (fun fmt -> Path. print fmt path)
393- Logger. fmt (fun fmt -> Shape. print fmt shape)
394- Logger. fmt (fun fmt ->
395- Format. pp_print_option Shape.Uid. print fmt shape.uid);
396- Option. map ~f: (fun uid -> uid, path) shape.uid
397-
398356let from_uid ~config ~ml_or_mli uid loc path =
399357 let loc_of_comp_unit comp_unit =
400358 match load_cmt ~config comp_unit ml_or_mli with
@@ -430,20 +388,6 @@ let from_uid ~config ~ml_or_mli uid loc path =
430388 log ~title " Shapes successfully loaded, looking for %a"
431389 Logger. fmt (fun fmt -> Shape.Uid. print fmt uid);
432390 begin match Shape.Uid.Tbl. find_opt cmt.cmt_uid_to_loc uid with
433- | Some loc when
434- String. ends_with ~suffix: " ml-gen" loc.loc_start.pos_fname ->
435- log ~title " Found location in generated file: %a"
436- Logger. fmt (fun fmt -> Location. print_loc fmt loc);
437- (* This notably happens when using Dune. In that case we
438- try to resolve the alias immediately. *)
439- begin match module_aliasing ~bin_annots: cmt.cmt_annots uid with
440- | Some (Shape.Uid. Compilation_unit comp_unit as uid , _path ) ->
441- log ~title
442- " The alias points to another compilation unit %s" comp_unit;
443- loc_of_comp_unit comp_unit
444- |> Option. map ~f: (fun loc -> uid, loc)
445- | _ -> Some (uid, loc)
446- end
447391 | Some loc ->
448392 log ~title " Found location: %a"
449393 Logger. fmt (fun fmt -> Location. print_loc fmt loc);
0 commit comments