From 460f80a22ab5b3ae2549afa7145c004ec75a520c Mon Sep 17 00:00:00 2001 From: eidheim Date: Thu, 16 Jul 2015 12:27:37 +0200 Subject: [PATCH] Autocomplete and reparse should now live in perfect symbiosis. --- juci/source.cc | 26 ++++++++++++++------------ juci/source.h | 5 +++-- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/juci/source.cc b/juci/source.cc index d7d7ab2..17e1378 100644 --- a/juci/source.cc +++ b/juci/source.cc @@ -225,13 +225,7 @@ parse_thread_go(true), parse_thread_mapped(false), parse_thread_stop(false) { }); get_buffer()->signal_changed().connect([this]() { - parse_thread_mapped=false; - clang_readable=false; - delayed_reparse_connection.disconnect(); - delayed_reparse_connection=Glib::signal_timeout().connect([this]() { - parse_thread_go=true; - return false; - }, 1000); + start_reparse(); type_tooltips.hide(); diagnostic_tooltips.hide(); if(last_similar_tokens_tagged!="") { @@ -266,15 +260,23 @@ init_syntax_highlighting(const std::map clang_tokens=clang_tu->get_tokens(0, buffers.find(file_path)->second.size()-1); } -std::map Source::ClangView:: -get_buffer_map() const { +std::map Source::ClangView::get_buffer_map() const { std::map buffer_map; buffer_map[file_path]=get_source_buffer()->get_text().raw(); return buffer_map; } -int Source::ClangView:: -reparse(const std::map &buffer) { +void Source::ClangView::start_reparse() { + parse_thread_mapped=false; + clang_readable=false; + delayed_reparse_connection.disconnect(); + delayed_reparse_connection=Glib::signal_timeout().connect([this]() { + parse_thread_go=true; + return false; + }, 1000); +} + +int Source::ClangView::reparse(const std::map &buffer) { int status = clang_tu->ReparseTranslationUnit(buffer); clang_tokens=clang_tu->get_tokens(0, parse_thread_buffer_map.find(file_path)->second.size()-1); return status; @@ -569,7 +571,7 @@ bool Source::ClangView::on_key_press_event(GdkEventKey* key) { Source::ClangViewAutocomplete::ClangViewAutocomplete(const std::string& file_path, const std::string& project_path, Terminal::Controller& terminal): Source::ClangView(file_path, project_path, terminal), selection_dialog(*this), autocomplete_cancel_starting(false) { selection_dialog.on_hide=[this](){ - //TODO: start parsing again? + start_reparse(); }; get_buffer()->signal_changed().connect([this](){ diff --git a/juci/source.h b/juci/source.h index 2131831..7a2a05a 100644 --- a/juci/source.h +++ b/juci/source.h @@ -70,12 +70,13 @@ namespace Source { ClangView(const std::string& file_path, const std::string& project_path, Terminal::Controller& terminal); ~ClangView(); protected: + void start_reparse(); + bool on_key_press_event(GdkEventKey* key); + bool on_focus_out_event(GdkEventFocus* event); std::unique_ptr clang_tu; std::map get_buffer_map() const; std::mutex parsing_mutex; sigc::connection delayed_reparse_connection; - bool on_key_press_event(GdkEventKey* key); - bool on_focus_out_event(GdkEventFocus* event); private: // inits the syntax highligthing on file open void init_syntax_highlighting(const std::map