Browse Source

Cleanup: added multiple inheritance to ClangView

merge-requests/365/head
eidheim 10 years ago
parent
commit
fed28ce3e2
  1. 22
      src/source_clang.cc
  2. 11
      src/source_clang.h

22
src/source_clang.cc

@ -25,7 +25,7 @@ namespace sigc {
clang::Index Source::ClangViewParse::clang_index(0, 0); clang::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, Glib::RefPtr<Gsv::Language> language):
Source::View(file_path, language) { Source::View(file_path, language) {
auto tag_table=get_buffer()->get_tag_table(); auto tag_table=get_buffer()->get_tag_table();
for (auto &item : Config::get().source.clang_types) { for (auto &item : Config::get().source.clang_types) {
if(!tag_table->lookup(item.second)) { 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();
} }
} }
//type_tooltips.show(rectangle);
} }
//////////////////////////////
//// ClangViewAutocomplete /// Source::ClangViewAutocomplete::ClangViewAutocomplete(): autocomplete_state(AutocompleteState::IDLE) {
//////////////////////////////
Source::ClangViewAutocomplete::ClangViewAutocomplete(const boost::filesystem::path &file_path, Glib::RefPtr<Gsv::Language> language):
Source::ClangViewParse(file_path, language), autocomplete_state(AutocompleteState::IDLE) {
get_buffer()->signal_changed().connect([this](){ get_buffer()->signal_changed().connect([this](){
if(autocomplete_dialog && autocomplete_dialog->shown) if(autocomplete_dialog && autocomplete_dialog->shown)
delayed_reparse_connection.disconnect(); delayed_reparse_connection.disconnect();
@ -852,11 +847,8 @@ bool Source::ClangViewAutocomplete::full_reparse() {
return false; return false;
} }
////////////////////////////
//// ClangViewRefactor ///// Source::ClangViewRefactor::ClangViewRefactor() {
////////////////////////////
Source::ClangViewRefactor::ClangViewRefactor(const boost::filesystem::path &file_path, Glib::RefPtr<Gsv::Language> language):
Source::ClangViewAutocomplete(file_path, language) {
similar_identifiers_tag=get_buffer()->create_tag(); 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) 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<Gsv::Language> language): ClangViewRefactor(file_path, language) {
Source::ClangView::ClangView(const boost::filesystem::path &file_path, Glib::RefPtr<Gsv::Language> language):
ClangViewParse(file_path, language), ClangViewAutocomplete(), ClangViewRefactor() {
if(language) { if(language) {
get_source_buffer()->set_highlight_syntax(true); get_source_buffer()->set_highlight_syntax(true);
get_source_buffer()->set_language(language); get_source_buffer()->set_language(language);

11
src/source_clang.h

@ -24,6 +24,7 @@ namespace Source {
void soft_reparse() override; void soft_reparse() override;
protected: protected:
ClangViewParse() : View("", Glib::RefPtr<Gsv::Language>()) {}
Dispatcher dispatcher; Dispatcher dispatcher;
void parse_initialize(); void parse_initialize();
std::unique_ptr<clang::TranslationUnit> clang_tu; std::unique_ptr<clang::TranslationUnit> clang_tu;
@ -55,7 +56,7 @@ namespace Source {
std::vector<std::string> get_compilation_commands(); std::vector<std::string> get_compilation_commands();
}; };
class ClangViewAutocomplete : public ClangViewParse { class ClangViewAutocomplete : public virtual ClangViewParse {
protected: protected:
enum class AutocompleteState {IDLE, STARTING, RESTARTING, CANCELED}; enum class AutocompleteState {IDLE, STARTING, RESTARTING, CANCELED};
public: public:
@ -67,7 +68,7 @@ namespace Source {
std::string brief_comments; std::string brief_comments;
}; };
ClangViewAutocomplete(const boost::filesystem::path &file_path, Glib::RefPtr<Gsv::Language> language); ClangViewAutocomplete();
virtual void async_delete(); virtual void async_delete();
bool full_reparse() override; bool full_reparse() override;
@ -91,7 +92,7 @@ namespace Source {
bool full_reparse_running=false; bool full_reparse_running=false;
}; };
class ClangViewRefactor : public ClangViewAutocomplete { class ClangViewRefactor : public virtual ClangViewParse {
class Identifier { class Identifier {
public: public:
Identifier(clang::CursorKind kind, const std::string &spelling, const std::string &usr, const clang::Cursor &cursor=clang::Cursor()) : 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; clang::Cursor cursor;
}; };
public: public:
ClangViewRefactor(const boost::filesystem::path &file_path, Glib::RefPtr<Gsv::Language> language); ClangViewRefactor();
protected: protected:
sigc::connection delayed_tag_similar_identifiers_connection; sigc::connection delayed_tag_similar_identifiers_connection;
private: private:
@ -122,7 +123,7 @@ namespace Source {
bool renaming=false; bool renaming=false;
}; };
class ClangView : public ClangViewRefactor { class ClangView : public ClangViewAutocomplete, public ClangViewRefactor {
public: public:
ClangView(const boost::filesystem::path &file_path, Glib::RefPtr<Gsv::Language> language); ClangView(const boost::filesystem::path &file_path, Glib::RefPtr<Gsv::Language> language);
void async_delete() override; void async_delete() override;

Loading…
Cancel
Save