Soilihi BEN SOILIHI BOINA pushed to branch soilih at Stefan / Typer
Commits: dd13976d by Soilih BEN SOILIH at 2021-12-26T23:34:06-05:00 adding ctx and fixing line numbers in hover
- - - - -
1 changed file:
- src/typer_lsp_server.ml
Changes:
===================================== src/typer_lsp_server.ml ===================================== @@ -837,7 +837,7 @@ let def_loc_search (ctx : Debruijn.lexp_context) (v: vref) = | [] -> rlst | ((_, Some s) as vne, _, _)::tl -> if String.equal s str then - foo tl (comp + 1) str ((Some (vne,comp))::rlst) + foo tl (comp + 1) str ((Some (lctx,vne,comp))::rlst) else foo tl (comp + 1) str rlst | _::tl -> foo tl (comp + 1) str rlst in foo lctx_l 0 str [] @@ -858,23 +858,23 @@ let rec browse_defs (ctx:Debruijn.lexp_context) (e:Lexp.lexp) (cursor:Source.Loc | Sort (_, StypeOmega) -> None | Builtin (_, t) -> None | Var (vn, idx) - -> Some (vn,idx) + -> Some (ctx, vn,idx) | Susp (e, s) -> None | Let (l, defs, e) -> let ctx' = List.fold_left (fun ctx (v, _e, t) -> (Debruijn.lctx_extend ctx v ForwardRef t)) ctx defs in - let rec foo (ctx_list:Debruijn.env_elem list) cursor comp = + let rec foo ctx' (ctx_list:Debruijn.env_elem list) cursor comp = match ctx_list with | [] -> failwith "No Variable in the cursor" | ((l, (Some vn) as v),_,_)::tl - -> if (vn_on_the_cursor v cursor) then Some (v,comp) - else foo tl cursor (comp + 1) - | _::tl -> foo tl cursor (comp + 1) + -> if (vn_on_the_cursor v cursor) then Some (ctx',v,comp) + else foo ctx' tl cursor (comp + 1) + | _::tl -> foo ctx' tl cursor (comp + 1) in let ctx_list = Myers.list ctx' in - foo ctx_list cursor 0 + foo ctx' ctx_list cursor 0
| Arrow (ak, v, t1, l, t2) -> None @@ -1423,7 +1423,14 @@ class lsp_server = let (l_ctx_r,_,_,_) as ret = browse_lexp lctx lexp typer_loc in let ret' = (l_ctx_r,None,ltyp,lvn) in let (l_ctx,_,l_type,location) = browse_list_lexp [ret;ret'] typer_loc in - let range = lsp_range_of_loc location in + let location' = { + location + with + start_line = location.start_line - 1; + end_line = location.end_line - 1 + } + in + let range = lsp_range_of_loc location' in let s = try use_search_name_in_ctx l_ctx l_type with exe -> Lexp.lexp_string_for_lsp l_type in
View it on GitLab: https://gitlab.com/monnier/typer/-/commit/dd13976d45936915f1cd9fb9446af0b22a...