Skip to content

Commit 7755f17

Browse files
committed
refactor: rename error_type -> diag_type
1 parent aa4de15 commit 7755f17

28 files changed

+101
-102
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ class vscode_error_reporter final : public error_reporter {
137137

138138
::Napi::Array diagnostics() const { return this->diagnostics_; }
139139

140-
void report_impl(error_type type, void* error) override {
140+
void report_impl(diag_type type, void* error) override {
141141
vscode_error_formatter formatter(
142142
/*vscode=*/this->vscode_,
143143
/*env=*/this->env_,

src/buffering-error-reporter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ struct buffering_error_reporter::impl {
2929
#undef QLJS_DIAG_TYPE
3030
};
3131

32-
error_type type;
32+
diag_type type;
3333
underlying_error error;
3434
};
3535

@@ -56,7 +56,7 @@ buffering_error_reporter &buffering_error_reporter::operator=(
5656

5757
buffering_error_reporter::~buffering_error_reporter() = default;
5858

59-
void buffering_error_reporter::report_impl(error_type type, void *error) {
59+
void buffering_error_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),

src/c-api-error-reporter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ void c_api_error_reporter<Diagnostic, Locator>::reset() {
3434
}
3535

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

src/diagnostic.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ DIAGNOSTIC_CONSTEXPR_IF_POSSIBLE const diagnostic_info
165165
#undef QLJS_DIAG_TYPE
166166
};
167167

168-
const diagnostic_info& get_diagnostic_info(error_type type) noexcept {
168+
const diagnostic_info& get_diagnostic_info(diag_type type) noexcept {
169169
return all_diagnostic_infos[static_cast<std::ptrdiff_t>(type)];
170170
}
171171

@@ -178,16 +178,16 @@ QLJS_WARNING_PUSH
178178
// is.
179179
QLJS_WARNING_IGNORE_GCC("-Wstringop-overflow")
180180

181-
std::optional<error_type> error_type_from_code_slow(
181+
std::optional<diag_type> error_type_from_code_slow(
182182
std::string_view code) noexcept {
183-
for (int i = 0; i < error_type_count; ++i) {
183+
for (int i = 0; i < diag_type_count; ++i) {
184184
// TODO(strager): Parse the incoming code instead of stringifying each code
185185
// in the table.
186186
auto diag_code_string = all_diagnostic_infos[i].code_string();
187187
std::string_view diag_code_string_view(diag_code_string.data(),
188188
diag_code_string.size());
189189
if (diag_code_string_view == code) {
190-
return static_cast<error_type>(i);
190+
return static_cast<diag_type>(i);
191191
}
192192
}
193193
return std::nullopt;

src/emacs-lisp-error-reporter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ void emacs_lisp_error_reporter::set_source(padded_string_view input) {
2222
this->locator_.emplace(input);
2323
}
2424

25-
void emacs_lisp_error_reporter::report_impl(error_type type, void *error) {
25+
void emacs_lisp_error_reporter::report_impl(diag_type type, void *error) {
2626
QLJS_ASSERT(this->locator_.has_value());
2727
emacs_lisp_error_formatter formatter(/*output=*/&this->output_,
2828
/*locator=*/*this->locator_);

src/error-debug.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
#include <quick-lint-js/unreachable.h>
77

88
namespace quick_lint_js {
9-
std::ostream& operator<<(std::ostream& out, error_type type) {
9+
std::ostream& operator<<(std::ostream& out, diag_type type) {
1010
switch (type) {
1111
#define QLJS_DIAG_TYPE(name, code, severity, struct_body, format_call) \
12-
case error_type::name: \
12+
case diag_type::name: \
1313
return out << #name;
1414
QLJS_X_DIAG_TYPES
1515
#undef QLJS_DIAG_TYPE

src/error-list.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ parsed_error_list parse_error_list(const char* const raw_error_list) {
9999

100100
void compiled_error_list::add(const parsed_error_list& error_list) {
101101
auto add_code = [this](std::string_view code, auto& code_set) -> void {
102-
std::optional<error_type> code_error_type = error_type_from_code_slow(code);
102+
std::optional<diag_type> code_error_type = error_type_from_code_slow(code);
103103
if (code_error_type.has_value()) {
104104
code_set[static_cast<std::size_t>(*code_error_type)] = true;
105105
} else {
@@ -159,7 +159,7 @@ std::vector<std::string> compiled_error_list::parse_warnings() const {
159159
return warnings;
160160
}
161161

162-
bool compiled_error_list::is_present(error_type type) const noexcept {
162+
bool compiled_error_list::is_present(diag_type type) const noexcept {
163163
bool is_default = true; // For now, all codes are enabled by default.
164164
bool present = true;
165165
for (const codes& c : this->parsed_error_lists_) {

src/lsp-error-reporter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ lsp_error_reporter::lsp_error_reporter(byte_buffer &output,
2828

2929
void lsp_error_reporter::finish() { this->output_.append_copy(u8"]"sv); }
3030

31-
void lsp_error_reporter::report_impl(error_type type, void *error) {
31+
void lsp_error_reporter::report_impl(diag_type type, void *error) {
3232
if (this->need_comma_) {
3333
this->output_.append_copy(u8",\n"sv);
3434
}

src/quick-lint-js/buffering-error-reporter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class buffering_error_reporter final : public error_reporter {
2020

2121
~buffering_error_reporter() override;
2222

23-
void report_impl(error_type type, void *error) override;
23+
void report_impl(diag_type type, void *error) override;
2424

2525
void copy_into(error_reporter *other) const;
2626
void move_into(error_reporter *other);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class c_api_error_reporter final : public error_reporter {
3535

3636
const Diagnostic *get_diagnostics();
3737

38-
void report_impl(error_type type, void *error) override;
38+
void report_impl(diag_type type, void *error) override;
3939

4040
private:
4141
char8 *allocate_c_string(string8_view);

0 commit comments

Comments
 (0)