@@ -40,11 +40,6 @@ namespace {
4040constexpr lsp_endpoint_handler::request_id_type
4141 initial_configuration_request_id = 1 ;
4242
43- struct string_json_token {
44- string8_view data;
45- string8_view json;
46- };
47-
4843// Returns std::nullopt on failure (e.g. missing key or not a string).
4944std::optional<string_json_token> maybe_get_string_token (
5045 ::simdjson::ondemand::value& string);
@@ -437,7 +432,18 @@ void linting_lsp_server_handler::handle_text_document_did_open_notification(
437432 return ;
438433 }
439434
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 );
441447 if (document_path.empty ()) {
442448 // TODO(strager): Report a warning and use a default configuration.
443449 QLJS_UNIMPLEMENTED ();
@@ -446,12 +452,12 @@ void linting_lsp_server_handler::handle_text_document_did_open_notification(
446452 auto init_document = [&](document_base& doc) {
447453 this ->config_fs_ .open_document (document_path, &doc.doc );
448454
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 ;
451457 };
452458
453459 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 )) {
455461 auto doc = std::make_unique<lintable_document>();
456462 init_document (*doc);
457463 doc->lint_options = lang->lint_options ;
@@ -476,7 +482,7 @@ void linting_lsp_server_handler::handle_text_document_did_open_notification(
476482 this ->write_configuration_loader_error_notification (
477483 document_path, config_file.error_to_string (), message_json);
478484 }
479- this ->linter_ .lint (*doc, uri-> json , this ->outgoing_messages_ );
485+ this ->linter_ .lint (*doc, notification. uri . json , this ->outgoing_messages_ );
480486
481487 doc_ptr = std::move (doc);
482488 } 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(
490496 byte_buffer& config_diagnostics_json =
491497 this ->outgoing_messages_ .new_message ();
492498 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);
494501
495502 std::vector<configuration_change> config_changes =
496503 this ->config_loader_ .refresh ();
@@ -504,7 +511,7 @@ void linting_lsp_server_handler::handle_text_document_did_open_notification(
504511
505512 // If the document already exists, deallocate that document_base and use ours.
506513 // 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);
508515}
509516
510517void linting_lsp_server_handler::
0 commit comments