diff --git a/src/source_clang.cc b/src/source_clang.cc index 499e124..4b9c2ca 100644 --- a/src/source_clang.cc +++ b/src/source_clang.cc @@ -25,7 +25,7 @@ namespace sigc { clang::Index Source::ClangViewParse::clang_index(0, 0); Source::ClangViewParse::ClangViewParse(const boost::filesystem::path &file_path, Glib::RefPtr language): -Source::View(file_path, language) { + Source::View(file_path, language) { auto tag_table=get_buffer()->get_tag_table(); for (auto &item : Config::get().source.clang_types) { if(!tag_table->lookup(item.second)) { @@ -484,15 +484,10 @@ void Source::ClangViewParse::show_type_tooltips(const Gdk::Rectangle &rectangle) type_tooltips.show(); } } - - //type_tooltips.show(rectangle); } -////////////////////////////// -//// ClangViewAutocomplete /// -////////////////////////////// -Source::ClangViewAutocomplete::ClangViewAutocomplete(const boost::filesystem::path &file_path, Glib::RefPtr language): -Source::ClangViewParse(file_path, language), autocomplete_state(AutocompleteState::IDLE) { + +Source::ClangViewAutocomplete::ClangViewAutocomplete(): autocomplete_state(AutocompleteState::IDLE) { get_buffer()->signal_changed().connect([this](){ if(autocomplete_dialog && autocomplete_dialog->shown) delayed_reparse_connection.disconnect(); @@ -852,11 +847,8 @@ bool Source::ClangViewAutocomplete::full_reparse() { return false; } -//////////////////////////// -//// ClangViewRefactor ///// -//////////////////////////// -Source::ClangViewRefactor::ClangViewRefactor(const boost::filesystem::path &file_path, Glib::RefPtr language): -Source::ClangViewAutocomplete(file_path, language) { + +Source::ClangViewRefactor::ClangViewRefactor() { similar_identifiers_tag=get_buffer()->create_tag(); similar_identifiers_tag->property_weight()=1000; //TODO: replace with Pango::WEIGHT_ULTRAHEAVY in 2016 or so (when Ubuntu 14 is history) @@ -1362,7 +1354,9 @@ void Source::ClangViewRefactor::tag_similar_identifiers(const Identifier &identi } } -Source::ClangView::ClangView(const boost::filesystem::path &file_path, Glib::RefPtr language): ClangViewRefactor(file_path, language) { + +Source::ClangView::ClangView(const boost::filesystem::path &file_path, Glib::RefPtr language): + ClangViewParse(file_path, language), ClangViewAutocomplete(), ClangViewRefactor() { if(language) { get_source_buffer()->set_highlight_syntax(true); get_source_buffer()->set_language(language); diff --git a/src/source_clang.h b/src/source_clang.h index a57606e..85686bb 100644 --- a/src/source_clang.h +++ b/src/source_clang.h @@ -24,6 +24,7 @@ namespace Source { void soft_reparse() override; protected: + ClangViewParse() : View("", Glib::RefPtr()) {} Dispatcher dispatcher; void parse_initialize(); std::unique_ptr clang_tu; @@ -55,7 +56,7 @@ namespace Source { std::vector get_compilation_commands(); }; - class ClangViewAutocomplete : public ClangViewParse { + class ClangViewAutocomplete : public virtual ClangViewParse { protected: enum class AutocompleteState {IDLE, STARTING, RESTARTING, CANCELED}; public: @@ -67,7 +68,7 @@ namespace Source { std::string brief_comments; }; - ClangViewAutocomplete(const boost::filesystem::path &file_path, Glib::RefPtr language); + ClangViewAutocomplete(); virtual void async_delete(); bool full_reparse() override; @@ -91,7 +92,7 @@ namespace Source { bool full_reparse_running=false; }; - class ClangViewRefactor : public ClangViewAutocomplete { + class ClangViewRefactor : public virtual ClangViewParse { class Identifier { public: Identifier(clang::CursorKind kind, const std::string &spelling, const std::string &usr, const clang::Cursor &cursor=clang::Cursor()) : @@ -108,7 +109,7 @@ namespace Source { clang::Cursor cursor; }; public: - ClangViewRefactor(const boost::filesystem::path &file_path, Glib::RefPtr language); + ClangViewRefactor(); protected: sigc::connection delayed_tag_similar_identifiers_connection; private: @@ -122,7 +123,7 @@ namespace Source { bool renaming=false; }; - class ClangView : public ClangViewRefactor { + class ClangView : public ClangViewAutocomplete, public ClangViewRefactor { public: ClangView(const boost::filesystem::path &file_path, Glib::RefPtr language); void async_delete() override;