@@ -34,6 +34,8 @@ type t =
34
34
module_paths : P.Module .t Ident .tbl ;
35
35
module_types : Id.ModuleType .t Ident .tbl ;
36
36
types : Id.DataType .t Ident .tbl ;
37
+ exceptions : Id.Exception .t Ident .tbl ;
38
+ extensions : Id.Extension .t Ident .tbl ;
37
39
values : Id.Value .t Ident .tbl ;
38
40
classes : Id.Class .t Ident .tbl ;
39
41
class_types : Id.ClassType .t Ident .tbl ;
@@ -46,6 +48,8 @@ let empty () =
46
48
module_paths = Ident. empty;
47
49
module_types = Ident. empty;
48
50
types = Ident. empty;
51
+ exceptions = Ident. empty;
52
+ extensions = Ident. empty;
49
53
values = Ident. empty;
50
54
classes = Ident. empty;
51
55
class_types = Ident. empty;
@@ -110,13 +114,19 @@ let rec extract_signature_type_items items =
110
114
`ClassType (id, obj_id, None , false , None ) :: extract_signature_type_items rest
111
115
#endif
112
116
113
- | Sig_typext _ :: rest ->
114
- extract_signature_type_items rest
117
+ | Sig_typext (id , constr , Text_exception, Exported) :: rest ->
118
+ `Exception (id, Some constr.ext_loc)
119
+ :: extract_signature_type_items rest
120
+
121
+ | Sig_typext (id , constr , _ , Exported) :: rest ->
122
+ `Extension (id, Some constr.ext_loc)
123
+ :: extract_signature_type_items rest
115
124
116
125
| Sig_class_type (_, _, _, Hidden ) :: Sig_type (_, _, _, _)
117
126
:: Sig_type (_, _, _, _) :: rest
118
127
| Sig_class (_, _, _, Hidden ) :: Sig_class_type (_, _, _, _)
119
128
:: Sig_type (_, _, _, _) :: Sig_type (_, _, _, _) :: rest
129
+ | Sig_typext (_,_,_,Hidden ) :: rest
120
130
| Sig_modtype (_, _, Hidden ) :: rest
121
131
| Sig_module (_, _, _, _, Hidden ) :: rest
122
132
| Sig_type (_, _, _, Hidden ) :: rest
@@ -204,6 +214,18 @@ let rec extract_signature_tree_items : bool -> Typedtree.signature_item list ->
204
214
else Some (`Type (decl.typ_id, hide_item, Some decl.typ_loc)))
205
215
decls @ extract_signature_tree_items hide_item rest
206
216
217
+ #if OCAML_VERSION < (4 ,8 ,0 )
218
+ | { sig_desc = Tsig_exception tyexn_constructor ; _ } :: rest ->
219
+ #else
220
+ | { sig_desc = Tsig_exception { tyexn_constructor; _ } ; _ } :: rest ->
221
+ #endif
222
+ `Exception (tyexn_constructor.ext_id, Some tyexn_constructor.ext_loc) :: extract_signature_tree_items hide_item rest
223
+
224
+ | { sig_desc = Tsig_typext { tyext_constructors; _ } ; _} :: rest ->
225
+ let x = List. map (fun { ext_id; ext_loc; _ } -> `Extension (ext_id, Some ext_loc)) tyext_constructors in
226
+ x @ extract_signature_tree_items hide_item rest
227
+
228
+
207
229
#if OCAML_VERSION > = (4 ,10 ,0 )
208
230
| { sig_desc = Tsig_module { md_id = Some id ; _ } ; sig_loc; _} :: rest ->
209
231
[`Module (id, hide_item, Some sig_loc)] @ extract_signature_tree_items hide_item rest
@@ -272,8 +294,6 @@ let rec extract_signature_tree_items : bool -> Typedtree.signature_item list ->
272
294
| { sig_desc = Tsig_modtypesubst mtd ; sig_loc; _ } :: rest ->
273
295
[`ModuleType (mtd.mtd_id, hide_item, Some sig_loc)] @ extract_signature_tree_items hide_item rest
274
296
#endif
275
- | { sig_desc = Tsig_typext _; _} :: rest
276
- | { sig_desc = Tsig_exception _; _} :: rest
277
297
| { sig_desc = Tsig_open _ ;_} :: rest -> extract_signature_tree_items hide_item rest
278
298
| [] -> []
279
299
@@ -310,20 +330,16 @@ let rec extract_structure_tree_items : bool -> Typedtree.structure_item list ->
310
330
List. map (fun decl -> `Type (decl.typ_id, hide_item, Some decl.typ_loc))
311
331
decls @ extract_structure_tree_items hide_item rest
312
332
313
- #if OCAML_VERSION < (4 ,14 ,0 )
314
- | { str_desc = Tstr_exception _ ; _ } :: rest -> extract_structure_tree_items hide_item rest
333
+ #if OCAML_VERSION < (4 ,8 ,0 )
334
+ | { str_desc = Tstr_exception tyexn_constructor ; _ } :: rest ->
315
335
#else
316
- | { str_desc = Tstr_exception { tyexn_constructor; tyexn_loc = _ ; _ } ; _ } :: rest ->
317
- `Exception (tyexn_constructor.ext_id, Some tyexn_constructor.ext_loc) :: extract_structure_tree_items hide_item rest
336
+ | { str_desc = Tstr_exception { tyexn_constructor; _ } ; _ } :: rest ->
318
337
#endif
338
+ `Exception (tyexn_constructor.ext_id, Some tyexn_constructor.ext_loc) :: extract_structure_tree_items hide_item rest
319
339
320
- #if OCAML_VERSION < (4 ,14 ,0 )
321
- | { str_desc = Tstr_typext _ ; _} :: rest -> extract_structure_tree_items hide_item rest
322
- #else
323
340
| { str_desc = Tstr_typext { tyext_constructors; _ } ; _} :: rest ->
324
341
let x = List. map (fun { ext_id; ext_loc; _ } -> `Extension (ext_id, Some ext_loc)) tyext_constructors in
325
342
x @ extract_structure_tree_items hide_item rest
326
- #endif
327
343
328
344
#if OCAML_VERSION < (4 ,3 ,0 )
329
345
| { str_desc = Tstr_value (_ , vbs ); _} :: rest ->
@@ -401,7 +417,7 @@ let rec extract_structure_tree_items : bool -> Typedtree.structure_item list ->
401
417
| [] -> []
402
418
403
419
404
- let flatten_extracted : items list -> item list = fun items ->
420
+ let flatten_includes : items list -> item list = fun items ->
405
421
List. map (function
406
422
| `Type _
407
423
| `Module _
@@ -451,13 +467,15 @@ let env_of_items : Id.Signature.t -> item list -> t -> t = fun parent items env
451
467
let name = Ident. name t in
452
468
let identifier = Mk. exception_(parent, ExceptionName. make_std name) in
453
469
(match loc with | Some l -> LocHashtbl. add env.loc_to_ident l (identifier :> Id.any ) | _ -> () );
454
- inner rest env
470
+ let exceptions = Ident. add t identifier env.exceptions in
471
+ inner rest {env with exceptions }
455
472
456
473
| `Extension (t , loc ) :: rest ->
457
474
let name = Ident. name t in
458
475
let identifier = Mk. extension(parent, ExtensionName. make_std name) in
459
476
(match loc with | Some l -> LocHashtbl. add env.loc_to_ident l (identifier :> Id.any ) | _ -> () );
460
- inner rest env
477
+ let extensions = Ident. add t identifier env.extensions in
478
+ inner rest {env with extensions }
461
479
462
480
| `Value (t , is_hidden_item , loc ) :: rest ->
463
481
let name = Ident. name t in
@@ -545,12 +563,12 @@ let identifier_of_loc : t -> Warnings.loc -> Odoc_model.Paths.Identifier.t optio
545
563
546
564
let add_signature_tree_items : Paths.Identifier.Signature.t -> Typedtree.signature -> t -> t =
547
565
fun parent sg env ->
548
- let items = extract_signature_tree_items false sg.sig_items |> flatten_extracted in
566
+ let items = extract_signature_tree_items false sg.sig_items |> flatten_includes in
549
567
env_of_items parent items env
550
568
551
569
let add_structure_tree_items : Paths.Identifier.Signature.t -> Typedtree.structure -> t -> t =
552
570
fun parent sg env ->
553
- let items = extract_structure_tree_items false sg.str_items |> flatten_extracted in
571
+ let items = extract_structure_tree_items false sg.str_items |> flatten_includes in
554
572
env_of_items parent items env
555
573
556
574
let handle_signature_type_items : Paths.Identifier.Signature.t -> Compat.signature -> t -> t =
@@ -576,6 +594,12 @@ let find_module_type env id =
576
594
let find_type_identifier env id =
577
595
Ident. find_same id env.types
578
596
597
+ let find_exception_identifier env id =
598
+ Ident. find_same id env.exceptions
599
+
600
+ let find_extension_identifier env id =
601
+ Ident. find_same id env.extensions
602
+
579
603
let find_value_identifier env id =
580
604
Ident. find_same id env.values
581
605
0 commit comments