Skip to content

Commit 8e34bd5

Browse files
committed
refactor(cli): move get_language out of File_To_Lint
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.
1 parent 01b73b9 commit 8e34bd5

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

src/quick-lint-js/cli/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ void run(Options o) {
301301
source.error().print_and_exit();
302302
}
303303
Linter_Options lint_options =
304-
get_linter_options_from_language(file.get_language());
304+
get_linter_options_from_language(get_language(file));
305305
lint_options.print_parser_visits = o.print_parser_visits;
306306
reporter->set_source(&*source, file);
307307
parse_and_lint(&*source, *reporter->get(), config->globals(),

src/quick-lint-js/cli/options.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,8 @@ bool Options::dump_errors(Output_Stream& out) const {
261261
return have_errors;
262262
}
263263

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

268268
Resolved_Input_File_Language get_language(const char* file,

src/quick-lint-js/cli/options.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,9 @@ struct File_To_Lint {
5353

5454
bool is_stdin = false;
5555
std::optional<int> vim_bufnr;
56-
57-
Resolved_Input_File_Language get_language() const;
5856
};
5957

58+
Resolved_Input_File_Language get_language(const File_To_Lint &file);
6059
Resolved_Input_File_Language get_language(const char *file,
6160
Raw_Input_File_Language language);
6261

0 commit comments

Comments
 (0)