diff --git a/src/cmake.cc b/src/cmake.cc index f3945ac..225fce9 100644 --- a/src/cmake.cc +++ b/src/cmake.cc @@ -333,7 +333,7 @@ std::vector CMake::get_function_parameters(std::string &data) { } std::vector > > CMake::get_functions_parameters(const std::string &name) { - const std::regex function_regex("^ *"+name+" *\\( *(.*)\\) *\\r?$", std::regex::icase); + const std::regex function_regex("^ *"+name+R"( *\( *(.*)\) *\r?$)", std::regex::icase); variables.clear(); if(!parsed) parse(); @@ -348,8 +348,8 @@ std::vector > > CMak if(end_line>start_line) { auto line=files[c].substr(start_line, end_line-start_line); std::smatch sm; - const static std::regex set_regex("^ *set *\\( *([A-Za-z_][A-Za-z_0-9]*) +(.*)\\) *\\r?$", std::regex::icase); - const static std::regex project_regex("^ *project *\\( *([^ ]+).*\\) *\\r?$", std::regex::icase); + const static std::regex set_regex(R"(^ *set *\( *([A-Za-z_][A-Za-z_0-9]*) +(.*)\) *\r?$)", std::regex::icase); + const static std::regex project_regex(R"(^ *project *\( *([^ ]+).*\) *\r?$)", std::regex::icase); if(std::regex_match(line, sm, set_regex)) { auto data=sm[2].str(); while(data.size()>0 && data.back()==' ') diff --git a/src/debug_lldb.cc b/src/debug_lldb.cc index f70b3aa..ece42c3 100644 --- a/src/debug_lldb.cc +++ b/src/debug_lldb.cc @@ -1,7 +1,7 @@ #include "debug_lldb.h" -#include +#include #ifdef __APPLE__ -#include +#include #endif #include #include @@ -103,8 +103,8 @@ void Debug::LLDB::start(const std::string &command, const boost::filesystem::pat auto &arguments=std::get<2>(parsed_run_arguments); std::vector argv; - for(size_t c=0;cCreateTarget(executable.c_str()); diff --git a/src/directories.h b/src/directories.h index da6191f..53d768f 100644 --- a/src/directories.h +++ b/src/directories.h @@ -24,7 +24,7 @@ class Directories : public Gtk::ListViewText { class TreeStore : public Gtk::TreeStore { protected: - TreeStore() {} + TreeStore()=default; bool row_drop_possible_vfunc(const Gtk::TreeModel::Path &path, const Gtk::SelectionData &selection_data) const override; bool drag_data_received_vfunc(const TreeModel::Path &path, const Gtk::SelectionData &selection_data) override; @@ -56,7 +56,7 @@ public: static Directories singleton; return singleton; } - ~Directories(); + ~Directories() override; void open(const boost::filesystem::path &dir_path=""); void update(); diff --git a/src/entrybox.cc b/src/entrybox.cc index b5cd663..f29c5e0 100644 --- a/src/entrybox.cc +++ b/src/entrybox.cc @@ -2,7 +2,7 @@ std::unordered_map > EntryBox::entry_histories; -EntryBox::Entry::Entry(const std::string& content, std::function on_activate, unsigned width_chars) : Gtk::Entry(), on_activate(on_activate) { +EntryBox::Entry::Entry(const std::string& content, std::function on_activate_, unsigned width_chars) : Gtk::Entry(), on_activate(std::move(on_activate_)) { set_max_length(0); set_width_chars(width_chars); set_text(content); @@ -41,7 +41,7 @@ EntryBox::Entry::Entry(const std::string& content, std::function on_activate) : Gtk::Button(label), on_activate(on_activate) { +EntryBox::Button::Button(const std::string& label, std::function on_activate_) : Gtk::Button(label), on_activate(std::move(on_activate_)) { set_focus_on_click(false); signal_clicked().connect([this](){ if(this->on_activate) @@ -49,7 +49,7 @@ EntryBox::Button::Button(const std::string& label, std::function on_acti }); } -EntryBox::ToggleButton::ToggleButton(const std::string& label, std::function on_activate) : Gtk::ToggleButton(label), on_activate(on_activate) { +EntryBox::ToggleButton::ToggleButton(const std::string& label, std::function on_activate_) : Gtk::ToggleButton(label), on_activate(std::move(on_activate_)) { set_focus_on_click(false); signal_clicked().connect([this](){ if(this->on_activate) @@ -57,7 +57,7 @@ EntryBox::ToggleButton::ToggleButton(const std::string& label, std::function update) : Gtk::Label(), update(update) { +EntryBox::Label::Label(std::function update_) : Gtk::Label(), update(std::move(update_)) { if(this->update) this->update(-1, ""); } diff --git a/src/entrybox.h b/src/entrybox.h index 3a722be..7781e5c 100644 --- a/src/entrybox.h +++ b/src/entrybox.h @@ -10,24 +10,24 @@ class EntryBox : public Gtk::Box { public: class Entry : public Gtk::Entry { public: - Entry(const std::string& content="", std::function on_activate=nullptr, unsigned width_chars=-1); + Entry(const std::string& content="", std::function on_activate_=nullptr, unsigned width_chars=-1); std::function on_activate; private: size_t selected_history; }; class Button : public Gtk::Button { public: - Button(const std::string& label, std::function on_activate=nullptr); + Button(const std::string& label, std::function on_activate_=nullptr); std::function on_activate; }; class ToggleButton : public Gtk::ToggleButton { public: - ToggleButton(const std::string& label, std::function on_activate=nullptr); + ToggleButton(const std::string& label, std::function on_activate_=nullptr); std::function on_activate; }; class Label : public Gtk::Label { public: - Label(std::function update=nullptr); + Label(std::function update_=nullptr); std::function update; }; diff --git a/src/git.cc b/src/git.cc index 0a1d119..dfadb89 100644 --- a/src/git.cc +++ b/src/git.cc @@ -225,7 +225,7 @@ boost::filesystem::path Git::Repository::get_path() noexcept { boost::filesystem::path Git::Repository::get_root_path(const boost::filesystem::path &path) { initialize(); - git_buf root = {0, 0, 0}; + git_buf root = {nullptr, 0, 0}; { Error error; std::lock_guard lock(mutex); diff --git a/src/git.h b/src/git.h index eaf9526..616e8b0 100644 --- a/src/git.h +++ b/src/git.h @@ -17,7 +17,6 @@ public: std::string message() noexcept; public: int code=0; - Error() {} operator bool() noexcept {return code<0;} }; @@ -42,13 +41,12 @@ public: private: friend class Repository; Diff(const boost::filesystem::path &path, git_repository *repository); - git_repository *repository; - std::shared_ptr blob; + git_repository *repository=nullptr; + std::shared_ptr blob=nullptr; git_diff_options options; static int hunk_cb(const git_diff_delta *delta, const git_diff_hunk *hunk, void *payload) noexcept; static int line_cb(const git_diff_delta *delta, const git_diff_hunk *hunk, const git_diff_line *line, void *payload) noexcept; public: - Diff() : repository(nullptr), blob(nullptr) {} Lines get_lines(const std::string &buffer); static std::vector get_hunks(const std::string &old_buffer, const std::string &new_buffer); std::string get_details(const std::string &buffer, int line_nr); diff --git a/src/juci.cc b/src/juci.cc index a063a1d..a0ad677 100644 --- a/src/juci.cc +++ b/src/juci.cc @@ -6,7 +6,7 @@ #include "config.h" #include "terminal.h" #ifndef _WIN32 -#include +#include #endif int Application::on_command_line(const Glib::RefPtr &cmd) { diff --git a/src/menu.h b/src/menu.h index 9d56d6f..9a3c9ad 100644 --- a/src/menu.h +++ b/src/menu.h @@ -5,7 +5,7 @@ #include class Menu { - Menu() {} + Menu() = default; public: static Menu &get() { static Menu singleton; diff --git a/src/notebook.h b/src/notebook.h index 1a601f1..6798f4c 100644 --- a/src/notebook.h +++ b/src/notebook.h @@ -15,7 +15,7 @@ class Notebook : public Gtk::Paned { class CursorLocation { public: - CursorLocation(Source::View *view, Glib::RefPtr mark) : view(view), mark(mark) {} + CursorLocation(Source::View *view, Glib::RefPtr mark_) : view(view), mark(std::move(mark_)) {} Source::View *view; Glib::RefPtr mark; }; diff --git a/src/project.cc b/src/project.cc index 508ffcd..eea330f 100644 --- a/src/project.cc +++ b/src/project.cc @@ -713,7 +713,7 @@ void Project::LanguageProtocol::show_symbols() { } std::vector names; std::promise result_processed; - client->write_request(nullptr, "workspace/symbol", "\"query\":\""+text+"\"", [&result_processed, &names, offsets, project_path](const boost::property_tree::ptree &result, bool error) { + client->write_request(nullptr, "workspace/symbol", R"("query":")"+text+'"', [&result_processed, &names, offsets, project_path](const boost::property_tree::ptree &result, bool error) { if(!error) { for(auto it=result.begin();it!=result.end();++it) { auto name=it->second.get("name", ""); diff --git a/src/project.h b/src/project.h index d0db2c6..ca09ac5 100644 --- a/src/project.h +++ b/src/project.h @@ -41,9 +41,9 @@ namespace Project { protected: static std::unique_ptr debug_options; public: - Base() {} + Base() = default; Base(std::unique_ptr &&build): build(std::move(build)) {} - virtual ~Base() {} + virtual ~Base() = default; std::unique_ptr build; @@ -78,8 +78,7 @@ namespace Project { class LLDB : public virtual Base { public: - LLDB() {} - ~LLDB() { dispatcher.disconnect(); } + ~LLDB() override { dispatcher.disconnect(); } #ifdef JUCI_ENABLE_DEBUG std::pair debug_get_run_arguments() override; @@ -104,7 +103,6 @@ namespace Project { class LanguageProtocol : public virtual Base { public: - LanguageProtocol() {} virtual std::string get_language_id()=0; void show_symbols() override; }; @@ -122,7 +120,7 @@ namespace Project { class Markdown : public Base { public: Markdown(std::unique_ptr &&build) : Base(std::move(build)) {} - ~Markdown(); + ~Markdown() override; boost::filesystem::path last_temp_path; void compile_and_run() override; diff --git a/src/project_build.h b/src/project_build.h index d2128db..0198c88 100644 --- a/src/project_build.h +++ b/src/project_build.h @@ -6,7 +6,6 @@ namespace Project { class Build { public: - Build() {} virtual ~Build() {} boost::filesystem::path project_path; diff --git a/src/selection_dialog.cc b/src/selection_dialog.cc index 97ea28e..dd8ae62 100644 --- a/src/selection_dialog.cc +++ b/src/selection_dialog.cc @@ -36,8 +36,8 @@ void SelectionDialogBase::ListViewText::clear() { size=0; } -SelectionDialogBase::SelectionDialogBase(Gtk::TextView *text_view, Glib::RefPtr start_mark, bool show_search_entry, bool use_markup): - start_mark(start_mark), text_view(text_view), window(Gtk::WindowType::WINDOW_POPUP), vbox(Gtk::Orientation::ORIENTATION_VERTICAL), list_view_text(use_markup), show_search_entry(show_search_entry) { +SelectionDialogBase::SelectionDialogBase(Gtk::TextView *text_view, Glib::RefPtr start_mark_, bool show_search_entry, bool use_markup): + start_mark(std::move(start_mark_)), text_view(text_view), window(Gtk::WindowType::WINDOW_POPUP), vbox(Gtk::Orientation::ORIENTATION_VERTICAL), list_view_text(use_markup), show_search_entry(show_search_entry) { auto g_application=g_application_get_default(); auto gio_application=Glib::wrap(g_application, true); auto application=Glib::RefPtr::cast_static(gio_application); @@ -133,7 +133,7 @@ void SelectionDialogBase::cursor_changed() { if(!is_visible()) return; auto it=list_view_text.get_selection()->get_selected(); - unsigned int index=static_cast(-1); + auto index=static_cast(-1); if(it) index=it->get_value(list_view_text.column_record.index); if(last_index==index) diff --git a/src/selection_dialog.h b/src/selection_dialog.h index c041f4a..c8747a3 100644 --- a/src/selection_dialog.h +++ b/src/selection_dialog.h @@ -34,7 +34,7 @@ class SelectionDialogBase { }; public: - SelectionDialogBase(Gtk::TextView *text_view, Glib::RefPtr start_mark, bool show_search_entry, bool use_markup); + SelectionDialogBase(Gtk::TextView *text_view, Glib::RefPtr start_mark_, bool show_search_entry, bool use_markup); virtual ~SelectionDialogBase(); void add_row(const std::string& row); void erase_rows(); diff --git a/src/source.cc b/src/source.cc index edaf097..e40b863 100644 --- a/src/source.cc +++ b/src/source.cc @@ -71,8 +71,8 @@ Glib::RefPtr Source::guess_language(const boost::filesystem::path return language; } -Source::FixIt::FixIt(const std::string &source, const std::pair &offsets) : source(source), offsets(offsets) { - if(source.size()==0) +Source::FixIt::FixIt(std::string source_, std::pair offsets_) : source(std::move(source_)), offsets(std::move(offsets_)) { + if(this->source.size()==0) type=Type::ERASE; else { if(this->offsets.first==this->offsets.second) @@ -82,7 +82,7 @@ Source::FixIt::FixIt(const std::string &source, const std::pair } } -std::string Source::FixIt::string(Glib::RefPtr buffer) { +std::string Source::FixIt::string(const Glib::RefPtr &buffer) { auto iter=buffer->get_iter_at_line_index(offsets.first.line, offsets.first.index); unsigned first_line_offset=iter.get_line_offset()+1; iter=buffer->get_iter_at_line_index(offsets.second.line, offsets.second.index); @@ -641,7 +641,7 @@ void Source::View::setup_format_style(bool is_generic_view) { } } else if(is_generic_view) { - static std::regex regex("^\\[error\\] stdin: (.*) \\(([0-9]*):([0-9]*)\\)$"); + static std::regex regex(R"(^\[error\] stdin: (.*) \(([0-9]*):([0-9]*)\)$)"); std::string line; std::getline(stderr_stream, line); std::smatch sm; diff --git a/src/source.h b/src/source.h index 10b5153..026bd4f 100644 --- a/src/source.h +++ b/src/source.h @@ -25,8 +25,8 @@ namespace Source { class Offset { public: - Offset() {} - Offset(unsigned line, unsigned index, const boost::filesystem::path &file_path=""): line(line), index(index), file_path(file_path) {} + Offset() = default; + Offset(unsigned line, unsigned index, boost::filesystem::path file_path_=""): line(line), index(index), file_path(std::move(file_path_)) {} operator bool() { return !file_path.empty(); } bool operator==(const Offset &o) {return (line==o.line && index==o.index);} @@ -39,9 +39,9 @@ namespace Source { public: enum class Type {INSERT, REPLACE, ERASE}; - FixIt(const std::string &source, const std::pair &offsets); + FixIt(std::string source_, std::pair offsets_); - std::string string(Glib::RefPtr buffer); + std::string string(const Glib::RefPtr &buffer); Type type; std::string source; @@ -54,7 +54,7 @@ namespace Source { static std::unordered_set views; View(const boost::filesystem::path &file_path, Glib::RefPtr language, bool is_generic_view=false); - ~View(); + ~View() override; bool save() override; diff --git a/src/source_base.cc b/src/source_base.cc index 8a6813b..8f9972a 100644 --- a/src/source_base.cc +++ b/src/source_base.cc @@ -1,3 +1,5 @@ +#include + #include "source_base.h" #include "info.h" #include "terminal.h" @@ -5,9 +7,9 @@ #include "config.h" #include -Source::BaseView::BaseView(const boost::filesystem::path &file_path, Glib::RefPtr language): Gsv::View(), file_path(file_path), language(language), status_diagnostics(0, 0, 0) { +Source::BaseView::BaseView(boost::filesystem::path file_path_, Glib::RefPtr language_): Gsv::View(), file_path(std::move(file_path_)), language(std::move(language_)), status_diagnostics(0, 0, 0) { load(true); - get_buffer()->place_cursor(get_buffer()->get_iter_at_offset(0)); + get_buffer()->place_cursor(get_buffer()->get_iter_at_offset(0)); signal_focus_in_event().connect([this](GdkEventFocus *event) { if(this->last_write_time!=static_cast(-1)) @@ -119,10 +121,10 @@ void Source::BaseView::replace_text(const std::string &new_text) { std::vector> new_lines; const char* line_start=new_text.c_str(); - for(size_t i=0;i language); - ~BaseView(); + BaseView(boost::filesystem::path file_path_, Glib::RefPtr language_); + ~BaseView() override; boost::filesystem::path file_path; Glib::RefPtr language; diff --git a/src/source_clang.cc b/src/source_clang.cc index 76f5e79..f8146a7 100644 --- a/src/source_clang.cc +++ b/src/source_clang.cc @@ -535,7 +535,7 @@ Source::ClangViewAutocomplete::ClangViewAutocomplete(const boost::filesystem::pa show_arguments=false; std::string line=" "+get_line_before(); - const static std::regex dot_or_arrow("^.*[a-zA-Z0-9_\\)\\]\\>](\\.|->)([a-zA-Z0-9_]*)$"); + const static std::regex dot_or_arrow(R"(^.*[a-zA-Z0-9_\)\]\>](\.|->)([a-zA-Z0-9_]*)$)"); const static std::regex colon_colon("^.*::([a-zA-Z0-9_]*)$"); const static std::regex part_of_symbol("^.*[^a-zA-Z0-9_]+([a-zA-Z0-9_]{3,})$"); std::smatch sm; diff --git a/src/source_clang.h b/src/source_clang.h index 06faaa3..c7e1aaa 100644 --- a/src/source_clang.h +++ b/src/source_clang.h @@ -70,8 +70,8 @@ namespace Source { class ClangViewRefactor : public virtual ClangViewParse { class Identifier { public: - Identifier(const std::string &spelling, const clangmm::Cursor &cursor) - : kind(cursor.get_kind()), spelling(spelling), usr_extended(cursor.get_usr_extended()), cursor(cursor) {} + Identifier(std::string spelling_, const clangmm::Cursor &cursor) + : kind(cursor.get_kind()), spelling(std::move(spelling_)), usr_extended(cursor.get_usr_extended()), cursor(cursor) {} Identifier() : kind(static_cast(0)) {} operator bool() const { return static_cast(kind)!=0; } diff --git a/src/source_diff.h b/src/source_diff.h index d1a7ece..ed37d0b 100644 --- a/src/source_diff.h +++ b/src/source_diff.h @@ -30,7 +30,7 @@ namespace Source { }; public: DiffView(const boost::filesystem::path &file_path, Glib::RefPtr language); - ~DiffView(); + ~DiffView() override; void configure() override; diff --git a/src/source_language_protocol.cc b/src/source_language_protocol.cc index fc10ec1..2cbfccc 100644 --- a/src/source_language_protocol.cc +++ b/src/source_language_protocol.cc @@ -88,7 +88,7 @@ LanguageProtocol::Capabilities LanguageProtocol::Client::initialize(Source::Lang return capabilities; std::promise result_processed; - write_request(nullptr, "initialize", "\"processId\":"+std::to_string(process->get_id())+",\"rootUri\":\"file://"+root_uri+"\",\"capabilities\":{\"workspace\":{\"didChangeConfiguration\":{\"dynamicRegistration\":true},\"didChangeWatchedFiles\":{\"dynamicRegistration\":true},\"symbol\":{\"dynamicRegistration\":true},\"executeCommand\":{\"dynamicRegistration\":true}},\"textDocument\":{\"synchronization\":{\"dynamicRegistration\":true,\"willSave\":true,\"willSaveWaitUntil\":true,\"didSave\":true},\"completion\":{\"dynamicRegistration\":true,\"completionItem\":{\"snippetSupport\":true}},\"hover\":{\"dynamicRegistration\":true},\"signatureHelp\":{\"dynamicRegistration\":true},\"definition\":{\"dynamicRegistration\":true},\"references\":{\"dynamicRegistration\":true},\"documentHighlight\":{\"dynamicRegistration\":true},\"documentSymbol\":{\"dynamicRegistration\":true},\"codeAction\":{\"dynamicRegistration\":true},\"codeLens\":{\"dynamicRegistration\":true},\"formatting\":{\"dynamicRegistration\":true},\"rangeFormatting\":{\"dynamicRegistration\":true},\"onTypeFormatting\":{\"dynamicRegistration\":true},\"rename\":{\"dynamicRegistration\":true},\"documentLink\":{\"dynamicRegistration\":true}}},\"initializationOptions\":{\"omitInitBuild\":true},\"trace\":\"off\"", [this, &result_processed](const boost::property_tree::ptree &result, bool error) { + write_request(nullptr, "initialize", "\"processId\":"+std::to_string(process->get_id())+R"(,"rootUri":"file://)"+root_uri+R"(","capabilities":{"workspace":{"didChangeConfiguration":{"dynamicRegistration":true},"didChangeWatchedFiles":{"dynamicRegistration":true},"symbol":{"dynamicRegistration":true},"executeCommand":{"dynamicRegistration":true}},"textDocument":{"synchronization":{"dynamicRegistration":true,"willSave":true,"willSaveWaitUntil":true,"didSave":true},"completion":{"dynamicRegistration":true,"completionItem":{"snippetSupport":true}},"hover":{"dynamicRegistration":true},"signatureHelp":{"dynamicRegistration":true},"definition":{"dynamicRegistration":true},"references":{"dynamicRegistration":true},"documentHighlight":{"dynamicRegistration":true},"documentSymbol":{"dynamicRegistration":true},"codeAction":{"dynamicRegistration":true},"codeLens":{"dynamicRegistration":true},"formatting":{"dynamicRegistration":true},"rangeFormatting":{"dynamicRegistration":true},"onTypeFormatting":{"dynamicRegistration":true},"rename":{"dynamicRegistration":true},"documentLink":{"dynamicRegistration":true}}},"initializationOptions":{"omitInitBuild":true},"trace":"off")", [this, &result_processed](const boost::property_tree::ptree &result, bool error) { if(!error) { auto capabilities_pt=result.find("capabilities"); if(capabilities_pt!=result.not_found()) { @@ -106,7 +106,7 @@ LanguageProtocol::Capabilities LanguageProtocol::Client::initialize(Source::Lang write_notification("initialized", ""); if(language_id=="rust") - write_notification("workspace/didChangeConfiguration", "\"settings\":{\"rust\":{\"sysroot\":null,\"target\":null,\"rustflags\":null,\"clear_env_rust_log\":true,\"build_lib\":null,\"build_bin\":null,\"cfg_test\":false,\"unstable_features\":false,\"wait_to_build\":500,\"show_warnings\":true,\"goto_def_racer_fallback\":false,\"use_crate_blacklist\":true,\"build_on_save\":false,\"workspace_mode\":true,\"analyze_package\":null,\"features\":[],\"all_features\":false,\"no_default_features\":false}}"); + write_notification("workspace/didChangeConfiguration", R"("settings":{"rust":{"sysroot":null,"target":null,"rustflags":null,"clear_env_rust_log":true,"build_lib":null,"build_bin":null,"cfg_test":false,"unstable_features":false,"wait_to_build":500,"show_warnings":true,"goto_def_racer_fallback":false,"use_crate_blacklist":true,"build_on_save":false,"workspace_mode":true,"analyze_package":null,"features":[],"all_features":false,"no_default_features":false}})"); } result_processed.set_value(); }); @@ -261,7 +261,7 @@ void LanguageProtocol::Client::write_request(Source::LanguageProtocolView *view, } }); } - std::string content("{\"jsonrpc\":\"2.0\",\"id\":"+std::to_string(message_id++)+",\"method\":\""+method+"\",\"params\":{"+params+"}}"); + std::string content(R"({"jsonrpc":"2.0","id":)"+std::to_string(message_id++)+R"(,"method":")"+method+R"(","params":{)"+params+"}}"); auto message="Content-Length: "+std::to_string(content.size())+"\r\n\r\n"+content; if(output_messages_and_errors) std::cout << "Language client: " << content << std::endl; @@ -280,7 +280,7 @@ void LanguageProtocol::Client::write_request(Source::LanguageProtocolView *view, void LanguageProtocol::Client::write_notification(const std::string &method, const std::string ¶ms) { std::unique_lock lock(read_write_mutex); - std::string content("{\"jsonrpc\":\"2.0\",\"method\":\""+method+"\",\"params\":{"+params+"}}"); + std::string content(R"({"jsonrpc":"2.0","method":")"+method+R"(","params":{)"+params+"}}"); auto message="Content-Length: "+std::to_string(content.size())+"\r\n\r\n"+content; if(output_messages_and_errors) std::cout << "Language client: " << content << std::endl; @@ -356,7 +356,7 @@ Source::LanguageProtocolView::LanguageProtocolView(const boost::filesystem::path std::string text=get_buffer()->get_text(); escape_text(text); - client->write_notification("textDocument/didOpen", "\"textDocument\":{\"uri\":\""+uri+"\",\"languageId\":\""+language_id+"\",\"version\":"+std::to_string(document_version++)+",\"text\":\""+text+"\"}"); + client->write_notification("textDocument/didOpen", R"("textDocument":{"uri":")"+uri+R"(","languageId":")"+language_id+R"(","version":)"+std::to_string(document_version++)+R"(,"text":")"+text+"\"}"); setup_autocomplete(); setup_navigation_and_refactoring(); @@ -391,14 +391,14 @@ Source::LanguageProtocolView::LanguageProtocolView(const boost::filesystem::path if(capabilities.text_document_sync==LanguageProtocol::Capabilities::TextDocumentSync::INCREMENTAL) { std::string text=text_; escape_text(text); - content_changes="{\"range\":{\"start\":{\"line\": "+std::to_string(start.get_line())+",\"character\":"+std::to_string(start.get_line_offset())+"},\"end\":{\"line\":"+std::to_string(start.get_line())+",\"character\":"+std::to_string(start.get_line_offset())+"}},\"text\":\""+text+"\"}"; + content_changes=R"({"range":{"start":{"line": )"+std::to_string(start.get_line())+",\"character\":"+std::to_string(start.get_line_offset())+R"(},"end":{"line":)"+std::to_string(start.get_line())+",\"character\":"+std::to_string(start.get_line_offset())+R"(}},"text":")"+text+"\"}"; } else { std::string text=get_buffer()->get_text(); escape_text(text); - content_changes="{\"text\":\""+text+"\"}"; + content_changes=R"({"text":")"+text+"\"}"; } - client->write_notification("textDocument/didChange", "\"textDocument\":{\"uri\":\""+uri+"\",\"version\":"+std::to_string(document_version++)+"},\"contentChanges\":["+content_changes+"]"); + client->write_notification("textDocument/didChange", R"("textDocument":{"uri":")"+uri+R"(","version":)"+std::to_string(document_version++)+"},\"contentChanges\":["+content_changes+"]"); }, false); get_buffer()->signal_erase().connect([this](const Gtk::TextBuffer::iterator &start, const Gtk::TextBuffer::iterator &end) { @@ -406,13 +406,13 @@ Source::LanguageProtocolView::LanguageProtocolView(const boost::filesystem::path if(capabilities.text_document_sync==LanguageProtocol::Capabilities::TextDocumentSync::NONE) return; if(capabilities.text_document_sync==LanguageProtocol::Capabilities::TextDocumentSync::INCREMENTAL) - content_changes="{\"range\":{\"start\":{\"line\": "+std::to_string(start.get_line())+",\"character\":"+std::to_string(start.get_line_offset())+"},\"end\":{\"line\":"+std::to_string(end.get_line())+",\"character\":"+std::to_string(end.get_line_offset())+"}},\"text\":\"\"}"; + content_changes=R"({"range":{"start":{"line": )"+std::to_string(start.get_line())+",\"character\":"+std::to_string(start.get_line_offset())+R"(},"end":{"line":)"+std::to_string(end.get_line())+",\"character\":"+std::to_string(end.get_line_offset())+R"(}},"text":""})"; else { std::string text=get_buffer()->get_text(); escape_text(text); - content_changes="{\"text\":\""+text+"\"}"; + content_changes=R"({"text":")"+text+"\"}"; } - client->write_notification("textDocument/didChange", "\"textDocument\":{\"uri\":\""+uri+"\",\"version\":"+std::to_string(document_version++)+"},\"contentChanges\":["+content_changes+"]"); + client->write_notification("textDocument/didChange", R"("textDocument":{"uri":")"+uri+R"(","version":)"+std::to_string(document_version++)+"},\"contentChanges\":["+content_changes+"]"); }, false); } @@ -424,7 +424,7 @@ Source::LanguageProtocolView::~LanguageProtocolView() { if(autocomplete.thread.joinable()) autocomplete.thread.join(); - client->write_notification("textDocument/didClose", "\"textDocument\":{\"uri\":\""+uri+"\"}"); + client->write_notification("textDocument/didClose", R"("textDocument":{"uri":")"+uri+"\"}"); client->close(this); client=nullptr; @@ -477,11 +477,11 @@ void Source::LanguageProtocolView::setup_navigation_and_refactoring() { method="textDocument/rangeFormatting"; Gtk::TextIter start, end; get_buffer()->get_selection_bounds(start, end); - params="\"textDocument\":{\"uri\":\""+uri+"\"},\"range\":{\"start\":{\"line\":"+std::to_string(start.get_line())+",\"character\":"+std::to_string(start.get_line_offset())+"},\"end\":{\"line\":"+std::to_string(end.get_line())+",\"character\":"+std::to_string(end.get_line_offset())+"}},\"options\":{"+options+"}"; + params=R"("textDocument":{"uri":")"+uri+R"("},"range":{"start":{"line":)"+std::to_string(start.get_line())+",\"character\":"+std::to_string(start.get_line_offset())+R"(},"end":{"line":)"+std::to_string(end.get_line())+",\"character\":"+std::to_string(end.get_line_offset())+"}},\"options\":{"+options+"}"; } else { method="textDocument/formatting"; - params="\"textDocument\":{\"uri\":\""+uri+"\"},\"options\":{"+options+"}"; + params=R"("textDocument":{"uri":")"+uri+R"("},"options":{)"+options+"}"; } client->write_request(this, method, params, [&replaces, &result_processed](const boost::property_tree::ptree &result, bool error) { @@ -552,7 +552,7 @@ void Source::LanguageProtocolView::setup_navigation_and_refactoring() { std::vector> usages; std::vector end_offsets; std::promise result_processed; - client->write_request(this, "textDocument/references", "\"textDocument\":{\"uri\":\""+uri+"\"}, \"position\": {\"line\": "+std::to_string(iter.get_line())+", \"character\": "+std::to_string(iter.get_line_offset())+"}, \"context\": {\"includeDeclaration\": true}", [&usages, &end_offsets, &result_processed](const boost::property_tree::ptree &result, bool error) { + client->write_request(this, "textDocument/references", R"("textDocument":{"uri":")"+uri+R"("}, "position": {"line": )"+std::to_string(iter.get_line())+", \"character\": "+std::to_string(iter.get_line_offset())+R"(}, "context": {"includeDeclaration": true})", [&usages, &end_offsets, &result_processed](const boost::property_tree::ptree &result, bool error) { if(!error) { try { for(auto it=result.begin();it!=result.end();++it) { @@ -612,7 +612,7 @@ void Source::LanguageProtocolView::setup_navigation_and_refactoring() { }; std::map> file_lines; - size_t c=static_cast(-1); + auto c=static_cast(-1); for(auto &usage: usages) { ++c; auto view_it=views.end(); @@ -697,7 +697,7 @@ void Source::LanguageProtocolView::setup_navigation_and_refactoring() { auto iter=get_buffer()->get_insert()->get_iter(); std::vector usages; std::promise result_processed; - client->write_request(this, "textDocument/rename", "\"textDocument\":{\"uri\":\""+uri+"\"}, \"position\": {\"line\": "+std::to_string(iter.get_line())+", \"character\": "+std::to_string(iter.get_line_offset())+"}, \"newName\": \""+text+"\"", [this, &usages, &result_processed](const boost::property_tree::ptree &result, bool error) { + client->write_request(this, "textDocument/rename", R"("textDocument":{"uri":")"+uri+R"("}, "position": {"line": )"+std::to_string(iter.get_line())+", \"character\": "+std::to_string(iter.get_line_offset())+R"(}, "newName": ")"+text+"\"", [this, &usages, &result_processed](const boost::property_tree::ptree &result, bool error) { if(!error) { boost::filesystem::path project_path; auto build=Project::Build::create(file_path); @@ -955,7 +955,7 @@ void Source::LanguageProtocolView::show_type_tooltips(const Gdk::Rectangle &rect static int request_count=0; request_count++; auto current_request=request_count; - client->write_request(this, "textDocument/hover", "\"textDocument\": {\"uri\":\"file://"+file_path.string()+"\"}, \"position\": {\"line\": "+std::to_string(iter.get_line())+", \"character\": "+std::to_string(iter.get_line_offset())+"}", [this, offset, current_request](const boost::property_tree::ptree &result, bool error) { + client->write_request(this, "textDocument/hover", R"("textDocument": {"uri":"file://)"+file_path.string()+R"("}, "position": {"line": )"+std::to_string(iter.get_line())+", \"character\": "+std::to_string(iter.get_line_offset())+"}", [this, offset, current_request](const boost::property_tree::ptree &result, bool error) { if(!error) { // hover result structure vary significantly from the different language servers std::string content; @@ -1053,7 +1053,7 @@ void Source::LanguageProtocolView::tag_similar_symbols() { static int request_count=0; request_count++; auto current_request=request_count; - client->write_request(this, method, "\"textDocument\":{\"uri\":\""+uri+"\"}, \"position\": {\"line\": "+std::to_string(iter.get_line())+", \"character\": "+std::to_string(iter.get_line_offset())+"}, \"context\": {\"includeDeclaration\": true}", [this, current_request](const boost::property_tree::ptree &result, bool error) { + client->write_request(this, method, R"("textDocument":{"uri":")"+uri+R"("}, "position": {"line": )"+std::to_string(iter.get_line())+", \"character\": "+std::to_string(iter.get_line_offset())+R"(}, "context": {"includeDeclaration": true})", [this, current_request](const boost::property_tree::ptree &result, bool error) { if(!error) { std::vector> offsets; for(auto it=result.begin();it!=result.end();++it) { @@ -1089,7 +1089,7 @@ void Source::LanguageProtocolView::tag_similar_symbols() { Source::Offset Source::LanguageProtocolView::get_declaration(const Gtk::TextIter &iter) { auto offset=std::make_shared(); std::promise result_processed; - client->write_request(this, "textDocument/definition", "\"textDocument\":{\"uri\":\""+uri+"\"}, \"position\": {\"line\": "+std::to_string(iter.get_line())+", \"character\": "+std::to_string(iter.get_line_offset())+"}", [offset, &result_processed](const boost::property_tree::ptree &result, bool error) { + client->write_request(this, "textDocument/definition", R"("textDocument":{"uri":")"+uri+R"("}, "position": {"line": )"+std::to_string(iter.get_line())+", \"character\": "+std::to_string(iter.get_line_offset())+"}", [offset, &result_processed](const boost::property_tree::ptree &result, bool error) { if(!error) { for(auto it=result.begin();it!=result.end();++it) { auto uri=it->second.get("uri", ""); @@ -1147,7 +1147,7 @@ void Source::LanguageProtocolView::setup_autocomplete() { return false; std::string line=" "+get_line_before(); - const static std::regex dot_or_arrow("^.*[a-zA-Z0-9_\\)\\]\\>\"'](\\.)([a-zA-Z0-9_]*)$"); + const static std::regex dot_or_arrow(R"(^.*[a-zA-Z0-9_\)\]\>"'](\.)([a-zA-Z0-9_]*)$)"); const static std::regex colon_colon("^.*::([a-zA-Z0-9_]*)$"); const static std::regex part_of_symbol("^.*[^a-zA-Z0-9_]+([a-zA-Z0-9_]{3,})$"); std::smatch sm; @@ -1211,7 +1211,7 @@ void Source::LanguageProtocolView::setup_autocomplete() { autocomplete_comment.clear(); autocomplete_insert.clear(); std::promise result_processed; - client->write_request(this, "textDocument/completion", "\"textDocument\":{\"uri\":\""+uri+"\"}, \"position\": {\"line\": "+std::to_string(line_number-1)+", \"character\": "+std::to_string(column-1)+"}", [this, &result_processed](const boost::property_tree::ptree &result, bool error) { + client->write_request(this, "textDocument/completion", R"("textDocument":{"uri":")"+uri+R"("}, "position": {"line": )"+std::to_string(line_number-1)+", \"character\": "+std::to_string(column-1)+"}", [this, &result_processed](const boost::property_tree::ptree &result, bool error) { if(!error) { auto begin=result.begin(); // rust language server is bugged auto end=result.end(); diff --git a/src/source_language_protocol.h b/src/source_language_protocol.h index 967c6fc..71e68c3 100644 --- a/src/source_language_protocol.h +++ b/src/source_language_protocol.h @@ -85,7 +85,7 @@ namespace Source { class LanguageProtocolView : public View { public: LanguageProtocolView(const boost::filesystem::path &file_path, Glib::RefPtr language, std::string language_id_); - ~LanguageProtocolView(); + ~LanguageProtocolView() override; std::string uri; bool save() override; diff --git a/src/source_spellcheck.h b/src/source_spellcheck.h index a320760..e5df4cc 100644 --- a/src/source_spellcheck.h +++ b/src/source_spellcheck.h @@ -6,7 +6,7 @@ namespace Source { class SpellCheckView : virtual public Source::BaseView { public: SpellCheckView(const boost::filesystem::path &file_path, Glib::RefPtr language); - ~SpellCheckView(); + ~SpellCheckView() override; void configure() override; void hide_dialogs() override; diff --git a/src/tooltips.cc b/src/tooltips.cc index 7e61221..841016c 100644 --- a/src/tooltips.cc +++ b/src/tooltips.cc @@ -4,9 +4,9 @@ std::set Tooltips::shown_tooltips; Gdk::Rectangle Tooltips::drawn_tooltips_rectangle=Gdk::Rectangle(); -Tooltip::Tooltip(std::function()> create_tooltip_buffer, Gtk::TextView *text_view, -Glib::RefPtr start_mark, Glib::RefPtr end_mark) - : start_mark(start_mark), end_mark(end_mark), create_tooltip_buffer(create_tooltip_buffer), text_view(text_view) {} +Tooltip::Tooltip(std::function()> create_tooltip_buffer_, Gtk::TextView *text_view, + Glib::RefPtr start_mark_, Glib::RefPtr end_mark_) + : start_mark(std::move(start_mark_)), end_mark(std::move(end_mark_)), create_tooltip_buffer(std::move(create_tooltip_buffer_)), text_view(text_view) {} Tooltip::~Tooltip() { Tooltips::shown_tooltips.erase(this); diff --git a/src/tooltips.h b/src/tooltips.h index a032cb2..26f8896 100644 --- a/src/tooltips.h +++ b/src/tooltips.h @@ -7,8 +7,8 @@ class Tooltip { public: - Tooltip(std::function()> create_tooltip_buffer, Gtk::TextView *text_view, Glib::RefPtr start_mark, Glib::RefPtr end_mark); - Tooltip(std::function()> create_tooltip_buffer) : Tooltip(create_tooltip_buffer, nullptr, Glib::RefPtr(), Glib::RefPtr()) {} + Tooltip(std::function()> create_tooltip_buffer_, Gtk::TextView *text_view, Glib::RefPtr start_mark_, Glib::RefPtr end_mark_); + Tooltip(std::function()> create_tooltip_buffer_) : Tooltip(std::move(create_tooltip_buffer_), nullptr, Glib::RefPtr(), Glib::RefPtr()) {} ~Tooltip(); void update(); diff --git a/src/usages_clang.cc b/src/usages_clang.cc index 6b861b1..ccd54cf 100644 --- a/src/usages_clang.cc +++ b/src/usages_clang.cc @@ -33,9 +33,9 @@ bool Usages::Clang::Cache::Cursor::operator==(const Cursor &o) { return false; } -Usages::Clang::Cache::Cache(const boost::filesystem::path &project_path, const boost::filesystem::path &build_path, const boost::filesystem::path &path, +Usages::Clang::Cache::Cache(boost::filesystem::path project_path_, boost::filesystem::path build_path_, const boost::filesystem::path &path, std::time_t before_parse_time, clangmm::TranslationUnit *translation_unit, clangmm::Tokens *clang_tokens) - : project_path(project_path), build_path(build_path) { + : project_path(std::move(project_path_)), build_path(std::move(build_path_)) { for(auto &clang_token : *clang_tokens) { tokens.emplace_back(Token{clang_token.get_spelling(), clang_token.get_source_range().get_offsets(), static_cast(-1)}); @@ -71,7 +71,7 @@ Usages::Clang::Cache::Cache(const boost::filesystem::path &project_path, const b std::time_t before_parse_time; std::map &paths_and_last_write_times; }; - VisitorData visitor_data{project_path, path, before_parse_time, paths_and_last_write_times}; + VisitorData visitor_data{this->project_path, path, before_parse_time, paths_and_last_write_times}; clang_getInclusions(translation_unit->cx_tu, [](CXFile included_file, CXSourceLocation *inclusion_stack, unsigned include_len, CXClientData data) { auto visitor_data = static_cast(data); diff --git a/src/usages_clang.h b/src/usages_clang.h index 492a21c..bce406b 100644 --- a/src/usages_clang.h +++ b/src/usages_clang.h @@ -30,7 +30,7 @@ namespace boost { namespace Usages { class Clang { public: - typedef std::set PathSet; + using PathSet = std::set; class Usages { public: @@ -89,8 +89,8 @@ namespace Usages { std::vector cursors; std::map paths_and_last_write_times; - Cache() {} - Cache(const boost::filesystem::path &project_path, const boost::filesystem::path &build_path, const boost::filesystem::path &path, + Cache() = default; + Cache(boost::filesystem::path project_path_, boost::filesystem::path build_path_, const boost::filesystem::path &path, std::time_t before_parse_time, clangmm::TranslationUnit *translation_unit, clangmm::Tokens *clang_tokens); operator bool() const { return !paths_and_last_write_times.empty(); } diff --git a/src/window.cc b/src/window.cc index e9f3311..62a6dc8 100644 --- a/src/window.cc +++ b/src/window.cc @@ -235,9 +235,9 @@ void Window::set_menu_actions() { boost::filesystem::path project_path = Dialog::new_folder(Notebook::get().get_current_folder()); if(project_path!="") { auto project_name=project_path.filename().string(); - for(size_t c=0;c