Skip to content

Commit fa815ea

Browse files
committed
refactor(lsp): rename lint_and_get_diagnostics_notification -> lint
1 parent 92d65c9 commit fa815ea

File tree

3 files changed

+25
-34
lines changed

3 files changed

+25
-34
lines changed

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

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -377,8 +377,7 @@ void linting_lsp_server_handler::config_document::on_text_changed(
377377

378378
void linting_lsp_server_handler::lintable_document::on_text_changed(
379379
linting_lsp_server_handler& handler, string8_view document_uri_json) {
380-
handler.linter_.lint_and_get_diagnostics_notification(
381-
*this, document_uri_json, handler.outgoing_messages_);
380+
handler.linter_.lint(*this, document_uri_json, handler.outgoing_messages_);
382381
}
383382

384383
void linting_lsp_server_handler::unknown_document::on_text_changed(
@@ -477,8 +476,7 @@ void linting_lsp_server_handler::handle_text_document_did_open_notification(
477476
this->write_configuration_loader_error_notification(
478477
document_path, config_file.error_to_string(), message_json);
479478
}
480-
this->linter_.lint_and_get_diagnostics_notification(
481-
*doc, uri->json, this->outgoing_messages_);
479+
this->linter_.lint(*doc, uri->json, this->outgoing_messages_);
482480

483481
doc_ptr = std::move(doc);
484482
} else if (this->config_loader_.is_config_file_path(document_path)) {
@@ -577,9 +575,8 @@ void linting_lsp_server_handler::lintable_document::on_config_file_changed(
577575
// TODO(strager): Don't copy document_uri if it contains only non-special
578576
// characters.
579577
// TODO(strager): Cache the result of to_json_escaped_string?
580-
handler.linter_.lint_and_get_diagnostics_notification(
581-
*this, to_json_escaped_string_with_quotes(document_uri),
582-
handler.outgoing_messages_);
578+
handler.linter_.lint(*this, to_json_escaped_string_with_quotes(document_uri),
579+
handler.outgoing_messages_);
583580
}
584581

585582
void linting_lsp_server_handler::unknown_document::on_config_file_changed(
@@ -717,15 +714,14 @@ void linting_lsp_server_handler::write_invalid_request_error_response(
717714

718715
lsp_linter::~lsp_linter() = default;
719716

720-
void lsp_linter::lint_and_get_diagnostics_notification(
721-
linting_lsp_server_handler::lintable_document& doc, string8_view uri_json,
722-
outgoing_lsp_message_queue& outgoing_messages) {
723-
this->lint_and_get_diagnostics_notification(
724-
*doc.config, doc.lint_options, doc.doc.string(), uri_json,
725-
doc.version_json, outgoing_messages);
717+
void lsp_linter::lint(linting_lsp_server_handler::lintable_document& doc,
718+
string8_view uri_json,
719+
outgoing_lsp_message_queue& outgoing_messages) {
720+
this->lint(*doc.config, doc.lint_options, doc.doc.string(), uri_json,
721+
doc.version_json, outgoing_messages);
726722
}
727723

728-
void lsp_javascript_linter::lint_and_get_diagnostics_notification(
724+
void lsp_javascript_linter::lint(
729725
configuration& config, linter_options lint_options, padded_string_view code,
730726
string8_view uri_json, string8_view version_json,
731727
outgoing_lsp_message_queue& outgoing_messages) {

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

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -214,25 +214,21 @@ class lsp_linter {
214214

215215
virtual ~lsp_linter();
216216

217-
// TODO(strager): Rename to just 'lint'.
218-
virtual void lint_and_get_diagnostics_notification(
219-
configuration& config, linter_options lint_options,
220-
padded_string_view code, string8_view uri_json, string8_view version_json,
221-
outgoing_lsp_message_queue&) = 0;
222-
223-
void lint_and_get_diagnostics_notification(
224-
linting_lsp_server_handler::lintable_document&, string8_view uri_json,
225-
outgoing_lsp_message_queue&);
217+
virtual void lint(configuration& config, linter_options lint_options,
218+
padded_string_view code, string8_view uri_json,
219+
string8_view version_json, outgoing_lsp_message_queue&) = 0;
220+
221+
void lint(linting_lsp_server_handler::lintable_document&,
222+
string8_view uri_json, outgoing_lsp_message_queue&);
226223
};
227224

228225
class lsp_javascript_linter final : public lsp_linter {
229226
public:
230227
~lsp_javascript_linter() override = default;
231228

232-
void lint_and_get_diagnostics_notification(
233-
configuration&, linter_options, padded_string_view code,
234-
string8_view uri_json, string8_view version_json,
235-
outgoing_lsp_message_queue&) override;
229+
void lint(configuration&, linter_options, padded_string_view code,
230+
string8_view uri_json, string8_view version_json,
231+
outgoing_lsp_message_queue&) override;
236232

237233
private:
238234
void lint_and_get_diagnostics(configuration&, linter_options,

test/test-lsp-server.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ class mock_lsp_linter final : public lsp_linter {
7878

7979
~mock_lsp_linter() override = default;
8080

81-
void lint_and_get_diagnostics_notification(
82-
configuration& config, linter_options lint_options,
83-
padded_string_view code, string8_view uri_json, string8_view version_json,
84-
outgoing_lsp_message_queue& outgoing_messages) override {
81+
void lint(configuration& config, linter_options lint_options,
82+
padded_string_view code, string8_view uri_json,
83+
string8_view version_json,
84+
outgoing_lsp_message_queue& outgoing_messages) override {
8585
this->callback_(config, lint_options, code, uri_json, version_json,
8686
outgoing_messages);
8787
}
@@ -2502,9 +2502,8 @@ TEST(test_lsp_javascript_linter, linting_gives_diagnostics) {
25022502
configuration config;
25032503

25042504
lsp_javascript_linter linter;
2505-
linter.lint_and_get_diagnostics_notification(config, linter_options(), &code,
2506-
u8"\"file:///test.js\""_sv,
2507-
u8"10"_sv, notifications);
2505+
linter.lint(config, linter_options(), &code, u8"\"file:///test.js\""_sv,
2506+
u8"10"_sv, notifications);
25082507

25092508
spy_lsp_endpoint_remote endpoint;
25102509
notifications.send(endpoint);

0 commit comments

Comments
 (0)