Skip to content

Commit

Permalink
Remove ClassName and ClassTypeName
Browse files Browse the repository at this point in the history
They are replaced by TypeName as they are little risk of mixing them.
  • Loading branch information
jonludlam authored and Julow committed Jul 26, 2024
1 parent 8973686 commit b7faf79
Show file tree
Hide file tree
Showing 25 changed files with 165 additions and 180 deletions.
9 changes: 4 additions & 5 deletions src/document/comment.ml
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@ module Reference = struct
| `Exception (r, s) ->
render_resolved (r :> t) ^ "." ^ ExceptionName.to_string s
| `Value (r, s) -> render_resolved (r :> t) ^ "." ^ ValueName.to_string s
| `Class (r, s) -> render_resolved (r :> t) ^ "." ^ ClassName.to_string s
| `ClassType (r, s) ->
render_resolved (r :> t) ^ "." ^ ClassTypeName.to_string s
| `Class (r, s) -> render_resolved (r :> t) ^ "." ^ TypeName.to_string s
| `ClassType (r, s) -> render_resolved (r :> t) ^ "." ^ TypeName.to_string s
| `Method (r, s) ->
(* CR trefis: do we really want to print anything more than [s] here? *)
render_resolved (r :> t) ^ "." ^ MethodName.to_string s
Expand Down Expand Up @@ -94,9 +93,9 @@ module Reference = struct
| `Exception (p, f) ->
render_unresolved (p :> t) ^ "." ^ ExceptionName.to_string f
| `Value (p, f) -> render_unresolved (p :> t) ^ "." ^ ValueName.to_string f
| `Class (p, f) -> render_unresolved (p :> t) ^ "." ^ ClassName.to_string f
| `Class (p, f) -> render_unresolved (p :> t) ^ "." ^ TypeName.to_string f
| `ClassType (p, f) ->
render_unresolved (p :> t) ^ "." ^ ClassTypeName.to_string f
render_unresolved (p :> t) ^ "." ^ TypeName.to_string f
| `Method (p, f) ->
render_unresolved (p :> t) ^ "." ^ MethodName.to_string f
| `InstanceVariable (p, f) ->
Expand Down
8 changes: 4 additions & 4 deletions src/document/generator.ml
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ module Make (Syntax : SYNTAX) = struct
| `Module (`Root _, s) -> ModuleName.to_string s
| `Module_type (`Root _, s) -> ModuleTypeName.to_string s
| `Type (`Root _, s) -> TypeName.to_string s
| `Class (`Root _, s) -> ClassName.to_string s
| `ClassType (`Root _, s) -> ClassTypeName.to_string s
| `Class (`Root _, s) -> TypeName.to_string s
| `ClassType (`Root _, s) -> TypeName.to_string s
| `Module (rr, s) ->
dot (render_resolved_fragment (rr :> t)) (ModuleName.to_string s)
| `Module_type (rr, s) ->
Expand All @@ -173,9 +173,9 @@ module Make (Syntax : SYNTAX) = struct
| `Type (rr, s) ->
dot (render_resolved_fragment (rr :> t)) (TypeName.to_string s)
| `Class (rr, s) ->
dot (render_resolved_fragment (rr :> t)) (ClassName.to_string s)
dot (render_resolved_fragment (rr :> t)) (TypeName.to_string s)
| `ClassType (rr, s) ->
dot (render_resolved_fragment (rr :> t)) (ClassTypeName.to_string s)
dot (render_resolved_fragment (rr :> t)) (TypeName.to_string s)
| `OpaqueModule r -> render_resolved_fragment (r :> t)

let resolved_fragment_to_ir : Fragment.Resolved.leaf -> text =
Expand Down
9 changes: 4 additions & 5 deletions src/document/url.ml
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,8 @@ let render_path : Odoc_model.Paths.Path.t -> string =
render_resolved (p :> t) ^ "." ^ ModuleTypeName.to_string s
| `Type (p, s) -> render_resolved (p :> t) ^ "." ^ TypeName.to_string s
| `Value (p, s) -> render_resolved (p :> t) ^ "." ^ ValueName.to_string s
| `Class (p, s) -> render_resolved (p :> t) ^ "." ^ ClassName.to_string s
| `ClassType (p, s) ->
render_resolved (p :> t) ^ "." ^ ClassTypeName.to_string s
| `Class (p, s) -> render_resolved (p :> t) ^ "." ^ TypeName.to_string s
| `ClassType (p, s) -> render_resolved (p :> t) ^ "." ^ TypeName.to_string s
and render_path : Odoc_model.Paths.Path.t -> string =
fun x ->
match x with
Expand Down Expand Up @@ -172,12 +171,12 @@ module Path = struct
| { iv = `Class (parent, name); _ } ->
let parent = from_identifier (parent :> any) in
let kind = `Class in
let name = ClassName.to_string name in
let name = TypeName.to_string name in
mk ~parent kind name
| { iv = `ClassType (parent, name); _ } ->
let parent = from_identifier (parent :> any) in
let kind = `ClassType in
let name = ClassTypeName.to_string name in
let name = TypeName.to_string name in
mk ~parent kind name
| { iv = `Result p; _ } -> from_identifier (p :> any)
| { iv = `SourceDir (parent, name); _ } ->
Expand Down
8 changes: 4 additions & 4 deletions src/loader/ident_env.cppo.ml
Original file line number Diff line number Diff line change
Expand Up @@ -522,8 +522,8 @@ let add_items : Id.Signature.t -> item list -> t -> t = fun parent items env ->
in
let identifier, shadowed =
if is_shadowed
then Mk.class_(parent, ClassName.shadowed_of_string name), class_types @ env.shadowed
else Mk.class_(parent, (if is_hidden_item then ClassName.hidden_of_string else ClassName.make_std) name), env.shadowed
then Mk.class_(parent, TypeName.shadowed_of_string name), class_types @ env.shadowed
else Mk.class_(parent, (if is_hidden_item then TypeName.hidden_of_string else TypeName.make_std) name), env.shadowed
in

let classes =
Expand All @@ -543,8 +543,8 @@ let add_items : Id.Signature.t -> item list -> t -> t = fun parent items env ->
in
let identifier, shadowed =
if is_shadowed
then Mk.class_type(parent, ClassTypeName.shadowed_of_string name), class_types @ env.shadowed
else Mk.class_type(parent, (if is_hidden_item then ClassTypeName.hidden_of_string else ClassTypeName.make_std) name), env.shadowed
then Mk.class_type(parent, TypeName.shadowed_of_string name), class_types @ env.shadowed
else Mk.class_type(parent, (if is_hidden_item then TypeName.hidden_of_string else TypeName.make_std) name), env.shadowed
in
let class_types =
List.fold_right (fun id class_types -> Ident.add id identifier class_types)
Expand Down
4 changes: 2 additions & 2 deletions src/loader/implementation.ml
Original file line number Diff line number Diff line change
Expand Up @@ -220,14 +220,14 @@ let anchor_of_identifier id =
let anchor = anchor `Exception (ExceptionName.to_string name) in
continue anchor parent
| `Class (parent, name) ->
let anchor = anchor `Class (ClassName.to_string name) in
let anchor = anchor `Class (TypeName.to_string name) in
continue anchor parent
| `Page _ -> assert false
| `LeafPage _ -> assert false
| `CoreType _ -> assert false
| `SourceLocation _ -> assert false
| `ClassType (parent, name) ->
let anchor = anchor `ClassType (ClassTypeName.to_string name) in
let anchor = anchor `ClassType (TypeName.to_string name) in
continue anchor parent
| `SourcePage _ -> assert false
| `Value (parent, name) ->
Expand Down
4 changes: 2 additions & 2 deletions src/model/lang.ml
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ and Include : sig
s_module_types : (string * Names.ModuleTypeName.t) list;
s_values : (string * Names.ValueName.t) list;
s_types : (string * Names.TypeName.t) list;
s_classes : (string * Names.ClassName.t) list;
s_class_types : (string * Names.ClassTypeName.t) list;
s_classes : (string * Names.TypeName.t) list;
s_class_types : (string * Names.TypeName.t) list;
}

type expansion = { shadowed : shadowed; content : Signature.t }
Expand Down
2 changes: 0 additions & 2 deletions src/model/names.ml
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,6 @@ module FieldName = SimpleName
module ExtensionName = SimpleName
module ExceptionName = SimpleName
module ValueName = Name
module ClassName = Name
module ClassTypeName = Name
module MethodName = SimpleName
module InstanceVariableName = SimpleName
module LabelName = SimpleName
Expand Down
4 changes: 0 additions & 4 deletions src/model/names.mli
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,6 @@ module ExceptionName : SimpleName

module ValueName : Name

module ClassName : Name

module ClassTypeName : Name

module MethodName : SimpleName

module InstanceVariableName : SimpleName
Expand Down
23 changes: 11 additions & 12 deletions src/model/paths.ml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ module Identifier = struct
| `Exception (_, name) -> ExceptionName.to_string name
| `CoreException name -> ExceptionName.to_string name
| `Value (_, name) -> ValueName.to_string name
| `Class (_, name) -> ClassName.to_string name
| `ClassType (_, name) -> ClassTypeName.to_string name
| `Class (_, name) -> TypeName.to_string name
| `ClassType (_, name) -> TypeName.to_string name
| `Method (_, name) -> MethodName.to_string name
| `InstanceVariable (_, name) -> InstanceVariableName.to_string name
| `Label (_, name) -> LabelName.to_string name
Expand Down Expand Up @@ -82,8 +82,8 @@ module Identifier = struct
| `Exception (parent, _) -> is_hidden (parent :> t)
| `CoreException _ -> false
| `Value (_, name) -> ValueName.is_hidden name
| `Class (_, name) -> ClassName.is_hidden name
| `ClassType (_, name) -> ClassTypeName.is_hidden name
| `Class (_, name) -> TypeName.is_hidden name
| `ClassType (_, name) -> TypeName.is_hidden name
| `Method (parent, _) -> is_hidden (parent :> t)
| `InstanceVariable (parent, _) -> is_hidden (parent :> t)
| `Label (parent, _) -> is_hidden (parent :> t)
Expand Down Expand Up @@ -127,9 +127,9 @@ module Identifier = struct
| `Value (parent, name) ->
ValueName.to_string name :: full_name_aux (parent :> t)
| `Class (parent, name) ->
ClassName.to_string name :: full_name_aux (parent :> t)
TypeName.to_string name :: full_name_aux (parent :> t)
| `ClassType (parent, name) ->
ClassTypeName.to_string name :: full_name_aux (parent :> t)
TypeName.to_string name :: full_name_aux (parent :> t)
| `Method (parent, name) ->
MethodName.to_string name :: full_name_aux (parent :> t)
| `InstanceVariable (parent, name) ->
Expand Down Expand Up @@ -553,14 +553,13 @@ module Identifier = struct
mk_parent ModuleTypeName.to_string "mt" (fun (p, n) -> `ModuleType (p, n))

let class_ :
Signature.t * ClassName.t -> [> `Class of Signature.t * ClassName.t ] id
=
mk_parent ClassName.to_string "c" (fun (p, n) -> `Class (p, n))
Signature.t * TypeName.t -> [> `Class of Signature.t * TypeName.t ] id =
mk_parent TypeName.to_string "c" (fun (p, n) -> `Class (p, n))

let class_type :
Signature.t * ClassTypeName.t ->
[> `ClassType of Signature.t * ClassTypeName.t ] id =
mk_parent ClassTypeName.to_string "ct" (fun (p, n) -> `ClassType (p, n))
Signature.t * TypeName.t ->
[> `ClassType of Signature.t * TypeName.t ] id =
mk_parent TypeName.to_string "ct" (fun (p, n) -> `ClassType (p, n))

let type_ :
Signature.t * TypeName.t -> [> `Type of Signature.t * TypeName.t ] id =
Expand Down
5 changes: 2 additions & 3 deletions src/model/paths.mli
Original file line number Diff line number Diff line change
Expand Up @@ -276,11 +276,10 @@ module Identifier : sig
[> `ModuleType of Signature.t * ModuleTypeName.t ] id

val class_ :
Signature.t * ClassName.t -> [> `Class of Signature.t * ClassName.t ] id
Signature.t * TypeName.t -> [> `Class of Signature.t * TypeName.t ] id

val class_type :
Signature.t * ClassTypeName.t ->
[> `ClassType of Signature.t * ClassTypeName.t ] id
Signature.t * TypeName.t -> [> `ClassType of Signature.t * TypeName.t ] id

val type_ :
Signature.t * TypeName.t -> [> `Type of Signature.t * TypeName.t ] id
Expand Down
Loading

0 comments on commit b7faf79

Please sign in to comment.