@@ -833,20 +833,21 @@ let rec handle_module_expr ~env ~extra expr =
833
833
| _ -> ()
834
834
835
835
let getIterator ~env ~(extra : extra ) ~(file : File.t ) =
836
- let enter_structure_item item =
837
- match item.str_desc with
836
+ let structure_item ( iter : Tast_iterator.iterator ) item =
837
+ ( match item.str_desc with
838
838
| Tstr_include {incl_mod = expr } ->
839
839
handle_module_expr ~env ~extra expr.mod_desc
840
840
| Tstr_module {mb_expr} -> handle_module_expr ~env ~extra mb_expr.mod_desc
841
841
| Tstr_open {open_path; open_txt = {txt; loc} } ->
842
842
(* Log.log("Have an open here"); *)
843
843
addForLongident ~env ~extra None open_path txt loc;
844
844
Hashtbl. replace extra.opens loc ()
845
- | _ -> ()
845
+ | _ -> () );
846
+ Tast_iterator. default_iterator.structure_item iter item
846
847
in
847
848
848
- let enter_signature_item item =
849
- match item.sig_desc with
849
+ let signature_item ( iter : Tast_iterator.iterator ) item =
850
+ ( match item.sig_desc with
850
851
| Tsig_value {val_id; val_loc; val_name = name ; val_desc; val_attributes} ->
851
852
let stamp = Ident. binding_time val_id in
852
853
if Stamps. findValue file.stamps stamp = None then (
@@ -858,97 +859,77 @@ let getIterator ~env ~(extra : extra) ~(file : File.t) =
858
859
addReference ~extra stamp name.loc;
859
860
addLocItem extra name.loc
860
861
(Typed (name.txt, val_desc.ctyp_type, Definition (stamp, Value ))))
861
- | _ -> ()
862
+ | _ -> () );
863
+ Tast_iterator. default_iterator.signature_item iter item
862
864
in
863
865
864
- let enter_core_type {ctyp_type; ctyp_desc} =
865
- match ctyp_desc with
866
+ let typ ( iter : Tast_iterator.iterator ) ( item : Typedtree.core_type ) =
867
+ ( match item. ctyp_desc with
866
868
| Ttyp_constr (path , {txt; loc} , _args ) ->
867
- addForLongident ~env ~extra (Some (ctyp_type, Type )) path txt loc
868
- | _ -> ()
869
+ addForLongident ~env ~extra (Some (item.ctyp_type, Type )) path txt loc
870
+ | _ -> () );
871
+ Tast_iterator. default_iterator.typ iter item
869
872
in
870
873
871
- let enter_pattern {pat_desc; pat_loc; pat_type; pat_attributes} =
874
+ let pat ( iter : Tast_iterator.iterator ) ( pattern : Typedtree.pattern ) =
872
875
let addForPattern stamp name =
873
876
if Stamps. findValue file.stamps stamp = None then (
874
877
let declared =
875
878
ProcessAttributes. newDeclared ~name ~stamp ~module Path:NotVisible
876
- ~extent: pat_loc ~item: pat_type false pat_attributes
879
+ ~extent: pattern.pat_loc ~item: pattern.pat_type false
880
+ pattern.pat_attributes
877
881
in
878
882
Stamps. addValue file.stamps stamp declared;
879
883
addReference ~extra stamp name.loc;
880
884
addLocItem extra name.loc
881
- (Typed (name.txt, pat_type, Definition (stamp, Value ))))
885
+ (Typed (name.txt, pattern. pat_type, Definition (stamp, Value ))))
882
886
in
883
887
(* Log.log("Entering pattern " ++ Utils.showLocation(pat_loc)); *)
884
- match pat_desc with
885
- | Tpat_record (items , _ ) -> addForRecord ~env ~extra pat_type items
888
+ ( match pattern. pat_desc with
889
+ | Tpat_record (items , _ ) -> addForRecord ~env ~extra pattern. pat_type items
886
890
| Tpat_construct (lident , constructor , _ ) ->
887
- addForConstructor ~env ~extra pat_type lident constructor
891
+ addForConstructor ~env ~extra pattern. pat_type lident constructor
888
892
| Tpat_alias (_inner , ident , name ) ->
889
893
let stamp = Ident. binding_time ident in
890
894
addForPattern stamp name
891
895
| Tpat_var (ident , name ) ->
892
896
(* Log.log("Pattern " ++ name.txt); *)
893
897
let stamp = Ident. binding_time ident in
894
898
addForPattern stamp name
895
- | _ -> ()
896
- in
897
-
898
- let enter_expression expression =
899
- expression.exp_extra
900
- |> List. iter (fun (e , eloc , _ ) ->
901
- match e with
902
- | Texp_open (_ , _path , _ident , _ ) -> Hashtbl. add extra.opens eloc ()
903
- | _ -> () );
904
- match expression.exp_desc with
905
- | Texp_ident (path , {txt; loc} , _ ) ->
906
- addForLongident ~env ~extra
907
- (Some (expression.exp_type, Value ))
908
- path txt loc
909
- | Texp_record {fields} ->
910
- addForRecord ~env ~extra expression.exp_type
911
- (fields |> Array. to_list
912
- |> Utils. filterMap (fun (desc , item ) ->
913
- match item with
914
- | Overridden (loc , _ ) -> Some (loc, desc, () )
915
- | _ -> None ))
916
- | Texp_constant constant ->
917
- addLocItem extra expression.exp_loc (Constant constant)
918
- (* Skip unit and list literals *)
919
- | Texp_construct ({txt = Lident (" ()" | " ::" ); loc}, _, _args)
920
- when loc.loc_end.pos_cnum - loc.loc_start.pos_cnum <> 2 ->
921
- ()
922
- | Texp_construct (lident , constructor , _args ) ->
923
- addForConstructor ~env ~extra expression.exp_type lident constructor
924
- | Texp_field (inner , lident , _label_description ) ->
925
- addForField ~env ~extra inner.exp_type expression.exp_type lident
926
- | _ -> ()
927
- in
928
-
929
- let structure_item (iter : Tast_iterator.iterator ) item =
930
- enter_structure_item item;
931
- Tast_iterator. default_iterator.structure_item iter item
932
- in
933
-
934
- let signature_item (iter : Tast_iterator.iterator ) item =
935
- enter_signature_item item;
936
- Tast_iterator. default_iterator.signature_item iter item
937
- in
938
-
939
- let typ (iter : Tast_iterator.iterator ) item =
940
- enter_core_type item;
941
- Tast_iterator. default_iterator.typ iter item
942
- in
943
-
944
- let pat (iter : Tast_iterator.iterator ) item =
945
- enter_pattern item;
946
- Tast_iterator. default_iterator.pat iter item
899
+ | _ -> () );
900
+ Tast_iterator. default_iterator.pat iter pattern
947
901
in
948
902
949
- let expr (iter : Tast_iterator.iterator ) item =
950
- enter_expression item;
951
- Tast_iterator. default_iterator.expr iter item
903
+ let expr (iter : Tast_iterator.iterator ) (expression : Typedtree.expression ) =
904
+ (expression.exp_extra
905
+ |> List. iter (fun (e , eloc , _ ) ->
906
+ match e with
907
+ | Texp_open (_ , _path , _ident , _ ) -> Hashtbl. add extra.opens eloc ()
908
+ | _ -> () );
909
+ match expression.exp_desc with
910
+ | Texp_ident (path , {txt; loc} , _ ) ->
911
+ addForLongident ~env ~extra
912
+ (Some (expression.exp_type, Value ))
913
+ path txt loc
914
+ | Texp_record {fields} ->
915
+ addForRecord ~env ~extra expression.exp_type
916
+ (fields |> Array. to_list
917
+ |> Utils. filterMap (fun (desc , item ) ->
918
+ match item with
919
+ | Overridden (loc , _ ) -> Some (loc, desc, () )
920
+ | _ -> None ))
921
+ | Texp_constant constant ->
922
+ addLocItem extra expression.exp_loc (Constant constant)
923
+ (* Skip unit and list literals *)
924
+ | Texp_construct ({txt = Lident (" ()" | " ::" ); loc}, _, _args)
925
+ when loc.loc_end.pos_cnum - loc.loc_start.pos_cnum <> 2 ->
926
+ ()
927
+ | Texp_construct (lident , constructor , _args ) ->
928
+ addForConstructor ~env ~extra expression.exp_type lident constructor
929
+ | Texp_field (inner , lident , _label_description ) ->
930
+ addForField ~env ~extra inner.exp_type expression.exp_type lident
931
+ | _ -> () );
932
+ Tast_iterator. default_iterator.expr iter expression
952
933
in
953
934
954
935
{
0 commit comments