Skip to content

Commit 2ae10f6

Browse files
panglesdjonludlam
authored andcommitted
Remove occurrence count for constructors
The resolving of constructor paths introduced was wrong and never tested. It is removed in this commit as well. Signed-off-by: Paul-Elliot <[email protected]>
1 parent 831dc84 commit 2ae10f6

File tree

7 files changed

+23
-28
lines changed

7 files changed

+23
-28
lines changed

src/document/generator.ml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,6 @@ module Make (Syntax : SYNTAX) = struct
286286
| Type v -> to_link v
287287
| ClassType v -> to_link v
288288
| Value v -> to_link v
289-
| Constructor v -> to_link v
290289

291290
let source id syntax_info infos source_code =
292291
let url = path id in

src/loader/implementation.ml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -332,11 +332,6 @@ let process_occurrences env poses loc_to_id local_ident_to_loc =
332332
process p Ident_env.Path.read_type
333333
|> Option.iter @@ fun l ->
334334
AnnotHashtbl.replace occ_tbl (Type l, pos_of_loc loc) ()
335-
| Constructor _p, loc ->
336-
(* process p Ident_env.Path.read_constructor *)
337-
None
338-
|> Option.iter @@ fun l ->
339-
AnnotHashtbl.replace occ_tbl (Constructor l, pos_of_loc loc) ()
340335
| LocalDefinition _, _ -> ())
341336
poses;
342337
AnnotHashtbl.fold (fun k () acc -> k :: acc) occ_tbl []

src/loader/typedtree_traverse.ml

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,17 @@ module Analysis = struct
88
| ClassType of Path.t
99
| ModuleType of Path.t
1010
| Type of Path.t
11-
| Constructor of Path.t
1211

1312
let expr poses expr =
1413
let exp_loc = expr.Typedtree.exp_loc in
1514
if exp_loc.loc_ghost then ()
1615
else
1716
match expr.exp_desc with
1817
| Texp_ident (p, _, _) -> poses := (Value p, exp_loc) :: !poses
19-
| Texp_construct (_, { cstr_res; _ }, _) -> (
20-
let desc = Types.get_desc cstr_res in
21-
match desc with
22-
| Types.Tconstr (p, _, _) ->
23-
poses := (Constructor p, exp_loc) :: !poses
24-
| _ -> ())
2518
| _ -> ()
2619

2720
let pat env (type a) poses : a Typedtree.general_pattern -> unit = function
2821
| { Typedtree.pat_desc; pat_loc; _ } when not pat_loc.loc_ghost ->
29-
let () =
30-
match pat_desc with
31-
| Typedtree.Tpat_construct (_, { cstr_res; _ }, _, _) -> (
32-
let desc = Types.get_desc cstr_res in
33-
match desc with
34-
| Types.Tconstr (p, _, _) ->
35-
poses := (Constructor p, pat_loc) :: !poses
36-
| _ -> ())
37-
| _ -> ()
38-
in
3922
let maybe_localvalue id loc =
4023
match Ident_env.identifier_of_loc env loc with
4124
| None -> Some (LocalDefinition id, loc)

src/model/lang.ml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ module Source_info = struct
3434
| ClassType of Path.ClassType.t jump_to
3535
| ModuleType of Path.ModuleType.t jump_to
3636
| Type of Path.Type.t jump_to
37-
| Constructor of Path.Constructor.t jump_to
3837

3938
type 'a with_pos = 'a * (int * int)
4039

src/xref2/compile.ml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ and source_info_infos env infos =
9191
| Module v -> Module (map_doc (module_path env) v)
9292
| ModuleType v -> ModuleType (map_doc (module_type_path env) v)
9393
| Type v -> Type (map_doc (type_path env) v)
94-
| Constructor v -> Constructor (map_doc (constructor_path env) v)
9594
| ClassType v -> ClassType (map_doc (class_type_path env) v)
9695
| Definition _ as d -> d
9796
in

src/xref2/link.ml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -421,9 +421,6 @@ let rec unit env t =
421421
(jump_to v
422422
(Shape_tools.lookup_type_path env)
423423
(type_path env))
424-
| Constructor v ->
425-
Constructor
426-
(jump_to v (fun _ -> None) (constructor_path env))
427424
| ClassType v ->
428425
ClassType
429426
(jump_to v

src/xref2/tools.ml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,29 @@ and lookup_type_gpath :
830830
in
831831
res
832832

833+
and lookup_value_gpath :
834+
Env.t ->
835+
Odoc_model.Paths.Path.Resolved.Value.t ->
836+
(Find.value, simple_value_lookup_error) Result.result =
837+
fun env p ->
838+
let do_value p name =
839+
lookup_parent_gpath ~mark_substituted:true env p
840+
|> map_error (fun e -> (e :> simple_value_lookup_error))
841+
>>= fun (sg, sub) ->
842+
match Find.value_in_sig sg name with
843+
| `FValue (name, t) :: _ -> Ok (`FValue (name, Subst.value sub t))
844+
| [] -> Error `Find_failure
845+
in
846+
let res =
847+
match p with
848+
| `Identifier ({ iv = `Value _; _ } as i) ->
849+
of_option ~error:(`Lookup_failureV i) (Env.(lookup_by_id s_value) i env)
850+
>>= fun (`Value ({ iv = `Value (_, name); _ }, t)) ->
851+
Ok (`FValue (name, t))
852+
| `Value (p, id) -> do_value p (ValueName.to_string id)
853+
in
854+
res
855+
833856
and lookup_class_type_gpath :
834857
Env.t ->
835858
Odoc_model.Paths.Path.Resolved.ClassType.t ->

0 commit comments

Comments
 (0)