@@ -137,9 +137,6 @@ let rec forSignatureTypeItem env (exported : SharedTypes.exported) item =
137137 env.stamps.types
138138 in
139139 [{declared with item = MType (declared.item, recStatus)}]
140- (* | Sig_module({stamp, name}, {md_type: Mty_ident(path) | Mty_alias(path), md_attributes, md_loc}, _) =>
141- let declared = addItem(~contents=Module.Ident(path), ~name=Location.mknoloc(name), ~stamp, ~env, md_attributes, exported.modules, env.stamps.modules);
142- [{...declared, contents: Module.Module(declared.contents)}, ...items] *)
143140 | Sig_module (ident , {md_type; md_attributes; md_loc} , _ ) ->
144141 let declared =
145142 addItem ~extent: md_loc
@@ -521,12 +518,12 @@ let fileForCmt ~moduleName ~uri cmt =
521518 | Error e -> Error e
522519 | Ok infos -> Ok (forCmt ~module Name ~uri infos)
523520
521+ let addLocItem extra loc locType =
522+ if not loc.Warnings. loc_ghost then
523+ extra.locItems < - {loc; locType} :: extra.locItems
524+
524525let extraForFile ~(file : SharedTypes.file ) =
525526 let extra = initExtra () in
526- let addLocation loc ident =
527- if not loc.Warnings. loc_ghost then
528- extra.locations < - (loc, ident) :: extra.locations
529- in
530527 let addReference stamp loc =
531528 Hashtbl. replace extra.internalReferences stamp
532529 (loc
@@ -537,23 +534,23 @@ let extraForFile ~(file : SharedTypes.file) =
537534 in
538535 file.stamps.modules
539536 |> Hashtbl. iter (fun stamp d ->
540- addLocation d.name.loc (LModule (Definition (stamp, Module )));
537+ addLocItem extra d.name.loc (LModule (Definition (stamp, Module )));
541538 addReference stamp d.name.loc);
542539 file.stamps.values
543540 |> Hashtbl. iter (fun stamp d ->
544- addLocation d.name.loc (Typed (d.item, Definition (stamp, Value )));
541+ addLocItem extra d.name.loc (Typed (d.item, Definition (stamp, Value )));
545542 addReference stamp d.name.loc);
546543 file.stamps.types
547544 |> Hashtbl. iter (fun stamp d ->
548- addLocation d.name.loc
545+ addLocItem extra d.name.loc
549546 (TypeDefinition (d.name.txt, d.item.Type. decl, stamp));
550547 addReference stamp d.name.loc;
551548 match d.item.Type. kind with
552549 | Record labels ->
553550 labels
554551 |> List. iter (fun {stamp; fname; typ} ->
555552 addReference stamp fname.loc;
556- addLocation fname.loc
553+ addLocItem extra fname.loc
557554 (Typed (typ, Definition (d.stamp, Field fname.txt))))
558555 | Variant constructos ->
559556 constructos
@@ -571,7 +568,7 @@ let extraForFile ~(file : SharedTypes.file) =
571568 ref Types. Mnil );
572569 }
573570 in
574- addLocation cname.loc
571+ addLocItem extra cname.loc
575572 (Typed (t, Definition (d.stamp, Constructor cname.txt))))
576573 | _ -> () );
577574 extra
@@ -684,8 +681,6 @@ struct
684681 | None -> ()
685682 | Some relpath -> tracker.used < - (relpath, tip, loc) :: tracker.used)
686683
687- let addLocation loc ident = extra.locations < - (loc, ident) :: extra.locations
688-
689684 let addReference stamp loc =
690685 Hashtbl. replace extra.internalReferences stamp
691686 (loc
@@ -732,7 +727,7 @@ struct
732727 | None -> NotFound )
733728 | `GlobalMod _ -> NotFound
734729 in
735- addLocation loc (Typed (typ, locType))
730+ addLocItem extra loc (Typed (typ, locType))
736731
737732 let addForPathParent path loc =
738733 let locType =
@@ -754,7 +749,7 @@ struct
754749 LModule (LocalReference (stamp, Module ))
755750 | None -> LModule NotFound )
756751 in
757- addLocation loc locType
752+ addLocItem extra loc locType
758753
759754 let getTypeAtPath ~env path =
760755 match fromCompilerPath ~env path with
@@ -809,7 +804,7 @@ struct
809804 GlobalReference (moduleName, path, Field name)
810805 | _ -> NotFound
811806 in
812- addLocation nameLoc (Typed (lbl_res, locType))
807+ addLocItem extra nameLoc (Typed (lbl_res, locType))
813808 | _ -> ()
814809
815810 let addForRecord recordType items =
@@ -837,7 +832,7 @@ struct
837832 GlobalReference (moduleName, path, Field name)
838833 | _ -> NotFound
839834 in
840- addLocation nameLoc (Typed (lbl_res, locType)))
835+ addLocItem extra nameLoc (Typed (lbl_res, locType)))
841836 | _ -> ()
842837
843838 let addForConstructor constructorType {Asttypes. txt; loc} {Types. cstr_name} =
@@ -863,7 +858,7 @@ struct
863858 GlobalReference (moduleName, path, Constructor name)
864859 | _ -> NotFound
865860 in
866- addLocation nameLoc (Typed (constructorType, locType))
861+ addLocItem extra nameLoc (Typed (constructorType, locType))
867862 | _ -> ()
868863
869864 let currentScopeExtent () =
@@ -973,14 +968,13 @@ struct
973968 in
974969 Hashtbl. add Collector. file.stamps.values stamp declared;
975970 addReference stamp name.loc;
976- addLocation name.loc
971+ addLocItem extra name.loc
977972 (Typed (val_desc.ctyp_type, Definition (stamp, Value ))))
978973 | _ -> ()
979974
980975 let enter_core_type {ctyp_type; ctyp_desc} =
981976 match ctyp_desc with
982977 | Ttyp_constr (path , {txt; loc} , _args ) ->
983- (* addForPath(path, txt, loc, Shared.makeFlexible(ctyp_type), Type) *)
984978 addForLongident (Some (ctyp_type, Type )) path txt loc
985979 | _ -> ()
986980
@@ -1000,7 +994,7 @@ struct
1000994 in
1001995 Hashtbl. add Collector. file.stamps.values stamp declared;
1002996 addReference stamp name.loc;
1003- addLocation name.loc (Typed (pat_type, Definition (stamp, Value ))))
997+ addLocItem extra name.loc (Typed (pat_type, Definition (stamp, Value ))))
1004998 in
1005999 (* Log.log("Entering pattern " ++ Utils.showLocation(pat_loc)); *)
10061000 match pat_desc with
@@ -1035,7 +1029,7 @@ struct
10351029 | Overridden (loc , _ ) -> Some (loc, desc, () )
10361030 | _ -> None ))
10371031 | Texp_constant constant ->
1038- addLocation expression.exp_loc (Constant constant)
1032+ addLocItem extra expression.exp_loc (Constant constant)
10391033 (* Skip unit and list literals *)
10401034 | Texp_construct ({txt = Lident (" ()" | " ::" ); loc}, _, _args)
10411035 when loc.loc_end.pos_cnum - loc.loc_start.pos_cnum <> 2 ->
0 commit comments