@@ -512,18 +512,6 @@ let forCmt ~moduleName ~uri ({cmt_modname; cmt_annots} : Cmt_format.cmt_infos) =
512512 {uri; moduleName = cmt_modname; stamps = env.stamps; structure}
513513 | _ -> File. create moduleName uri
514514
515- let fileForCmt ~moduleName ~cmt ~uri =
516- if Hashtbl. mem state.cmtCache cmt then
517- let file = Hashtbl. find state.cmtCache cmt in
518- Some file
519- else
520- match Shared. tryReadCmt cmt with
521- | None -> None
522- | Some infos ->
523- let file = forCmt ~module Name ~uri infos in
524- Hashtbl. replace state.cmtCache cmt file;
525- Some file
526-
527515let addLocItem extra loc locType =
528516 if not loc.Warnings. loc_ghost then
529517 extra.locItems < - {loc; locType} :: extra.locItems
@@ -681,13 +669,22 @@ let extraForCmt ~(iterator : Tast_iterator.iterator)
681669 | _ -> extraForStructureItems ~iterator []
682670
683671let fileForModule modname ~package =
672+ let getFile ~moduleName ~cmt ~uri =
673+ if Hashtbl. mem state.cmtCache cmt then Hashtbl. find_opt state.cmtCache cmt
674+ else
675+ match Shared. tryReadCmt cmt with
676+ | None -> None
677+ | Some infos ->
678+ let file = forCmt ~module Name ~uri infos in
679+ Hashtbl. replace state.cmtCache cmt file;
680+ Some file
681+ in
684682 if Hashtbl. mem package.pathsForModule modname then (
685683 let paths = Hashtbl. find package.pathsForModule modname in
686- (* TODO: do better *)
687684 let uri = getUri paths in
688685 let cmt = getCmtPath ~uri paths in
689686 Log. log (" fileForModule " ^ showPaths paths);
690- match fileForCmt ~module Name:modname ~cmt ~uri with
687+ match getFile ~module Name:modname ~cmt ~uri with
691688 | None -> None
692689 | Some docs -> Some docs)
693690 else (
0 commit comments