Skip to content

Commit 5890d87

Browse files
committed
refactor(fe): store Diag_List directly in Lexer
Stop using a Diag_List_Diag_Reporter in Lexer.
1 parent 45d339c commit 5890d87

File tree

4 files changed

+7
-12
lines changed

4 files changed

+7
-12
lines changed

src/quick-lint-js/diag/diag-list.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ Span_Size Diag_List::size() const {
8181
}
8282

8383
bool Diag_List::reported_any_diagnostic_except_since(
84-
std::initializer_list<Diag_Type> ignored_types, const Rewind_State &r) {
84+
std::initializer_list<Diag_Type> ignored_types,
85+
const Rewind_State &r) const {
8586
for (Node_Base *node = r.last_ == nullptr ? this->first_ : r.last_;
8687
node != nullptr; node = node->next) {
8788
if (!contains(ignored_types, node->type)) {

src/quick-lint-js/diag/diag-list.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ class Diag_List {
7070
Span_Size size() const;
7171

7272
bool reported_any_diagnostic_except_since(
73-
std::initializer_list<Diag_Type> ignored_types, const Rewind_State &);
73+
std::initializer_list<Diag_Type> ignored_types,
74+
const Rewind_State &) const;
7475
bool have_diagnostic(Diag_Type type) const;
7576

7677
// Removes all diagnostics, but does not deallocate memory.

src/quick-lint-js/fe/lex.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1252,7 +1252,7 @@ void Lexer::roll_back_transaction(Lexer_Transaction&& transaction) {
12521252
this->last_last_token_end_ = transaction.old_last_last_token_end;
12531253
this->input_ = transaction.old_input;
12541254

1255-
this->diag_list_.diags().rewind(std::move(transaction.diag_list_rewind));
1255+
this->diags_.rewind(std::move(transaction.diag_list_rewind));
12561256
}
12571257

12581258
bool Lexer::transaction_has_lex_diagnostics(const Lexer_Transaction& transaction) const {

src/quick-lint-js/fe/lex.h

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,7 @@ class Lexer {
144144
bool test_for_regexp(const Char8* regexp_begin);
145145

146146
// Returns all the diagnostics reported so far by the the lexer.
147-
Diag_List& diags() { return this->diag_list_.diags(); }
148-
149-
// TODO(#1154): Delete.
150-
Diag_List_Diag_Reporter& diag_list_diag_reporter() {
151-
return this->diag_list_;
152-
}
147+
Diag_List& diags() { return this->diags_; }
153148

154149
// Save lexer state.
155150
//
@@ -348,9 +343,7 @@ class Lexer {
348343

349344
Monotonic_Allocator allocator_{"lexer::allocator_"};
350345

351-
Diag_List_Diag_Reporter diag_list_ =
352-
Diag_List_Diag_Reporter(&this->allocator_);
353-
Diag_List& diags_ = diag_list_.diags();
346+
Diag_List diags_ = Diag_List(&this->allocator_);
354347

355348
friend struct Lex_Tables;
356349
};

0 commit comments

Comments
 (0)