this repo has no description
1
fork

Configure Feed

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

feat: add open/include tracking to source linking

Add handling for open and include statements in the typedtree traversal:
- open_declaration: open statements in structures (e.g. open List)
- open_description: open statements in signatures (e.g. open List)
- Tstr_include: include statements in structures (e.g. include List)
- Tsig_include: include statements in signatures (e.g. include S)

These are linked as Module references, reusing the existing annotation
type. Only simple module path includes are handled (Tmod_ident for
structures, Tmty_ident for signatures); complex module expressions
in include statements are not linked.

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

+56
+56
src/loader/typedtree_traverse.cppo.ml
··· 124 124 when not ctyp_loc.loc_ghost -> 125 125 poses := (Type p, ctyp_loc) :: !poses 126 126 | _ -> () 127 + 128 + let open_declaration poses (od : Typedtree.open_declaration) = 129 + if not od.open_loc.loc_ghost then 130 + match od.open_expr with 131 + | { mod_desc = Tmod_ident (p, _); _ } -> 132 + poses := (Module p, od.open_loc) :: !poses 133 + | _ -> () 134 + 135 + let open_description poses (od : Typedtree.open_description) = 136 + if not od.open_loc.loc_ghost then 137 + let (p, _) = od.open_expr in 138 + poses := (Module p, od.open_loc) :: !poses 139 + 140 + let structure_item poses (item : Typedtree.structure_item) = 141 + if not item.str_loc.loc_ghost then 142 + match item.str_desc with 143 + | Tstr_include incl -> ( 144 + match incl.incl_mod with 145 + | { mod_desc = Tmod_ident (p, _); _ } -> 146 + poses := (Module p, incl.incl_loc) :: !poses 147 + | _ -> ()) 148 + | _ -> () 149 + 150 + let signature_item poses (item : Typedtree.signature_item) = 151 + if not item.sig_loc.loc_ghost then 152 + match item.sig_desc with 153 + #if defined OXCAML 154 + | Tsig_include (incl, _) -> ( 155 + #else 156 + | Tsig_include incl -> ( 157 + #endif 158 + match incl.incl_mod with 159 + | { mty_desc = Tmty_ident (p, _); _ } -> 160 + poses := (Module p, incl.incl_loc) :: !poses 161 + | _ -> ()) 162 + | _ -> () 127 163 end 128 164 129 165 let of_cmt env structure = ··· 153 189 Analysis.module_binding env poses mb; 154 190 iter.module_binding iterator mb 155 191 in 192 + let open_declaration iterator od = 193 + Analysis.open_declaration poses od; 194 + iter.open_declaration iterator od 195 + in 196 + let open_description iterator od = 197 + Analysis.open_description poses od; 198 + iter.open_description iterator od 199 + in 200 + let structure_item iterator item = 201 + Analysis.structure_item poses item; 202 + iter.structure_item iterator item 203 + in 204 + let signature_item iterator item = 205 + Analysis.signature_item poses item; 206 + iter.signature_item iterator item 207 + in 156 208 let iterator = 157 209 { 158 210 iter with ··· 162 214 typ; 163 215 module_type; 164 216 module_binding; 217 + open_declaration; 218 + open_description; 219 + structure_item; 220 + signature_item; 165 221 } 166 222 in 167 223 iterator.structure iterator structure;