@@ -512,18 +512,6 @@ let forCmt ~moduleName ~uri ({cmt_modname; cmt_annots} : Cmt_format.cmt_infos) =
512
512
{uri; moduleName = cmt_modname; stamps = env.stamps; structure}
513
513
| _ -> File. create moduleName uri
514
514
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
-
527
515
let addLocItem extra loc locType =
528
516
if not loc.Warnings. loc_ghost then
529
517
extra.locItems < - {loc; locType} :: extra.locItems
@@ -681,13 +669,22 @@ let extraForCmt ~(iterator : Tast_iterator.iterator)
681
669
| _ -> extraForStructureItems ~iterator []
682
670
683
671
let 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
684
682
if Hashtbl. mem package.pathsForModule modname then (
685
683
let paths = Hashtbl. find package.pathsForModule modname in
686
- (* TODO: do better *)
687
684
let uri = getUri paths in
688
685
let cmt = getCmtPath ~uri paths in
689
686
Log. log (" fileForModule " ^ showPaths paths);
690
- match fileForCmt ~module Name:modname ~cmt ~uri with
687
+ match getFile ~module Name:modname ~cmt ~uri with
691
688
| None -> None
692
689
| Some docs -> Some docs)
693
690
else (
0 commit comments