Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(lsp): Add Inlay types #2005

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
chore: Apply suggestions from code review
  • Loading branch information
spotandjake committed Oct 4, 2024
commit 04048dea47b647a4e7588539a430dd89b81b7ed0
32 changes: 13 additions & 19 deletions compiler/src/language_server/inlayhint.re
Original file line number Diff line number Diff line change
Expand Up @@ -118,25 +118,19 @@ let find_hints = (~toggle_type_hints: bool, program) => {
};

let enter_binding = ({vb_pat, vb_expr}: value_binding, toplevel: bool) =>
if (!toplevel) {
switch (vb_pat.pat_extra) {
| [] =>
if (toggle_type_hints) {
switch (vb_pat.pat_desc) {
| TPatVar(_, {loc}) =>
let bind_end = loc.loc_end;
let p: Protocol.position = {
line: bind_end.pos_lnum - 1,
character: bind_end.pos_cnum - bind_end.pos_bol,
};
let typ = vb_pat.pat_type;
if (!is_func_typ(typ)) {
let typeSignature = string_of_typ(typ);
hints := [build_hint(p, typeSignature), ...hints^];
};
| _ => ()
};
}
if (!toplevel && toggle_type_hints) {
switch (vb_pat) {
| {pat_extra: [], pat_desc: TPatVar(_, {loc})} =>
let bind_end = loc.loc_end;
let p: Protocol.position = {
line: bind_end.pos_lnum - 1,
character: bind_end.pos_cnum - bind_end.pos_bol,
};
let typ = vb_pat.pat_type;
if (!is_func_typ(typ)) {
let typeSignature = string_of_typ(typ);
hints := [build_hint(p, typeSignature), ...hints^];
};
| _ => ()
};
};
Expand Down