Skip to content

Commit

Permalink
refactor: fix clang-format formatting of templates
Browse files Browse the repository at this point in the history
clang-format's auto-detection of the language version is inconsistent,
causing different files to be formatted differently. Specify the
language version explicitly, fixing formatting in some files.
  • Loading branch information
strager committed Jul 27, 2023
1 parent aa337b9 commit 53052e8
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 31 deletions.
2 changes: 2 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

BasedOnStyle: Google

Standard: Cpp11 # TODO(strager): c++20

IncludeBlocks: Merge
IncludeCategories: [
# These headers must be included after <Windows.h>:
Expand Down
4 changes: 2 additions & 2 deletions src/quick-lint-js/configuration/change-detecting-filesystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,9 @@ class Change_Detecting_Filesystem_Win32 : public Configuration_Filesystem {
Windows_Handle_File_Ref io_completion_port_;
::ULONG_PTR completion_key_;

Hash_Map<Canonical_Path, std::unique_ptr<Watched_Directory> >
Hash_Map<Canonical_Path, std::unique_ptr<Watched_Directory>>
watched_directories_;
std::vector<std::unique_ptr<Watched_Directory> >
std::vector<std::unique_ptr<Watched_Directory>>
cancelling_watched_directories_;
std::vector<Watch_IO_Error> watch_errors_;
};
Expand Down
4 changes: 2 additions & 2 deletions src/quick-lint-js/io/event-loop-poll.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Poll_Event_Loop : public Event_Loop_Base<Derived> {
Platform_File_Ref pipe = this->const_derived().get_readable_pipe();
QLJS_SLOW_ASSERT(pipe.is_pipe_non_blocking());

Fixed_Vector< ::pollfd, 3> pollfds;
Fixed_Vector<::pollfd, 3> pollfds;

Fixed_Vector_Size read_pipe_index = pollfds.size();
pollfds.push_back(
Expand Down Expand Up @@ -73,7 +73,7 @@ class Poll_Event_Loop : public Event_Loop_Base<Derived> {
#endif

QLJS_ASSERT(pollfds.size() > 0);
int rc = ::poll(pollfds.data(), narrow_cast< ::nfds_t>(pollfds.size()),
int rc = ::poll(pollfds.data(), narrow_cast<::nfds_t>(pollfds.size()),
/*timeout=*/-1);
if (rc == -1) {
QLJS_UNIMPLEMENTED();
Expand Down
2 changes: 1 addition & 1 deletion src/quick-lint-js/logging/trace-flusher.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class Trace_Flusher {

struct Shared_State {
std::vector<Trace_Flusher_Backend*> backends;
std::vector<std::unique_ptr<Registered_Thread> > registered_threads;
std::vector<std::unique_ptr<Registered_Thread>> registered_threads;
Trace_Flusher_Thread_Index next_thread_index = 1;
bool stop_flushing_thread = false;

Expand Down
2 changes: 1 addition & 1 deletion src/quick-lint-js/lsp/lsp-json-rpc-message-parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ JSON_RPC_Message_Handler::~JSON_RPC_Message_Handler() = default;
LSP_JSON_RPC_Message_Parser::LSP_JSON_RPC_Message_Parser(
JSON_RPC_Message_Handler* handler)
: handler_(handler),
json_parser_(std::make_unique< ::simdjson::ondemand::parser>()) {}
json_parser_(std::make_unique<::simdjson::ondemand::parser>()) {}

LSP_JSON_RPC_Message_Parser::~LSP_JSON_RPC_Message_Parser() = default;

Expand Down
2 changes: 1 addition & 1 deletion src/quick-lint-js/lsp/lsp-json-rpc-message-parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class LSP_JSON_RPC_Message_Parser
void write_invalid_request_error_response();

JSON_RPC_Message_Handler* handler_;
std::unique_ptr< ::simdjson::ondemand::parser> json_parser_;
std::unique_ptr<::simdjson::ondemand::parser> json_parser_;
Outgoing_JSON_RPC_Message_Queue error_responses_;

friend Message_Parser;
Expand Down
2 changes: 1 addition & 1 deletion src/quick-lint-js/lsp/lsp-server.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ struct LSP_Documents {
};

// Key: URI
Hash_Map<String8, std::unique_ptr<Document_Base> > documents;
Hash_Map<String8, std::unique_ptr<Document_Base>> documents;
};

// A Linting_LSP_Server_Handler listens for JavaScript code changes and notifies
Expand Down
2 changes: 1 addition & 1 deletion src/quick-lint-js/lsp/lsp-workspace-configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ bool LSP_Workspace_Configuration::process_response(

bool LSP_Workspace_Configuration::process_notification(
::simdjson::ondemand::object settings) {
for (simdjson::simdjson_result< ::simdjson::ondemand::field> setting_field :
for (simdjson::simdjson_result<::simdjson::ondemand::field> setting_field :
settings) {
std::string_view name;
if (setting_field.unescaped_key().get(name) != ::simdjson::SUCCESS) {
Expand Down
2 changes: 1 addition & 1 deletion test/quick-lint-js/fake-configuration-filesystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class Fake_Configuration_Filesystem : public Configuration_Filesystem {
void clear();

private:
Hash_Map<Canonical_Path, Heap_Function<Read_File_Result()> > files_;
Hash_Map<Canonical_Path, Heap_Function<Read_File_Result()>> files_;
};
}

Expand Down
4 changes: 2 additions & 2 deletions test/test-lsp-json-rpc-message-parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ struct Test_JSON_RPC_Message_Handler : public JSON_RPC_Message_Handler {
};

std::string json_get_string(
::simdjson::simdjson_result< ::simdjson::ondemand::value>&& value) {
::simdjson::simdjson_result<::simdjson::ondemand::value>&& value) {
std::string_view s = "<not found>";
EXPECT_EQ(value.get(s), ::simdjson::error_code::SUCCESS);
return std::string(s);
Expand Down Expand Up @@ -285,7 +285,7 @@ TEST(Test_LSP_JSON_RPC_Message_Parser, single_notification_with_reply) {
this->pending_notifications.push_back(reply);
}

std::vector< ::boost::json::value> pending_notifications;
std::vector<::boost::json::value> pending_notifications;
};
Mock_LSP_Server_Handler handler;
Spy_LSP_Endpoint_Remote remote;
Expand Down
36 changes: 18 additions & 18 deletions test/test-lsp-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ TEST_F(Test_Linting_LSP_Server, initialize) {
this->server->flush_error_responses(*this->client);
this->handler->flush_pending_notifications(*this->client);

std::vector< ::boost::json::object> responses = this->client->responses();
std::vector<::boost::json::object> responses = this->client->responses();
ASSERT_EQ(responses.size(), 1);
::boost::json::object response = responses[0];
EXPECT_EQ(response["id"], 1);
Expand Down Expand Up @@ -215,7 +215,7 @@ TEST_F(Test_Linting_LSP_Server, initialize_with_different_request_ids) {
this->server->flush_error_responses(*this->client);
this->handler->flush_pending_notifications(*this->client);

std::vector< ::boost::json::object> responses = this->client->responses();
std::vector<::boost::json::object> responses = this->client->responses();
ASSERT_EQ(responses.size(), 1);
EXPECT_EQ(responses[0]["id"], test.id);
}
Expand Down Expand Up @@ -243,7 +243,7 @@ TEST_F(Test_Linting_LSP_Server, loads_config_after_client_initialization) {
this->server->flush_error_responses(*this->client);
this->handler->flush_pending_notifications(*this->client);

std::vector< ::boost::json::object> requests = this->client->requests();
std::vector<::boost::json::object> requests = this->client->requests();
ASSERT_EQ(requests.size(), 1);
::boost::json::object request = requests[0];
EXPECT_EQ(look_up(request, "method"), "workspace/configuration");
Expand All @@ -269,7 +269,7 @@ TEST_F(Test_Linting_LSP_Server, stores_config_values_after_config_response) {
this->server->flush_error_responses(*this->client);
this->handler->flush_pending_notifications(*this->client);

std::vector< ::boost::json::object> requests = this->client->requests();
std::vector<::boost::json::object> requests = this->client->requests();
ASSERT_EQ(requests.size(), 1);
::boost::json::object config_request = requests[0];
::boost::json::value config_request_id = look_up(config_request, "id");
Expand Down Expand Up @@ -322,7 +322,7 @@ TEST_F(Test_Linting_LSP_Server, config_can_be_set_with_initialize_request) {
this->server->flush_error_responses(*this->client);
this->handler->flush_pending_notifications(*this->client);

std::vector< ::boost::json::object> responses = this->client->responses();
std::vector<::boost::json::object> responses = this->client->responses();
ASSERT_EQ(responses.size(), 1);
EXPECT_EQ(responses[0]["id"], 100);

Expand Down Expand Up @@ -485,7 +485,7 @@ TEST_F(Test_Linting_LSP_Server, shutdown) {
this->server->flush_error_responses(*this->client);
this->handler->flush_pending_notifications(*this->client);

std::vector< ::boost::json::object> responses = this->client->responses();
std::vector<::boost::json::object> responses = this->client->responses();
ASSERT_EQ(responses.size(), 1);
::boost::json::object response = responses[0];
EXPECT_EQ(response["id"], 10);
Expand Down Expand Up @@ -593,7 +593,7 @@ TEST_F(Test_Linting_LSP_Server, opening_document_lints) {
this->server->flush_error_responses(*this->client);
this->handler->flush_pending_notifications(*this->client);

std::vector< ::boost::json::object> notifications =
std::vector<::boost::json::object> notifications =
this->client->notifications();
ASSERT_EQ(notifications.size(), 1);
::boost::json::object response = notifications[0];
Expand Down Expand Up @@ -1693,7 +1693,7 @@ TEST_F(Test_Linting_LSP_Server,

EXPECT_TRUE(after_config_was_loaded);

std::vector< ::boost::json::object> notifications =
std::vector<::boost::json::object> notifications =
this->client->notifications();
ASSERT_THAT(notifications, ElementsAreArray({::testing::_}));
::boost::json::object notification = notifications[0];
Expand Down Expand Up @@ -1885,7 +1885,7 @@ TEST_F(Test_Linting_LSP_Server, opening_js_file_with_unreadable_config_lints) {
EXPECT_THAT(this->lint_calls, ElementsAreArray({u8"testjs"}))
<< "should have linted despite config file being unloadable";

std::vector< ::boost::json::object> notifications =
std::vector<::boost::json::object> notifications =
this->client->notifications();
ASSERT_EQ(notifications.size(), 2);
std::size_t showMessageIndex =
Expand Down Expand Up @@ -1949,7 +1949,7 @@ TEST_F(Test_Linting_LSP_Server,
EXPECT_THAT(this->lint_calls, ElementsAreArray({u8"testjs"}))
<< "should have linted despite config file being unloadable";

std::vector< ::boost::json::object> notifications =
std::vector<::boost::json::object> notifications =
this->client->notifications();
ASSERT_EQ(notifications.size(), 2);
std::size_t showMessageIndex =
Expand Down Expand Up @@ -2024,7 +2024,7 @@ TEST_F(Test_Linting_LSP_Server, making_config_file_unreadable_relints) {
<< "should have linted twice: once on open, and once after config file "
"changed";

std::vector< ::boost::json::object> notifications =
std::vector<::boost::json::object> notifications =
this->client->notifications();
ASSERT_EQ(notifications.size(), 2);
std::size_t showMessageIndex =
Expand Down Expand Up @@ -2057,7 +2057,7 @@ TEST_F(Test_Linting_LSP_Server, opening_broken_config_file_shows_diagnostics) {
this->server->flush_error_responses(*this->client);
this->handler->flush_pending_notifications(*this->client);

std::vector< ::boost::json::object> notifications =
std::vector<::boost::json::object> notifications =
this->client->notifications();
ASSERT_EQ(notifications.size(), 1);
::boost::json::object response = notifications[0];
Expand Down Expand Up @@ -2122,7 +2122,7 @@ TEST_F(Test_Linting_LSP_Server,
this->server->flush_error_responses(*this->client);
this->handler->flush_pending_notifications(*this->client);

std::vector< ::boost::json::object> notifications =
std::vector<::boost::json::object> notifications =
this->client->notifications();
ASSERT_EQ(notifications.size(), 1);
::boost::json::object response = notifications[0];
Expand Down Expand Up @@ -2355,7 +2355,7 @@ TEST_F(Test_Linting_LSP_Server, showing_io_errors_shows_only_first) {
});
this->handler->flush_pending_notifications(*this->client);

std::vector< ::boost::json::object> notifications =
std::vector<::boost::json::object> notifications =
this->client->notifications();
ASSERT_EQ(notifications.size(), 1);
::boost::json::object show_message_message = notifications[0];
Expand Down Expand Up @@ -2385,7 +2385,7 @@ TEST_F(Test_Linting_LSP_Server, showing_io_errors_shows_only_first_ever) {
});
this->handler->flush_pending_notifications(*this->client);

std::vector< ::boost::json::object> notifications =
std::vector<::boost::json::object> notifications =
this->client->notifications();
ASSERT_EQ(notifications.size(), 1);
::boost::json::object show_message_message = notifications[0];
Expand Down Expand Up @@ -2437,7 +2437,7 @@ TEST_F(Test_Linting_LSP_Server, unimplemented_method_in_request_returns_error) {
this->server->flush_error_responses(*this->client);
this->handler->flush_pending_notifications(*this->client);

std::vector< ::boost::json::object> responses = this->client->responses();
std::vector<::boost::json::object> responses = this->client->responses();
ASSERT_EQ(responses.size(), 1);
::boost::json::object response = responses[0];
EXPECT_EQ(look_up(response, "id"), 10);
Expand Down Expand Up @@ -2650,7 +2650,7 @@ TEST(Test_LSP_JavaScript_Linter,
server.flush_error_responses(client);
handler.flush_pending_notifications(client);

std::vector< ::boost::json::object> notifications = client.notifications();
std::vector<::boost::json::object> notifications = client.notifications();
ASSERT_EQ(notifications.size(), 1);
::boost::json::object notification = notifications[0];
EXPECT_EQ(look_up(notification, "method"), "textDocument/publishDiagnostics");
Expand Down Expand Up @@ -2683,7 +2683,7 @@ TEST(Test_LSP_JavaScript_Linter,
server.flush_error_responses(client);
handler.flush_pending_notifications(client);

std::vector< ::boost::json::object> notifications = client.notifications();
std::vector<::boost::json::object> notifications = client.notifications();
ASSERT_EQ(notifications.size(), 1);
::boost::json::object notification = notifications[0];
EXPECT_EQ(look_up(notification, "method"), "textDocument/publishDiagnostics");
Expand Down
2 changes: 1 addition & 1 deletion test/test-pipe-writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Byte_Buffer byte_buffer_of(String8_View data) {
}

TEST_F(Test_Pipe_Writer, large_write_sends_fully) {
std::future<Result<Padded_String, Read_File_IO_Error> > data_future =
std::future<Result<Padded_String, Read_File_IO_Error>> data_future =
std::async(std::launch::async, [this] {
return read_file("<pipe>", this->pipe.reader.ref());
});
Expand Down

0 comments on commit 53052e8

Please sign in to comment.