@@ -609,32 +609,6 @@ let extraForFile ~(file : File.t) =
609
609
| _ -> () );
610
610
extra
611
611
612
- let rec relative ident path =
613
- match (ident, path) with
614
- | Longident. Lident name , Path. Pdot (path , pname , _ ) when pname = name ->
615
- Some path
616
- | Longident. Ldot (ident, name), Path. Pdot (path, pname, _) when pname = name
617
- ->
618
- relative ident path
619
- (* | (Ldot(Lident("*predef*" | "exn"), _), Pident(_)) => None *)
620
- | _ -> None
621
-
622
- let findClosestMatchingOpen opens path ident loc =
623
- match relative ident path with
624
- | None -> None
625
- | Some openNeedle -> (
626
- let matching =
627
- Hashtbl. fold
628
- (fun _ op res ->
629
- if Utils. locWithinLoc loc op.extent && Path. same op.path openNeedle
630
- then op :: res
631
- else res)
632
- opens []
633
- |> List. sort (fun (a : SharedTypes.openTracker ) b ->
634
- b.loc.loc_start.pos_cnum - a.loc.loc_start.pos_cnum)
635
- in
636
- match matching with [] -> None | first :: _ -> Some first)
637
-
638
612
let rec joinPaths modulePath path =
639
613
match modulePath with
640
614
| Path. Pident ident -> (ident.stamp, ident.name, path)
@@ -698,26 +672,6 @@ end) =
698
672
struct
699
673
let extra = Collector. extra
700
674
701
- let makeRelativePath basePath otherPath =
702
- let rec loop base other tip =
703
- if Path. same base other then Some tip
704
- else
705
- match other with
706
- | Pdot (inner , name , _ ) -> loop basePath inner (Nested (name, tip))
707
- | _ -> None
708
- in
709
- match otherPath with
710
- | Path. Pdot (inner , name , _ ) -> loop basePath inner (Tip name)
711
- | _ -> None
712
-
713
- let maybeAddUse path ident loc tip =
714
- match findClosestMatchingOpen extra.opens path ident loc with
715
- | None -> ()
716
- | Some tracker -> (
717
- match makeRelativePath tracker.path path with
718
- | None -> ()
719
- | Some relpath -> tracker.used < - (relpath, tip, loc) :: tracker.used)
720
-
721
675
let addReference stamp loc =
722
676
Hashtbl. replace extra.internalReferences stamp
723
677
(loc
@@ -746,7 +700,6 @@ struct
746
700
let env = QueryEnv. fromFile Collector. file
747
701
748
702
let addForPath path lident loc typ tip =
749
- maybeAddUse path lident loc tip;
750
703
let identName = Longident. last lident in
751
704
let identLoc = Utils. endOfLocation loc (String. length identName) in
752
705
let locType =
@@ -815,26 +768,18 @@ struct
815
768
| Some declaredType -> `Local declaredType
816
769
| None -> `Not_found )
817
770
818
- let handleConstructor path txt =
819
- let typeName =
820
- match path with
821
- | Path. Pdot (_path , typename , _ ) -> typename
822
- | Pident ident -> Ident. name ident
823
- | _ -> assert false
824
- in
825
- let open Longident in
771
+ let handleConstructor txt =
826
772
match txt with
827
- | Longident. Lident name -> ( name, Lident typeName)
828
- | Ldot (left , name ) -> ( name, Ldot (left, typeName))
773
+ | Longident. Lident name -> name
774
+ | Ldot (_left , name ) -> name
829
775
| Lapply (_ , _ ) -> assert false
830
776
831
777
let addForField recordType item {Asttypes. txt; loc} =
832
778
match (Shared. dig recordType).desc with
833
779
| Tconstr (path , _args , _memo ) ->
834
780
let t = getTypeAtPath ~env path in
835
781
let {Types. lbl_res} = item in
836
- let name, typeLident = handleConstructor path txt in
837
- maybeAddUse path typeLident loc (Field name);
782
+ let name = handleConstructor txt in
838
783
let nameLoc = Utils. endOfLocation loc (String. length name) in
839
784
let locType =
840
785
match t with
@@ -859,8 +804,7 @@ struct
859
804
items
860
805
|> List. iter (fun ({Asttypes. txt; loc} , {Types. lbl_res} , _ ) ->
861
806
(* let name = Longident.last(txt); *)
862
- let name, typeLident = handleConstructor path txt in
863
- maybeAddUse path typeLident loc (Field name);
807
+ let name = handleConstructor txt in
864
808
let nameLoc = Utils. endOfLocation loc (String. length name) in
865
809
let locType =
866
810
match t with
@@ -883,8 +827,7 @@ struct
883
827
let addForConstructor constructorType {Asttypes. txt; loc} {Types. cstr_name} =
884
828
match (Shared. dig constructorType).desc with
885
829
| Tconstr (path , _args , _memo ) ->
886
- let name, typeLident = handleConstructor path txt in
887
- maybeAddUse path typeLident loc (Constructor name);
830
+ let name = handleConstructor txt in
888
831
let nameLoc = Utils. endOfLocation loc (String. length name) in
889
832
let t = getTypeAtPath ~env path in
890
833
let locType =
@@ -944,7 +887,6 @@ struct
944
887
| Tmod_constraint (expr , _ , _ , _ ) -> handle_module_expr expr.mod_desc
945
888
| Tmod_ident (path , {txt; loc} ) ->
946
889
Log. log (" Ident!! " ^ String. concat " ." (Longident. flatten txt));
947
- maybeAddUse path txt loc Module ;
948
890
addForLongident None path txt loc
949
891
| Tmod_functor (_ident , _argName , _maybeType , resultExpr ) ->
950
892
handle_module_expr resultExpr.mod_desc
@@ -961,22 +903,8 @@ struct
961
903
| Tstr_module {mb_expr} -> handle_module_expr mb_expr.mod_desc
962
904
| Tstr_open {open_path; open_txt = {txt; loc} } ->
963
905
(* Log.log("Have an open here"); *)
964
- maybeAddUse open_path txt loc Module ;
965
- let tracker =
966
- {
967
- path = open_path;
968
- loc;
969
- used = [] ;
970
- extent =
971
- {
972
- loc_ghost = true ;
973
- loc_start = loc.loc_end;
974
- loc_end = (currentScopeExtent () ).loc_end;
975
- };
976
- }
977
- in
978
906
addForLongident None open_path txt loc;
979
- Hashtbl. replace Collector. extra.opens loc tracker
907
+ Hashtbl. replace Collector. extra.opens loc ()
980
908
| _ -> ()
981
909
982
910
let enter_structure {str_items} =
@@ -1058,9 +986,7 @@ struct
1058
986
expression.exp_extra
1059
987
|> List. iter (fun (e , eloc , _ ) ->
1060
988
match e with
1061
- | Texp_open (_ , path , _ident , _ ) ->
1062
- Hashtbl. add extra.opens eloc
1063
- {path; loc = eloc; extent = expression.exp_loc; used = [] }
989
+ | Texp_open (_ , _path , _ident , _ ) -> Hashtbl. add extra.opens eloc ()
1064
990
| _ -> () );
1065
991
match expression.exp_desc with
1066
992
| Texp_ident (path , {txt; loc} , {val_type} ) ->
0 commit comments