Skip to content

Commit b429f36

Browse files
committed
refactor: rename *_error_reporter -> *_diag_reporter
1 parent d57a027 commit b429f36

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+316
-320
lines changed

benchmark/benchmark-configuration.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ namespace {
1313
void benchmark_parse_config_json(::benchmark::State& state,
1414
string8_view config_json) {
1515
padded_string config_json_string(config_json);
16-
null_error_reporter error_reporter;
16+
null_diag_reporter diag_reporter;
1717

1818
configuration config;
1919
for (auto _ : state) {
2020
config.reset();
21-
config.load_from_json(&config_json_string, &error_reporter);
21+
config.load_from_json(&config_json_string, &diag_reporter);
2222
::benchmark::ClobberMemory();
2323
}
2424
}

benchmark/benchmark-lex.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace {
1212
void benchmark_lex(::benchmark::State &state, string8_view raw_source) {
1313
padded_string source(raw_source);
1414
for (auto _ : state) {
15-
lexer l(&source, &null_error_reporter::instance);
15+
lexer l(&source, &null_diag_reporter::instance);
1616
while (l.peek().type != token_type::end_of_file) {
1717
l.skip();
1818
}

benchmark/benchmark-lint.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ void benchmark_lint(benchmark::State &state) {
3333
padded_string source = quick_lint_js::read_file_or_exit(source_path);
3434

3535
configuration config;
36-
parser p(&source, &null_error_reporter::instance);
36+
parser p(&source, &null_diag_reporter::instance);
3737
buffering_visitor visitor(new_delete_resource());
3838
p.parse_and_visit_module(visitor);
3939

4040
for (auto _ : state) {
41-
linter l(&null_error_reporter::instance, &config.globals());
41+
linter l(&null_diag_reporter::instance, &config.globals());
4242
visitor.copy_into(l);
4343
}
4444
}
@@ -58,8 +58,8 @@ void benchmark_parse_and_lint(benchmark::State &state) {
5858

5959
configuration config;
6060
for (auto _ : state) {
61-
parser p(&source, &null_error_reporter::instance);
62-
linter l(&null_error_reporter::instance, &config.globals());
61+
parser p(&source, &null_diag_reporter::instance);
62+
linter l(&null_diag_reporter::instance, &config.globals());
6363
p.parse_and_visit_module(l);
6464
}
6565
}
@@ -97,7 +97,7 @@ void benchmark_undeclared_variable_references(benchmark::State &state) {
9797
}
9898

9999
for (auto _ : state) {
100-
linter l(&null_error_reporter::instance, &globals);
100+
linter l(&null_diag_reporter::instance, &globals);
101101
for (identifier &variable_use : variable_use_identifiers) {
102102
l.visit_variable_use(variable_use);
103103
}

benchmark/benchmark-parse.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ void benchmark_parse_file(benchmark::State &state) {
2929
padded_string source = quick_lint_js::read_file_or_exit(source_path);
3030

3131
for (auto _ : state) {
32-
parser p(&source, &null_error_reporter::instance);
32+
parser p(&source, &null_diag_reporter::instance);
3333
null_visitor visitor;
3434
p.parse_and_visit_module(visitor);
3535
}
@@ -39,7 +39,7 @@ BENCHMARK(benchmark_parse_file);
3939
void benchmark_parse(benchmark::State &state, string8_view raw_source) {
4040
padded_string source(raw_source);
4141
for (auto _ : state) {
42-
parser p(&source, &null_error_reporter::instance);
42+
parser p(&source, &null_diag_reporter::instance);
4343
null_visitor visitor;
4444
p.parse_and_visit_module(visitor);
4545
}

plugin/vscode/quick-lint-js-vscode-node.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,18 +98,18 @@ class qljs_document : public ::Napi::ObjectWrap<qljs_document> {
9898
QLJS_ASSERT(this->type_ == document_type::lintable);
9999
vscode->load_non_persistent(env);
100100

101-
vscode_error_reporter error_reporter(
102-
vscode, env, &this->document_.locator(), this->uri());
101+
vscode_diag_reporter diag_reporter(vscode, env, &this->document_.locator(),
102+
this->uri());
103103
parser_options p_options;
104104
p_options.jsx = true;
105-
parser p(this->document_.string(), &error_reporter, p_options);
106-
linter l(&error_reporter, &this->config_->globals());
105+
parser p(this->document_.string(), &diag_reporter, p_options);
106+
linter l(&diag_reporter, &this->config_->globals());
107107
bool ok = p.parse_and_visit_module_catching_fatal_parse_errors(l);
108108
if (!ok) {
109109
// TODO(strager): Show a pop-up message explaining that the parser
110110
// crashed.
111111
}
112-
return std::move(error_reporter).diagnostics();
112+
return std::move(diag_reporter).diagnostics();
113113
}
114114

115115
::Napi::Array lint_config(::Napi::Env env, vscode_module* vscode,
@@ -118,9 +118,9 @@ class qljs_document : public ::Napi::ObjectWrap<qljs_document> {
118118
vscode->load_non_persistent(env);
119119

120120
lsp_locator locator(&loaded_config->file_content);
121-
vscode_error_reporter error_reporter(vscode, env, &locator, this->uri());
122-
loaded_config->errors.copy_into(&error_reporter);
123-
return std::move(error_reporter).diagnostics();
121+
vscode_diag_reporter diag_reporter(vscode, env, &locator, this->uri());
122+
loaded_config->errors.copy_into(&diag_reporter);
123+
return std::move(diag_reporter).diagnostics();
124124
}
125125

126126
::Napi::Value uri() { return this->vscode_document_.Value().uri(); }

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,11 @@ class vscode_error_formatter
124124
string8 message_;
125125
};
126126

127-
class vscode_error_reporter final : public error_reporter {
127+
class vscode_diag_reporter final : public diag_reporter {
128128
public:
129-
explicit vscode_error_reporter(vscode_module* vscode, ::Napi::Env env,
130-
const lsp_locator* locator,
131-
::Napi::Value document_uri) noexcept
129+
explicit vscode_diag_reporter(vscode_module* vscode, ::Napi::Env env,
130+
const lsp_locator* locator,
131+
::Napi::Value document_uri) noexcept
132132
: vscode_(vscode),
133133
env_(env),
134134
diagnostics_(::Napi::Array::New(env)),

src/buffering-error-reporter.cpp

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

1515
namespace quick_lint_js {
16-
struct buffering_error_reporter::impl {
16+
struct buffering_diag_reporter::impl {
1717
explicit impl(boost::container::pmr::memory_resource *memory) noexcept
1818
: memory_(memory) {}
1919

@@ -38,25 +38,25 @@ struct buffering_error_reporter::impl {
3838
errors_{this->memory_};
3939
};
4040

41-
void buffering_error_reporter::impl_deleter::operator()(impl *i) noexcept {
41+
void buffering_diag_reporter::impl_deleter::operator()(impl *i) noexcept {
4242
if (i) {
4343
delete_object(i->memory_, i);
4444
}
4545
}
4646

47-
buffering_error_reporter::buffering_error_reporter(
47+
buffering_diag_reporter::buffering_diag_reporter(
4848
boost::container::pmr::memory_resource *memory)
4949
: impl_(new_object<impl>(memory, memory)) {}
5050

51-
buffering_error_reporter::buffering_error_reporter(
52-
buffering_error_reporter &&) = default;
51+
buffering_diag_reporter::buffering_diag_reporter(buffering_diag_reporter &&) =
52+
default;
5353

54-
buffering_error_reporter &buffering_error_reporter::operator=(
55-
buffering_error_reporter &&) = default;
54+
buffering_diag_reporter &buffering_diag_reporter::operator=(
55+
buffering_diag_reporter &&) = default;
5656

57-
buffering_error_reporter::~buffering_error_reporter() = default;
57+
buffering_diag_reporter::~buffering_diag_reporter() = default;
5858

59-
void buffering_error_reporter::report_impl(diag_type type, void *error) {
59+
void buffering_diag_reporter::report_impl(diag_type type, void *error) {
6060
static constexpr unsigned char error_sizes[] = {
6161
#define QLJS_DIAG_TYPE(name, code, severity, struct_body, format) \
6262
sizeof(::quick_lint_js::name),
@@ -69,21 +69,21 @@ void buffering_error_reporter::report_impl(diag_type type, void *error) {
6969
std::memcpy(&e.error, error, error_sizes[static_cast<std::ptrdiff_t>(type)]);
7070
}
7171

72-
void buffering_error_reporter::copy_into(error_reporter *other) const {
72+
void buffering_diag_reporter::copy_into(diag_reporter *other) const {
7373
for (impl::any_error &error : this->impl_->errors_) {
7474
other->report_impl(error.type, &error.error);
7575
}
7676
}
7777

78-
void buffering_error_reporter::move_into(error_reporter *other) {
78+
void buffering_diag_reporter::move_into(diag_reporter *other) {
7979
this->copy_into(other);
8080
}
8181

82-
bool buffering_error_reporter::empty() const noexcept {
82+
bool buffering_diag_reporter::empty() const noexcept {
8383
return this->impl_->errors_.empty();
8484
}
8585

86-
void buffering_error_reporter::clear() noexcept {
86+
void buffering_diag_reporter::clear() noexcept {
8787
return this->impl_->errors_.clear();
8888
}
8989
}

src/c-api-error-reporter.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,38 +18,38 @@
1818

1919
namespace quick_lint_js {
2020
template <class Diagnostic, class Locator>
21-
c_api_error_reporter<Diagnostic, Locator>::c_api_error_reporter() = default;
21+
c_api_diag_reporter<Diagnostic, Locator>::c_api_diag_reporter() = default;
2222

2323
template <class Diagnostic, class Locator>
24-
void c_api_error_reporter<Diagnostic, Locator>::set_input(
24+
void c_api_diag_reporter<Diagnostic, Locator>::set_input(
2525
padded_string_view input, const Locator *locator) {
2626
this->locator_ = locator;
2727
this->input_ = input.data();
2828
}
2929

3030
template <class Diagnostic, class Locator>
31-
void c_api_error_reporter<Diagnostic, Locator>::reset() {
31+
void c_api_diag_reporter<Diagnostic, Locator>::reset() {
3232
this->diagnostics_.clear();
3333
// TODO(strager): Release allocated string memory.
3434
}
3535

3636
template <class Diagnostic, class Locator>
37-
void c_api_error_reporter<Diagnostic, Locator>::report_impl(diag_type type,
38-
void *error) {
37+
void c_api_diag_reporter<Diagnostic, Locator>::report_impl(diag_type type,
38+
void *error) {
3939
c_api_error_formatter formatter(this);
4040
formatter.format(get_diagnostic_info(type), error);
4141
}
4242

4343
template <class Diagnostic, class Locator>
44-
const Diagnostic *c_api_error_reporter<Diagnostic, Locator>::get_diagnostics() {
44+
const Diagnostic *c_api_diag_reporter<Diagnostic, Locator>::get_diagnostics() {
4545
// Null-terminate the returned errors.
4646
this->diagnostics_.emplace_back();
4747

4848
return this->diagnostics_.data();
4949
}
5050

5151
template <class Diagnostic, class Locator>
52-
char8 *c_api_error_reporter<Diagnostic, Locator>::allocate_c_string(
52+
char8 *c_api_diag_reporter<Diagnostic, Locator>::allocate_c_string(
5353
string8_view string) {
5454
char8 *result =
5555
this->string_allocator_.template allocate_uninitialized_array<char8>(
@@ -61,7 +61,7 @@ char8 *c_api_error_reporter<Diagnostic, Locator>::allocate_c_string(
6161

6262
template <class Diagnostic, class Locator>
6363
c_api_error_formatter<Diagnostic, Locator>::c_api_error_formatter(
64-
c_api_error_reporter<Diagnostic, Locator> *reporter)
64+
c_api_diag_reporter<Diagnostic, Locator> *reporter)
6565
: reporter_(reporter) {}
6666

6767
template <class Diagnostic, class Locator>
@@ -123,7 +123,7 @@ void c_api_error_formatter<Diagnostic, Locator>::write_after_message(
123123

124124
template class c_api_error_formatter<qljs_web_demo_diagnostic,
125125
web_demo_locator>;
126-
template class c_api_error_reporter<qljs_web_demo_diagnostic, web_demo_locator>;
126+
template class c_api_diag_reporter<qljs_web_demo_diagnostic, web_demo_locator>;
127127
}
128128

129129
// quick-lint-js finds bugs in JavaScript programs.

src/c-api.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ class qljs_document_base {
5555
struct qljs_web_demo_document final
5656
: public quick_lint_js::qljs_document_base<
5757
quick_lint_js::web_demo_locator,
58-
quick_lint_js::c_api_error_reporter<
59-
qljs_web_demo_diagnostic, quick_lint_js::web_demo_locator>> {
58+
quick_lint_js::c_api_diag_reporter<qljs_web_demo_diagnostic,
59+
quick_lint_js::web_demo_locator>> {
6060
public:
6161
void set_text(quick_lint_js::string8_view replacement) {
6262
this->document_.set_text(replacement);
@@ -66,7 +66,7 @@ struct qljs_web_demo_document final
6666
quick_lint_js::padded_string padded_text(text);
6767
this->config_.reset();
6868
this->config_.load_from_json(&padded_text,
69-
&quick_lint_js::null_error_reporter::instance);
69+
&quick_lint_js::null_diag_reporter::instance);
7070
}
7171
};
7272

src/configuration.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ void configuration::remove_global_variable(string8_view name) {
6666
}
6767

6868
void configuration::load_from_json(padded_string_view json,
69-
error_reporter* reporter) {
69+
diag_reporter* reporter) {
7070
::simdjson::ondemand::parser json_parser;
7171
::simdjson::ondemand::document document;
7272
::simdjson::error_code parse_error =
@@ -145,8 +145,7 @@ void configuration::reset() {
145145
}
146146

147147
bool configuration::load_global_groups_from_json(
148-
::simdjson::ondemand::value& global_groups_value,
149-
error_reporter* reporter) {
148+
::simdjson::ondemand::value& global_groups_value, diag_reporter* reporter) {
150149
::simdjson::ondemand::json_type global_groups_value_type;
151150
if (global_groups_value.type().get(global_groups_value_type) !=
152151
::simdjson::SUCCESS) {
@@ -220,7 +219,7 @@ bool configuration::load_global_groups_from_json(
220219
}
221220

222221
bool configuration::load_globals_from_json(
223-
::simdjson::ondemand::object& globals_value, error_reporter* reporter) {
222+
::simdjson::ondemand::object& globals_value, diag_reporter* reporter) {
224223
for (simdjson::simdjson_result<::simdjson::ondemand::field> global_field :
225224
globals_value) {
226225
std::string_view key;
@@ -393,7 +392,7 @@ bool configuration::should_remove_global_variable(string8_view name) {
393392
template <class Error>
394393
bool configuration::get_bool_or_default(
395394
::simdjson::simdjson_result<::simdjson::ondemand::value>&& value, bool* out,
396-
bool default_value, error_reporter* reporter) {
395+
bool default_value, diag_reporter* reporter) {
397396
::simdjson::ondemand::value v;
398397
::simdjson::error_code error = value.get(v);
399398
switch (error) {
@@ -415,7 +414,7 @@ bool configuration::get_bool_or_default(
415414
}
416415

417416
void configuration::report_json_error(padded_string_view json,
418-
error_reporter* reporter) {
417+
diag_reporter* reporter) {
419418
// TODO(strager): Produce better error messages. simdjson provides no location
420419
// information for errors:
421420
// https://github.com/simdjson/simdjson/issues/237

0 commit comments

Comments
 (0)