@@ -517,42 +517,42 @@ let addLocItem extra loc locType =
517
517
if not loc.Warnings. loc_ghost then
518
518
extra.locItems < - {loc; locType} :: extra.locItems
519
519
520
+ let addReference ~extra stamp loc =
521
+ Hashtbl. replace extra.internalReferences stamp
522
+ (loc
523
+ ::
524
+ (if Hashtbl. mem extra.internalReferences stamp then
525
+ Hashtbl. find extra.internalReferences stamp
526
+ else [] ))
527
+
520
528
let extraForFile ~(file : File.t ) =
521
529
let extra = initExtra () in
522
- let addReference stamp loc =
523
- Hashtbl. replace extra.internalReferences stamp
524
- (loc
525
- ::
526
- (if Hashtbl. mem extra.internalReferences stamp then
527
- Hashtbl. find extra.internalReferences stamp
528
- else [] ))
529
- in
530
530
file.stamps
531
531
|> Stamps. iterModules (fun stamp (d : Module.t Declared.t ) ->
532
532
addLocItem extra d.name.loc (LModule (Definition (stamp, Module )));
533
- addReference stamp d.name.loc);
533
+ addReference ~extra stamp d.name.loc);
534
534
file.stamps
535
535
|> Stamps. iterValues (fun stamp (d : Types.type_expr Declared.t ) ->
536
536
addLocItem extra d.name.loc
537
537
(Typed (d.name.txt, d.item, Definition (stamp, Value )));
538
- addReference stamp d.name.loc);
538
+ addReference ~extra stamp d.name.loc);
539
539
file.stamps
540
540
|> Stamps. iterTypes (fun stamp (d : Type.t Declared.t ) ->
541
541
addLocItem extra d.name.loc
542
542
(TypeDefinition (d.name.txt, d.item.Type. decl, stamp));
543
- addReference stamp d.name.loc;
543
+ addReference ~extra stamp d.name.loc;
544
544
match d.item.Type. kind with
545
545
| Record labels ->
546
546
labels
547
547
|> List. iter (fun {stamp; fname; typ} ->
548
- addReference stamp fname.loc;
548
+ addReference ~extra stamp fname.loc;
549
549
addLocItem extra fname.loc
550
550
(Typed
551
551
(d.name.txt, typ, Definition (d.stamp, Field fname.txt))))
552
552
| Variant constructors ->
553
553
constructors
554
554
|> List. iter (fun {Constructor. stamp; cname} ->
555
- addReference stamp cname.loc;
555
+ addReference ~extra stamp cname.loc;
556
556
let t =
557
557
{
558
558
Types. id = 0 ;
@@ -627,15 +627,6 @@ let fromCompilerPath ~(env : QueryEnv.t) path =
627
627
| Some (`Global (moduleName , fullPath )) -> `Global (moduleName, fullPath))
628
628
629
629
let getIterator (extra : extra ) (file : File.t ) =
630
- let addReference stamp loc =
631
- Hashtbl. replace extra.internalReferences stamp
632
- (loc
633
- ::
634
- (if Hashtbl. mem extra.internalReferences stamp then
635
- Hashtbl. find extra.internalReferences stamp
636
- else [] ))
637
- in
638
-
639
630
let addExternalReference moduleName path tip loc =
640
631
(* TODO need to follow the path, and be able to load the files to follow module references... *)
641
632
Hashtbl. replace extra.externalReferences moduleName
@@ -663,7 +654,7 @@ let getIterator (extra : extra) (file : File.t) =
663
654
let locType =
664
655
match fromCompilerPath ~env path with
665
656
| `Stamp stamp ->
666
- addReference stamp identLoc;
657
+ addReference ~extra stamp identLoc;
667
658
LocalReference (stamp, tip)
668
659
| `Not_found -> NotFound
669
660
| `Global (moduleName , path ) ->
@@ -676,7 +667,7 @@ let getIterator (extra : extra) (file : File.t) =
676
667
| _ -> Exported. find env.exported Exported. Value name
677
668
with
678
669
| Some stamp ->
679
- addReference stamp identLoc;
670
+ addReference ~extra stamp identLoc;
680
671
LocalReference (stamp, tip)
681
672
| None -> NotFound )
682
673
| `GlobalMod _ -> NotFound
@@ -691,7 +682,7 @@ let getIterator (extra : extra) (file : File.t) =
691
682
addFileReference moduleName loc;
692
683
TopLevelModule moduleName
693
684
| `Stamp stamp ->
694
- addReference stamp loc;
685
+ addReference ~extra stamp loc;
695
686
LModule (LocalReference (stamp, Module ))
696
687
| `Not_found -> LModule NotFound
697
688
| `Global (moduleName , path ) ->
@@ -700,7 +691,7 @@ let getIterator (extra : extra) (file : File.t) =
700
691
| `Exported (env , name ) -> (
701
692
match Exported. find env.exported Exported. Module name with
702
693
| Some stamp ->
703
- addReference stamp loc;
694
+ addReference ~extra stamp loc;
704
695
LModule (LocalReference (stamp, Module ))
705
696
| None -> LModule NotFound )
706
697
in
@@ -745,7 +736,7 @@ let getIterator (extra : extra) (file : File.t) =
745
736
| `Local {stamp; item = {kind = Record fields } } -> (
746
737
match fields |> List. find_opt (fun f -> f.fname.txt = name) with
747
738
| Some {stamp = astamp } ->
748
- addReference astamp nameLoc;
739
+ addReference ~extra astamp nameLoc;
749
740
LocalReference (stamp, Field name)
750
741
| None -> NotFound )
751
742
| `Global (moduleName , path ) ->
@@ -773,7 +764,7 @@ let getIterator (extra : extra) (file : File.t) =
773
764
fields |> List. find_opt (fun f -> f.fname.txt = name)
774
765
with
775
766
| Some {stamp = astamp } ->
776
- addReference astamp nameLoc;
767
+ addReference ~extra astamp nameLoc;
777
768
LocalReference (stamp, Field name)
778
769
| None -> NotFound )
779
770
| `Global (moduleName , path ) ->
@@ -799,7 +790,7 @@ let getIterator (extra : extra) (file : File.t) =
799
790
|> List. find_opt (fun c -> c.Constructor. cname.txt = cstr_name)
800
791
with
801
792
| Some {stamp = cstamp } ->
802
- addReference cstamp nameLoc;
793
+ addReference ~extra cstamp nameLoc;
803
794
LocalReference (stamp, Constructor name)
804
795
| None -> NotFound )
805
796
| `Global (moduleName , path ) ->
@@ -878,7 +869,7 @@ let getIterator (extra : extra) (file : File.t) =
878
869
~module Path:NotVisible ~item: val_desc.ctyp_type false val_attributes
879
870
in
880
871
Stamps. addValue file.stamps stamp declared;
881
- addReference stamp name.loc;
872
+ addReference ~extra stamp name.loc;
882
873
addLocItem extra name.loc
883
874
(Typed (name.txt, val_desc.ctyp_type, Definition (stamp, Value ))))
884
875
| _ -> ()
@@ -899,7 +890,7 @@ let getIterator (extra : extra) (file : File.t) =
899
890
~extent: pat_loc ~item: pat_type false pat_attributes
900
891
in
901
892
Stamps. addValue file.stamps stamp declared;
902
- addReference stamp name.loc;
893
+ addReference ~extra stamp name.loc;
903
894
addLocItem extra name.loc
904
895
(Typed (name.txt, pat_type, Definition (stamp, Value ))))
905
896
in
0 commit comments