Browse Source

Fixed most of clang-tidy's performance checks

merge-requests/382/head
eidheim 8 years ago
parent
commit
31b64848e3
  1. 4
      src/cmake.cc
  2. 2
      src/ctags.cc
  3. 2
      src/ctags.h
  4. 3
      src/debug_lldb.cc
  5. 11
      src/directories.cc
  6. 4
      src/directories.h
  7. 2
      src/documentation_cppreference.cc
  8. 2
      src/documentation_cppreference.h
  9. 2
      src/menu.cc
  10. 2
      src/menu.h
  11. 2
      src/meson.cc
  12. 2
      src/notebook.cc
  13. 2
      src/notebook.h
  14. 8
      src/selection_dialog.cc
  15. 10
      src/selection_dialog.h
  16. 4
      src/source.cc
  17. 4
      src/source.h
  18. 8
      src/source_base.cc
  19. 8
      src/source_base.h
  20. 10
      src/source_clang.cc
  21. 8
      src/source_clang.h
  22. 2
      src/source_diff.cc
  23. 2
      src/source_diff.h
  24. 26
      src/source_language_protocol.cc
  25. 2
      src/source_language_protocol.h
  26. 2
      src/source_spellcheck.cc
  27. 2
      src/source_spellcheck.h
  28. 4
      src/terminal.cc
  29. 4
      src/terminal.h
  30. 2
      tests/stubs/directories.cc
  31. 6
      tests/stubs/selection_dialog.cc

4
src/cmake.cc

@ -272,11 +272,11 @@ void CMake::parse_variable_parameters(std::string &data) {
//Remove variables we do not know:
pos=data.find("${");
auto pos_end=data.find("}", pos+2);
auto pos_end=data.find('}', pos+2);
while(pos!=std::string::npos && pos_end!=std::string::npos) {
data.erase(pos, pos_end-pos+1);
pos=data.find("${");
pos_end=data.find("}", pos+2);
pos_end=data.find('}', pos+2);
}
}

2
src/ctags.cc

@ -100,7 +100,7 @@ Ctags::Location Ctags::get_location(const std::string &line, bool markup) {
}
///Split up a type into its various significant parts
std::vector<std::string> Ctags::get_type_parts(const std::string type) {
std::vector<std::string> Ctags::get_type_parts(const std::string &type) {
std::vector<std::string> parts;
size_t text_start=-1;
for(size_t c=0;c<type.size();++c) {

2
src/ctags.h

@ -23,5 +23,5 @@ public:
static std::vector<Location> get_locations(const boost::filesystem::path &path, const std::string &name, const std::string &type);
private:
static std::vector<std::string> get_type_parts(const std::string type);
static std::vector<std::string> get_type_parts(const std::string &type);
};

3
src/debug_lldb.cc

@ -103,6 +103,7 @@ void Debug::LLDB::start(const std::string &command, const boost::filesystem::pat
auto &arguments=std::get<2>(parsed_run_arguments);
std::vector<const char*> argv;
argv.reserve(arguments.size());
for(auto &argument : arguments)
argv.emplace_back(argument.c_str());
argv.emplace_back(nullptr);
@ -149,6 +150,7 @@ void Debug::LLDB::start(const std::string &command, const boost::filesystem::pat
// Create environment array
std::vector<const char*> environment;
environment.reserve(environment_from_arguments.size());
for(auto &e: environment_from_arguments)
environment.emplace_back(e.c_str());
environment.emplace_back(nullptr);
@ -160,6 +162,7 @@ void Debug::LLDB::start(const std::string &command, const boost::filesystem::pat
else {
// Create environment array
std::vector<const char*> environment;
environment.reserve(environment_from_arguments.size());
for(auto &e: environment_from_arguments)
environment.emplace_back(e.c_str());
size_t environ_size=0;

11
src/directories.cc

@ -394,7 +394,7 @@ void Directories::update() {
add_or_update_path(directory.first, directory.second, false);
}
void Directories::on_save_file(boost::filesystem::path file_path) {
void Directories::on_save_file(const boost::filesystem::path &file_path) {
auto it=directories.find(file_path.parent_path().string());
if(it!=directories.end()) {
if(it->second.repository)
@ -639,8 +639,9 @@ void Directories::remove_path(const boost::filesystem::path &dir_path) {
}
}
void Directories::colorize_path(const boost::filesystem::path &dir_path, bool include_parent_paths) {
auto it=directories.find(dir_path.string());
void Directories::colorize_path(boost::filesystem::path dir_path_, bool include_parent_paths) {
auto dir_path=std::make_shared<boost::filesystem::path>(std::move(dir_path_));
auto it=directories.find(dir_path->string());
if(it==directories.end())
return;
@ -655,8 +656,8 @@ void Directories::colorize_path(const boost::filesystem::path &dir_path, bool in
Terminal::get().async_print(std::string("Error (git): ")+e.what()+'\n', true);
}
dispatcher.post([this, dir_path=std::move(dir_path), include_parent_paths, status=std::move(status)] {
auto it=directories.find(dir_path.string());
dispatcher.post([this, dir_path, include_parent_paths, status=std::move(status)] {
auto it=directories.find(dir_path->string());
if(it==directories.end())
return;

4
src/directories.h

@ -60,7 +60,7 @@ public:
void open(const boost::filesystem::path &dir_path="");
void update();
void on_save_file(boost::filesystem::path file_path);
void on_save_file(const boost::filesystem::path &file_path);
void select(const boost::filesystem::path &path);
boost::filesystem::path path;
@ -71,7 +71,7 @@ protected:
private:
void add_or_update_path(const boost::filesystem::path &dir_path, const Gtk::TreeModel::Row &row, bool include_parent_paths);
void remove_path(const boost::filesystem::path &dir_path);
void colorize_path(const boost::filesystem::path &dir_path, bool include_parent_paths);
void colorize_path(boost::filesystem::path dir_path_, bool include_parent_paths);
Glib::RefPtr<Gtk::TreeStore> tree_store;
TreeStore::ColumnRecord column_record;

2
src/documentation_cppreference.cc

@ -1,7 +1,7 @@
#include "documentation_cppreference.h"
#include <unordered_map>
std::string Documentation::CppReference::get_url(const std::string symbol) noexcept {
std::string Documentation::CppReference::get_url(const std::string &symbol) noexcept {
// Copied from http://upload.cppreference.com/mwiki/images/d/df/html_book_20170409.zip/reference/cppreference-export-ns0,4,8,10.xml
// Using raw string instead of map to reduce compile time
const static std::string symbol_urls = R"(size_t c/types/size_t

2
src/documentation_cppreference.h

@ -4,6 +4,6 @@
namespace Documentation {
class CppReference {
public:
static std::string get_url(const std::string symbol) noexcept;
static std::string get_url(const std::string &symbol) noexcept;
};
}

2
src/menu.cc

@ -477,7 +477,7 @@ const Glib::ustring menu_xml= R"RAW(<interface>
</interface>
)RAW";
void Menu::add_action(const std::string &name, std::function<void()> action) {
void Menu::add_action(const std::string &name, const std::function<void()> &action) {
auto g_application=g_application_get_default();
auto gio_application=Glib::wrap(g_application, true);
auto application=Glib::RefPtr<Gtk::Application>::cast_static(gio_application);

2
src/menu.h

@ -12,7 +12,7 @@ public:
return singleton;
}
void add_action(const std::string &name, std::function<void()> action);
void add_action(const std::string &name, const std::function<void()> &action);
std::unordered_map<std::string, Glib::RefPtr<Gio::SimpleAction> > actions;
void set_keys();

2
src/meson.cc

@ -95,7 +95,7 @@ boost::filesystem::path Meson::get_executable(const boost::filesystem::path &bui
auto values=command.parameter_values("-o");
if(!values.empty()) {
size_t pos;
if((pos=values[0].find("@"))!=std::string::npos) {
if((pos=values[0].find('@'))!=std::string::npos) {
if(pos+1<values[0].size() && values[0].compare(pos+1, 3, "exe")==0) {
auto executable=build_path/values[0].substr(0, pos);
if(command_file==file_path)

2
src/notebook.cc

@ -10,7 +10,7 @@
#include "source_language_protocol.h"
#include "gtksourceview-3.0/gtksourceview/gtksourcemap.h"
Notebook::TabLabel::TabLabel(std::function<void()> on_close) {
Notebook::TabLabel::TabLabel(const std::function<void()> &on_close) {
set_can_focus(false);
auto button=Gtk::manage(new Gtk::Button());

2
src/notebook.h

@ -9,7 +9,7 @@
class Notebook : public Gtk::Paned {
class TabLabel : public Gtk::EventBox {
public:
TabLabel(std::function<void()> on_close);
TabLabel(const std::function<void()> &on_close);
Gtk::Label label;
};

8
src/selection_dialog.cc

@ -36,8 +36,8 @@ void SelectionDialogBase::ListViewText::clear() {
size=0;
}
SelectionDialogBase::SelectionDialogBase(Gtk::TextView *text_view, Glib::RefPtr<Gtk::TextBuffer::Mark> 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) {
SelectionDialogBase::SelectionDialogBase(Gtk::TextView *text_view, const Glib::RefPtr<Gtk::TextBuffer::Mark> &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) {
auto g_application=g_application_get_default();
auto gio_application=Glib::wrap(g_application, true);
auto application=Glib::RefPtr<Gtk::Application>::cast_static(gio_application);
@ -195,7 +195,7 @@ void SelectionDialogBase::hide() {
std::unique_ptr<SelectionDialog> SelectionDialog::instance;
SelectionDialog::SelectionDialog(Gtk::TextView *text_view, Glib::RefPtr<Gtk::TextBuffer::Mark> start_mark, bool show_search_entry, bool use_markup) : SelectionDialogBase(text_view, start_mark, show_search_entry, use_markup) {
SelectionDialog::SelectionDialog(Gtk::TextView *text_view, const Glib::RefPtr<Gtk::TextBuffer::Mark> &start_mark, bool show_search_entry, bool use_markup) : SelectionDialogBase(text_view, start_mark, show_search_entry, use_markup) {
auto search_key=std::make_shared<std::string>();
auto filter_model=Gtk::TreeModelFilter::create(list_view_text.get_model());
@ -322,7 +322,7 @@ bool SelectionDialog::on_key_press(GdkEventKey* key) {
std::unique_ptr<CompletionDialog> CompletionDialog::instance;
CompletionDialog::CompletionDialog(Gtk::TextView *text_view, Glib::RefPtr<Gtk::TextBuffer::Mark> start_mark) : SelectionDialogBase(text_view, start_mark, false, false) {
CompletionDialog::CompletionDialog(Gtk::TextView *text_view, const Glib::RefPtr<Gtk::TextBuffer::Mark> &start_mark) : SelectionDialogBase(text_view, start_mark, false, false) {
show_offset=text_view->get_buffer()->get_insert()->get_iter().get_offset();
auto search_key=std::make_shared<std::string>();

10
src/selection_dialog.h

@ -34,7 +34,7 @@ class SelectionDialogBase {
};
public:
SelectionDialogBase(Gtk::TextView *text_view, Glib::RefPtr<Gtk::TextBuffer::Mark> start_mark_, bool show_search_entry, bool use_markup);
SelectionDialogBase(Gtk::TextView *text_view, const Glib::RefPtr<Gtk::TextBuffer::Mark> &start_mark, bool show_search_entry, bool use_markup);
virtual ~SelectionDialogBase();
void add_row(const std::string& row);
void erase_rows();
@ -67,12 +67,12 @@ protected:
};
class SelectionDialog : public SelectionDialogBase {
SelectionDialog(Gtk::TextView *text_view, Glib::RefPtr<Gtk::TextBuffer::Mark> start_mark, bool show_search_entry, bool use_markup);
SelectionDialog(Gtk::TextView *text_view, const Glib::RefPtr<Gtk::TextBuffer::Mark> &start_mark, bool show_search_entry, bool use_markup);
static std::unique_ptr<SelectionDialog> instance;
public:
bool on_key_press(GdkEventKey* key);
static void create(Gtk::TextView *text_view, Glib::RefPtr<Gtk::TextBuffer::Mark> start_mark, bool show_search_entry=true, bool use_markup=false) {
static void create(Gtk::TextView *text_view, const Glib::RefPtr<Gtk::TextBuffer::Mark> &start_mark, bool show_search_entry=true, bool use_markup=false) {
instance=std::unique_ptr<SelectionDialog>(new SelectionDialog(text_view, start_mark, show_search_entry, use_markup));
}
static void create(bool show_search_entry=true, bool use_markup=false) {
@ -82,13 +82,13 @@ public:
};
class CompletionDialog : public SelectionDialogBase {
CompletionDialog(Gtk::TextView *text_view, Glib::RefPtr<Gtk::TextBuffer::Mark> start_mark);
CompletionDialog(Gtk::TextView *text_view, const Glib::RefPtr<Gtk::TextBuffer::Mark> &start_mark);
static std::unique_ptr<CompletionDialog> instance;
public:
bool on_key_release(GdkEventKey* key);
bool on_key_press(GdkEventKey* key);
static void create(Gtk::TextView *text_view, Glib::RefPtr<Gtk::TextBuffer::Mark> start_mark) {
static void create(Gtk::TextView *text_view, const Glib::RefPtr<Gtk::TextBuffer::Mark> &start_mark) {
instance=std::unique_ptr<CompletionDialog>(new CompletionDialog(text_view, start_mark));
}
static std::unique_ptr<CompletionDialog> &get() {return instance;}

4
src/source.cc

@ -114,7 +114,7 @@ std::string Source::FixIt::string(const Glib::RefPtr<Gtk::TextBuffer> &buffer) {
std::unordered_set<Source::View*> Source::View::non_deleted_views;
std::unordered_set<Source::View*> Source::View::views;
Source::View::View(const boost::filesystem::path &file_path, Glib::RefPtr<Gsv::Language> language, bool is_generic_view): BaseView(file_path, language), SpellCheckView(file_path, language), DiffView(file_path, language) {
Source::View::View(const boost::filesystem::path &file_path, const Glib::RefPtr<Gsv::Language> &language, bool is_generic_view): BaseView(file_path, language), SpellCheckView(file_path, language), DiffView(file_path, language) {
non_deleted_views.emplace(this);
views.emplace(this);
@ -2893,7 +2893,7 @@ std::pair<char, unsigned> Source::View::find_tab_char_and_size() {
/////////////////////
//// GenericView ////
/////////////////////
Source::GenericView::GenericView(const boost::filesystem::path &file_path, Glib::RefPtr<Gsv::Language> language) : BaseView(file_path, language), View(file_path, language, true) {
Source::GenericView::GenericView(const boost::filesystem::path &file_path, const Glib::RefPtr<Gsv::Language> &language) : BaseView(file_path, language), View(file_path, language, true) {
configure();
spellcheck_all=true;

4
src/source.h

@ -53,7 +53,7 @@ namespace Source {
static std::unordered_set<View*> non_deleted_views;
static std::unordered_set<View*> views;
View(const boost::filesystem::path &file_path, Glib::RefPtr<Gsv::Language> language, bool is_generic_view=false);
View(const boost::filesystem::path &file_path, const Glib::RefPtr<Gsv::Language> &language, bool is_generic_view=false);
~View() override;
bool save() override;
@ -169,7 +169,7 @@ namespace Source {
static Glib::RefPtr<CompletionBuffer> create() {return Glib::RefPtr<CompletionBuffer>(new CompletionBuffer());}
};
public:
GenericView(const boost::filesystem::path &file_path, Glib::RefPtr<Gsv::Language> language);
GenericView(const boost::filesystem::path &file_path, const Glib::RefPtr<Gsv::Language> &language);
void parse_language_file(Glib::RefPtr<CompletionBuffer> &completion_buffer, bool &has_context_class, const boost::property_tree::ptree &pt);
};

8
src/source_base.cc

@ -5,7 +5,7 @@
#include "config.h"
#include <fstream>
Source::BaseView::BaseView(boost::filesystem::path file_path_, Glib::RefPtr<Gsv::Language> language_): Gsv::View(), file_path(std::move(file_path_)), language(std::move(language_)), status_diagnostics(0, 0, 0) {
Source::BaseView::BaseView(const boost::filesystem::path &file_path, const Glib::RefPtr<Gsv::Language> &language): Gsv::View(), file_path(file_path), language(language), status_diagnostics(0, 0, 0) {
load(true);
get_buffer()->place_cursor(get_buffer()->get_iter_at_offset(0));
@ -337,7 +337,7 @@ std::string Source::BaseView::get_line(const Gtk::TextIter &iter) {
std::string line(get_buffer()->get_text(line_start_it, line_end_it));
return line;
}
std::string Source::BaseView::get_line(Glib::RefPtr<Gtk::TextBuffer::Mark> mark) {
std::string Source::BaseView::get_line(const Glib::RefPtr<Gtk::TextBuffer::Mark> &mark) {
return get_line(mark->get_iter());
}
std::string Source::BaseView::get_line(int line_nr) {
@ -352,7 +352,7 @@ std::string Source::BaseView::get_line_before(const Gtk::TextIter &iter) {
std::string line(get_buffer()->get_text(line_it, iter));
return line;
}
std::string Source::BaseView::get_line_before(Glib::RefPtr<Gtk::TextBuffer::Mark> mark) {
std::string Source::BaseView::get_line_before(const Glib::RefPtr<Gtk::TextBuffer::Mark> &mark) {
return get_line_before(mark->get_iter());
}
std::string Source::BaseView::get_line_before() {
@ -362,7 +362,7 @@ std::string Source::BaseView::get_line_before() {
Gtk::TextIter Source::BaseView::get_tabs_end_iter(const Gtk::TextIter &iter) {
return get_tabs_end_iter(iter.get_line());
}
Gtk::TextIter Source::BaseView::get_tabs_end_iter(Glib::RefPtr<Gtk::TextBuffer::Mark> mark) {
Gtk::TextIter Source::BaseView::get_tabs_end_iter(const Glib::RefPtr<Gtk::TextBuffer::Mark> &mark) {
return get_tabs_end_iter(mark->get_iter());
}
Gtk::TextIter Source::BaseView::get_tabs_end_iter(int line_nr) {

8
src/source_base.h

@ -8,7 +8,7 @@
namespace Source {
class BaseView : public Gsv::View {
public:
BaseView(boost::filesystem::path file_path_, Glib::RefPtr<Gsv::Language> language_);
BaseView(const boost::filesystem::path &file_path, const Glib::RefPtr<Gsv::Language> &language);
~BaseView() override;
boost::filesystem::path file_path;
@ -61,14 +61,14 @@ namespace Source {
Gtk::TextIter get_smart_end_iter(const Gtk::TextIter &iter);
std::string get_line(const Gtk::TextIter &iter);
std::string get_line(Glib::RefPtr<Gtk::TextBuffer::Mark> mark);
std::string get_line(const Glib::RefPtr<Gtk::TextBuffer::Mark> &mark);
std::string get_line(int line_nr);
std::string get_line();
std::string get_line_before(const Gtk::TextIter &iter);
std::string get_line_before(Glib::RefPtr<Gtk::TextBuffer::Mark> mark);
std::string get_line_before(const Glib::RefPtr<Gtk::TextBuffer::Mark> &mark);
std::string get_line_before();
Gtk::TextIter get_tabs_end_iter(const Gtk::TextIter &iter);
Gtk::TextIter get_tabs_end_iter(Glib::RefPtr<Gtk::TextBuffer::Mark> mark);
Gtk::TextIter get_tabs_end_iter(const Glib::RefPtr<Gtk::TextBuffer::Mark> &mark);
Gtk::TextIter get_tabs_end_iter(int line_nr);
Gtk::TextIter get_tabs_end_iter();

10
src/source_clang.cc

@ -16,7 +16,7 @@
clangmm::Index Source::ClangViewParse::clang_index(0, 0);
Source::ClangViewParse::ClangViewParse(const boost::filesystem::path &file_path, Glib::RefPtr<Gsv::Language> language):
Source::ClangViewParse::ClangViewParse(const boost::filesystem::path &file_path, const Glib::RefPtr<Gsv::Language> &language):
BaseView(file_path, language), Source::View(file_path, language) {
Usages::Clang::erase_cache(file_path);
@ -441,7 +441,7 @@ void Source::ClangViewParse::show_type_tooltips(const Gdk::Rectangle &rectangle)
}
Source::ClangViewAutocomplete::ClangViewAutocomplete(const boost::filesystem::path &file_path, Glib::RefPtr<Gsv::Language> language):
Source::ClangViewAutocomplete::ClangViewAutocomplete(const boost::filesystem::path &file_path, const Glib::RefPtr<Gsv::Language> &language):
BaseView(file_path, language), Source::ClangViewParse(file_path, language), autocomplete(this, interactive_completion, last_keyval, true) {
non_interactive_completion=[this] {
if(CompletionDialog::get() && CompletionDialog::get()->is_visible())
@ -816,7 +816,7 @@ const std::unordered_map<std::string, std::string> &Source::ClangViewAutocomplet
}
Source::ClangViewRefactor::ClangViewRefactor(const boost::filesystem::path &file_path, Glib::RefPtr<Gsv::Language> language) :
Source::ClangViewRefactor::ClangViewRefactor(const boost::filesystem::path &file_path, const Glib::RefPtr<Gsv::Language> &language) :
BaseView(file_path, language), Source::ClangViewParse(file_path, language) {
similar_identifiers_tag=get_buffer()->create_tag();
similar_identifiers_tag->property_weight()=Pango::WEIGHT_ULTRAHEAVY;
@ -1502,7 +1502,7 @@ Source::ClangViewRefactor::ClangViewRefactor(const boost::filesystem::path &file
std::string method;
if(kind!=clangmm::Cursor::Kind::Constructor && kind!=clangmm::Cursor::Kind::Destructor) {
method+=cursor.get_type().get_result().get_spelling();
auto pos=method.find(" ");
auto pos=method.find(' ');
if(pos!=std::string::npos)
method.erase(pos, 1);
method+=" ";
@ -1744,7 +1744,7 @@ void Source::ClangViewRefactor::tag_similar_identifiers(const Identifier &identi
}
Source::ClangView::ClangView(const boost::filesystem::path &file_path, Glib::RefPtr<Gsv::Language> language):
Source::ClangView::ClangView(const boost::filesystem::path &file_path, const Glib::RefPtr<Gsv::Language>& language):
BaseView(file_path, language), ClangViewParse(file_path, language), ClangViewAutocomplete(file_path, language), ClangViewRefactor(file_path, language) {
if(language) {
get_source_buffer()->set_highlight_syntax(true);

8
src/source_clang.h

@ -16,7 +16,7 @@ namespace Source {
enum class ParseProcessState {IDLE, STARTING, PREPROCESSING, PROCESSING, POSTPROCESSING};
public:
ClangViewParse(const boost::filesystem::path &file_path, Glib::RefPtr<Gsv::Language> language);
ClangViewParse(const boost::filesystem::path &file_path, const Glib::RefPtr<Gsv::Language> &language);
bool save() override;
void configure() override;
@ -55,7 +55,7 @@ namespace Source {
class ClangViewAutocomplete : public virtual ClangViewParse {
public:
ClangViewAutocomplete(const boost::filesystem::path &file_path, Glib::RefPtr<Gsv::Language> language);
ClangViewAutocomplete(const boost::filesystem::path &file_path, const Glib::RefPtr<Gsv::Language> &language);
protected:
Autocomplete autocomplete;
std::unique_ptr<clangmm::CodeCompleteResults> code_complete_results;
@ -84,7 +84,7 @@ namespace Source {
clangmm::Cursor cursor;
};
public:
ClangViewRefactor(const boost::filesystem::path &file_path, Glib::RefPtr<Gsv::Language> language);
ClangViewRefactor(const boost::filesystem::path &file_path, const Glib::RefPtr<Gsv::Language> &language);
private:
Identifier get_identifier();
void wait_parsing();
@ -97,7 +97,7 @@ namespace Source {
class ClangView : public ClangViewAutocomplete, public ClangViewRefactor {
public:
ClangView(const boost::filesystem::path &file_path, Glib::RefPtr<Gsv::Language> language);
ClangView(const boost::filesystem::path &file_path, const Glib::RefPtr<Gsv::Language> &language);
void full_reparse() override;
void async_delete();

2
src/source_diff.cc

@ -34,7 +34,7 @@ void Source::DiffView::Renderer::draw_vfunc(const Cairo::RefPtr<Cairo::Context>
}
}
Source::DiffView::DiffView(const boost::filesystem::path &file_path, Glib::RefPtr<Gsv::Language> language) : BaseView(file_path, language), renderer(new Renderer()) {
Source::DiffView::DiffView(const boost::filesystem::path &file_path, const Glib::RefPtr<Gsv::Language> &language) : BaseView(file_path, language), renderer(new Renderer()) {
boost::system::error_code ec;
canonical_file_path=boost::filesystem::canonical(file_path, ec);
if(ec)

2
src/source_diff.h

@ -29,7 +29,7 @@ namespace Source {
Gsv::GutterRendererState p6) override;
};
public:
DiffView(const boost::filesystem::path &file_path, Glib::RefPtr<Gsv::Language> language);
DiffView(const boost::filesystem::path &file_path, const Glib::RefPtr<Gsv::Language> &language);
~DiffView() override;
void configure() override;

26
src/source_language_protocol.cc

@ -317,7 +317,7 @@ void LanguageProtocol::Client::handle_server_request(const std::string &method,
}
}
Source::LanguageProtocolView::LanguageProtocolView(const boost::filesystem::path &file_path, Glib::RefPtr<Gsv::Language> language, std::string language_id_)
Source::LanguageProtocolView::LanguageProtocolView(const boost::filesystem::path &file_path, const Glib::RefPtr<Gsv::Language> &language, std::string language_id_)
: Source::BaseView(file_path, language), Source::View(file_path, language), uri("file://"+file_path.string()), language_id(std::move(language_id_)), client(LanguageProtocol::Client::get(file_path, language_id)), autocomplete(this, interactive_completion, last_keyval, false) {
configure();
get_source_buffer()->set_language(language);
@ -958,37 +958,37 @@ void Source::LanguageProtocolView::show_type_tooltips(const Gdk::Rectangle &rect
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;
auto content=std::make_shared<std::string>();
auto contents_pt=result.get_child("contents", boost::property_tree::ptree());
for(auto it=contents_pt.begin();it!=contents_pt.end();++it) {
auto value=it->second.get<std::string>("value", "");
if(!value.empty())
content.insert(0, value+(content.empty()?"":"\n\n"));
content->insert(0, value+(content->empty()?"":"\n\n"));
else {
value=it->second.get_value<std::string>("");
if(!value.empty())
content+=(content.empty()?"":"\n\n")+value;
*content+=(content->empty()?"":"\n\n")+value;
}
}
if(content.empty()) {
if(content->empty()) {
auto contents_it=result.find("contents");
if(contents_it!=result.not_found()) {
content=contents_it->second.get<std::string>("value", "");
if(content.empty())
content=contents_it->second.get_value<std::string>("");
*content=contents_it->second.get<std::string>("value", "");
if(content->empty())
*content=contents_it->second.get_value<std::string>("");
}
}
if(!content.empty()) {
while(!content.empty() && content.back()=='\n') { content.pop_back(); } // Remove unnecessary newlines
dispatcher.post([this, offset, content=std::move(content), current_request] {
if(!content->empty()) {
while(!content->empty() && content->back()=='\n') { content->pop_back(); } // Remove unnecessary newlines
dispatcher.post([this, offset, content, current_request] {
if(current_request!=request_count)
return;
if(offset>=get_buffer()->get_char_count())
return;
type_tooltips.clear();
auto create_tooltip_buffer=[this, offset, content=std::move(content)]() {
auto create_tooltip_buffer=[this, offset, content]() {
auto tooltip_buffer=Gtk::TextBuffer::create(get_buffer()->get_tag_table());
tooltip_buffer->insert(tooltip_buffer->get_insert()->get_iter(), content);
tooltip_buffer->insert(tooltip_buffer->get_insert()->get_iter(), *content);
#ifdef JUCI_ENABLE_DEBUG
if(language_id=="rust" && capabilities.definition) {

2
src/source_language_protocol.h

@ -84,7 +84,7 @@ namespace LanguageProtocol {
namespace Source {
class LanguageProtocolView : public View {
public:
LanguageProtocolView(const boost::filesystem::path &file_path, Glib::RefPtr<Gsv::Language> language, std::string language_id_);
LanguageProtocolView(const boost::filesystem::path &file_path, const Glib::RefPtr<Gsv::Language> &language, std::string language_id_);
~LanguageProtocolView() override;
std::string uri;

2
src/source_spellcheck.cc

@ -6,7 +6,7 @@
AspellConfig* Source::SpellCheckView::spellcheck_config=nullptr;
Source::SpellCheckView::SpellCheckView(const boost::filesystem::path &file_path, Glib::RefPtr<Gsv::Language> language): BaseView(file_path, language) {
Source::SpellCheckView::SpellCheckView(const boost::filesystem::path &file_path, const Glib::RefPtr<Gsv::Language> &language): BaseView(file_path, language) {
if(spellcheck_config==nullptr)
spellcheck_config=new_aspell_config();
spellcheck_checker=nullptr;

2
src/source_spellcheck.h

@ -5,7 +5,7 @@
namespace Source {
class SpellCheckView : virtual public Source::BaseView {
public:
SpellCheckView(const boost::filesystem::path &file_path, Glib::RefPtr<Gsv::Language> language);
SpellCheckView(const boost::filesystem::path &file_path, const Glib::RefPtr<Gsv::Language> &language);
~SpellCheckView() override;
void configure() override;

4
src/terminal.cc

@ -77,7 +77,7 @@ int Terminal::process(std::istream &stdin_stream, std::ostream &stdout_stream, c
return process.get_exit_status();
}
void Terminal::async_process(const std::string &command, const boost::filesystem::path &path, std::function<void(int exit_status)> callback, bool quiet) {
void Terminal::async_process(const std::string &command, const boost::filesystem::path &path, const std::function<void(int exit_status)> &callback, bool quiet) {
std::thread async_execute_thread([this, command, path, callback, quiet]() {
std::unique_lock<std::mutex> processes_lock(processes_mutex);
stdin_buffer.clear();
@ -190,7 +190,7 @@ std::tuple<size_t, size_t, std::string, std::string, std::string> Terminal::find
return std::make_tuple(start_position, end_position, path, line_number, line_offset);
}
void Terminal::apply_link_tags(Gtk::TextIter start_iter, Gtk::TextIter end_iter) {
void Terminal::apply_link_tags(const Gtk::TextIter &start_iter, const Gtk::TextIter &end_iter) {
auto iter=start_iter;
Gtk::TextIter line_start;
bool line_start_set=false;

4
src/terminal.h

@ -18,7 +18,7 @@ public:
int process(const std::string &command, const boost::filesystem::path &path="", bool use_pipes=true);
int process(std::istream &stdin_stream, std::ostream &stdout_stream, const std::string &command, const boost::filesystem::path &path="", std::ostream *stderr_stream=nullptr);
void async_process(const std::string &command, const boost::filesystem::path &path="", std::function<void(int exit_status)> callback=nullptr, bool quiet=false);
void async_process(const std::string &command, const boost::filesystem::path &path="", const std::function<void(int exit_status)> &callback=nullptr, bool quiet=false);
void kill_last_async_process(bool force=false);
void kill_async_processes(bool force=false);
@ -42,7 +42,7 @@ private:
size_t deleted_lines=0;
std::tuple<size_t, size_t, std::string, std::string, std::string> find_link(const std::string &line);
void apply_link_tags(Gtk::TextIter start_iter, Gtk::TextIter end_iter);
void apply_link_tags(const Gtk::TextIter &start_iter, const Gtk::TextIter &end_iter);
std::vector<std::shared_ptr<TinyProcessLib::Process>> processes;
std::mutex processes_mutex;

2
tests/stubs/directories.cc

@ -4,7 +4,7 @@ Directories::Directories() : ListViewText(1) {}
Directories::~Directories() {}
void Directories::on_save_file(boost::filesystem::path file_path) {}
void Directories::on_save_file(const boost::filesystem::path &file_path) {}
bool Directories::on_button_press_event(GdkEventButton *event) {
return false;

6
tests/stubs/selection_dialog.cc

@ -2,7 +2,7 @@
SelectionDialogBase::ListViewText::ListViewText(bool use_markup) {}
SelectionDialogBase::SelectionDialogBase(Gtk::TextView *text_view, Glib::RefPtr<Gtk::TextBuffer::Mark> start_mark, bool show_search_entry, bool use_markup):
SelectionDialogBase::SelectionDialogBase(Gtk::TextView *text_view, const Glib::RefPtr<Gtk::TextBuffer::Mark> &start_mark, bool show_search_entry, bool use_markup):
text_view(text_view), list_view_text(use_markup) {}
void SelectionDialogBase::show() {}
@ -13,7 +13,7 @@ void SelectionDialogBase::add_row(const std::string& row) {}
std::unique_ptr<SelectionDialog> SelectionDialog::instance;
SelectionDialog::SelectionDialog(Gtk::TextView *text_view, Glib::RefPtr<Gtk::TextBuffer::Mark> start_mark, bool show_search_entry, bool use_markup) :
SelectionDialog::SelectionDialog(Gtk::TextView *text_view, const Glib::RefPtr<Gtk::TextBuffer::Mark> &start_mark, bool show_search_entry, bool use_markup) :
SelectionDialogBase(text_view, start_mark, show_search_entry, use_markup) {}
SelectionDialogBase::~SelectionDialogBase() {}
@ -22,7 +22,7 @@ bool SelectionDialog::on_key_press(GdkEventKey* key) { return true; }
std::unique_ptr<CompletionDialog> CompletionDialog::instance;
CompletionDialog::CompletionDialog(Gtk::TextView *text_view, Glib::RefPtr<Gtk::TextBuffer::Mark> start_mark):
CompletionDialog::CompletionDialog(Gtk::TextView *text_view, const Glib::RefPtr<Gtk::TextBuffer::Mark> &start_mark):
SelectionDialogBase(text_view, start_mark, false, false) {}
bool CompletionDialog::on_key_press(GdkEventKey* key) { return true;}

Loading…
Cancel
Save