Skip to content

Commit 309863e

Browse files
committed
refactor: rename classes and type aliases to Upper_Snake_Case
See the updates to ADR018.
1 parent 8af513a commit 309863e

File tree

432 files changed

+28385
-28381
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

432 files changed

+28385
-28381
lines changed

benchmark/benchmark-cli-location.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ namespace quick_lint_js {
1313
namespace {
1414
void benchmark_location_scale_of_long_line(::benchmark::State &state) {
1515
int line_length = 10'000;
16-
padded_string line(string8(narrow_cast<std::size_t>(line_length), u8'x'));
16+
Padded_String line(String8(narrow_cast<std::size_t>(line_length), u8'x'));
1717
for (auto _ : state) {
18-
cli_locator l(&line);
18+
CLI_Locator l(&line);
1919
for (int i = 0; i < line_length; ++i) {
20-
cli_source_position p = l.position(&line[i]);
20+
CLI_Source_Position p = l.position(&line[i]);
2121
::benchmark::DoNotOptimize(p);
2222
}
2323
}
@@ -26,11 +26,11 @@ BENCHMARK(benchmark_location_scale_of_long_line);
2626

2727
void benchmark_location_scale_of_empty_lines(::benchmark::State &state) {
2828
int line_count = 10'000;
29-
padded_string lines(string8(narrow_cast<std::size_t>(line_count), u8'\n'));
29+
Padded_String lines(String8(narrow_cast<std::size_t>(line_count), u8'\n'));
3030
for (auto _ : state) {
31-
cli_locator l(&lines);
31+
CLI_Locator l(&lines);
3232
for (int i = 0; i < line_count; ++i) {
33-
cli_source_position p = l.position(&lines[i]);
33+
CLI_Source_Position p = l.position(&lines[i]);
3434
::benchmark::DoNotOptimize(p);
3535
}
3636
}
@@ -40,12 +40,12 @@ BENCHMARK(benchmark_location_scale_of_empty_lines);
4040
void benchmark_range_scale_of_empty_lines(::benchmark::State &state) {
4141
int line_length = 10'000;
4242
int span_length = 5;
43-
padded_string line(string8(narrow_cast<std::size_t>(line_length), u8'\n'));
43+
Padded_String line(String8(narrow_cast<std::size_t>(line_length), u8'\n'));
4444
for (auto _ : state) {
45-
cli_locator l(&line);
45+
CLI_Locator l(&line);
4646
for (int i = 0; i < line_length - span_length; i += span_length) {
47-
source_code_span span(&line[i], &line[i + span_length]);
48-
cli_source_range r = l.range(span);
47+
Source_Code_Span span(&line[i], &line[i + span_length]);
48+
CLI_Source_Range r = l.range(span);
4949
::benchmark::DoNotOptimize(r);
5050
}
5151
}
@@ -59,9 +59,9 @@ void benchmark_location_realisticish(::benchmark::State &state) {
5959
/*line_count=*/line_count, /*span_count=*/span_count);
6060

6161
for (auto _ : state) {
62-
cli_locator l(code.source.get());
63-
for (const source_code_span &span : code.spans) {
64-
cli_source_range r = l.range(span);
62+
CLI_Locator l(code.source.get());
63+
for (const Source_Code_Span &span : code.spans) {
64+
CLI_Source_Range r = l.range(span);
6565
::benchmark::DoNotOptimize(r);
6666
}
6767
}

benchmark/benchmark-configuration-loader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ void benchmark_no_config_file(::benchmark::State& state) {
2626
write_file_or_exit(path, u8"");
2727

2828
for (auto _ : state) {
29-
configuration_loader loader(basic_configuration_filesystem::instance());
29+
Configuration_Loader loader(Basic_Configuration_Filesystem::instance());
3030
auto config = loader.load_for_file(path);
3131
::benchmark::DoNotOptimize(config);
3232
}

benchmark/benchmark-configuration.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ using namespace std::literals::string_view_literals;
1111
namespace quick_lint_js {
1212
namespace {
1313
void benchmark_parse_config_json(::benchmark::State& state,
14-
string8_view config_json) {
15-
padded_string config_json_string(config_json);
16-
null_diag_reporter diag_reporter;
14+
String8_View config_json) {
15+
Padded_String config_json_string(config_json);
16+
Null_Diag_Reporter diag_reporter;
1717

18-
configuration config;
18+
Configuration config;
1919
for (auto _ : state) {
2020
config.reset();
2121
config.load_from_json(&config_json_string, &diag_reporter);
@@ -47,7 +47,7 @@ BENCHMARK_CAPTURE(benchmark_parse_config_json, medium_sized,
4747
)"sv);
4848

4949
void benchmark_config_globals_default(::benchmark::State& state) {
50-
configuration config;
50+
Configuration config;
5151
for (auto _ : state) {
5252
config.reset();
5353
::benchmark::DoNotOptimize(config.globals());
@@ -56,7 +56,7 @@ void benchmark_config_globals_default(::benchmark::State& state) {
5656
BENCHMARK(benchmark_config_globals_default);
5757

5858
void benchmark_config_globals_cleared(::benchmark::State& state) {
59-
configuration config;
59+
Configuration config;
6060
for (auto _ : state) {
6161
config.reset();
6262
config.reset_global_groups();

benchmark/benchmark-lex.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99

1010
namespace quick_lint_js {
1111
namespace {
12-
void benchmark_lex(::benchmark::State &state, string8_view raw_source) {
13-
padded_string source(raw_source);
12+
void benchmark_lex(::benchmark::State &state, String8_View raw_source) {
13+
Padded_String source(raw_source);
1414
for (auto _ : state) {
15-
lexer l(&source, &null_diag_reporter::instance);
16-
while (l.peek().type != token_type::end_of_file) {
15+
Lexer l(&source, &Null_Diag_Reporter::instance);
16+
while (l.peek().type != Token_Type::end_of_file) {
1717
l.skip();
1818
}
1919
::benchmark::DoNotOptimize(l.peek().type);

benchmark/benchmark-lint.cpp

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,18 @@ void benchmark_lint(benchmark::State &state) {
3131
source_path_env_var);
3232
std::exit(1);
3333
}
34-
padded_string source = quick_lint_js::read_file_or_exit(source_path);
34+
Padded_String source = quick_lint_js::read_file_or_exit(source_path);
3535

36-
configuration config;
37-
parser_options p_options;
38-
parser p(&source, &null_diag_reporter::instance, p_options);
39-
buffering_visitor visitor(new_delete_resource());
36+
Configuration config;
37+
Parser_Options p_options;
38+
Parser p(&source, &Null_Diag_Reporter::instance, p_options);
39+
Buffering_Visitor visitor(new_delete_resource());
4040
p.parse_and_visit_module(visitor);
4141

42-
variable_analyzer_options var_options;
42+
Variable_Analyzer_Options var_options;
4343

4444
for (auto _ : state) {
45-
variable_analyzer l(&null_diag_reporter::instance, &config.globals(),
45+
Variable_Analyzer l(&Null_Diag_Reporter::instance, &config.globals(),
4646
var_options);
4747
visitor.copy_into(l);
4848
}
@@ -61,14 +61,14 @@ void benchmark_parse_and_lint(benchmark::State &state) {
6161
source_path_env_var);
6262
std::exit(1);
6363
}
64-
padded_string source = quick_lint_js::read_file_or_exit(source_path);
64+
Padded_String source = quick_lint_js::read_file_or_exit(source_path);
6565

66-
parser_options p_options;
67-
variable_analyzer_options var_options;
68-
configuration config;
66+
Parser_Options p_options;
67+
Variable_Analyzer_Options var_options;
68+
Configuration config;
6969
for (auto _ : state) {
70-
parser p(&source, &null_diag_reporter::instance, p_options);
71-
variable_analyzer l(&null_diag_reporter::instance, &config.globals(),
70+
Parser p(&source, &Null_Diag_Reporter::instance, p_options);
71+
Variable_Analyzer l(&Null_Diag_Reporter::instance, &config.globals(),
7272
var_options);
7373
p.parse_and_visit_module(l);
7474
}
@@ -80,36 +80,36 @@ void benchmark_undeclared_variable_references(benchmark::State &state) {
8080
int global_variable_count = 1000;
8181
int variable_use_count = 1000;
8282

83-
global_declared_variable_set globals;
83+
Global_Declared_Variable_Set globals;
8484
for (int i = 0; i < global_variable_count; ++i) {
8585
globals.add_predefined_global_variable(
8686
to_string8("global" + std::to_string(i)).c_str(), /*is_writable=*/true);
8787
}
8888

8989
std::vector<std::pair<std::size_t, std::size_t>> variable_use_ranges;
90-
string8 variable_uses;
90+
String8 variable_uses;
9191
for (int i = 0; i < variable_use_count; ++i) {
9292
// NOTE(strager): The implementation might short circuit based on identifier
9393
// length. Use the same prefix so more work needs to be done.
94-
string8 variable_name = to_string8("usage_" + std::to_string(i));
94+
String8 variable_name = to_string8("usage_" + std::to_string(i));
9595
std::size_t use_begin = variable_uses.size();
9696
variable_uses += variable_name;
9797
std::size_t use_end = variable_uses.size();
9898
variable_use_ranges.emplace_back(use_begin, use_end);
9999
}
100100

101-
std::vector<identifier> variable_use_identifiers;
101+
std::vector<Identifier> variable_use_identifiers;
102102
for (auto [begin_index, end_index] : variable_use_ranges) {
103-
const char8 *begin = &variable_uses[begin_index];
104-
const char8 *end = &variable_uses[end_index];
105-
variable_use_identifiers.emplace_back(source_code_span(begin, end),
103+
const Char8 *begin = &variable_uses[begin_index];
104+
const Char8 *end = &variable_uses[end_index];
105+
variable_use_identifiers.emplace_back(Source_Code_Span(begin, end),
106106
make_string_view(begin, end));
107107
}
108108

109-
variable_analyzer_options var_options;
109+
Variable_Analyzer_Options var_options;
110110
for (auto _ : state) {
111-
variable_analyzer l(&null_diag_reporter::instance, &globals, var_options);
112-
for (identifier &variable_use : variable_use_identifiers) {
111+
Variable_Analyzer l(&Null_Diag_Reporter::instance, &globals, var_options);
112+
for (Identifier &variable_use : variable_use_identifiers) {
113113
l.visit_variable_use(variable_use);
114114
}
115115
l.visit_end_of_module();

benchmark/benchmark-lsp-document-text.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
namespace quick_lint_js {
1818
namespace {
19-
string8_view sentence = u8"The quick brown fox jumps over the lazy dog.";
19+
String8_View sentence = u8"The quick brown fox jumps over the lazy dog.";
2020

2121
// Simulate opening a document and typing a sentence.
2222
void benchmark_lsp_create_and_insert_single_characters(
@@ -26,22 +26,22 @@ void benchmark_lsp_create_and_insert_single_characters(
2626
std::mt19937_64 rng;
2727
std::vector<int> line_lengths =
2828
random_line_lengths(rng, /*line_count=*/line_count);
29-
padded_string base_code =
29+
Padded_String base_code =
3030
make_source_code(/*line_lengths=*/line_lengths, /*newline=*/u8"\n");
31-
string8_view base_code_view = base_code.string_view();
31+
String8_View base_code_view = base_code.string_view();
3232

3333
int insertion_line = narrow_cast<int>(line_lengths.size() / 2);
3434
int initial_insertion_character =
3535
line_lengths[narrow_cast<std::size_t>(insertion_line)] / 2;
3636

3737
for (auto _ : state) {
38-
lsp_document_text doc;
38+
LSP_Document_Text doc;
3939
doc.set_text(base_code_view);
4040

4141
for (int i = 0; i < narrow_cast<int>(sentence.size()); ++i) {
4242
int insertion_character = initial_insertion_character + i;
4343
doc.replace_text(
44-
lsp_range{
44+
LSP_Range{
4545
.start = {.line = insertion_line,
4646
.character = insertion_character},
4747
.end = {.line = insertion_line, .character = insertion_character},

benchmark/benchmark-lsp-location.cpp

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ namespace quick_lint_js {
1313
namespace {
1414
void benchmark_location_scale_of_long_line(::benchmark::State &state) {
1515
int line_length = 10'000;
16-
padded_string line(string8(narrow_cast<std::size_t>(line_length), u8'x'));
16+
Padded_String line(String8(narrow_cast<std::size_t>(line_length), u8'x'));
1717
for (auto _ : state) {
18-
lsp_locator l(&line);
18+
LSP_Locator l(&line);
1919
for (int i = 0; i < line_length; ++i) {
20-
lsp_position p = l.position(&line[i]);
20+
LSP_Position p = l.position(&line[i]);
2121
::benchmark::DoNotOptimize(p);
2222
}
2323
}
@@ -26,11 +26,11 @@ BENCHMARK(benchmark_location_scale_of_long_line);
2626

2727
void benchmark_from_position_scale_of_long_line(::benchmark::State &state) {
2828
int line_length = 10'000;
29-
padded_string line(string8(narrow_cast<std::size_t>(line_length), u8'x'));
29+
Padded_String line(String8(narrow_cast<std::size_t>(line_length), u8'x'));
3030
for (auto _ : state) {
31-
lsp_locator l(&line);
31+
LSP_Locator l(&line);
3232
for (int i = 0; i < line_length; ++i) {
33-
const char8 *c = l.from_position(lsp_position{.line = 0, .character = i});
33+
const Char8 *c = l.from_position(LSP_Position{.line = 0, .character = i});
3434
::benchmark::DoNotOptimize(c);
3535
}
3636
}
@@ -39,11 +39,11 @@ BENCHMARK(benchmark_from_position_scale_of_long_line);
3939

4040
void benchmark_location_scale_of_empty_lines(::benchmark::State &state) {
4141
int line_count = 10'000;
42-
padded_string lines(string8(narrow_cast<std::size_t>(line_count), u8'\n'));
42+
Padded_String lines(String8(narrow_cast<std::size_t>(line_count), u8'\n'));
4343
for (auto _ : state) {
44-
lsp_locator l(&lines);
44+
LSP_Locator l(&lines);
4545
for (int i = 0; i < line_count; ++i) {
46-
lsp_position p = l.position(&lines[i]);
46+
LSP_Position p = l.position(&lines[i]);
4747
::benchmark::DoNotOptimize(p);
4848
}
4949
}
@@ -52,11 +52,11 @@ BENCHMARK(benchmark_location_scale_of_empty_lines);
5252

5353
void benchmark_from_position_scale_of_empty_lines(::benchmark::State &state) {
5454
int line_count = 10'000;
55-
padded_string lines(string8(narrow_cast<std::size_t>(line_count), u8'\n'));
55+
Padded_String lines(String8(narrow_cast<std::size_t>(line_count), u8'\n'));
5656
for (auto _ : state) {
57-
lsp_locator l(&lines);
57+
LSP_Locator l(&lines);
5858
for (int i = 0; i < line_count; ++i) {
59-
const char8 *c = l.from_position({.line = i, .character = 0});
59+
const Char8 *c = l.from_position({.line = i, .character = 0});
6060
::benchmark::DoNotOptimize(c);
6161
}
6262
}
@@ -66,12 +66,12 @@ BENCHMARK(benchmark_from_position_scale_of_empty_lines);
6666
void benchmark_range_scale_of_empty_lines(::benchmark::State &state) {
6767
int line_length = 10'000;
6868
int span_length = 5;
69-
padded_string line(string8(narrow_cast<std::size_t>(line_length), u8'\n'));
69+
Padded_String line(String8(narrow_cast<std::size_t>(line_length), u8'\n'));
7070
for (auto _ : state) {
71-
lsp_locator l(&line);
71+
LSP_Locator l(&line);
7272
for (int i = 0; i < line_length - span_length; i += span_length) {
73-
source_code_span span(&line[i], &line[i + span_length]);
74-
lsp_range r = l.range(span);
73+
Source_Code_Span span(&line[i], &line[i + span_length]);
74+
LSP_Range r = l.range(span);
7575
::benchmark::DoNotOptimize(r);
7676
}
7777
}
@@ -85,9 +85,9 @@ void benchmark_location_realisticish(::benchmark::State &state) {
8585
/*line_count=*/line_count, /*span_count=*/span_count);
8686

8787
for (auto _ : state) {
88-
lsp_locator l(code.source.get());
89-
for (const source_code_span &span : code.spans) {
90-
lsp_range r = l.range(span);
88+
LSP_Locator l(code.source.get());
89+
for (const Source_Code_Span &span : code.spans) {
90+
LSP_Range r = l.range(span);
9191
::benchmark::DoNotOptimize(r);
9292
}
9393
}
@@ -100,20 +100,20 @@ void benchmark_from_position_realisticish(::benchmark::State &state) {
100100
source_code_with_spans code = make_realisticish_code(
101101
/*line_count=*/line_count, /*span_count=*/span_count);
102102

103-
std::vector<lsp_position> positions;
103+
std::vector<LSP_Position> positions;
104104
{
105-
lsp_locator l(code.source.get());
106-
for (const source_code_span &span : code.spans) {
107-
lsp_range r = l.range(span);
105+
LSP_Locator l(code.source.get());
106+
for (const Source_Code_Span &span : code.spans) {
107+
LSP_Range r = l.range(span);
108108
positions.push_back(r.start);
109109
positions.push_back(r.end);
110110
}
111111
}
112112

113113
for (auto _ : state) {
114-
lsp_locator l(code.source.get());
115-
for (const lsp_position &position : positions) {
116-
const char8 *c = l.from_position(position);
114+
LSP_Locator l(code.source.get());
115+
for (const LSP_Position &position : positions) {
116+
const Char8 *c = l.from_position(position);
117117
::benchmark::DoNotOptimize(c);
118118
}
119119
}

0 commit comments

Comments
 (0)