@@ -56,7 +56,7 @@ let is_func_typ = (typ: Types.type_expr) => {
56
56
};
57
57
};
58
58
59
- let find_hints = (~toggle_type_hints : bool , program) => {
59
+ let find_hints = program => {
60
60
let hints = ref ([] );
61
61
open Typedtree ;
62
62
open Protocol ;
@@ -65,57 +65,53 @@ let find_hints = (~toggle_type_hints: bool, program) => {
65
65
include TypedtreeIter . DefaultIteratorArgument ;
66
66
67
67
let enter_expression = ({exp_desc, exp_type}: expression ) =>
68
- if (toggle_type_hints) {
69
- switch (exp_desc) {
70
- | TExpLambda (bindings , _ ) =>
71
- List . iter(
72
- ({mb_pat, mb_loc}: match_branch ) => {
73
- switch (mb_pat. pat_desc) {
74
- | TPatTuple (args ) =>
75
- switch (resolve_typ(exp_type).desc) {
76
- | TTyArrow (typ_args , _ , _ ) =>
77
- let argument_typs =
78
- List . map(
79
- ((arg, typ: Types . type_expr )) =>
80
- switch (arg) {
81
- | Default (_ ) => None
82
- | _ => Some (typ)
83
- },
84
- typ_args,
85
- );
86
- w;
87
- if (List . length(argument_typs) == List . length(args)) {
88
- List . iter(
89
- ((arg: pattern , typ: option (Types . type_expr ))) => {
90
- switch (arg. pat_desc, typ) {
91
- | (TPatVar (_ , _ ), Some (typ )) =>
92
- let bind_end = arg. pat_loc. loc_end;
93
- let p : Protocol . position = {
94
- line: bind_end. pos_lnum - 1 ,
95
- character: bind_end. pos_cnum - bind_end. pos_bol,
96
- };
97
- let typeSignature = string_of_typ(typ);
98
- hints :=
99
- [ build_hint(p, typeSignature), ... hints^ ] ;
100
- | _ => ()
101
- }
68
+ switch (exp_desc) {
69
+ | TExpLambda (bindings , _ ) =>
70
+ List . iter(
71
+ ({mb_pat, mb_loc}: match_branch ) => {
72
+ switch (mb_pat. pat_desc) {
73
+ | TPatTuple (args ) =>
74
+ switch (resolve_typ(exp_type).desc) {
75
+ | TTyArrow (typ_args , _ , _ ) =>
76
+ let argument_typs =
77
+ List . map(
78
+ ((arg, typ: Types . type_expr )) =>
79
+ switch (arg) {
80
+ | Default (_ ) => None
81
+ | _ => Some (typ)
102
82
},
103
- List . combine(args, argument_typs),
104
- );
105
- };
106
- | _ => ()
107
- }
83
+ typ_args,
84
+ );
85
+ if (List . length(argument_typs) == List . length(args)) {
86
+ List . iter(
87
+ ((arg: pattern , typ: option (Types . type_expr ))) => {
88
+ switch (arg. pat_desc, typ) {
89
+ | (TPatVar (_ , _ ), Some (typ )) =>
90
+ let bind_end = arg. pat_loc. loc_end;
91
+ let p : Protocol . position = {
92
+ line: bind_end. pos_lnum - 1 ,
93
+ character: bind_end. pos_cnum - bind_end. pos_bol,
94
+ };
95
+ let typeSignature = string_of_typ(typ);
96
+ hints := [ build_hint(p, typeSignature), ... hints^ ] ;
97
+ | _ => ()
98
+ }
99
+ },
100
+ List . combine(args, argument_typs),
101
+ );
102
+ };
108
103
| _ => ()
109
104
}
110
- },
111
- bindings,
112
- )
113
- | _ => ()
114
- };
105
+ | _ => ()
106
+ }
107
+ },
108
+ bindings,
109
+ )
110
+ | _ => ()
115
111
};
116
112
117
113
let enter_binding = ({vb_pat, vb_expr}: value_binding , toplevel: bool ) =>
118
- if (! toplevel && toggle_type_hints ) {
114
+ if (! toplevel) {
119
115
switch (vb_pat) {
120
116
| {pat_extra: [] , pat_desc: TPatVar (_ , {loc})} =>
121
117
let bind_end = loc. loc_end;
@@ -141,14 +137,13 @@ let process =
141
137
~id: Protocol . message_id ,
142
138
~compiled_code: Hashtbl . t (Protocol . uri , code ),
143
139
~documents: Hashtbl . t (Protocol . uri , string ),
144
- ~toggle_type_hints: bool ,
145
140
params: RequestParams . t ,
146
141
) => {
147
142
Trace . log("Inlay hint request received" );
148
143
switch (Hashtbl . find_opt(compiled_code, params. text_document. uri)) {
149
144
| None => send_no_result(~id)
150
145
| Some ({program, sourcetree}) =>
151
- let hints = find_hints(~toggle_type_hints , program);
146
+ let hints = find_hints(program);
152
147
Protocol . response(~id, ResponseResult . to_yojson(hints));
153
148
};
154
149
};
0 commit comments