this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: add constructor references to source linking

Add handling for Texp_construct and Tpat_construct in the typedtree
traversal. Constructor references (e.g. Some, None, pattern variants)
are linked to their parent type definition by extracting the type path
from the constructor_description's result type.

Uses Approach A from the investigation — links to the parent type
rather than creating synthetic constructor-specific anchors.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

+18
+18
src/loader/typedtree_traverse.cppo.ml
··· 8 8 | ModuleType of Path.t 9 9 | Type of Path.t 10 10 11 + (** Extract the type path from a constructor_description's result type. *) 12 + let type_path_of_constructor_desc (cstr : Types.constructor_description) = 13 + match Types.get_desc cstr.cstr_res with 14 + | Tconstr (p, _, _) -> Some p 15 + | _ -> None 16 + 11 17 let expr poses expr = 12 18 let exp_loc = expr.Typedtree.exp_loc in 13 19 if exp_loc.loc_ghost then () ··· 19 25 | Texp_ident (p, _, _) -> 20 26 #endif 21 27 poses := (Value p, exp_loc) :: !poses 28 + #if defined OXCAML 29 + | Texp_construct (_, cstr_desc, _, _) -> ( 30 + #else 31 + | Texp_construct (_, cstr_desc, _) -> ( 32 + #endif 33 + match type_path_of_constructor_desc cstr_desc with 34 + | Some p -> poses := (Type p, exp_loc) :: !poses 35 + | None -> ()) 22 36 | _ -> () 23 37 24 38 let pat env (type a) poses : a Typedtree.general_pattern -> unit = function ··· 51 65 #endif 52 66 match maybe_localvalue id loc.loc with 53 67 | Some x -> poses := x :: !poses 68 + | None -> ()) 69 + | Tpat_construct (_, cstr_desc, _, _) -> ( 70 + match type_path_of_constructor_desc cstr_desc with 71 + | Some p -> poses := (Type p, pat_loc) :: !poses 54 72 | None -> ()) 55 73 | _ -> () 56 74 in