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