Browse Source

Cleanup: added multiple inheritance to ClangView

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

20
src/source_clang.cc

@ -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<Gsv::Language> 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<Gsv::Language> 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<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) {
get_source_buffer()->set_highlight_syntax(true);
get_source_buffer()->set_language(language);

11
src/source_clang.h

@ -24,6 +24,7 @@ namespace Source {
void soft_reparse() override;
protected:
ClangViewParse() : View("", Glib::RefPtr<Gsv::Language>()) {}
Dispatcher dispatcher;
void parse_initialize();
std::unique_ptr<clang::TranslationUnit> clang_tu;
@ -55,7 +56,7 @@ namespace Source {
std::vector<std::string> 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<Gsv::Language> 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<Gsv::Language> 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<Gsv::Language> language);
void async_delete() override;

Loading…
Cancel
Save