Skip to content

Commit

Permalink
refactor(cli): move get_language out of File_To_Lint
Browse files Browse the repository at this point in the history
get_language is a bit weird. There are two functions: a top-level
function and a member function of File_To_Lint. Make both versions
top-level functions. This makes it more obvious that the functions do
the same thing, and will make it more natural to add some features to
get_language later.
  • Loading branch information
strager committed Oct 19, 2023
1 parent 8e05726 commit a0f9c15
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/quick-lint-js/cli/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ void run(Options o) {
source.error().print_and_exit();
}
Linter_Options lint_options =
get_linter_options_from_language(file.get_language());
get_linter_options_from_language(get_language(file));
lint_options.print_parser_visits = o.print_parser_visits;
reporter->set_source(&*source, file);
parse_and_lint(&*source, *reporter->get(), config->globals(),
Expand Down
4 changes: 2 additions & 2 deletions src/quick-lint-js/cli/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,8 @@ bool Options::dump_errors(Output_Stream& out) const {
return have_errors;
}

Resolved_Input_File_Language File_To_Lint::get_language() const {
return quick_lint_js::get_language(this->path, this->language);
Resolved_Input_File_Language get_language(const File_To_Lint& file) {
return get_language(file.path, file.language);
}

Resolved_Input_File_Language get_language(const char* file,
Expand Down
3 changes: 1 addition & 2 deletions src/quick-lint-js/cli/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,9 @@ struct File_To_Lint {

bool is_stdin = false;
std::optional<int> vim_bufnr;

Resolved_Input_File_Language get_language() const;
};

Resolved_Input_File_Language get_language(const File_To_Lint &file);
Resolved_Input_File_Language get_language(const char *file,
Raw_Input_File_Language language);

Expand Down

0 comments on commit a0f9c15

Please sign in to comment.