Skip to content

Commit f052bbc

Browse files
committed
refactor(lsp): split long function into parsing func + logic func
1 parent 710c574 commit f052bbc

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/quick-lint-js/lsp/lsp-server.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,15 +387,23 @@ void linting_lsp_server_handler::handle_text_document_did_close_notification(
387387
// Ignore invalid notification.
388388
return;
389389
}
390-
std::string path = parse_file_from_lsp_uri(uri);
390+
this->handle_text_document_did_close_notification(
391+
lsp_text_document_did_close_notification{
392+
.uri = uri,
393+
});
394+
}
395+
396+
void linting_lsp_server_handler::handle_text_document_did_close_notification(
397+
const lsp_text_document_did_close_notification& notification) {
398+
std::string path = parse_file_from_lsp_uri(notification.uri);
391399
if (path.empty()) {
392400
// TODO(strager): Report a warning.
393401
QLJS_UNIMPLEMENTED();
394402
}
395403

396404
this->config_loader_.unwatch_file(path);
397405
this->config_fs_.close_document(path);
398-
this->documents_.erase(string8(uri));
406+
this->documents_.erase(string8(notification.uri));
399407
// TODO(strager): Signal to configuration_loader and
400408
// change_detecting_filesystem_* that we no longer need to track changes to
401409
// this .js document's config file.

src/quick-lint-js/lsp/lsp-server.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,14 @@ class linting_lsp_server_handler final : public lsp_endpoint_handler {
160160
void handle_initialized_notification();
161161
void handle_text_document_did_change_notification(
162162
::simdjson::ondemand::object& request);
163+
164+
struct lsp_text_document_did_close_notification {
165+
string8_view uri;
166+
};
163167
void handle_text_document_did_close_notification(
164168
::simdjson::ondemand::object& request);
169+
void handle_text_document_did_close_notification(
170+
const lsp_text_document_did_close_notification& notification);
165171

166172
struct lsp_text_document_did_open_notification {
167173
std::string_view language_id;

0 commit comments

Comments
 (0)