@@ -40,11 +40,6 @@ namespace {
40
40
constexpr lsp_endpoint_handler::request_id_type
41
41
initial_configuration_request_id = 1 ;
42
42
43
- struct string_json_token {
44
- string8_view data;
45
- string8_view json;
46
- };
47
-
48
43
// Returns std::nullopt on failure (e.g. missing key or not a string).
49
44
std::optional<string_json_token> maybe_get_string_token (
50
45
::simdjson::ondemand::value& string);
@@ -437,7 +432,18 @@ void linting_lsp_server_handler::handle_text_document_did_open_notification(
437
432
return ;
438
433
}
439
434
440
- std::string document_path = parse_file_from_lsp_uri (uri->data );
435
+ this ->handle_text_document_did_open_notification (
436
+ lsp_text_document_did_open_notification{
437
+ .language_id = language_id,
438
+ .uri = *uri,
439
+ .version_json = get_raw_json (version),
440
+ .text = text,
441
+ });
442
+ }
443
+
444
+ void linting_lsp_server_handler::handle_text_document_did_open_notification (
445
+ const lsp_text_document_did_open_notification& notification) {
446
+ std::string document_path = parse_file_from_lsp_uri (notification.uri .data );
441
447
if (document_path.empty ()) {
442
448
// TODO(strager): Report a warning and use a default configuration.
443
449
QLJS_UNIMPLEMENTED ();
@@ -446,12 +452,12 @@ void linting_lsp_server_handler::handle_text_document_did_open_notification(
446
452
auto init_document = [&](document_base& doc) {
447
453
this ->config_fs_ .open_document (document_path, &doc.doc );
448
454
449
- doc.doc .set_text (text);
450
- doc.version_json = get_raw_json (version) ;
455
+ doc.doc .set_text (notification. text );
456
+ doc.version_json = notification. version_json ;
451
457
};
452
458
453
459
std::unique_ptr<document_base> doc_ptr;
454
- if (const lsp_language* lang = lsp_language::find (language_id)) {
460
+ if (const lsp_language* lang = lsp_language::find (notification. language_id )) {
455
461
auto doc = std::make_unique<lintable_document>();
456
462
init_document (*doc);
457
463
doc->lint_options = lang->lint_options ;
@@ -476,7 +482,7 @@ void linting_lsp_server_handler::handle_text_document_did_open_notification(
476
482
this ->write_configuration_loader_error_notification (
477
483
document_path, config_file.error_to_string (), message_json);
478
484
}
479
- this ->linter_ .lint (*doc, uri-> json , this ->outgoing_messages_ );
485
+ this ->linter_ .lint (*doc, notification. uri . json , this ->outgoing_messages_ );
480
486
481
487
doc_ptr = std::move (doc);
482
488
} else if (this ->config_loader_ .is_config_file_path (document_path)) {
@@ -490,7 +496,8 @@ void linting_lsp_server_handler::handle_text_document_did_open_notification(
490
496
byte_buffer& config_diagnostics_json =
491
497
this ->outgoing_messages_ .new_message ();
492
498
this ->get_config_file_diagnostics_notification (
493
- *config_file, uri->json , doc->version_json , config_diagnostics_json);
499
+ *config_file, notification.uri .json , doc->version_json ,
500
+ config_diagnostics_json);
494
501
495
502
std::vector<configuration_change> config_changes =
496
503
this ->config_loader_ .refresh ();
@@ -504,7 +511,7 @@ void linting_lsp_server_handler::handle_text_document_did_open_notification(
504
511
505
512
// If the document already exists, deallocate that document_base and use ours.
506
513
// TODO(strager): Should we report a warning if a document already existed?
507
- this ->documents_ [string8 (uri-> data )] = std::move (doc_ptr);
514
+ this ->documents_ [string8 (notification. uri . data )] = std::move (doc_ptr);
508
515
}
509
516
510
517
void linting_lsp_server_handler::
0 commit comments