@@ -3,37 +3,39 @@ let print_string json =
33let print_null () = `Null |> print_string
44let print_list l = `List l |> print_string
55
6- let completion ~debug ~path ~pos ~current_file =
7- let full = Cmt. load_full_cmt_from_path ~path in
6+ let completion ~state ~ debug ~path ~pos ~current_file =
7+ let full = Cmt. load_full_cmt_from_path ~state ~ path in
88 let kind_file = Files. classify_source_file current_file in
99 match Files. read_file current_file with
1010 | None | Some "" -> print_null ()
1111 | Some source ->
12- Commands. completion ~debug ~source ~kind_file ~pos ~full
12+ Commands. completion ~state ~ debug ~source ~kind_file ~pos ~full
1313 |> List. map (fun c -> Lsp.Types.CompletionItem. yojson_of_t c)
1414 |> print_list
1515
16- let completion_resolve ~path ~module_path =
17- let full = Cmt. load_full_cmt_from_path ~path in
18- match Commands. completion_resolve ~full ~module_path with
16+ let completion_resolve ~state ~ path ~module_path =
17+ let full = Cmt. load_full_cmt_from_path ~state ~ path in
18+ match Commands. completion_resolve ~state ~ full ~module_path with
1919 | None -> print_null ()
2020 | Some (`MarkupContent {value} ) -> `String value |> print_string
2121
22- let inlayhint ~path ~pos ~max_length ~debug =
23- let full = Cmt. load_full_cmt_from_path ~path in
22+ let inlayhint ~state ~ path ~pos ~max_length ~debug =
23+ let full = Cmt. load_full_cmt_from_path ~state ~ path in
2424 let kind_file = Files. classify_source_file path in
2525 match Files. read_file path with
2626 | None -> print_null ()
2727 | Some source -> (
28- match Hint. inlay ~source ~kind_file ~pos ~max_length ~full ~debug with
28+ match
29+ Hint. inlay ~source ~kind_file ~pos ~max_length ~full ~state ~debug
30+ with
2931 | Some hints ->
3032 hints
3133 |> List. map (fun h -> Lsp.Types.InlayHint. yojson_of_t h)
3234 |> print_list
3335 | None -> print_null () )
3436
35- let code_lens ~path ~debug =
36- let full = Cmt. load_full_cmt_from_path ~path in
37+ let code_lens ~state ~ path ~debug =
38+ let full = Cmt. load_full_cmt_from_path ~state ~ path in
3739 let kind_file = Files. classify_source_file path in
3840 match Files. read_file path with
3941 | None -> print_null ()
@@ -43,68 +45,68 @@ let code_lens ~path ~debug =
4345 lens |> List. map (fun l -> Lsp.Types.CodeLens. yojson_of_t l) |> print_list
4446 | None -> print_null () )
4547
46- let hover ~path ~pos ~current_file ~debug ~supports_markdown_links =
47- let full = Cmt. load_full_cmt_from_path ~path in
48+ let hover ~state ~ path ~pos ~current_file ~debug ~supports_markdown_links =
49+ let full = Cmt. load_full_cmt_from_path ~state ~ path in
4850 let kind_file = Files. classify_source_file current_file in
4951 match Files. read_file current_file with
5052 | None -> print_null ()
5153 | Some source -> (
5254 match
5355 Commands. hover ~source ~kind_file ~pos ~debug ~supports_markdown_links
54- ~full
56+ ~state ~ full
5557 with
5658 | Some value -> Lsp.Types.Hover. yojson_of_t value |> print_string
5759 | None -> print_null () )
5860
59- let signature_help ~path ~pos ~current_file ~debug
61+ let signature_help ~state ~ path ~pos ~current_file ~debug
6062 ~allow_for_constructor_payloads =
61- let full = Cmt. load_full_cmt_from_path ~path in
63+ let full = Cmt. load_full_cmt_from_path ~state ~ path in
6264 let kind_file = Files. classify_source_file current_file in
6365 match Files. read_file current_file with
6466 | None -> print_null ()
6567 | Some source -> (
6668 match
67- Signature_help . signature_help ~source ~kind_file ~pos
68- ~allow_for_constructor_payloads ~full ~debug
69+ Commands . signature_help ~source ~kind_file ~pos
70+ ~allow_for_constructor_payloads ~full ~state ~ debug
6971 with
7072 | None -> print_null ()
7173 | Some s -> Lsp.Types.SignatureHelp. yojson_of_t s |> print_string)
7274
73- let code_action ~path ~start_pos ~end_pos ~current_file ~debug =
75+ let code_action ~state ~ path ~start_pos ~end_pos ~current_file ~debug =
7476 let kind_file = Files. classify_source_file current_file in
7577 match Files. read_file current_file with
7678 | None -> print_null ()
7779 | Some source ->
78- Xform. extract_code_actions ~path ~start_pos ~end_pos ~source ~kind_file
79- ~debug
80+ Xform. extract_code_actions ~state ~ path ~start_pos ~end_pos ~source
81+ ~kind_file ~ debug
8082 |> List. map (fun c -> Lsp.Types.CodeAction. yojson_of_t c)
8183 |> print_list
8284
83- let definition ~path ~pos ~debug =
84- let full = Cmt. load_full_cmt_from_path ~path in
85+ let definition ~state ~ path ~pos ~debug =
86+ let full = Cmt. load_full_cmt_from_path ~state ~ path in
8587
86- match Commands. definition ~full ~pos ~debug with
88+ match Commands. definition ~state ~ full ~pos ~debug with
8789 | None -> print_null ()
8890 | Some location -> location |> Lsp.Types.Location. yojson_of_t |> print_string
8991
90- let type_definition ~path ~pos ~debug =
91- let full = Cmt. load_full_cmt_from_path ~path in
92- match Commands. type_definition ~full ~pos ~debug with
92+ let type_definition ~state ~ path ~pos ~debug =
93+ let full = Cmt. load_full_cmt_from_path ~state ~ path in
94+ match Commands. type_definition ~state ~ full ~pos ~debug with
9395 | None -> print_null ()
9496 | Some location -> location |> Lsp.Types.Location. yojson_of_t |> print_string
9597
96- let references ~path ~pos ~debug =
97- let full = Cmt. load_full_cmt_from_path ~path in
98- let all_locs = Commands. references ~full ~pos ~debug in
98+ let references ~state ~ path ~pos ~debug =
99+ let full = Cmt. load_full_cmt_from_path ~state ~ path in
100+ let all_locs = Commands. references ~state ~ full ~pos ~debug in
99101 if all_locs = [] then print_null ()
100102 else
101103 all_locs
102104 |> List. map (fun l -> Lsp.Types.Location. yojson_of_t l)
103105 |> print_list
104106
105- let rename ~path ~pos ~new_name ~debug =
106- let full = Cmt. load_full_cmt_from_path ~path in
107- match Commands. rename ~full ~pos ~new_name ~debug with
107+ let rename ~state ~ path ~pos ~new_name ~debug =
108+ let full = Cmt. load_full_cmt_from_path ~state ~ path in
109+ match Commands. rename ~state ~ full ~pos ~new_name ~debug with
108110 | Some {documentChanges = Some document_changes } ->
109111 document_changes
110112 |> List. map (fun c ->
@@ -116,8 +118,8 @@ let rename ~path ~pos ~new_name ~debug =
116118 |> print_list
117119 | _ -> print_null ()
118120
119- let prepare_rename ~path ~pos ~debug =
120- let full = Cmt. load_full_cmt_from_path ~path in
121+ let prepare_rename ~state ~ path ~pos ~debug =
122+ let full = Cmt. load_full_cmt_from_path ~state ~ path in
121123 match Commands. prepare_rename ~full ~pos ~debug with
122124 | None -> print_null ()
123125 | Some {range; placeholder = None } ->
@@ -159,7 +161,7 @@ let semantic_tokens ~path =
159161 let tokens = Semantic_tokens. semantic_tokens ~source ~kind_file in
160162 Lsp.Types.SemanticTokens. yojson_of_t tokens |> print_string
161163
162- let test ~path =
164+ let test ~state ~ path =
163165 Uri. strip_path := true ;
164166 match Files. read_file path with
165167 | None -> assert false
@@ -224,19 +226,19 @@ let test ~path =
224226 print_endline
225227 (" Definition " ^ path ^ " " ^ string_of_int line ^ " :"
226228 ^ string_of_int col);
227- definition ~path ~pos: (line, col) ~debug: true
229+ definition ~state ~ path ~pos: (line, col) ~debug: true
228230 | "com" ->
229231 print_endline
230232 (" Complete " ^ path ^ " " ^ string_of_int line ^ " :"
231233 ^ string_of_int col);
232234 let current_file = create_current_file () in
233- completion ~debug: true ~path ~pos: (line, col) ~current_file ;
235+ completion ~state ~ debug:true ~path ~pos: (line, col) ~current_file ;
234236 Sys. remove current_file
235237 | "cre" ->
236238 let module_path = String. sub rest 3 (String. length rest - 3 ) in
237239 let module_path = String. trim module_path in
238240 print_endline (" Completion resolve: " ^ module_path);
239- completion_resolve ~path ~module_path
241+ completion_resolve ~state ~ path ~module_path
240242 | "dce" ->
241243 print_endline (" DCE " ^ path);
242244 Reanalyze.Run_config. run_config.suppress < - [" src" ];
@@ -259,16 +261,16 @@ let test ~path =
259261 (" Hover " ^ path ^ " " ^ string_of_int line ^ " :"
260262 ^ string_of_int col);
261263 let current_file = create_current_file () in
262- hover ~supports_markdown_links: true ~path ~pos: (line, col)
264+ hover ~state ~ supports_markdown_links:true ~path ~pos: (line, col)
263265 ~current_file ~debug: true ;
264266 Sys. remove current_file
265267 | "she" ->
266268 print_endline
267269 (" Signature help " ^ path ^ " " ^ string_of_int line ^ " :"
268270 ^ string_of_int col);
269271 let current_file = create_current_file () in
270- signature_help ~path ~pos: (line, col) ~current_file ~debug: true
271- ~allow_for_constructor_payloads: true ;
272+ signature_help ~state ~ path ~pos: (line, col) ~current_file
273+ ~debug: true ~ allow_for_constructor_payloads:true ;
272274 Sys. remove current_file
273275 | "int" ->
274276 print_endline (" Create Interface " ^ path);
@@ -279,30 +281,30 @@ let test ~path =
279281 let dir = dirname path in
280282 dir ++ parent_dir_name ++ " lib" ++ " bs" ++ " src" ++ name
281283 in
282- Printf. printf " %s" (Create_interface. command ~path ~cmi_file )
284+ Printf. printf " %s" (Create_interface. command ~state ~ path ~cmi_file )
283285 | "ref" ->
284286 print_endline
285287 (" References " ^ path ^ " " ^ string_of_int line ^ " :"
286288 ^ string_of_int col);
287- references ~path ~pos: (line, col) ~debug: true
289+ references ~state ~ path ~pos: (line, col) ~debug: true
288290 | "pre" ->
289291 print_endline
290292 (" PrepareRename " ^ path ^ " " ^ string_of_int line ^ " :"
291293 ^ string_of_int col);
292- prepare_rename ~path ~pos: (line, col) ~debug: true
294+ prepare_rename ~state ~ path ~pos: (line, col) ~debug: true
293295 | "ren" ->
294296 let new_name = String. sub rest 4 (len - mlen - 4 ) in
295297 let () =
296298 print_endline
297299 (" Rename " ^ path ^ " " ^ string_of_int line ^ " :"
298300 ^ string_of_int col ^ " " ^ new_name)
299301 in
300- rename ~path ~pos: (line, col) ~new_name ~debug: true
302+ rename ~state ~ path ~pos: (line, col) ~new_name ~debug: true
301303 | "typ" ->
302304 print_endline
303305 (" TypeDefinition " ^ path ^ " " ^ string_of_int line ^ " :"
304306 ^ string_of_int col);
305- type_definition ~path ~pos: (line, col) ~debug: true
307+ type_definition ~state ~ path ~pos: (line, col) ~debug: true
306308 | "xfm" ->
307309 let current_file = create_current_file () in
308310 (* +2 is to ensure that the character ^ points to is what's considered the end of the selection. *)
@@ -323,8 +325,8 @@ let test ~path =
323325 in
324326 let kind_file = Files. classify_source_file current_file in
325327 let code_actions =
326- Xform. extract_code_actions ~path ~start_pos ~end_pos ~source
327- ~kind_file ~debug: true
328+ Xform. extract_code_actions ~state ~ path ~start_pos ~end_pos
329+ ~source ~ kind_file ~debug: true
328330 in
329331 Sys. remove current_file;
330332 code_actions
@@ -402,11 +404,11 @@ let test ~path =
402404 print_endline
403405 (" Inlay Hint " ^ path ^ " " ^ string_of_int line_start ^ " :"
404406 ^ string_of_int line_end);
405- inlayhint ~path ~pos: (line_start, line_end) ~max_length: " 25"
407+ inlayhint ~state ~ path ~pos: (line_start, line_end) ~max_length: " 25"
406408 ~debug: false
407409 | "cle" ->
408410 print_endline (" Code Lens " ^ path);
409- code_lens ~path ~debug: false
411+ code_lens ~state ~ path ~debug: false
410412 | "ast" ->
411413 print_endline
412414 (" Dump AST " ^ path ^ " " ^ string_of_int line ^ " :"
0 commit comments