Soilihi BEN SOILIHI BOINA pushed to branch wop-server at Stefan / Typer
Commits: e743b867 by Soilih at 2022-07-18T12:01:25-04:00 -
- - - - -
1 changed file:
- src/typer_lsp_server.ml
Changes:
===================================== src/typer_lsp_server.ml ===================================== @@ -997,22 +997,50 @@ let browse_list_defs (tab : Source.Location.t list) (cursor:Source.Location.t) = browse_defs lxp cursor) args None))
| Inductive (l, _label, args, cases) - (*(Lexp.arg_kind * vname * Lexp.lexp) list SMap.t*) - -> let (_, lst) = List.hd (SMap.bindings cases) in + -> let lst = SMap.bindings cases in let rec foo cursor lst = match lst with | [] -> failwith "cursor is not on a vdef" - | (_, vn, lxp)::tl - -> if (vn_on_the_cursor vn cursor) then Some (lxp, vn, List.length tl) + | (_, ls)::tl + -> (let rec foo' cursor ls comp = + match ls with + | [] -> foo cursor tl + | (_, vn, _)::tail + -> let ldum = Source.Location.dummy in + let mySmap = SMap.empty in + let tl_map = SMap.add "nokey" tail mySmap in + let lxp = Lexp.mkInductive + (ldum, (ldum, ""), tail, tl_map) + in + if (vn_on_the_cursor vn cursor) then Some (lxp, vn, -comp) + else( + let ret = browse_defs lxp cursor in + match ret with + | Some _ -> ret + | None -> foo' cursor tail (comp + 1)) + in foo' cursor ls 0 + ) + in + let rec foo2 cursor args comp = + match args with + | [] -> failwith "cursor is not on a vdef" + | (_, vn, _)::tl + -> let ldum = Source.Location.dummy in + let mySmap = SMap.empty in + let tl_map = SMap.add "nokey" tl mySmap in + let lxp = Lexp.mkInductive + (ldum, (ldum, ""), tl, tl_map) + in + if (vn_on_the_cursor vn cursor) then Some (lxp, vn, -comp) else( let ret = browse_defs lxp cursor in match ret with | Some _ -> ret - | None -> foo cursor tl) - in + | None -> foo2 cursor tl (comp + 1)) + in ( try foo cursor lst - with _ -> foo cursor args + with _ -> foo2 cursor args 0 ) | Proj (_, e, (_, _)) -> browse_defs e cursor | Case (_, e, _, branches, _)
View it on GitLab: https://gitlab.com/monnier/typer/-/commit/e743b86711314671dab2e959e57776c217...