Skip to content

Commit 7ee6c2c

Browse files
committed
refactor: rename *_error_reporter -> *_diag_reporter
1 parent b8f9c06 commit 7ee6c2c

13 files changed

+86
-88
lines changed

plugin/vscode/quick-lint-js/vscode-diag-reporter.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
#include <string_view>
1313

1414
namespace quick_lint_js {
15-
class vscode_error_formatter
16-
: public diagnostic_formatter<vscode_error_formatter> {
15+
class vscode_diag_formatter
16+
: public diagnostic_formatter<vscode_diag_formatter> {
1717
public:
18-
explicit vscode_error_formatter(vscode_module* vscode, ::Napi::Env env,
19-
::Napi::Array diagnostics,
20-
const lsp_locator* locator,
21-
::Napi::Value document_uri)
18+
explicit vscode_diag_formatter(vscode_module* vscode, ::Napi::Env env,
19+
::Napi::Array diagnostics,
20+
const lsp_locator* locator,
21+
::Napi::Value document_uri)
2222
: vscode_(vscode),
2323
env_(env),
2424
diagnostics_(diagnostics),
@@ -138,7 +138,7 @@ class vscode_diag_reporter final : public diag_reporter {
138138
::Napi::Array diagnostics() const { return this->diagnostics_; }
139139

140140
void report_impl(diag_type type, void* error) override {
141-
vscode_error_formatter formatter(
141+
vscode_diag_formatter formatter(
142142
/*vscode=*/this->vscode_,
143143
/*env=*/this->env_,
144144
/*diagnostics=*/this->diagnostics_,

src/c-api-diag-reporter.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ void c_api_diag_reporter<Diagnostic, Locator>::reset() {
3636
template <class Diagnostic, class Locator>
3737
void c_api_diag_reporter<Diagnostic, Locator>::report_impl(diag_type type,
3838
void *error) {
39-
c_api_error_formatter formatter(this);
39+
c_api_diag_formatter formatter(this);
4040
formatter.format(get_diagnostic_info(type), error);
4141
}
4242

@@ -60,12 +60,12 @@ char8 *c_api_diag_reporter<Diagnostic, Locator>::allocate_c_string(
6060
}
6161

6262
template <class Diagnostic, class Locator>
63-
c_api_error_formatter<Diagnostic, Locator>::c_api_error_formatter(
63+
c_api_diag_formatter<Diagnostic, Locator>::c_api_diag_formatter(
6464
c_api_diag_reporter<Diagnostic, Locator> *reporter)
6565
: reporter_(reporter) {}
6666

6767
template <class Diagnostic, class Locator>
68-
void c_api_error_formatter<Diagnostic, Locator>::write_before_message(
68+
void c_api_diag_formatter<Diagnostic, Locator>::write_before_message(
6969
std::string_view, diagnostic_severity sev, const source_code_span &) {
7070
if (sev == diagnostic_severity::note) {
7171
// Don't write notes. Only write the main message.
@@ -75,7 +75,7 @@ void c_api_error_formatter<Diagnostic, Locator>::write_before_message(
7575
}
7676

7777
template <class Diagnostic, class Locator>
78-
void c_api_error_formatter<Diagnostic, Locator>::write_message_part(
78+
void c_api_diag_formatter<Diagnostic, Locator>::write_message_part(
7979
std::string_view, diagnostic_severity sev, string8_view message) {
8080
if (sev == diagnostic_severity::note) {
8181
// Don't write notes. Only write the main message.
@@ -85,7 +85,7 @@ void c_api_error_formatter<Diagnostic, Locator>::write_message_part(
8585
}
8686

8787
template <class Diagnostic, class Locator>
88-
void c_api_error_formatter<Diagnostic, Locator>::write_after_message(
88+
void c_api_diag_formatter<Diagnostic, Locator>::write_after_message(
8989
std::string_view code, diagnostic_severity sev,
9090
const source_code_span &origin) {
9191
qljs_severity diag_severity = qljs_severity_error;
@@ -121,8 +121,7 @@ void c_api_error_formatter<Diagnostic, Locator>::write_after_message(
121121
diag.severity = diag_severity;
122122
}
123123

124-
template class c_api_error_formatter<qljs_web_demo_diagnostic,
125-
web_demo_locator>;
124+
template class c_api_diag_formatter<qljs_web_demo_diagnostic, web_demo_locator>;
126125
template class c_api_diag_reporter<qljs_web_demo_diagnostic, web_demo_locator>;
127126
}
128127

src/emacs-lisp-diag-reporter.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@ void emacs_lisp_diag_reporter::set_source(padded_string_view input) {
2424

2525
void emacs_lisp_diag_reporter::report_impl(diag_type type, void *error) {
2626
QLJS_ASSERT(this->locator_.has_value());
27-
emacs_lisp_error_formatter formatter(/*output=*/&this->output_,
28-
/*locator=*/*this->locator_);
27+
emacs_lisp_diag_formatter formatter(/*output=*/&this->output_,
28+
/*locator=*/*this->locator_);
2929
formatter.format(get_diagnostic_info(type), error);
3030
}
3131

32-
emacs_lisp_error_formatter::emacs_lisp_error_formatter(output_stream *output,
33-
emacs_locator &locator)
32+
emacs_lisp_diag_formatter::emacs_lisp_diag_formatter(output_stream *output,
33+
emacs_locator &locator)
3434
: output_(*output), locator_(locator) {}
3535

36-
void emacs_lisp_error_formatter::write_before_message(
36+
void emacs_lisp_diag_formatter::write_before_message(
3737
std::string_view code, diagnostic_severity sev,
3838
const source_code_span &origin) {
3939
if (sev == diagnostic_severity::note) {
@@ -67,7 +67,7 @@ void write_elisp_stringp_escaped_message(output_stream &output,
6767
}
6868
}
6969

70-
void emacs_lisp_error_formatter::write_message_part(
70+
void emacs_lisp_diag_formatter::write_message_part(
7171
[[maybe_unused]] std::string_view code, diagnostic_severity sev,
7272
string8_view message) {
7373
if (sev == diagnostic_severity::note) {
@@ -76,7 +76,7 @@ void emacs_lisp_error_formatter::write_message_part(
7676
write_elisp_stringp_escaped_message(this->output_, message);
7777
}
7878

79-
void emacs_lisp_error_formatter::write_after_message(
79+
void emacs_lisp_diag_formatter::write_after_message(
8080
[[maybe_unused]] std::string_view code, diagnostic_severity sev,
8181
const source_code_span &) {
8282
if (sev == diagnostic_severity::note) {

src/lsp-diag-reporter.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,18 @@ void lsp_diag_reporter::report_impl(diag_type type, void *error) {
3333
this->output_.append_copy(u8",\n"sv);
3434
}
3535
this->need_comma_ = true;
36-
lsp_error_formatter formatter(/*output=*/this->output_,
37-
/*locator=*/this->locator_);
36+
lsp_diag_formatter formatter(/*output=*/this->output_,
37+
/*locator=*/this->locator_);
3838
formatter.format(get_diagnostic_info(type), error);
3939
}
4040

41-
lsp_error_formatter::lsp_error_formatter(byte_buffer &output,
42-
lsp_locator &locator)
41+
lsp_diag_formatter::lsp_diag_formatter(byte_buffer &output,
42+
lsp_locator &locator)
4343
: output_(output), locator_(locator) {}
4444

45-
void lsp_error_formatter::write_before_message(std::string_view code,
46-
diagnostic_severity sev,
47-
const source_code_span &origin) {
45+
void lsp_diag_formatter::write_before_message(std::string_view code,
46+
diagnostic_severity sev,
47+
const source_code_span &origin) {
4848
char8 severity_type{};
4949
switch (sev) {
5050
case diagnostic_severity::error:
@@ -84,7 +84,7 @@ void lsp_error_formatter::write_before_message(std::string_view code,
8484
u8",\"message\":\""sv);
8585
}
8686

87-
void lsp_error_formatter::write_message_part(
87+
void lsp_diag_formatter::write_message_part(
8888
[[maybe_unused]] std::string_view code, diagnostic_severity sev,
8989
string8_view message) {
9090
if (sev == diagnostic_severity::note) {
@@ -95,7 +95,7 @@ void lsp_error_formatter::write_message_part(
9595
write_json_escaped_string(this->output_, message);
9696
}
9797

98-
void lsp_error_formatter::write_after_message(
98+
void lsp_diag_formatter::write_after_message(
9999
[[maybe_unused]] std::string_view code, diagnostic_severity sev,
100100
const source_code_span &) {
101101
if (sev == diagnostic_severity::note) {

src/quick-lint-js/c-api-diag-reporter.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class lsp_locator;
2323
class web_demo_locator;
2424

2525
template <class Diagnostic, class Locator>
26-
class c_api_error_formatter;
26+
class c_api_diag_formatter;
2727

2828
template <class Diagnostic, class Locator>
2929
class c_api_diag_reporter final : public diag_reporter {
@@ -45,14 +45,14 @@ class c_api_diag_reporter final : public diag_reporter {
4545
const char8 *input_;
4646
monotonic_allocator string_allocator_;
4747

48-
friend c_api_error_formatter<Diagnostic, Locator>;
48+
friend c_api_diag_formatter<Diagnostic, Locator>;
4949
};
5050

5151
template <class Diagnostic, class Locator>
52-
class c_api_error_formatter
53-
: public diagnostic_formatter<c_api_error_formatter<Diagnostic, Locator>> {
52+
class c_api_diag_formatter
53+
: public diagnostic_formatter<c_api_diag_formatter<Diagnostic, Locator>> {
5454
public:
55-
explicit c_api_error_formatter(
55+
explicit c_api_diag_formatter(
5656
c_api_diag_reporter<Diagnostic, Locator> *reporter);
5757

5858
void write_before_message(std::string_view code, diagnostic_severity,
@@ -70,8 +70,8 @@ class c_api_error_formatter
7070
QLJS_WARNING_PUSH
7171
QLJS_WARNING_IGNORE_CLANG("-Wweak-template-vtables")
7272

73-
extern template class c_api_error_formatter<qljs_web_demo_diagnostic,
74-
web_demo_locator>;
73+
extern template class c_api_diag_formatter<qljs_web_demo_diagnostic,
74+
web_demo_locator>;
7575
extern template class c_api_diag_reporter<qljs_web_demo_diagnostic,
7676
web_demo_locator>;
7777

src/quick-lint-js/emacs-lisp-diag-reporter.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include <quick-lint-js/token.h>
1818

1919
namespace quick_lint_js {
20-
class emacs_lisp_error_formatter;
20+
class emacs_lisp_diag_formatter;
2121

2222
class emacs_lisp_diag_reporter final : public diag_reporter {
2323
public:
@@ -33,11 +33,11 @@ class emacs_lisp_diag_reporter final : public diag_reporter {
3333
std::optional<emacs_locator> locator_;
3434
};
3535

36-
class emacs_lisp_error_formatter
37-
: public diagnostic_formatter<emacs_lisp_error_formatter> {
36+
class emacs_lisp_diag_formatter
37+
: public diagnostic_formatter<emacs_lisp_diag_formatter> {
3838
public:
39-
explicit emacs_lisp_error_formatter(output_stream *output,
40-
emacs_locator &locator);
39+
explicit emacs_lisp_diag_formatter(output_stream *output,
40+
emacs_locator &locator);
4141

4242
void write_before_message(std::string_view code, diagnostic_severity,
4343
const source_code_span &origin);

src/quick-lint-js/lsp-diag-reporter.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include <string>
2222

2323
namespace quick_lint_js {
24-
class lsp_error_formatter;
24+
class lsp_diag_formatter;
2525

2626
class lsp_diag_reporter final : public diag_reporter {
2727
public:
@@ -37,9 +37,9 @@ class lsp_diag_reporter final : public diag_reporter {
3737
bool need_comma_ = false;
3838
};
3939

40-
class lsp_error_formatter : public diagnostic_formatter<lsp_error_formatter> {
40+
class lsp_diag_formatter : public diagnostic_formatter<lsp_diag_formatter> {
4141
public:
42-
explicit lsp_error_formatter(byte_buffer &output, lsp_locator &);
42+
explicit lsp_diag_formatter(byte_buffer &output, lsp_locator &);
4343
void write_before_message(std::string_view code, diagnostic_severity,
4444
const source_code_span &origin);
4545
void write_message_part(std::string_view code, diagnostic_severity,

src/quick-lint-js/text-diag-reporter.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include <quick-lint-js/token.h>
1919

2020
namespace quick_lint_js {
21-
class text_error_formatter;
21+
class text_diag_formatter;
2222

2323
class text_diag_reporter final : public diag_reporter {
2424
public:
@@ -35,11 +35,10 @@ class text_diag_reporter final : public diag_reporter {
3535
bool format_escape_errors_;
3636
};
3737

38-
class text_error_formatter : public diagnostic_formatter<text_error_formatter> {
38+
class text_diag_formatter : public diagnostic_formatter<text_diag_formatter> {
3939
public:
40-
explicit text_error_formatter(output_stream *output, const char *file_path,
41-
cli_locator &locator,
42-
bool format_escape_errors);
40+
explicit text_diag_formatter(output_stream *output, const char *file_path,
41+
cli_locator &locator, bool format_escape_errors);
4342

4443
void write_before_message(std::string_view code, diagnostic_severity,
4544
const source_code_span &origin);

src/quick-lint-js/vim-qflist-json-diag-reporter.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include <string>
1717

1818
namespace quick_lint_js {
19-
class vim_qflist_json_error_formatter;
19+
class vim_qflist_json_diag_formatter;
2020

2121
class vim_qflist_json_diag_reporter final : public diag_reporter {
2222
public:
@@ -41,13 +41,13 @@ class vim_qflist_json_diag_reporter final : public diag_reporter {
4141
bool need_comma_ = false;
4242
};
4343

44-
class vim_qflist_json_error_formatter
45-
: public diagnostic_formatter<vim_qflist_json_error_formatter> {
44+
class vim_qflist_json_diag_formatter
45+
: public diagnostic_formatter<vim_qflist_json_diag_formatter> {
4646
public:
47-
explicit vim_qflist_json_error_formatter(output_stream *output,
48-
quick_lint_js::vim_locator &locator,
49-
std::string_view file_name,
50-
std::string_view bufnr);
47+
explicit vim_qflist_json_diag_formatter(output_stream *output,
48+
quick_lint_js::vim_locator &locator,
49+
std::string_view file_name,
50+
std::string_view bufnr);
5151
void write_before_message(std::string_view code, diagnostic_severity,
5252
const source_code_span &origin);
5353
void write_message_part(std::string_view code, diagnostic_severity,

src/text-diag-reporter.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,24 +31,24 @@ void text_diag_reporter::set_source(padded_string_view input,
3131
void text_diag_reporter::report_impl(diag_type type, void *error) {
3232
QLJS_ASSERT(this->file_path_);
3333
QLJS_ASSERT(this->locator_.has_value());
34-
text_error_formatter formatter(
34+
text_diag_formatter formatter(
3535
/*output=*/&this->output_,
3636
/*file_path=*/this->file_path_,
3737
/*locator=*/*this->locator_,
3838
/*format_escape_errors=*/this->format_escape_errors_);
3939
formatter.format(get_diagnostic_info(type), error);
4040
}
4141

42-
text_error_formatter::text_error_formatter(output_stream *output,
43-
const char *file_path,
44-
cli_locator &locator,
45-
bool format_escape_errors)
42+
text_diag_formatter::text_diag_formatter(output_stream *output,
43+
const char *file_path,
44+
cli_locator &locator,
45+
bool format_escape_errors)
4646
: output_(*output),
4747
file_path_(file_path),
4848
locator_(locator),
4949
format_escape_errors_(format_escape_errors) {}
5050

51-
void text_error_formatter::write_before_message(
51+
void text_diag_formatter::write_before_message(
5252
[[maybe_unused]] std::string_view code, diagnostic_severity sev,
5353
const source_code_span &origin) {
5454
cli_source_range r = this->locator_.range(origin);
@@ -72,15 +72,15 @@ void text_error_formatter::write_before_message(
7272
}
7373
}
7474

75-
void text_error_formatter::write_message_part(
75+
void text_diag_formatter::write_message_part(
7676
[[maybe_unused]] std::string_view code, diagnostic_severity,
7777
string8_view message) {
7878
this->output_.append_copy(message);
7979
}
8080

81-
void text_error_formatter::write_after_message(std::string_view code,
82-
diagnostic_severity,
83-
const source_code_span &) {
81+
void text_diag_formatter::write_after_message(std::string_view code,
82+
diagnostic_severity,
83+
const source_code_span &) {
8484
if (this->format_escape_errors_) {
8585
this->output_.append_copy(
8686
u8" [\x1B]8;;https://quick-lint-js.com/errors/"sv);

0 commit comments

Comments
 (0)