1
- open Typedtree
2
1
open SharedTypes
3
2
4
3
let addItem ~(name : string Location.loc ) ~extent ~stamp ~(env : Env.t ) ~item
@@ -123,12 +122,12 @@ and forTypeModule env moduleType =
123
122
124
123
let getModuleTypePath mod_desc =
125
124
match mod_desc with
126
- | Tmty_ident (path , _ ) | Tmty_alias (path , _ ) -> Some path
125
+ | Typedtree. Tmty_ident (path , _ ) | Tmty_alias (path , _ ) -> Some path
127
126
| Tmty_signature _ | Tmty_functor _ | Tmty_with _ | Tmty_typeof _ -> None
128
127
129
128
let forTypeDeclaration ~env ~(exported : Exported.t )
130
129
{
131
- typ_id;
130
+ Typedtree. typ_id;
132
131
typ_loc;
133
132
typ_name = name ;
134
133
typ_attributes;
@@ -147,9 +146,10 @@ let forTypeDeclaration ~env ~(exported : Exported.t)
147
146
| Ttype_abstract -> (
148
147
match typ_manifest with
149
148
| Some {ctyp_desc = Ttyp_constr (path , _lident , args )} ->
150
- Abstract (Some (path, args |> List. map (fun t -> t.ctyp_type)))
149
+ Abstract
150
+ (Some (path, args |> List. map (fun t -> t.Typedtree. ctyp_type)))
151
151
| Some {ctyp_desc = Ttyp_tuple items } ->
152
- Tuple (items |> List. map (fun t -> t.ctyp_type))
152
+ Tuple (items |> List. map (fun t -> t.Typedtree. ctyp_type))
153
153
(* TODO dig *)
154
154
| _ -> Abstract None )
155
155
| Ttype_open -> Open
@@ -159,7 +159,7 @@ let forTypeDeclaration ~env ~(exported : Exported.t)
159
159
|> List. map
160
160
(fun
161
161
{
162
- cd_id;
162
+ Typedtree. cd_id;
163
163
cd_name = cname ;
164
164
cd_args;
165
165
cd_res;
@@ -176,7 +176,8 @@ let forTypeDeclaration ~env ~(exported : Exported.t)
176
176
(match cd_args with
177
177
| Cstr_tuple args ->
178
178
args
179
- |> List. map (fun t -> (t.ctyp_type, t.ctyp_loc))
179
+ |> List. map (fun t ->
180
+ (t.Typedtree. ctyp_type, t.ctyp_loc))
180
181
(* TODO(406) *)
181
182
| Cstr_record _ -> [] );
182
183
res =
@@ -197,7 +198,9 @@ let forTypeDeclaration ~env ~(exported : Exported.t)
197
198
Record
198
199
(fields
199
200
|> List. map
200
- (fun {ld_id; ld_name = fname ; ld_type = {ctyp_type} } ->
201
+ (fun
202
+ {Typedtree. ld_id; ld_name = fname ; ld_type = {ctyp_type} }
203
+ ->
201
204
let fstamp = Ident. binding_time ld_id in
202
205
{stamp = fstamp; fname; typ = ctyp_type})));
203
206
}
@@ -281,7 +284,7 @@ let forSignature ~env sigItems =
281
284
in
282
285
{Module. docstring; exported; items}
283
286
284
- let forTreeModuleType ~env {mty_desc} =
287
+ let forTreeModuleType ~env {Typedtree. mty_desc} =
285
288
match mty_desc with
286
289
| Tmty_ident _ -> None
287
290
| Tmty_signature {sig_items} ->
@@ -291,7 +294,7 @@ let forTreeModuleType ~env {mty_desc} =
291
294
292
295
let rec getModulePath mod_desc =
293
296
match mod_desc with
294
- | Tmod_ident (path , _lident ) -> Some path
297
+ | Typedtree. Tmod_ident (path , _lident ) -> Some path
295
298
| Tmod_structure _ -> None
296
299
| Tmod_functor (_ident , _argName , _maybeType , _resultExpr ) -> None
297
300
| Tmod_apply (functor_ , _arg , _coercion ) -> getModulePath functor_.mod_desc
@@ -300,11 +303,11 @@ let rec getModulePath mod_desc =
300
303
getModulePath expr.mod_desc
301
304
302
305
let rec forStructureItem ~env ~(exported : Exported.t ) item =
303
- match item.str_desc with
306
+ match item.Typedtree. str_desc with
304
307
| Tstr_value (_isRec , bindings ) ->
305
308
let items = ref [] in
306
309
let rec handlePattern attributes pat =
307
- match pat.pat_desc with
310
+ match pat.Typedtree. pat_desc with
308
311
| Tpat_var (ident, name)
309
312
| Tpat_alias (_ , ident , name ) (* let x : t = ... * ) ->
310
313
let item = pat.pat_type in
@@ -327,7 +330,8 @@ let rec forStructureItem ~env ~(exported : Exported.t) item =
327
330
| Tpat_variant (_ , None , _ ) | Tpat_any | Tpat_constant _ -> ()
328
331
in
329
332
List. iter
330
- (fun {vb_pat; vb_attributes} -> handlePattern vb_attributes vb_pat)
333
+ (fun {Typedtree. vb_pat; vb_attributes} ->
334
+ handlePattern vb_attributes vb_pat)
331
335
bindings;
332
336
! items
333
337
| Tstr_module
@@ -819,7 +823,7 @@ let rec addForLongident ~env ~extra top (path : Path.t) (txt : Longident.t) loc
819
823
820
824
let rec handle_module_expr ~env ~extra expr =
821
825
match expr with
822
- | Tmod_constraint (expr , _ , _ , _ ) ->
826
+ | Typedtree. Tmod_constraint (expr , _ , _ , _ ) ->
823
827
handle_module_expr ~env ~extra expr.mod_desc
824
828
| Tmod_ident (path , {txt; loc} ) ->
825
829
if not (lidIsComplex txt) then
@@ -833,7 +837,7 @@ let rec handle_module_expr ~env ~extra expr =
833
837
| _ -> ()
834
838
835
839
let structure_item ~env ~extra (iter : Tast_iterator.iterator ) item =
836
- (match item.str_desc with
840
+ (match item.Typedtree. str_desc with
837
841
| Tstr_include {incl_mod = expr } ->
838
842
handle_module_expr ~env ~extra expr.mod_desc
839
843
| Tstr_module {mb_expr} -> handle_module_expr ~env ~extra mb_expr.mod_desc
@@ -846,7 +850,7 @@ let structure_item ~env ~extra (iter : Tast_iterator.iterator) item =
846
850
847
851
let signature_item ~(file : File.t ) ~extra (iter : Tast_iterator.iterator ) item
848
852
=
849
- (match item.sig_desc with
853
+ (match item.Typedtree. sig_desc with
850
854
| Tsig_value {val_id; val_loc; val_name = name ; val_desc; val_attributes} ->
851
855
let stamp = Ident. binding_time val_id in
852
856
if Stamps. findValue file.stamps stamp = None then (
@@ -903,7 +907,8 @@ let expr ~env ~(extra : extra) (iter : Tast_iterator.iterator)
903
907
(expression.exp_extra
904
908
|> List. iter (fun (e , eloc , _ ) ->
905
909
match e with
906
- | Texp_open (_ , _path , _ident , _ ) -> Hashtbl. add extra.opens eloc ()
910
+ | Typedtree. Texp_open (_ , _path , _ident , _ ) ->
911
+ Hashtbl. add extra.opens eloc ()
907
912
| _ -> () );
908
913
match expression.exp_desc with
909
914
| Texp_ident (path , {txt; loc} , _ ) ->
@@ -915,7 +920,7 @@ let expr ~env ~(extra : extra) (iter : Tast_iterator.iterator)
915
920
(fields |> Array. to_list
916
921
|> Utils. filterMap (fun (desc , item ) ->
917
922
match item with
918
- | Overridden (loc , _ ) -> Some (loc, desc, () )
923
+ | Typedtree. Overridden (loc , _ ) -> Some (loc, desc, () )
919
924
| _ -> None ))
920
925
| Texp_constant constant ->
921
926
addLocItem extra expression.exp_loc (Constant constant)
0 commit comments