Skip to content

Commit bed9ef2

Browse files
committed
rename parent into fragment_type_parent
The former was too generic. Added some comments at the definition. Signed-off-by: Paul-Elliot <[email protected]>
1 parent c280154 commit bed9ef2

File tree

12 files changed

+107
-73
lines changed

12 files changed

+107
-73
lines changed

src/loader/cmi.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ let read_constructor_declaration env parent cd =
632632
let doc = Doc_attr.attached_no_tag container cd.cd_attributes in
633633
let args =
634634
read_constructor_declaration_arguments env
635-
(parent :> Identifier.Parent.t) cd.cd_args
635+
(parent :> Identifier.FragmentTypeParent.t) cd.cd_args
636636
in
637637
let res = opt_map (read_type_expr env) cd.cd_res in
638638
{id; doc; args; res}
@@ -652,7 +652,7 @@ let read_type_kind env parent =
652652
| Type_record(lbls, _) ->
653653
let lbls =
654654
List.map
655-
(read_label_declaration env (parent :> Identifier.Parent.t))
655+
(read_label_declaration env (parent :> Identifier.FragmentTypeParent.t))
656656
lbls
657657
in
658658
Some (Record lbls)
@@ -745,7 +745,7 @@ let read_extension_constructor env parent id ext =
745745
let doc = Doc_attr.attached_no_tag container ext.ext_attributes in
746746
let args =
747747
read_constructor_declaration_arguments env
748-
(parent : Identifier.Signature.t :> Identifier.Parent.t) ext.ext_args
748+
(parent : Identifier.Signature.t :> Identifier.FragmentTypeParent.t) ext.ext_args
749749
in
750750
let res = opt_map (read_type_expr env) ext.ext_ret_type in
751751
{id; locs; doc; args; res}
@@ -779,7 +779,7 @@ let read_exception env parent id ext =
779779
mark_exception ext;
780780
let args =
781781
read_constructor_declaration_arguments env
782-
(parent : Identifier.Signature.t :> Identifier.Parent.t) ext.ext_args
782+
(parent : Identifier.Signature.t :> Identifier.FragmentTypeParent.t) ext.ext_args
783783
in
784784
let res = opt_map (read_type_expr env) ext.ext_ret_type in
785785
{id; locs; doc; args; res}

src/loader/cmti.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ let read_constructor_declaration_arguments env parent label_parent arg =
214214
let read_constructor_declaration env parent cd =
215215
let open TypeDecl.Constructor in
216216
let id = Ident_env.find_constructor_identifier env cd.cd_id in
217-
let container = (parent :> Identifier.Parent.t) in
217+
let container = (parent :> Identifier.FragmentTypeParent.t) in
218218
let label_container = (container :> Identifier.LabelParent.t) in
219219
let doc = Doc_attr.attached_no_tag label_container cd.cd_attributes in
220220
let args =
@@ -231,7 +231,7 @@ let read_type_kind env parent =
231231
let cstrs = List.map (read_constructor_declaration env parent) cstrs in
232232
Some (Variant cstrs)
233233
| Ttype_record lbls ->
234-
let parent = (parent :> Identifier.Parent.t) in
234+
let parent = (parent :> Identifier.FragmentTypeParent.t) in
235235
let label_parent = (parent :> Identifier.LabelParent.t) in
236236
let lbls =
237237
List.map (read_label_declaration env parent label_parent) lbls in
@@ -292,7 +292,7 @@ let read_extension_constructor env parent ext =
292292
let open Extension.Constructor in
293293
let id = Env.find_extension_identifier env ext.ext_id in
294294
let locs = None in
295-
let container = (parent : Identifier.Signature.t :> Identifier.Parent.t) in
295+
let container = (parent : Identifier.Signature.t :> Identifier.FragmentTypeParent.t) in
296296
let label_container = (container :> Identifier.LabelParent.t) in
297297
let doc = Doc_attr.attached_no_tag label_container ext.ext_attributes in
298298
match ext.ext_kind with
@@ -325,7 +325,7 @@ let read_exception env parent (ext : extension_constructor) =
325325
let open Exception in
326326
let id = Env.find_exception_identifier env ext.ext_id in
327327
let locs = None in
328-
let container = (parent : Identifier.Signature.t :> Identifier.Parent.t) in
328+
let container = (parent : Identifier.Signature.t :> Identifier.FragmentTypeParent.t) in
329329
let label_container = (container :> Identifier.LabelParent.t) in
330330
let doc = Doc_attr.attached_no_tag label_container ext.ext_attributes in
331331
match ext.ext_kind with

src/model/paths.ml

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ module Identifier = struct
166166
| { iv = `Method (p, _); _ } | { iv = `InstanceVariable (p, _); _ } ->
167167
(p : class_signature :> label_parent)
168168
| { iv = `Constructor (p, _); _ } -> (p : datatype :> label_parent)
169-
| { iv = `Field (p, _); _ } -> (p : parent :> label_parent)
169+
| { iv = `Field (p, _); _ } -> (p : fragment_type_parent :> label_parent)
170170

171171
let label_parent n = label_parent_aux (n :> Id.non_src)
172172

@@ -217,9 +217,9 @@ module Identifier = struct
217217
type t_pv = Id.datatype_pv
218218
end
219219

220-
module Parent = struct
221-
type t = Id.parent
222-
type t_pv = Id.parent_pv
220+
module FragmentTypeParent = struct
221+
type t = Paths_types.Identifier.fragment_type_parent
222+
type t_pv = Paths_types.Identifier.fragment_type_parent_pv
223223
end
224224

225225
module LabelParent = struct
@@ -578,7 +578,8 @@ module Identifier = struct
578578
`Constructor (p, n))
579579

580580
let field :
581-
Parent.t * FieldName.t -> [> `Field of Parent.t * FieldName.t ] id =
581+
FragmentTypeParent.t * FieldName.t ->
582+
[> `Field of FragmentTypeParent.t * FieldName.t ] id =
582583
mk_parent FieldName.to_string "fld" (fun (p, n) -> `Field (p, n))
583584

584585
let extension :
@@ -991,12 +992,14 @@ module Reference = struct
991992
| `ClassType (sg, s) ->
992993
Identifier.Mk.class_type (parent_signature_identifier sg, s)
993994

994-
and parent_identifier : parent -> Identifier.Parent.t = function
995+
and parent_identifier :
996+
fragment_type_parent -> Identifier.FragmentTypeParent.t = function
995997
| `Identifier id -> id
996998
| (`Hidden _ | `Alias _ | `AliasModuleType _ | `Module _ | `ModuleType _)
997999
as sg ->
998-
(parent_signature_identifier sg :> Identifier.Parent.t)
999-
| `Type _ as t -> (parent_type_identifier t :> Identifier.Parent.t)
1000+
(parent_signature_identifier sg :> Identifier.FragmentTypeParent.t)
1001+
| `Type _ as t ->
1002+
(parent_type_identifier t :> Identifier.FragmentTypeParent.t)
10001003

10011004
and label_parent_identifier : label_parent -> Identifier.LabelParent.t =
10021005
function
@@ -1042,8 +1045,8 @@ module Reference = struct
10421045
type t = Paths_types.Resolved_reference.datatype
10431046
end
10441047

1045-
module Parent = struct
1046-
type t = Paths_types.Resolved_reference.parent
1048+
module FragmentTypeParent = struct
1049+
type t = Paths_types.Resolved_reference.fragment_type_parent
10471050
end
10481051

10491052
module LabelParent = struct
@@ -1127,8 +1130,8 @@ module Reference = struct
11271130
type t = Paths_types.Reference.datatype
11281131
end
11291132

1130-
module Parent = struct
1131-
type t = Paths_types.Reference.parent
1133+
module FragmentTypeParent = struct
1134+
type t = Paths_types.Reference.fragment_type_parent
11321135
end
11331136

11341137
module LabelParent = struct

src/model/paths.mli

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ module Identifier : sig
7979
type t = Id.datatype
8080
type t_pv = Id.datatype_pv
8181
end
82-
module Parent : sig
83-
type t = Id.parent
84-
type t_pv = Id.parent_pv
82+
module FragmentTypeParent : sig
83+
type t = Id.fragment_type_parent
84+
type t_pv = Id.fragment_type_parent_pv
8585
end
8686

8787
module FunctorResult : sig
@@ -294,7 +294,8 @@ module Identifier : sig
294294
[> `Constructor of DataType.t * ConstructorName.t ] id
295295

296296
val field :
297-
Parent.t * FieldName.t -> [> `Field of Parent.t * FieldName.t ] id
297+
FragmentTypeParent.t * FieldName.t ->
298+
[> `Field of FragmentTypeParent.t * FieldName.t ] id
298299

299300
val extension :
300301
Signature.t * ExtensionName.t ->
@@ -507,8 +508,8 @@ module rec Reference : sig
507508
type t = Paths_types.Resolved_reference.datatype
508509
end
509510

510-
module Parent : sig
511-
type t = Paths_types.Resolved_reference.parent
511+
module FragmentTypeParent : sig
512+
type t = Paths_types.Resolved_reference.fragment_type_parent
512513
end
513514

514515
module LabelParent : sig
@@ -592,8 +593,8 @@ module rec Reference : sig
592593
type t = Paths_types.Reference.datatype
593594
end
594595

595-
module Parent : sig
596-
type t = Paths_types.Reference.parent
596+
module FragmentTypeParent : sig
597+
type t = Paths_types.Reference.fragment_type_parent
597598
end
598599

599600
module LabelParent : sig

src/model/paths_types.ml

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,17 @@ module Identifier = struct
8181
and datatype = datatype_pv id
8282
(** @canonical Odoc_model.Paths.Identifier.DataType.t *)
8383

84-
type parent_pv = [ signature_pv | datatype_pv ]
85-
(** @canonical Odoc_model.Paths.Identifier.Parent.t_pv *)
84+
type fragment_type_parent_pv = [ signature_pv | datatype_pv ]
85+
(** @canonical Odoc_model.Paths.Identifier.FragmentTypeParent.t_pv *)
8686

87-
and parent = parent_pv id
88-
(** @canonical Odoc_model.Paths.Identifier.Parent.t *)
87+
(* fragment_type_parent in identifiers is for record fields parent. It’s type
88+
(for usual record fields) or [signature] for fields of inline records of
89+
extension constructor. *)
90+
and fragment_type_parent = fragment_type_parent_pv id
91+
(** @canonical Odoc_model.Paths.Identifier.FragmentTypeParent.t *)
8992

90-
type label_parent_pv = [ parent_pv | page_pv | class_signature_pv ]
93+
type label_parent_pv =
94+
[ fragment_type_parent_pv | page_pv | class_signature_pv ]
9195
(** @canonical Odoc_model.Paths.Identifier.LabelParent.t_pv *)
9296

9397
and label_parent = label_parent_pv id
@@ -138,7 +142,7 @@ module Identifier = struct
138142
and constructor = constructor_pv id
139143
(** @canonical Odoc_model.Paths.Identifier.Constructor.t *)
140144

141-
type field_pv = [ `Field of parent * FieldName.t ]
145+
type field_pv = [ `Field of fragment_type_parent * FieldName.t ]
142146
(** @canonical Odoc_model.Paths.Identifier.Field.t_pv *)
143147

144148
and field = field_pv id
@@ -206,7 +210,7 @@ module Identifier = struct
206210
[ signature_pv
207211
| class_signature_pv
208212
| datatype_pv
209-
| parent_pv
213+
| fragment_type_parent_pv
210214
| label_parent_pv
211215
| module_pv
212216
| functor_parameter_pv
@@ -617,14 +621,15 @@ module rec Reference : sig
617621
| `Type of signature * TypeName.t ]
618622
(** @canonical Odoc_model.Paths.Reference.DataType.t *)
619623

620-
and parent =
621-
[ `Resolved of Resolved_reference.parent
624+
(* Parent of fields and constructor. Can be either a type or [signature] *)
625+
and fragment_type_parent =
626+
[ `Resolved of Resolved_reference.fragment_type_parent
622627
| `Root of string * tag_parent
623628
| `Dot of label_parent * string
624629
| `Module of signature * ModuleName.t
625630
| `ModuleType of signature * ModuleTypeName.t
626631
| `Type of signature * TypeName.t ]
627-
(** @canonical Odoc_model.Paths.Reference.Parent.t *)
632+
(** @canonical Odoc_model.Paths.Reference.FragmentTypeParent.t *)
628633

629634
and label_parent =
630635
[ `Resolved of Resolved_reference.label_parent
@@ -664,7 +669,7 @@ module rec Reference : sig
664669
[ `Resolved of Resolved_reference.constructor
665670
| `Root of string * [ `TConstructor | `TExtension | `TException | `TUnknown ]
666671
| `Dot of label_parent * string
667-
| `Constructor of parent * ConstructorName.t
672+
| `Constructor of fragment_type_parent * ConstructorName.t
668673
| `Extension of signature * ExtensionName.t
669674
| `Exception of signature * ExceptionName.t ]
670675
(** @canonical Odoc_model.Paths.Reference.Constructor.t *)
@@ -673,7 +678,7 @@ module rec Reference : sig
673678
[ `Resolved of Resolved_reference.field
674679
| `Root of string * [ `TField | `TUnknown ]
675680
| `Dot of label_parent * string
676-
| `Field of parent * FieldName.t ]
681+
| `Field of fragment_type_parent * FieldName.t ]
677682
(** @canonical Odoc_model.Paths.Reference.Field.t *)
678683

679684
type extension =
@@ -754,8 +759,8 @@ module rec Reference : sig
754759
| `Module of signature * ModuleName.t
755760
| `ModuleType of signature * ModuleTypeName.t
756761
| `Type of signature * TypeName.t
757-
| `Constructor of parent * ConstructorName.t
758-
| `Field of parent * FieldName.t
762+
| `Constructor of fragment_type_parent * ConstructorName.t
763+
| `Field of fragment_type_parent * FieldName.t
759764
| `Extension of signature * ExtensionName.t
760765
| `ExtensionDecl of signature * ExtensionName.t
761766
| `Exception of signature * ExceptionName.t
@@ -803,16 +808,18 @@ and Resolved_reference : sig
803808
| `ClassType of signature * ClassTypeName.t ]
804809
(** @canonical Odoc_model.Paths.Reference.Resolved.ClassSignature.t *)
805810

806-
(* parent is [ signature | class_signature ] *)
807-
and parent =
808-
[ `Identifier of Identifier.parent
811+
(* fragment_type_parent in resolved references is for record fields parent.
812+
It’s type (for usual record fields) or [signature] for fields of inline
813+
records of extension constructor. *)
814+
and fragment_type_parent =
815+
[ `Identifier of Identifier.fragment_type_parent
809816
| `Alias of Resolved_path.module_ * module_
810817
| `AliasModuleType of Resolved_path.module_type * module_type
811818
| `Module of signature * ModuleName.t
812819
| `Hidden of module_
813820
| `ModuleType of signature * ModuleTypeName.t
814821
| `Type of signature * TypeName.t ]
815-
(** @canonical Odoc_model.Paths.Reference.Resolved.Parent.t *)
822+
(** @canonical Odoc_model.Paths.Reference.Resolved.FragmentTypeParent.t *)
816823

817824
(* The only difference between parent and label_parent
818825
is that the Identifier allows more types *)
@@ -850,7 +857,7 @@ and Resolved_reference : sig
850857

851858
type field =
852859
[ `Identifier of Identifier.reference_field
853-
| `Field of parent * FieldName.t ]
860+
| `Field of fragment_type_parent * FieldName.t ]
854861
(** @canonical Odoc_model.Paths.Reference.Resolved.Field.t *)
855862

856863
type extension =
@@ -917,7 +924,7 @@ and Resolved_reference : sig
917924
| `ModuleType of signature * ModuleTypeName.t
918925
| `Type of signature * TypeName.t
919926
| `Constructor of datatype * ConstructorName.t
920-
| `Field of parent * FieldName.t
927+
| `Field of fragment_type_parent * FieldName.t
921928
| `Extension of signature * ExtensionName.t
922929
| `ExtensionDecl of signature * ExtensionName.t * ExtensionName.t
923930
| `Exception of signature * ExceptionName.t

src/model/reference.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ let parse whole_reference_location s :
214214
| _ ->
215215
expected [ "module"; "module-type" ] location
216216
|> Error.raise_exception)
217-
and parent (kind, identifier, location) tokens : Parent.t =
217+
and parent (kind, identifier, location) tokens : FragmentTypeParent.t =
218218
let kind = match_reference_kind location kind in
219219
match tokens with
220220
| [] -> (

src/xref2/env.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ let add_type (identifier : Identifier.Type.t) t env =
301301
and add_field env (field : TypeDecl.Field.t) =
302302
let ident =
303303
Paths.Identifier.Mk.field
304-
( (identifier :> Paths.Identifier.Parent.t),
304+
( (identifier :> Paths.Identifier.FragmentTypeParent.t),
305305
FieldName.make_std field.name )
306306
in
307307
add_to_elts Kind_Field ident (`Field (ident, field)) env

src/xref2/ident.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ module Of_Identifier = struct
141141
| `Type (_, n) -> `LType (n, i)
142142
| `CoreType _n -> failwith "Bad"
143143

144-
let parent : Parent.t -> parent =
144+
let parent : FragmentTypeParent.t -> parent =
145145
fun p ->
146146
match p with
147147
| { iv = #Signature.t_pv; _ } as s -> (signature s :> parent)
@@ -152,7 +152,7 @@ module Of_Identifier = struct
152152
match p with
153153
| { iv = #ClassSignature.t_pv; _ } as s ->
154154
(class_signature s :> label_parent)
155-
| { iv = #Parent.t_pv; _ } as s -> (parent s :> label_parent)
155+
| { iv = #FragmentTypeParent.t_pv; _ } as s -> (parent s :> label_parent)
156156
| { iv = `Page (_, n); _ } -> `LPage (n, fresh_int ())
157157
| { iv = `LeafPage (_, n); _ } -> `LLeafPage (n, fresh_int ())
158158

0 commit comments

Comments
 (0)