Browse Source

Fixed warnings from clang-tidy's modernize checks

merge-requests/382/head
eidheim 8 years ago
parent
commit
b1ae1656a3
  1. 6
      src/cmake.cc
  2. 8
      src/debug_lldb.cc
  3. 4
      src/directories.h
  4. 8
      src/entrybox.cc
  5. 8
      src/entrybox.h
  6. 2
      src/git.cc
  7. 6
      src/git.h
  8. 2
      src/juci.cc
  9. 2
      src/menu.h
  10. 2
      src/notebook.h
  11. 2
      src/project.cc
  12. 10
      src/project.h
  13. 1
      src/project_build.h
  14. 6
      src/selection_dialog.cc
  15. 2
      src/selection_dialog.h
  16. 8
      src/source.cc
  17. 10
      src/source.h
  18. 14
      src/source_base.cc
  19. 4
      src/source_base.h
  20. 2
      src/source_clang.cc
  21. 4
      src/source_clang.h
  22. 2
      src/source_diff.h
  23. 44
      src/source_language_protocol.cc
  24. 2
      src/source_language_protocol.h
  25. 2
      src/source_spellcheck.h
  26. 6
      src/tooltips.cc
  27. 4
      src/tooltips.h
  28. 6
      src/usages_clang.cc
  29. 6
      src/usages_clang.h
  30. 12
      src/window.cc

6
src/cmake.cc

@ -333,7 +333,7 @@ std::vector<std::string> CMake::get_function_parameters(std::string &data) {
} }
std::vector<std::pair<boost::filesystem::path, std::vector<std::string> > > CMake::get_functions_parameters(const std::string &name) { std::vector<std::pair<boost::filesystem::path, std::vector<std::string> > > 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(); variables.clear();
if(!parsed) if(!parsed)
parse(); parse();
@ -348,8 +348,8 @@ std::vector<std::pair<boost::filesystem::path, std::vector<std::string> > > CMak
if(end_line>start_line) { if(end_line>start_line) {
auto line=files[c].substr(start_line, end_line-start_line); auto line=files[c].substr(start_line, end_line-start_line);
std::smatch sm; 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 set_regex(R"(^ *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 project_regex(R"(^ *project *\( *([^ ]+).*\) *\r?$)", std::regex::icase);
if(std::regex_match(line, sm, set_regex)) { if(std::regex_match(line, sm, set_regex)) {
auto data=sm[2].str(); auto data=sm[2].str();
while(data.size()>0 && data.back()==' ') while(data.size()>0 && data.back()==' ')

8
src/debug_lldb.cc

@ -1,7 +1,7 @@
#include "debug_lldb.h" #include "debug_lldb.h"
#include <stdio.h> #include <cstdio>
#ifdef __APPLE__ #ifdef __APPLE__
#include <stdlib.h> #include <cstdlib>
#endif #endif
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
#include <iostream> #include <iostream>
@ -103,8 +103,8 @@ void Debug::LLDB::start(const std::string &command, const boost::filesystem::pat
auto &arguments=std::get<2>(parsed_run_arguments); auto &arguments=std::get<2>(parsed_run_arguments);
std::vector<const char*> argv; std::vector<const char*> argv;
for(size_t c=0;c<arguments.size();c++) for(auto &argument : arguments)
argv.emplace_back(arguments[c].c_str()); argv.emplace_back(argument.c_str());
argv.emplace_back(nullptr); argv.emplace_back(nullptr);
auto target=debugger->CreateTarget(executable.c_str()); auto target=debugger->CreateTarget(executable.c_str());

4
src/directories.h

@ -24,7 +24,7 @@ class Directories : public Gtk::ListViewText {
class TreeStore : public Gtk::TreeStore { class TreeStore : public Gtk::TreeStore {
protected: protected:
TreeStore() {} TreeStore()=default;
bool row_drop_possible_vfunc(const Gtk::TreeModel::Path &path, const Gtk::SelectionData &selection_data) const override; 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; bool drag_data_received_vfunc(const TreeModel::Path &path, const Gtk::SelectionData &selection_data) override;
@ -56,7 +56,7 @@ public:
static Directories singleton; static Directories singleton;
return singleton; return singleton;
} }
~Directories(); ~Directories() override;
void open(const boost::filesystem::path &dir_path=""); void open(const boost::filesystem::path &dir_path="");
void update(); void update();

8
src/entrybox.cc

@ -2,7 +2,7 @@
std::unordered_map<std::string, std::vector<std::string> > EntryBox::entry_histories; std::unordered_map<std::string, std::vector<std::string> > EntryBox::entry_histories;
EntryBox::Entry::Entry(const std::string& content, std::function<void(const std::string& content)> on_activate, unsigned width_chars) : Gtk::Entry(), on_activate(on_activate) { EntryBox::Entry::Entry(const std::string& content, std::function<void(const std::string& content)> on_activate_, unsigned width_chars) : Gtk::Entry(), on_activate(std::move(on_activate_)) {
set_max_length(0); set_max_length(0);
set_width_chars(width_chars); set_width_chars(width_chars);
set_text(content); set_text(content);
@ -41,7 +41,7 @@ EntryBox::Entry::Entry(const std::string& content, std::function<void(const std:
}); });
} }
EntryBox::Button::Button(const std::string& label, std::function<void()> on_activate) : Gtk::Button(label), on_activate(on_activate) { EntryBox::Button::Button(const std::string& label, std::function<void()> on_activate_) : Gtk::Button(label), on_activate(std::move(on_activate_)) {
set_focus_on_click(false); set_focus_on_click(false);
signal_clicked().connect([this](){ signal_clicked().connect([this](){
if(this->on_activate) if(this->on_activate)
@ -49,7 +49,7 @@ EntryBox::Button::Button(const std::string& label, std::function<void()> on_acti
}); });
} }
EntryBox::ToggleButton::ToggleButton(const std::string& label, std::function<void()> on_activate) : Gtk::ToggleButton(label), on_activate(on_activate) { EntryBox::ToggleButton::ToggleButton(const std::string& label, std::function<void()> on_activate_) : Gtk::ToggleButton(label), on_activate(std::move(on_activate_)) {
set_focus_on_click(false); set_focus_on_click(false);
signal_clicked().connect([this](){ signal_clicked().connect([this](){
if(this->on_activate) if(this->on_activate)
@ -57,7 +57,7 @@ EntryBox::ToggleButton::ToggleButton(const std::string& label, std::function<voi
}); });
} }
EntryBox::Label::Label(std::function<void(int state, const std::string& message)> update) : Gtk::Label(), update(update) { EntryBox::Label::Label(std::function<void(int state, const std::string& message)> update_) : Gtk::Label(), update(std::move(update_)) {
if(this->update) if(this->update)
this->update(-1, ""); this->update(-1, "");
} }

8
src/entrybox.h

@ -10,24 +10,24 @@ class EntryBox : public Gtk::Box {
public: public:
class Entry : public Gtk::Entry { class Entry : public Gtk::Entry {
public: public:
Entry(const std::string& content="", std::function<void(const std::string& content)> on_activate=nullptr, unsigned width_chars=-1); Entry(const std::string& content="", std::function<void(const std::string& content)> on_activate_=nullptr, unsigned width_chars=-1);
std::function<void(const std::string& content)> on_activate; std::function<void(const std::string& content)> on_activate;
private: private:
size_t selected_history; size_t selected_history;
}; };
class Button : public Gtk::Button { class Button : public Gtk::Button {
public: public:
Button(const std::string& label, std::function<void()> on_activate=nullptr); Button(const std::string& label, std::function<void()> on_activate_=nullptr);
std::function<void()> on_activate; std::function<void()> on_activate;
}; };
class ToggleButton : public Gtk::ToggleButton { class ToggleButton : public Gtk::ToggleButton {
public: public:
ToggleButton(const std::string& label, std::function<void()> on_activate=nullptr); ToggleButton(const std::string& label, std::function<void()> on_activate_=nullptr);
std::function<void()> on_activate; std::function<void()> on_activate;
}; };
class Label : public Gtk::Label { class Label : public Gtk::Label {
public: public:
Label(std::function<void(int state, const std::string& message)> update=nullptr); Label(std::function<void(int state, const std::string& message)> update_=nullptr);
std::function<void(int state, const std::string& message)> update; std::function<void(int state, const std::string& message)> update;
}; };

2
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) { boost::filesystem::path Git::Repository::get_root_path(const boost::filesystem::path &path) {
initialize(); initialize();
git_buf root = {0, 0, 0}; git_buf root = {nullptr, 0, 0};
{ {
Error error; Error error;
std::lock_guard<std::mutex> lock(mutex); std::lock_guard<std::mutex> lock(mutex);

6
src/git.h

@ -17,7 +17,6 @@ public:
std::string message() noexcept; std::string message() noexcept;
public: public:
int code=0; int code=0;
Error() {}
operator bool() noexcept {return code<0;} operator bool() noexcept {return code<0;}
}; };
@ -42,13 +41,12 @@ public:
private: private:
friend class Repository; friend class Repository;
Diff(const boost::filesystem::path &path, git_repository *repository); Diff(const boost::filesystem::path &path, git_repository *repository);
git_repository *repository; git_repository *repository=nullptr;
std::shared_ptr<git_blob> blob; std::shared_ptr<git_blob> blob=nullptr;
git_diff_options options; git_diff_options options;
static int hunk_cb(const git_diff_delta *delta, const git_diff_hunk *hunk, void *payload) noexcept; 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; static int line_cb(const git_diff_delta *delta, const git_diff_hunk *hunk, const git_diff_line *line, void *payload) noexcept;
public: public:
Diff() : repository(nullptr), blob(nullptr) {}
Lines get_lines(const std::string &buffer); Lines get_lines(const std::string &buffer);
static std::vector<Hunk> get_hunks(const std::string &old_buffer, const std::string &new_buffer); static std::vector<Hunk> get_hunks(const std::string &old_buffer, const std::string &new_buffer);
std::string get_details(const std::string &buffer, int line_nr); std::string get_details(const std::string &buffer, int line_nr);

2
src/juci.cc

@ -6,7 +6,7 @@
#include "config.h" #include "config.h"
#include "terminal.h" #include "terminal.h"
#ifndef _WIN32 #ifndef _WIN32
#include <signal.h> #include <csignal>
#endif #endif
int Application::on_command_line(const Glib::RefPtr<Gio::ApplicationCommandLine> &cmd) { int Application::on_command_line(const Glib::RefPtr<Gio::ApplicationCommandLine> &cmd) {

2
src/menu.h

@ -5,7 +5,7 @@
#include <gtkmm.h> #include <gtkmm.h>
class Menu { class Menu {
Menu() {} Menu() = default;
public: public:
static Menu &get() { static Menu &get() {
static Menu singleton; static Menu singleton;

2
src/notebook.h

@ -15,7 +15,7 @@ class Notebook : public Gtk::Paned {
class CursorLocation { class CursorLocation {
public: public:
CursorLocation(Source::View *view, Glib::RefPtr<Gtk::TextBuffer::Mark> mark) : view(view), mark(mark) {} CursorLocation(Source::View *view, Glib::RefPtr<Gtk::TextBuffer::Mark> mark_) : view(view), mark(std::move(mark_)) {}
Source::View *view; Source::View *view;
Glib::RefPtr<Gtk::TextBuffer::Mark> mark; Glib::RefPtr<Gtk::TextBuffer::Mark> mark;
}; };

2
src/project.cc

@ -713,7 +713,7 @@ void Project::LanguageProtocol::show_symbols() {
} }
std::vector<std::string> names; std::vector<std::string> names;
std::promise<void> result_processed; std::promise<void> 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) { if(!error) {
for(auto it=result.begin();it!=result.end();++it) { for(auto it=result.begin();it!=result.end();++it) {
auto name=it->second.get<std::string>("name", ""); auto name=it->second.get<std::string>("name", "");

10
src/project.h

@ -41,9 +41,9 @@ namespace Project {
protected: protected:
static std::unique_ptr<DebugOptions> debug_options; static std::unique_ptr<DebugOptions> debug_options;
public: public:
Base() {} Base() = default;
Base(std::unique_ptr<Build> &&build): build(std::move(build)) {} Base(std::unique_ptr<Build> &&build): build(std::move(build)) {}
virtual ~Base() {} virtual ~Base() = default;
std::unique_ptr<Build> build; std::unique_ptr<Build> build;
@ -78,8 +78,7 @@ namespace Project {
class LLDB : public virtual Base { class LLDB : public virtual Base {
public: public:
LLDB() {} ~LLDB() override { dispatcher.disconnect(); }
~LLDB() { dispatcher.disconnect(); }
#ifdef JUCI_ENABLE_DEBUG #ifdef JUCI_ENABLE_DEBUG
std::pair<std::string, std::string> debug_get_run_arguments() override; std::pair<std::string, std::string> debug_get_run_arguments() override;
@ -104,7 +103,6 @@ namespace Project {
class LanguageProtocol : public virtual Base { class LanguageProtocol : public virtual Base {
public: public:
LanguageProtocol() {}
virtual std::string get_language_id()=0; virtual std::string get_language_id()=0;
void show_symbols() override; void show_symbols() override;
}; };
@ -122,7 +120,7 @@ namespace Project {
class Markdown : public Base { class Markdown : public Base {
public: public:
Markdown(std::unique_ptr<Build> &&build) : Base(std::move(build)) {} Markdown(std::unique_ptr<Build> &&build) : Base(std::move(build)) {}
~Markdown(); ~Markdown() override;
boost::filesystem::path last_temp_path; boost::filesystem::path last_temp_path;
void compile_and_run() override; void compile_and_run() override;

1
src/project_build.h

@ -6,7 +6,6 @@
namespace Project { namespace Project {
class Build { class Build {
public: public:
Build() {}
virtual ~Build() {} virtual ~Build() {}
boost::filesystem::path project_path; boost::filesystem::path project_path;

6
src/selection_dialog.cc

@ -36,8 +36,8 @@ void SelectionDialogBase::ListViewText::clear() {
size=0; size=0;
} }
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, 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) { 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 g_application=g_application_get_default();
auto gio_application=Glib::wrap(g_application, true); auto gio_application=Glib::wrap(g_application, true);
auto application=Glib::RefPtr<Gtk::Application>::cast_static(gio_application); auto application=Glib::RefPtr<Gtk::Application>::cast_static(gio_application);
@ -133,7 +133,7 @@ void SelectionDialogBase::cursor_changed() {
if(!is_visible()) if(!is_visible())
return; return;
auto it=list_view_text.get_selection()->get_selected(); auto it=list_view_text.get_selection()->get_selected();
unsigned int index=static_cast<unsigned int>(-1); auto index=static_cast<unsigned int>(-1);
if(it) if(it)
index=it->get_value(list_view_text.column_record.index); index=it->get_value(list_view_text.column_record.index);
if(last_index==index) if(last_index==index)

2
src/selection_dialog.h

@ -34,7 +34,7 @@ class SelectionDialogBase {
}; };
public: 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, Glib::RefPtr<Gtk::TextBuffer::Mark> start_mark_, bool show_search_entry, bool use_markup);
virtual ~SelectionDialogBase(); virtual ~SelectionDialogBase();
void add_row(const std::string& row); void add_row(const std::string& row);
void erase_rows(); void erase_rows();

8
src/source.cc

@ -71,8 +71,8 @@ Glib::RefPtr<Gsv::Language> Source::guess_language(const boost::filesystem::path
return language; return language;
} }
Source::FixIt::FixIt(const std::string &source, const std::pair<Offset, Offset> &offsets) : source(source), offsets(offsets) { Source::FixIt::FixIt(std::string source_, std::pair<Offset, Offset> offsets_) : source(std::move(source_)), offsets(std::move(offsets_)) {
if(source.size()==0) if(this->source.size()==0)
type=Type::ERASE; type=Type::ERASE;
else { else {
if(this->offsets.first==this->offsets.second) if(this->offsets.first==this->offsets.second)
@ -82,7 +82,7 @@ Source::FixIt::FixIt(const std::string &source, const std::pair<Offset, Offset>
} }
} }
std::string Source::FixIt::string(Glib::RefPtr<Gtk::TextBuffer> buffer) { std::string Source::FixIt::string(const Glib::RefPtr<Gtk::TextBuffer> &buffer) {
auto iter=buffer->get_iter_at_line_index(offsets.first.line, offsets.first.index); auto iter=buffer->get_iter_at_line_index(offsets.first.line, offsets.first.index);
unsigned first_line_offset=iter.get_line_offset()+1; unsigned first_line_offset=iter.get_line_offset()+1;
iter=buffer->get_iter_at_line_index(offsets.second.line, offsets.second.index); 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) { 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::string line;
std::getline(stderr_stream, line); std::getline(stderr_stream, line);
std::smatch sm; std::smatch sm;

10
src/source.h

@ -25,8 +25,8 @@ namespace Source {
class Offset { class Offset {
public: public:
Offset() {} Offset() = default;
Offset(unsigned line, unsigned index, const boost::filesystem::path &file_path=""): line(line), index(index), file_path(file_path) {} 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(); } operator bool() { return !file_path.empty(); }
bool operator==(const Offset &o) {return (line==o.line && index==o.index);} bool operator==(const Offset &o) {return (line==o.line && index==o.index);}
@ -39,9 +39,9 @@ namespace Source {
public: public:
enum class Type {INSERT, REPLACE, ERASE}; enum class Type {INSERT, REPLACE, ERASE};
FixIt(const std::string &source, const std::pair<Offset, Offset> &offsets); FixIt(std::string source_, std::pair<Offset, Offset> offsets_);
std::string string(Glib::RefPtr<Gtk::TextBuffer> buffer); std::string string(const Glib::RefPtr<Gtk::TextBuffer> &buffer);
Type type; Type type;
std::string source; std::string source;
@ -54,7 +54,7 @@ namespace Source {
static std::unordered_set<View*> 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, Glib::RefPtr<Gsv::Language> language, bool is_generic_view=false);
~View(); ~View() override;
bool save() override; bool save() override;

14
src/source_base.cc

@ -1,3 +1,5 @@
#include <utility>
#include "source_base.h" #include "source_base.h"
#include "info.h" #include "info.h"
#include "terminal.h" #include "terminal.h"
@ -5,9 +7,9 @@
#include "config.h" #include "config.h"
#include <fstream> #include <fstream>
Source::BaseView::BaseView(const boost::filesystem::path &file_path, Glib::RefPtr<Gsv::Language> language): Gsv::View(), file_path(file_path), language(language), status_diagnostics(0, 0, 0) { 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) {
load(true); 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) { signal_focus_in_event().connect([this](GdkEventFocus *event) {
if(this->last_write_time!=static_cast<std::time_t>(-1)) if(this->last_write_time!=static_cast<std::time_t>(-1))
@ -119,10 +121,10 @@ void Source::BaseView::replace_text(const std::string &new_text) {
std::vector<std::pair<const char*, const char*>> new_lines; std::vector<std::pair<const char*, const char*>> new_lines;
const char* line_start=new_text.c_str(); const char* line_start=new_text.c_str();
for(size_t i=0;i<new_text.size();++i) { for(const char &chr: new_text) {
if(new_text[i]=='\n') { if(chr=='\n') {
new_lines.emplace_back(line_start, &new_text[i]+1); new_lines.emplace_back(line_start, &chr+1);
line_start = &new_text[i]+1; line_start = &chr+1;
} }
} }
if(new_text.empty() || new_text.back()!='\n') if(new_text.empty() || new_text.back()!='\n')

4
src/source_base.h

@ -8,8 +8,8 @@
namespace Source { namespace Source {
class BaseView : public Gsv::View { class BaseView : public Gsv::View {
public: public:
BaseView(const boost::filesystem::path &file_path, Glib::RefPtr<Gsv::Language> language); BaseView(boost::filesystem::path file_path_, Glib::RefPtr<Gsv::Language> language_);
~BaseView(); ~BaseView() override;
boost::filesystem::path file_path; boost::filesystem::path file_path;
Glib::RefPtr<Gsv::Language> language; Glib::RefPtr<Gsv::Language> language;

2
src/source_clang.cc

@ -535,7 +535,7 @@ Source::ClangViewAutocomplete::ClangViewAutocomplete(const boost::filesystem::pa
show_arguments=false; show_arguments=false;
std::string line=" "+get_line_before(); 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 colon_colon("^.*::([a-zA-Z0-9_]*)$");
const static std::regex part_of_symbol("^.*[^a-zA-Z0-9_]+([a-zA-Z0-9_]{3,})$"); const static std::regex part_of_symbol("^.*[^a-zA-Z0-9_]+([a-zA-Z0-9_]{3,})$");
std::smatch sm; std::smatch sm;

4
src/source_clang.h

@ -70,8 +70,8 @@ namespace Source {
class ClangViewRefactor : public virtual ClangViewParse { class ClangViewRefactor : public virtual ClangViewParse {
class Identifier { class Identifier {
public: public:
Identifier(const std::string &spelling, const clangmm::Cursor &cursor) Identifier(std::string spelling_, const clangmm::Cursor &cursor)
: kind(cursor.get_kind()), spelling(spelling), usr_extended(cursor.get_usr_extended()), cursor(cursor) {} : kind(cursor.get_kind()), spelling(std::move(spelling_)), usr_extended(cursor.get_usr_extended()), cursor(cursor) {}
Identifier() : kind(static_cast<clangmm::Cursor::Kind>(0)) {} Identifier() : kind(static_cast<clangmm::Cursor::Kind>(0)) {}
operator bool() const { return static_cast<int>(kind)!=0; } operator bool() const { return static_cast<int>(kind)!=0; }

2
src/source_diff.h

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

44
src/source_language_protocol.cc

@ -88,7 +88,7 @@ LanguageProtocol::Capabilities LanguageProtocol::Client::initialize(Source::Lang
return capabilities; return capabilities;
std::promise<void> result_processed; std::promise<void> 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) { if(!error) {
auto capabilities_pt=result.find("capabilities"); auto capabilities_pt=result.find("capabilities");
if(capabilities_pt!=result.not_found()) { if(capabilities_pt!=result.not_found()) {
@ -106,7 +106,7 @@ LanguageProtocol::Capabilities LanguageProtocol::Client::initialize(Source::Lang
write_notification("initialized", ""); write_notification("initialized", "");
if(language_id=="rust") 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(); 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; auto message="Content-Length: "+std::to_string(content.size())+"\r\n\r\n"+content;
if(output_messages_and_errors) if(output_messages_and_errors)
std::cout << "Language client: " << content << std::endl; 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 &params) { void LanguageProtocol::Client::write_notification(const std::string &method, const std::string &params) {
std::unique_lock<std::mutex> lock(read_write_mutex); std::unique_lock<std::mutex> 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; auto message="Content-Length: "+std::to_string(content.size())+"\r\n\r\n"+content;
if(output_messages_and_errors) if(output_messages_and_errors)
std::cout << "Language client: " << content << std::endl; 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(); std::string text=get_buffer()->get_text();
escape_text(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_autocomplete();
setup_navigation_and_refactoring(); setup_navigation_and_refactoring();
@ -391,14 +391,14 @@ Source::LanguageProtocolView::LanguageProtocolView(const boost::filesystem::path
if(capabilities.text_document_sync==LanguageProtocol::Capabilities::TextDocumentSync::INCREMENTAL) { if(capabilities.text_document_sync==LanguageProtocol::Capabilities::TextDocumentSync::INCREMENTAL) {
std::string text=text_; std::string text=text_;
escape_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 { else {
std::string text=get_buffer()->get_text(); std::string text=get_buffer()->get_text();
escape_text(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); }, false);
get_buffer()->signal_erase().connect([this](const Gtk::TextBuffer::iterator &start, const Gtk::TextBuffer::iterator &end) { 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) if(capabilities.text_document_sync==LanguageProtocol::Capabilities::TextDocumentSync::NONE)
return; return;
if(capabilities.text_document_sync==LanguageProtocol::Capabilities::TextDocumentSync::INCREMENTAL) 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 { else {
std::string text=get_buffer()->get_text(); std::string text=get_buffer()->get_text();
escape_text(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); }, false);
} }
@ -424,7 +424,7 @@ Source::LanguageProtocolView::~LanguageProtocolView() {
if(autocomplete.thread.joinable()) if(autocomplete.thread.joinable())
autocomplete.thread.join(); autocomplete.thread.join();
client->write_notification("textDocument/didClose", "\"textDocument\":{\"uri\":\""+uri+"\"}"); client->write_notification("textDocument/didClose", R"("textDocument":{"uri":")"+uri+"\"}");
client->close(this); client->close(this);
client=nullptr; client=nullptr;
@ -477,11 +477,11 @@ void Source::LanguageProtocolView::setup_navigation_and_refactoring() {
method="textDocument/rangeFormatting"; method="textDocument/rangeFormatting";
Gtk::TextIter start, end; Gtk::TextIter start, end;
get_buffer()->get_selection_bounds(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 { else {
method="textDocument/formatting"; 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) { 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<std::pair<Offset, std::string>> usages; std::vector<std::pair<Offset, std::string>> usages;
std::vector<Offset> end_offsets; std::vector<Offset> end_offsets;
std::promise<void> result_processed; std::promise<void> 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) { if(!error) {
try { try {
for(auto it=result.begin();it!=result.end();++it) { for(auto it=result.begin();it!=result.end();++it) {
@ -612,7 +612,7 @@ void Source::LanguageProtocolView::setup_navigation_and_refactoring() {
}; };
std::map<boost::filesystem::path, std::vector<std::string>> file_lines; std::map<boost::filesystem::path, std::vector<std::string>> file_lines;
size_t c=static_cast<size_t>(-1); auto c=static_cast<size_t>(-1);
for(auto &usage: usages) { for(auto &usage: usages) {
++c; ++c;
auto view_it=views.end(); auto view_it=views.end();
@ -697,7 +697,7 @@ void Source::LanguageProtocolView::setup_navigation_and_refactoring() {
auto iter=get_buffer()->get_insert()->get_iter(); auto iter=get_buffer()->get_insert()->get_iter();
std::vector<Usages> usages; std::vector<Usages> usages;
std::promise<void> result_processed; std::promise<void> 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) { if(!error) {
boost::filesystem::path project_path; boost::filesystem::path project_path;
auto build=Project::Build::create(file_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; static int request_count=0;
request_count++; request_count++;
auto current_request=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) { if(!error) {
// hover result structure vary significantly from the different language servers // hover result structure vary significantly from the different language servers
std::string content; std::string content;
@ -1053,7 +1053,7 @@ void Source::LanguageProtocolView::tag_similar_symbols() {
static int request_count=0; static int request_count=0;
request_count++; request_count++;
auto current_request=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) { if(!error) {
std::vector<std::pair<Offset, Offset>> offsets; std::vector<std::pair<Offset, Offset>> offsets;
for(auto it=result.begin();it!=result.end();++it) { 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) { Source::Offset Source::LanguageProtocolView::get_declaration(const Gtk::TextIter &iter) {
auto offset=std::make_shared<Offset>(); auto offset=std::make_shared<Offset>();
std::promise<void> result_processed; std::promise<void> 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) { if(!error) {
for(auto it=result.begin();it!=result.end();++it) { for(auto it=result.begin();it!=result.end();++it) {
auto uri=it->second.get<std::string>("uri", ""); auto uri=it->second.get<std::string>("uri", "");
@ -1147,7 +1147,7 @@ void Source::LanguageProtocolView::setup_autocomplete() {
return false; return false;
std::string line=" "+get_line_before(); 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 colon_colon("^.*::([a-zA-Z0-9_]*)$");
const static std::regex part_of_symbol("^.*[^a-zA-Z0-9_]+([a-zA-Z0-9_]{3,})$"); const static std::regex part_of_symbol("^.*[^a-zA-Z0-9_]+([a-zA-Z0-9_]{3,})$");
std::smatch sm; std::smatch sm;
@ -1211,7 +1211,7 @@ void Source::LanguageProtocolView::setup_autocomplete() {
autocomplete_comment.clear(); autocomplete_comment.clear();
autocomplete_insert.clear(); autocomplete_insert.clear();
std::promise<void> result_processed; std::promise<void> 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) { if(!error) {
auto begin=result.begin(); // rust language server is bugged auto begin=result.begin(); // rust language server is bugged
auto end=result.end(); auto end=result.end();

2
src/source_language_protocol.h

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

2
src/source_spellcheck.h

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

6
src/tooltips.cc

@ -4,9 +4,9 @@
std::set<Tooltip*> Tooltips::shown_tooltips; std::set<Tooltip*> Tooltips::shown_tooltips;
Gdk::Rectangle Tooltips::drawn_tooltips_rectangle=Gdk::Rectangle(); Gdk::Rectangle Tooltips::drawn_tooltips_rectangle=Gdk::Rectangle();
Tooltip::Tooltip(std::function<Glib::RefPtr<Gtk::TextBuffer>()> create_tooltip_buffer, Gtk::TextView *text_view, Tooltip::Tooltip(std::function<Glib::RefPtr<Gtk::TextBuffer>()> create_tooltip_buffer_, Gtk::TextView *text_view,
Glib::RefPtr<Gtk::TextBuffer::Mark> start_mark, Glib::RefPtr<Gtk::TextBuffer::Mark> end_mark) Glib::RefPtr<Gtk::TextBuffer::Mark> start_mark_, Glib::RefPtr<Gtk::TextBuffer::Mark> end_mark_)
: start_mark(start_mark), end_mark(end_mark), create_tooltip_buffer(create_tooltip_buffer), text_view(text_view) {} : 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() { Tooltip::~Tooltip() {
Tooltips::shown_tooltips.erase(this); Tooltips::shown_tooltips.erase(this);

4
src/tooltips.h

@ -7,8 +7,8 @@
class Tooltip { class Tooltip {
public: public:
Tooltip(std::function<Glib::RefPtr<Gtk::TextBuffer>()> create_tooltip_buffer, Gtk::TextView *text_view, Glib::RefPtr<Gtk::TextBuffer::Mark> start_mark, Glib::RefPtr<Gtk::TextBuffer::Mark> end_mark); Tooltip(std::function<Glib::RefPtr<Gtk::TextBuffer>()> create_tooltip_buffer_, Gtk::TextView *text_view, Glib::RefPtr<Gtk::TextBuffer::Mark> start_mark_, Glib::RefPtr<Gtk::TextBuffer::Mark> end_mark_);
Tooltip(std::function<Glib::RefPtr<Gtk::TextBuffer>()> create_tooltip_buffer) : Tooltip(create_tooltip_buffer, nullptr, Glib::RefPtr<Gtk::TextBuffer::Mark>(), Glib::RefPtr<Gtk::TextBuffer::Mark>()) {} Tooltip(std::function<Glib::RefPtr<Gtk::TextBuffer>()> create_tooltip_buffer_) : Tooltip(std::move(create_tooltip_buffer_), nullptr, Glib::RefPtr<Gtk::TextBuffer::Mark>(), Glib::RefPtr<Gtk::TextBuffer::Mark>()) {}
~Tooltip(); ~Tooltip();
void update(); void update();

6
src/usages_clang.cc

@ -33,9 +33,9 @@ bool Usages::Clang::Cache::Cursor::operator==(const Cursor &o) {
return false; 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) 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) { for(auto &clang_token : *clang_tokens) {
tokens.emplace_back(Token{clang_token.get_spelling(), clang_token.get_source_range().get_offsets(), static_cast<size_t>(-1)}); tokens.emplace_back(Token{clang_token.get_spelling(), clang_token.get_source_range().get_offsets(), static_cast<size_t>(-1)});
@ -71,7 +71,7 @@ Usages::Clang::Cache::Cache(const boost::filesystem::path &project_path, const b
std::time_t before_parse_time; std::time_t before_parse_time;
std::map<boost::filesystem::path, std::time_t> &paths_and_last_write_times; std::map<boost::filesystem::path, std::time_t> &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) { clang_getInclusions(translation_unit->cx_tu, [](CXFile included_file, CXSourceLocation *inclusion_stack, unsigned include_len, CXClientData data) {
auto visitor_data = static_cast<VisitorData *>(data); auto visitor_data = static_cast<VisitorData *>(data);

6
src/usages_clang.h

@ -30,7 +30,7 @@ namespace boost {
namespace Usages { namespace Usages {
class Clang { class Clang {
public: public:
typedef std::set<boost::filesystem::path> PathSet; using PathSet = std::set<boost::filesystem::path>;
class Usages { class Usages {
public: public:
@ -89,8 +89,8 @@ namespace Usages {
std::vector<Cursor> cursors; std::vector<Cursor> cursors;
std::map<boost::filesystem::path, std::time_t> paths_and_last_write_times; std::map<boost::filesystem::path, std::time_t> paths_and_last_write_times;
Cache() {} Cache() = default;
Cache(const boost::filesystem::path &project_path, const boost::filesystem::path &build_path, const boost::filesystem::path &path, 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); std::time_t before_parse_time, clangmm::TranslationUnit *translation_unit, clangmm::Tokens *clang_tokens);
operator bool() const { return !paths_and_last_write_times.empty(); } operator bool() const { return !paths_and_last_write_times.empty(); }

12
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()); boost::filesystem::path project_path = Dialog::new_folder(Notebook::get().get_current_folder());
if(project_path!="") { if(project_path!="") {
auto project_name=project_path.filename().string(); auto project_name=project_path.filename().string();
for(size_t c=0;c<project_name.size();c++) { for(auto &chr: project_name) {
if(project_name[c]==' ') if(chr==' ')
project_name[c]='_'; chr='_';
} }
auto cmakelists_path=project_path; auto cmakelists_path=project_path;
cmakelists_path/="CMakeLists.txt"; cmakelists_path/="CMakeLists.txt";
@ -267,9 +267,9 @@ void Window::set_menu_actions() {
boost::filesystem::path project_path = Dialog::new_folder(Notebook::get().get_current_folder()); boost::filesystem::path project_path = Dialog::new_folder(Notebook::get().get_current_folder());
if(project_path!="") { if(project_path!="") {
auto project_name=project_path.filename().string(); auto project_name=project_path.filename().string();
for(size_t c=0;c<project_name.size();c++) { for(auto &chr: project_name) {
if(project_name[c]==' ') if(chr==' ')
project_name[c]='_'; chr='_';
} }
auto cmakelists_path=project_path; auto cmakelists_path=project_path;
cmakelists_path/="CMakeLists.txt"; cmakelists_path/="CMakeLists.txt";

Loading…
Cancel
Save