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: Simplify Function inlays
  • Loading branch information
spotandjake committed Oct 4, 2024
commit 1a5872ab485fc05b23c4c0ffc03975af7899ecb4
13 changes: 11 additions & 2 deletions compiler/src/language_server/inlayhint.re
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ let build_hint =
{label: ": " ++ message, position};
};

let rec string_of_typ = (typ: Types.type_expr) => {
switch (typ.desc) {
| TTyArrow(_, _, _) => "Function"
| TTyLink(type_expr)
| TTySubst(type_expr) => string_of_typ(type_expr)
| _ => Printtyp.string_of_type_scheme(typ)
};
};

let find_hints = program => {
let hints = ref([]);
open Typedtree;
Expand Down Expand Up @@ -72,8 +81,8 @@ let find_hints = program => {
line: bind_end.pos_lnum - 1,
character: bind_end.pos_cnum - bind_end.pos_bol,
};
let typeSignature =
Printtyp.string_of_type_scheme(vb_pat.pat_type);
let typ = vb_pat.pat_type;
let typeSignature = string_of_typ(typ);
hints := [build_hint(p, typeSignature), ...hints^];
| _ => ()
}
Expand Down