Browse Source

Autocomplete and reparse should now live in perfect symbiosis.

merge-requests/365/head
eidheim 11 years ago
parent
commit
460f80a22a
  1. 26
      juci/source.cc
  2. 5
      juci/source.h

26
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]() { get_buffer()->signal_changed().connect([this]() {
parse_thread_mapped=false; start_reparse();
clang_readable=false;
delayed_reparse_connection.disconnect();
delayed_reparse_connection=Glib::signal_timeout().connect([this]() {
parse_thread_go=true;
return false;
}, 1000);
type_tooltips.hide(); type_tooltips.hide();
diagnostic_tooltips.hide(); diagnostic_tooltips.hide();
if(last_similar_tokens_tagged!="") { if(last_similar_tokens_tagged!="") {
@ -266,15 +260,23 @@ init_syntax_highlighting(const std::map<std::string, std::string>
clang_tokens=clang_tu->get_tokens(0, buffers.find(file_path)->second.size()-1); clang_tokens=clang_tu->get_tokens(0, buffers.find(file_path)->second.size()-1);
} }
std::map<std::string, std::string> Source::ClangView:: std::map<std::string, std::string> Source::ClangView::get_buffer_map() const {
get_buffer_map() const {
std::map<std::string, std::string> buffer_map; std::map<std::string, std::string> buffer_map;
buffer_map[file_path]=get_source_buffer()->get_text().raw(); buffer_map[file_path]=get_source_buffer()->get_text().raw();
return buffer_map; return buffer_map;
} }
int Source::ClangView:: void Source::ClangView::start_reparse() {
reparse(const std::map<std::string, std::string> &buffer) { 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<std::string, std::string> &buffer) {
int status = clang_tu->ReparseTranslationUnit(buffer); int status = clang_tu->ReparseTranslationUnit(buffer);
clang_tokens=clang_tu->get_tokens(0, parse_thread_buffer_map.find(file_path)->second.size()-1); clang_tokens=clang_tu->get_tokens(0, parse_thread_buffer_map.find(file_path)->second.size()-1);
return status; 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::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) { Source::ClangView(file_path, project_path, terminal), selection_dialog(*this), autocomplete_cancel_starting(false) {
selection_dialog.on_hide=[this](){ selection_dialog.on_hide=[this](){
//TODO: start parsing again? start_reparse();
}; };
get_buffer()->signal_changed().connect([this](){ get_buffer()->signal_changed().connect([this](){

5
juci/source.h

@ -70,12 +70,13 @@ namespace Source {
ClangView(const std::string& file_path, const std::string& project_path, Terminal::Controller& terminal); ClangView(const std::string& file_path, const std::string& project_path, Terminal::Controller& terminal);
~ClangView(); ~ClangView();
protected: protected:
void start_reparse();
bool on_key_press_event(GdkEventKey* key);
bool on_focus_out_event(GdkEventFocus* event);
std::unique_ptr<clang::TranslationUnit> clang_tu; std::unique_ptr<clang::TranslationUnit> clang_tu;
std::map<std::string, std::string> get_buffer_map() const; std::map<std::string, std::string> get_buffer_map() const;
std::mutex parsing_mutex; std::mutex parsing_mutex;
sigc::connection delayed_reparse_connection; sigc::connection delayed_reparse_connection;
bool on_key_press_event(GdkEventKey* key);
bool on_focus_out_event(GdkEventFocus* event);
private: private:
// inits the syntax highligthing on file open // inits the syntax highligthing on file open
void init_syntax_highlighting(const std::map<std::string, std::string> void init_syntax_highlighting(const std::map<std::string, std::string>

Loading…
Cancel
Save