@@ -154,7 +154,8 @@ module Analysis = struct
154
154
155
155
and value_binding env vb = pattern env vb.vb_pat @ expression env vb.vb_expr
156
156
157
- and expression env { exp_desc; exp_loc; _ } = match exp_desc with
157
+ and expression env { exp_desc; exp_loc; _ } =
158
+ match exp_desc with
158
159
| Texp_ident (p , _ , value_description ) -> (
159
160
if exp_loc.loc_ghost then []
160
161
else
@@ -175,8 +176,7 @@ module Analysis = struct
175
176
| Texp_function f -> List. concat_map (case env) f.cases
176
177
| Texp_match (e , cases , _ ) ->
177
178
expression env e @ List. concat_map (case env) cases
178
- | Texp_try (e , cases ) ->
179
- expression env e @ List. concat_map (case env) cases
179
+ | Texp_try (e , cases ) -> expression env e @ List. concat_map (case env) cases
180
180
| Texp_tuple es -> List. concat_map (expression env) es
181
181
| Texp_construct (_ , cons_description , es ) ->
182
182
let x =
@@ -201,16 +201,13 @@ module Analysis = struct
201
201
in
202
202
e @ List. concat_map (record_fields env) (Array. to_list fields)
203
203
| Texp_field (e , _ , _ ) -> expression env e
204
- | Texp_setfield (e1 , _ , _ , e2 ) ->
205
- expression env e1 @ expression env e2
204
+ | Texp_setfield (e1 , _ , _ , e2 ) -> expression env e1 @ expression env e2
206
205
| Texp_array es -> List. concat_map (expression env) es
207
206
| Texp_ifthenelse (e1 , e2 , e3 ) ->
208
207
let e3 = match e3 with Some e -> expression env e | None -> [] in
209
208
e3 @ expression env e1 @ expression env e2
210
- | Texp_sequence (e1 , e2 ) ->
211
- expression env e1 @ expression env e2
212
- | Texp_while (e1 , e2 ) ->
213
- expression env e1 @ expression env e2
209
+ | Texp_sequence (e1 , e2 ) -> expression env e1 @ expression env e2
210
+ | Texp_while (e1 , e2 ) -> expression env e1 @ expression env e2
214
211
| Texp_for (id , p , e1 , e2 , _ , e3 ) ->
215
212
((LocalValue id, pos_of_loc p.ppat_loc) :: expression env e1)
216
213
@ expression env e2 @ expression env e3
@@ -303,20 +300,22 @@ module Analysis = struct
303
300
let sg = structure env parent str in
304
301
sg
305
302
| Tmod_functor (parameter , res ) ->
306
- let open Odoc_model.Names in
307
- let x, env =
308
- match parameter with
309
- | Unit -> [] , env
310
- | Named (id_opt , _ , arg ) ->
311
- match id_opt with
312
- | Some id ->
313
- let env = env_wrap
314
- (Ident_env. add_parameter parent id
315
- (ModuleName. of_ident id))
316
- env in
317
- let id = Ident_env. find_module_identifier (get_env env) id in
318
- module_type env (id :> Identifier.Signature.t ) arg, env
319
- | None -> [] , env
303
+ let open Odoc_model.Names in
304
+ let x, env =
305
+ match parameter with
306
+ | Unit -> ([] , env)
307
+ | Named (id_opt , _ , arg ) -> (
308
+ match id_opt with
309
+ | Some id ->
310
+ let env =
311
+ env_wrap
312
+ (Ident_env. add_parameter parent id
313
+ (ModuleName. of_ident id))
314
+ env
315
+ in
316
+ let id = Ident_env. find_module_identifier (get_env env) id in
317
+ (module_type env (id :> Identifier.Signature.t ) arg, env)
318
+ | None -> ([] , env))
320
319
in
321
320
x @ module_expr env (Odoc_model.Paths.Identifier.Mk. result parent) res
322
321
| Tmod_constraint (me , _ , constr , _ ) ->
@@ -456,52 +455,49 @@ let anchor_of_identifier id =
456
455
anchor_of_identifier [] id |> String. concat " ."
457
456
458
457
let of_cmt (source_id : Odoc_model.Paths.Identifier.SourcePage.t )
459
- (id : Odoc_model.Paths.Identifier.RootModule.t ) (structure : Typedtree.structure )
460
- (uid_to_loc : Warnings.loc Types.Uid.Tbl.t )
461
- =
462
- let env = Ident_env. empty () in
463
- let vs =
464
- Analysis. structure (env, uid_to_loc)
465
- (id :> Odoc_model.Paths.Identifier.Signature.t )
466
- structure
467
- in
468
- let uid_to_loc_map = Shape.Uid.Tbl. to_map uid_to_loc in
469
- let uid_to_id :
470
- Odoc_model.Paths.Identifier.SourceLocation. t Shape.Uid.Map. t =
471
- Shape.Uid.Map. filter_map
472
- (fun uid loc ->
473
- if loc.Location. loc_ghost then None
474
- else
475
- let identifier = Ident_env. identifier_of_loc env loc in
476
- let anchor =
477
- match identifier with
478
- | Some x ->
479
- Some
480
- (Odoc_model.Names.DefName. make_std
481
- (anchor_of_identifier x))
482
- | None -> (
483
- match uid with
484
- | Compilation_unit _ -> None
485
- | Item _ ->
486
- let name =
487
- Odoc_model.Names.DefName. make_std
488
- (Printf. sprintf " def_%d_%d" loc.loc_start.pos_cnum
489
- loc.loc_end.pos_cnum)
490
- in
491
- Some name
492
- | _ -> None )
493
- in
494
- match anchor with
495
- | Some a ->
496
- Some
497
- (Odoc_model.Paths.Identifier.Mk. source_location
498
- (source_id, a)
499
- :> Odoc_model.Paths.Identifier.SourceLocation. t)
500
- | None -> None )
501
- uid_to_loc_map
502
- in
503
-
504
- (uid_to_id, postprocess_poses source_id vs uid_to_id uid_to_loc )
458
+ (id : Odoc_model.Paths.Identifier.RootModule.t )
459
+ (structure : Typedtree.structure )
460
+ (uid_to_loc : Warnings.loc Types.Uid.Tbl.t ) =
461
+ let env = Ident_env. empty () in
462
+ let vs =
463
+ Analysis. structure (env, uid_to_loc)
464
+ (id :> Odoc_model.Paths.Identifier.Signature.t )
465
+ structure
466
+ in
467
+ let uid_to_loc_map = Shape.Uid.Tbl. to_map uid_to_loc in
468
+ let uid_to_id : Odoc_model.Paths.Identifier.SourceLocation.t Shape.Uid.Map.t =
469
+ Shape.Uid.Map. filter_map
470
+ (fun uid loc ->
471
+ if loc.Location. loc_ghost then None
472
+ else
473
+ let identifier = Ident_env. identifier_of_loc env loc in
474
+ let anchor =
475
+ match identifier with
476
+ | Some x ->
477
+ Some
478
+ (Odoc_model.Names.DefName. make_std (anchor_of_identifier x))
479
+ | None -> (
480
+ match uid with
481
+ | Compilation_unit _ -> None
482
+ | Item _ ->
483
+ let name =
484
+ Odoc_model.Names.DefName. make_std
485
+ (Printf. sprintf " def_%d_%d" loc.loc_start.pos_cnum
486
+ loc.loc_end.pos_cnum)
487
+ in
488
+ Some name
489
+ | _ -> None )
490
+ in
491
+ match anchor with
492
+ | Some a ->
493
+ Some
494
+ (Odoc_model.Paths.Identifier.Mk. source_location (source_id, a)
495
+ :> Odoc_model.Paths.Identifier.SourceLocation. t)
496
+ | None -> None )
497
+ uid_to_loc_map
498
+ in
499
+
500
+ (uid_to_id, postprocess_poses source_id vs uid_to_id uid_to_loc)
505
501
506
502
#else
507
503
0 commit comments