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: Disable type hints for functions.
  • Loading branch information
spotandjake committed Oct 4, 2024
commit da038be28fa3d2b66cb448a99be4819fca35ce6b
15 changes: 12 additions & 3 deletions compiler/src/language_server/inlayhint.re
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,17 @@ let rec resolve_typ = (typ: Types.type_expr) => {
| _ => typ
};
};
let rec string_of_typ = (typ: Types.type_expr) => {
let string_of_typ = (typ: Types.type_expr) => {
Printtyp.string_of_type_scheme(resolve_typ(typ));
};

let is_func_typ = (typ: Types.type_expr) => {
switch (resolve_typ(typ).desc) {
| TTyArrow(_, _, _) => true
| _ => false
};
};

let find_hints = program => {
let hints = ref([]);
open Typedtree;
Expand Down Expand Up @@ -119,8 +126,10 @@ let find_hints = program => {
character: bind_end.pos_cnum - bind_end.pos_bol,
};
let typ = vb_pat.pat_type;
let typeSignature = string_of_typ(typ);
hints := [build_hint(p, typeSignature), ...hints^];
if (!is_func_typ(typ)) {
let typeSignature = string_of_typ(typ);
hints := [build_hint(p, typeSignature), ...hints^];
};
| _ => ()
}
| _ => ()
Expand Down