Skip to content

Commit

Permalink
refactor(fe): delete unused user_diag_reporter_ code
Browse files Browse the repository at this point in the history
user_diag_reporter_ is always a Null_Diag_Reporter. Stop calling
Null_Diag_Reporter::report_impl (which does nothing).
  • Loading branch information
strager committed Aug 20, 2024
1 parent 327e3b2 commit 8dc6f4f
Show file tree
Hide file tree
Showing 7 changed files with 1 addition and 49 deletions.
11 changes: 0 additions & 11 deletions src/quick-lint-js/fe/lex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,6 @@ Lexer::Lexer(Padded_String_View input)

Lexer::Lexer(Padded_String_View input, Lexer_Options options)
: input_(input.data()),
user_diag_reporter_(&Null_Diag_Reporter::instance),
original_input_(input),
options_(options) {
this->last_token_.end = this->input_;
Expand Down Expand Up @@ -265,8 +264,6 @@ void Lexer::parse_bom_before_shebang() {
while (!this->try_parse_current_token()) {
// Loop.
}

this->flush_diags_to_user_reporter_if_needed();
}

bool Lexer::try_parse_current_token() {
Expand Down Expand Up @@ -1063,8 +1060,6 @@ void Lexer::skip_in_jsx() {
}
break;
}

this->flush_diags_to_user_reporter_if_needed();
}

void Lexer::skip_in_jsx_children() {
Expand Down Expand Up @@ -1244,8 +1239,6 @@ void Lexer::reparse_as_regexp() {

this->input_ = c;
this->last_token_.end = this->input_;

this->flush_diags_to_user_reporter_if_needed();
}

Lexer_Transaction Lexer::begin_transaction() {
Expand All @@ -1266,8 +1259,6 @@ void Lexer::commit_transaction(Lexer_Transaction&& transaction) {
this->diag_reporter_ = transaction.old_diag_reporter;

transaction.reporter.reset();

this->flush_diags_to_user_reporter_if_needed();
}

void Lexer::roll_back_transaction(Lexer_Transaction&& transaction) {
Expand Down Expand Up @@ -2307,8 +2298,6 @@ void Lexer::skip_jsx_text() {
done:
// TODO(strager): Should we set has_leading_newline?
this->input_ = c;

this->flush_diags_to_user_reporter_if_needed();
}

bool Lexer::is_eof(const Char8* input) const {
Expand Down
16 changes: 0 additions & 16 deletions src/quick-lint-js/fe/lex.h
Original file line number Diff line number Diff line change
Expand Up @@ -342,25 +342,9 @@ class Lexer {

static Token_Type identifier_token_type(String8_View);

public:
// TODO(#1154): Delete this.
void flush_diags_to_user_reporter_if_needed() {
int i = 0;
this->diags().for_each([&](Diag_Type diag_type, void* diag_data) {
if (i >= this->diags_reporter_to_user_) {
this->user_diag_reporter_->report_impl(diag_type, diag_data);
this->diags_reporter_to_user_ += 1;
}
i += 1;
});
}

private:
Token last_token_;
const Char8* last_last_token_end_;
const Char8* input_;
Diag_Reporter* user_diag_reporter_; // TODO(#1154): Delete.
int diags_reporter_to_user_ = 0; // TODO(#1154): Delete.
Padded_String_View original_input_;
Lexer_Options options_;

Expand Down
4 changes: 1 addition & 3 deletions src/quick-lint-js/fe/parse-expression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,9 +347,7 @@ Expression* Parser::parse_expression(Parse_Visitor_Base& v, Precedence prec) {
if (!prec.binary_operators && prec.math_or_logical_or_assignment) {
return ast;
}
ast = this->parse_expression_remainder(v, ast, prec);
this->flush_diags_to_user_reporter_if_needed();
return ast;
return this->parse_expression_remainder(v, ast, prec);
}

// TODO(strager): Why do we need precedence here? Could we get rid of prec?
Expand Down
6 changes: 0 additions & 6 deletions src/quick-lint-js/fe/parse-statement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ void Parser::parse_and_visit_module(Parse_Visitor_Base &v) {
}
this->check_all_jsx_attributes();
v.visit_end_of_module();
this->flush_diags_to_user_reporter_if_needed();
}

bool Parser::parse_and_visit_statement(Parse_Visitor_Base &v,
Expand Down Expand Up @@ -785,7 +784,6 @@ bool Parser::parse_and_visit_statement(Parse_Visitor_Base &v,

case Token_Type::end_of_file:
case Token_Type::right_curly:
this->flush_diags_to_user_reporter_if_needed();
// Do not set is_current_typescript_namespace_non_empty_.
return false;

Expand All @@ -794,7 +792,6 @@ bool Parser::parse_and_visit_statement(Parse_Visitor_Base &v,
break;
}

this->flush_diags_to_user_reporter_if_needed();
return true;
}

Expand Down Expand Up @@ -1684,7 +1681,6 @@ void Parser::parse_and_visit_typescript_generic_parameters(
});
}
this->skip();
this->flush_diags_to_user_reporter_if_needed();
return;
}
for (const Source_Code_Span &comma : leading_commas) {
Expand Down Expand Up @@ -1909,8 +1905,6 @@ void Parser::parse_and_visit_typescript_generic_parameters(

// See NOTE[generic-type-parameter-visit-order].
extends_visits.visitor().move_into(v);

this->flush_diags_to_user_reporter_if_needed();
}

void Parser::parse_and_visit_statement_block_no_scope(Parse_Visitor_Base &v) {
Expand Down
2 changes: 0 additions & 2 deletions src/quick-lint-js/fe/parse-type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -911,8 +911,6 @@ void Parser::parse_and_visit_typescript_type_expression_no_scope(
.parse_question_as_invalid = false,
});
}

this->flush_diags_to_user_reporter_if_needed();
}

void Parser::parse_and_visit_typescript_arrow_type_expression(
Expand Down
1 change: 0 additions & 1 deletion src/quick-lint-js/fe/parse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -965,7 +965,6 @@ void Parser::commit_transaction(Parser_Transaction&& transaction) {
this->diag_reporter_ = transaction.old_diag_reporter;

this->lexer_.commit_transaction(std::move(transaction.lex_transaction));
this->flush_diags_to_user_reporter_if_needed();
}

void Parser::roll_back_transaction(Parser_Transaction&& transaction) {
Expand Down
10 changes: 0 additions & 10 deletions src/quick-lint-js/fe/parse.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,6 @@ class Parser {
return this->lexer_.diag_list_diag_reporter();
}

private:
// TODO(#1154): Delete this.
void flush_diags_to_user_reporter_if_needed() {
this->lexer_.flush_diags_to_user_reporter_if_needed();
}

public:
// For testing and internal use only.
[[nodiscard]] Function_Guard enter_function(Function_Attributes);

Expand Down Expand Up @@ -179,7 +172,6 @@ class Parser {
break;
}

this->flush_diags_to_user_reporter_if_needed();
return false;
});

Expand Down Expand Up @@ -859,8 +851,6 @@ class Parser {
auto disable_guard = alloc.disable();
this->visit_expression(ast, v, Variable_Context::rhs);
}

this->flush_diags_to_user_reporter_if_needed();
}

Expression *parse_expression(Parse_Visitor_Base &, Precedence);
Expand Down

0 comments on commit 8dc6f4f

Please sign in to comment.