@@ -512,10 +512,17 @@ 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 ~uri cmt =
516
- match Shared. tryReadCmt cmt with
517
- | None -> None
518
- | Some infos -> Some (forCmt ~module Name ~uri infos)
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
519
526
520
527
let addLocItem extra loc locType =
521
528
if not loc.Warnings. loc_ghost then
@@ -673,42 +680,14 @@ let extraForCmt ~(iterator : Tast_iterator.iterator)
673
680
extraForParts parts
674
681
| _ -> extraForStructureItems ~iterator []
675
682
676
- let newFileForCmt ~moduleName cmtCache changed ~cmt ~uri =
677
- match fileForCmt ~module Name ~uri cmt with
678
- | None -> None
679
- | Some file ->
680
- Hashtbl. replace cmtCache cmt (changed, file);
681
- Some file
682
-
683
- let fileForCmt ~moduleName ~cmt ~uri state =
684
- if Hashtbl. mem state.cmtCache cmt then
685
- let mtime, docs = Hashtbl. find state.cmtCache cmt in
686
- (* TODO: I should really throttle this mtime checking to like every 50 ms or so *)
687
- match Files. getMtime cmt with
688
- | None ->
689
- Log. log
690
- (" \226\154\160\239\184\143 cannot get docs for nonexistant cmt " ^ cmt);
691
- None
692
- | Some changed ->
693
- if changed > mtime then
694
- newFileForCmt ~module Name state.cmtCache changed ~cmt ~uri
695
- else Some docs
696
- else
697
- match Files. getMtime cmt with
698
- | None ->
699
- Log. log
700
- (" \226\154\160\239\184\143 cannot get docs for nonexistant cmt " ^ cmt);
701
- None
702
- | Some changed -> newFileForCmt ~module Name state.cmtCache changed ~cmt ~uri
703
-
704
683
let fileForModule modname ~package =
705
684
if Hashtbl. mem package.pathsForModule modname then (
706
685
let paths = Hashtbl. find package.pathsForModule modname in
707
686
(* TODO: do better *)
708
687
let uri = getUri paths in
709
688
let cmt = getCmtPath ~uri paths in
710
689
Log. log (" fileForModule " ^ showPaths paths);
711
- match fileForCmt ~module Name:modname ~cmt ~uri state with
690
+ match fileForCmt ~module Name:modname ~cmt ~uri with
712
691
| None -> None
713
692
| Some docs -> Some docs)
714
693
else (
0 commit comments