this repo has no description

Occurrences: add shapes for other nodes, improve test

Signed-off-by: Paul-Elliot <peada@free.fr>

authored by

Paul-Elliot and committed by jon.recoil.org 22248aad e62ad5b9

+73 -21
+7 -2
src/xref2/link.ml
··· 565 | ModuleType v -> 566 ModuleType 567 (jump_to v 568 - (fun _ -> None) 569 (module_type_path ~report_errors:false env)) 570 | Type v -> 571 Type 572 (jump_to v 573 - (fun _ -> None) 574 (type_path ~report_errors:false env)) 575 | Constructor v -> 576 Constructor 577 (jump_to v 578 (fun _ -> None) 579 (constructor_path ~report_errors:false env)) 580 | i -> i 581 in 582 (info, pos))
··· 565 | ModuleType v -> 566 ModuleType 567 (jump_to v 568 + (Shape_tools.lookup_module_type_path env) 569 (module_type_path ~report_errors:false env)) 570 | Type v -> 571 Type 572 (jump_to v 573 + (Shape_tools.lookup_type_path env) 574 (type_path ~report_errors:false env)) 575 | Constructor v -> 576 Constructor 577 (jump_to v 578 (fun _ -> None) 579 (constructor_path ~report_errors:false env)) 580 + | ClassType v -> 581 + ClassType 582 + (jump_to v 583 + (Shape_tools.lookup_class_type_path env) 584 + (class_type_path ~report_errors:false env)) 585 | i -> i 586 in 587 (info, pos))
+22 -18
src/xref2/shape_tools.cppo.ml
··· 81 | `Identifier (id, _) -> 82 shape_of_id env (id :> Odoc_model.Paths.Identifier.NonSrc.t) 83 84 - let shape_of_value_path env : 85 - Odoc_model.Paths.Path.Value.t -> Shape.t option = 86 let proj parent kind name = 87 let item = Shape.Item.make name kind in 88 match shape_of_module_path env parent with 89 | Some shape -> Some (Shape.proj shape item) 90 | None -> None 91 in 92 - fun (path : Odoc_model.Paths.Path.Value.t) -> 93 match path with 94 | `Resolved _ -> None 95 - | `Dot (parent, name) -> proj parent Kind.Value name 96 | `Identifier (id, _) -> shape_of_id env (id :> Odoc_model.Paths.Identifier.NonSrc.t) 97 - 98 99 module MkId = Identifier.Mk 100 ··· 151 | None -> None 152 | Some query -> lookup_shape env query 153 154 - let lookup_value_path : 155 - Env.t -> 156 - Path.Value.t -> 157 - Identifier.SourceLocation.t option 158 - = fun env path -> 159 - match shape_of_value_path env path with 160 | None -> None 161 | Some query -> lookup_shape env query 162 163 - 164 - let lookup_module_path : 165 - Env.t -> 166 - Path.Module.t -> 167 - Identifier.SourceLocation.t option 168 - = fun env path -> 169 - match shape_of_module_path env path with 170 | None -> None 171 | Some query -> lookup_shape env query 172 173 #else 174 175 type t = unit ··· 179 let lookup_value_path _ _id = None 180 181 let lookup_module_path _ _id = None 182 183 #endif
··· 81 | `Identifier (id, _) -> 82 shape_of_id env (id :> Odoc_model.Paths.Identifier.NonSrc.t) 83 84 + let shape_of_kind_path env kind : 85 + _ -> Shape.t option = 86 let proj parent kind name = 87 let item = Shape.Item.make name kind in 88 match shape_of_module_path env parent with 89 | Some shape -> Some (Shape.proj shape item) 90 | None -> None 91 in 92 + fun path -> 93 match path with 94 | `Resolved _ -> None 95 + | `Dot (parent, name) -> proj parent kind name 96 | `Identifier (id, _) -> shape_of_id env (id :> Odoc_model.Paths.Identifier.NonSrc.t) 97 98 module MkId = Identifier.Mk 99 ··· 150 | None -> None 151 | Some query -> lookup_shape env query 152 153 + let lookup_module_path = fun env path -> 154 + match shape_of_module_path env path with 155 | None -> None 156 | Some query -> lookup_shape env query 157 158 + let lookup_kind_path = fun kind env path -> 159 + match shape_of_kind_path env kind path with 160 | None -> None 161 | Some query -> lookup_shape env query 162 163 + let lookup_value_path = lookup_kind_path Kind.Value 164 + 165 + let lookup_type_path = lookup_kind_path Kind.Type 166 + 167 + let lookup_module_type_path = lookup_kind_path Kind.Module_type 168 + 169 + let lookup_class_type_path = lookup_kind_path Kind.Class_type 170 + 171 #else 172 173 type t = unit ··· 177 let lookup_value_path _ _id = None 178 179 let lookup_module_path _ _id = None 180 + 181 + let lookup_type_path _ _id = None 182 + 183 + let lookup_module_type_path _ _id = None 184 + 185 + let lookup_class_type_path _ _id = None 186 187 #endif
+16
src/xref2/shape_tools.cppo.mli
··· 19 Path.Value.t -> 20 Identifier.SourceLocation.t option 21 22 val lookup_module_path : 23 Env.t -> 24 Path.Module.t -> 25 Identifier.SourceLocation.t option
··· 19 Path.Value.t -> 20 Identifier.SourceLocation.t option 21 22 + val lookup_type_path : 23 + Env.t -> 24 + Path.Type.t -> 25 + Identifier.SourceLocation.t option 26 + 27 val lookup_module_path : 28 Env.t -> 29 Path.Module.t -> 30 Identifier.SourceLocation.t option 31 + 32 + val lookup_module_type_path : 33 + Env.t -> 34 + Path.ModuleType.t -> 35 + Identifier.SourceLocation.t option 36 + 37 + val lookup_class_type_path : 38 + Env.t -> 39 + Path.ClassType.t -> 40 + Identifier.SourceLocation.t option 41 +
+2
test/occurrences/double_wrapped.t/a.ml
··· 5 module type M = sig end 6 7 let (||>) x y = x + y
··· 5 module type M = sig end 6 7 let (||>) x y = x + y 8 + 9 + let _ = x + x
+26 -1
test/occurrences/double_wrapped.t/run.t
··· 119 120 $ odoc count-occurrences -I main__A -o occurrences.txt --include-own --include-hidden 121 $ occurrences_print occurrences.txt | sort 122 string was used directly 1 times and indirectly 0 times 123 124 $ odoc count-occurrences -I . -o occurrences.txt --include-own ··· 160 Main__ was used directly 0 times and indirectly 2 times 161 Main__.C was used directly 1 times and indirectly 1 times 162 Main__.C.y was used directly 1 times and indirectly 0 times 163 - Main__A was used directly 1 times and indirectly 0 times 164 Main__B was used directly 1 times and indirectly 1 times 165 Main__B.Z was used directly 0 times and indirectly 1 times 166 Main__B.Z.y was used directly 1 times and indirectly 0 times 167 Main__C was used directly 1 times and indirectly 0 times 168 string was used directly 1 times and indirectly 0 times
··· 119 120 $ odoc count-occurrences -I main__A -o occurrences.txt --include-own --include-hidden 121 $ occurrences_print occurrences.txt | sort 122 + Main__A was used directly 0 times and indirectly 2 times 123 + Main__A.x was used directly 2 times and indirectly 0 times 124 string was used directly 1 times and indirectly 0 times 125 126 $ odoc count-occurrences -I . -o occurrences.txt --include-own ··· 162 Main__ was used directly 0 times and indirectly 2 times 163 Main__.C was used directly 1 times and indirectly 1 times 164 Main__.C.y was used directly 1 times and indirectly 0 times 165 + Main__A was used directly 1 times and indirectly 2 times 166 + Main__A.x was used directly 2 times and indirectly 0 times 167 Main__B was used directly 1 times and indirectly 1 times 168 Main__B.Z was used directly 0 times and indirectly 1 times 169 Main__B.Z.y was used directly 1 times and indirectly 0 times 170 Main__C was used directly 1 times and indirectly 0 times 171 string was used directly 1 times and indirectly 0 times 172 + 173 + 174 + REMARKS! 175 + 176 + $ odoc count-occurrences -I main__B -o b_only_persistent.occ 177 + $ odoc count-occurrences -I main__B -o b_with_own.occ --include-own 178 + $ occurrences_print b_only_persistent.occ | sort > only_persistent 179 + $ occurrences_print b_with_own.occ | sort > with_own 180 + $ diff only_persistent with_own | grep Main.A.x 181 + < Main.A.x was used directly 1 times and indirectly 0 times 182 + > Main.A.x was used directly 2 times and indirectly 0 times 183 + 184 + This is because the persistent Y.x is resolved into Main.A.x. So maybe relying 185 + on Ident.persistent is not the good way of knowing if it is persistent or not? 186 + 187 + $ odoc count-occurrences -I main__A -o a_with_own_and_hidden.occ --include-own --include-hidden 188 + $ occurrences_print a_with_own_and_hidden.occ | sort 189 + Main__A was used directly 0 times and indirectly 2 times 190 + Main__A.x was used directly 2 times and indirectly 0 times 191 + string was used directly 1 times and indirectly 0 times 192 + 193 + That's a problem: it should be Main.A and Main.A.x