Skip to content

Commit fc051e8

Browse files
panglesdjonludlam
authored andcommitted
Compatibility
Signed-off-by: Paul-Elliot <[email protected]>
1 parent 1b556be commit fc051e8

File tree

5 files changed

+29
-19
lines changed

5 files changed

+29
-19
lines changed

src/document/generator.ml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ open O.Infix
2323

2424
let tag tag t = O.span ~attr:tag t
2525

26+
let rec filter_map acc f = function
27+
| hd :: tl ->
28+
let acc = match f hd with Some x -> x :: acc | None -> acc in
29+
filter_map acc f tl
30+
| [] -> List.rev acc
31+
2632
let label t =
2733
match t with
2834
| Odoc_model.Lang.TypeExpr.Label s -> tag "label" (O.txt s)
@@ -265,7 +271,7 @@ module Make (Syntax : SYNTAX) = struct
265271
let mapper (info, loc) =
266272
match info_of_info info with Some x -> Some (x, loc) | None -> None
267273
in
268-
let infos = List.filter_map mapper infos in
274+
let infos = filter_map [] mapper infos in
269275
let syntax_info =
270276
List.map (fun (ty, loc) -> (Source_page.Syntax ty, loc)) syntax_info
271277
in

src/loader/cmt.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,11 +386,11 @@ let rec read_module_expr env parent label_parent mexpr =
386386
match arg with
387387
| None -> FunctorParameter.Unit
388388
| Some arg ->
389-
let id = Env.find_parameter_identifier env id in
389+
let id = Env.find_parameter_identifier new_env id in
390390
let arg = Cmti.read_module_type env (id :> Identifier.Signature.t) label_parent arg in
391391
Named { FunctorParameter. id; expr = arg; }
392392
in
393-
let res = read_module_expr env (Identifier.Mk.result parent) label_parent res in
393+
let res = read_module_expr new_env (Identifier.Mk.result parent) label_parent res in
394394
Functor(f_parameter, res)
395395
#endif
396396
| Tmod_apply _ ->

src/loader/ident_env.cppo.ml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ module P = Paths.Path
2424
type type_ident = Paths.Identifier.Path.Type.t
2525

2626
module LocHashtbl = Hashtbl.Make(struct
27-
type t = Warnings.loc
27+
type t = Location.t
2828
let equal l1 l2 = l1 = l2
2929
let hash = Hashtbl.hash
3030
end)
@@ -62,15 +62,15 @@ let empty () =
6262
(* The boolean is an override for whether it should be hidden - true only for
6363
items introduced by extended open *)
6464
type item = [
65-
`Module of Ident.t * bool * Warnings.loc option
66-
| `ModuleType of Ident.t * bool * Warnings.loc option
67-
| `Type of Ident.t * bool * Warnings.loc option
68-
| `Value of Ident.t * bool * Warnings.loc option
69-
| `Class of Ident.t * Ident.t * Ident.t * Ident.t option * bool * Warnings.loc option
70-
| `ClassType of Ident.t * Ident.t * Ident.t option * bool * Warnings.loc option
71-
| `Exception of Ident.t * Warnings.loc option
65+
`Module of Ident.t * bool * Location.t option
66+
| `ModuleType of Ident.t * bool * Location.t option
67+
| `Type of Ident.t * bool * Location.t option
68+
| `Value of Ident.t * bool * Location.t option
69+
| `Class of Ident.t * Ident.t * Ident.t * Ident.t option * bool * Location.t option
70+
| `ClassType of Ident.t * Ident.t * Ident.t option * bool * Location.t option
71+
| `Exception of Ident.t * Location.t option
7272
(* Exceptions needs to be added to the [loc_to_ident] table. *)
73-
| `Extension of Ident.t * Warnings.loc option
73+
| `Extension of Ident.t * Location.t option
7474
(* Extension constructor also need to be added to the [loc_to_ident] table,
7575
since they get an entry in the [uid_to_loc] table. *)
7676
]
@@ -560,8 +560,8 @@ let add_items : Id.Signature.t -> item list -> t -> t = fun parent items env ->
560560
| [] -> env
561561
in inner items env
562562

563-
let identifier_of_loc : t -> Warnings.loc -> Odoc_model.Paths.Identifier.t option = fun env loc ->
564-
LocHashtbl.find_opt env.loc_to_ident loc
563+
let identifier_of_loc : t -> Location.t -> Odoc_model.Paths.Identifier.t option = fun env loc ->
564+
try Some (LocHashtbl.find env.loc_to_ident loc) with Not_found -> None
565565

566566
let add_signature_tree_items : Paths.Identifier.Signature.t -> Typedtree.signature -> t -> t =
567567
fun parent sg env ->

src/loader/ident_env.cppo.mli

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@ module Fragment : sig
7575
val read_type : Longident.t -> Paths.Fragment.Type.t
7676
end
7777

78-
val identifier_of_loc :
79-
t -> Warnings.loc -> Odoc_model.Paths.Identifier.t option
78+
val identifier_of_loc : t -> Location.t -> Odoc_model.Paths.Identifier.t option
8079
(** Each generated id has its location stored. This allows to get back the id
8180
knowing only the location. This is used to generate links to source from the
8281
resolution of a shape. *)

src/loader/implementation.ml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ module Analysis = struct
1515
open Typedtree
1616
open Odoc_model.Paths
1717

18-
type env = Ident_env.t * Warnings.loc Shape.Uid.Tbl.t
18+
type env = Ident_env.t * Location.t Shape.Uid.Tbl.t
1919

2020
let env_wrap : (Ident_env.t -> Ident_env.t) -> env -> env =
2121
fun f (env, uid_to_loc) -> (f env, uid_to_loc)
2222

2323
let get_env : env -> Ident_env.t = fun (env, _) -> env
2424

25-
let get_uid_to_loc : env -> Warnings.loc Shape.Uid.Tbl.t =
25+
let get_uid_to_loc : env -> Location.t Shape.Uid.Tbl.t =
2626
fun (_, uid_to_loc) -> uid_to_loc
2727

2828
let rec structure env parent str =
@@ -222,7 +222,12 @@ module Analysis = struct
222222
List.concat_map (fun (_, _, e) -> expression env e) es
223223
| Texp_letmodule (_, _, _, _m, e) -> expression env e
224224
| Texp_letexception (_, e) -> expression env e
225-
| Texp_assert e -> expression env e
225+
#if OCAML_VERSION < (5,1,0)
226+
| Texp_assert e
227+
#else
228+
| Texp_assert (e, _)
229+
#endif
230+
-> expression env e
226231
| Texp_lazy e -> expression env e
227232
| Texp_object (_, _) -> []
228233
| Texp_pack _ -> []

0 commit comments

Comments
 (0)