Browse Source

Refactoring/operations accross files: added wait dialog if other tabs are parsing

merge-requests/365/head
eidheim 10 years ago
parent
commit
2393556e89
  1. 4
      src/dialogs.cc
  2. 2
      src/dialogs.h
  3. 39
      src/source_clang.cc
  4. 1
      src/source_clang.h
  5. 3
      src/window.cc

4
src/dialogs.cc

@ -28,6 +28,10 @@ Dialog::Message::Message(const std::string &text): Gtk::MessageDialog(text, fals
g_main_context_iteration(NULL, false); g_main_context_iteration(NULL, false);
} }
bool Dialog::Message::on_delete_event(GdkEventAny *event) {
return true;
}
std::string Dialog::gtk_dialog(const boost::filesystem::path &path, const std::string &title, std::string Dialog::gtk_dialog(const boost::filesystem::path &path, const std::string &title,
const std::vector<std::pair<std::string, Gtk::ResponseType>> &buttons, const std::vector<std::pair<std::string, Gtk::ResponseType>> &buttons,
Gtk::FileChooserAction gtk_options) { Gtk::FileChooserAction gtk_options) {

2
src/dialogs.h

@ -16,6 +16,8 @@ public:
class Message : public Gtk::MessageDialog { class Message : public Gtk::MessageDialog {
public: public:
Message(const std::string &text); Message(const std::string &text);
protected:
bool on_delete_event(GdkEventAny *event) override;
}; };
private: private:

39
src/source_clang.cc

@ -6,6 +6,7 @@
#include "debug_clang.h" #include "debug_clang.h"
#endif #endif
#include "info.h" #include "info.h"
#include "dialogs.h"
namespace sigc { namespace sigc {
#ifndef SIGC_FUNCTORS_DEDUCE_RESULT_TYPE_WITH_DECLTYPE #ifndef SIGC_FUNCTORS_DEDUCE_RESULT_TYPE_WITH_DECLTYPE
@ -891,6 +892,7 @@ Source::ClangViewAutocomplete(file_path, language) {
} }
auto token=get_token(); auto token=get_token();
if(token) { if(token) {
wait_parsing(views);
std::vector<Source::View*> renamed_views; std::vector<Source::View*> renamed_views;
for(auto &view: views) { for(auto &view: views) {
if(auto clang_view=dynamic_cast<Source::ClangView*>(view)) { if(auto clang_view=dynamic_cast<Source::ClangView*>(view)) {
@ -968,6 +970,8 @@ Source::ClangViewAutocomplete(file_path, language) {
return location; return location;
} }
auto token=get_token(); auto token=get_token();
if(token) {
wait_parsing(views);
for(auto &view: views) { for(auto &view: views) {
if(auto clang_view=dynamic_cast<Source::ClangView*>(view)) { if(auto clang_view=dynamic_cast<Source::ClangView*>(view)) {
if(clang_view->language && clang_view->language->get_id()!="chdr" && clang_view->language->get_id()!="cpphdr") { if(clang_view->language && clang_view->language->get_id()!="chdr" && clang_view->language->get_id()!="cpphdr") {
@ -991,6 +995,8 @@ Source::ClangViewAutocomplete(file_path, language) {
} }
} }
} }
Info::get().print("Could not find implementation");
}
return location; return location;
}; };
@ -1001,6 +1007,8 @@ Source::ClangViewAutocomplete(file_path, language) {
return usages; return usages;
} }
auto token=get_token(); auto token=get_token();
if(token) {
wait_parsing(views);
std::vector<Source::View*> views_reordered; std::vector<Source::View*> views_reordered;
views_reordered.emplace_back(this); views_reordered.emplace_back(this);
for(auto &view: views) { for(auto &view: views) {
@ -1044,6 +1052,7 @@ Source::ClangViewAutocomplete(file_path, language) {
} }
} }
} }
}
return usages; return usages;
}; };
@ -1277,6 +1286,36 @@ Source::ClangViewRefactor::Token Source::ClangViewRefactor::get_token() {
return Token(); return Token();
} }
void Source::ClangViewRefactor::wait_parsing(const std::vector<Source::View*> &views) {
std::unique_ptr<Dialog::Message> message;
std::vector<Source::ClangView*> clang_views;
for(auto &view: views) {
if(auto clang_view=dynamic_cast<Source::ClangView*>(view)) {
if(!clang_view->parsed) {
clang_views.emplace_back(clang_view);
if(!message)
message=std::unique_ptr<Dialog::Message>(new Dialog::Message("Please wait while all buffers finish parsing"));
}
}
}
if(message) {
for(;;) {
while(g_main_context_pending(NULL))
g_main_context_iteration(NULL, false);
bool all_parsed=true;
for(auto &clang_view: clang_views) {
if(!clang_view->parsed) {
all_parsed=false;
break;
}
}
if(all_parsed)
break;
}
message->hide();
}
}
void Source::ClangViewRefactor::tag_similar_tokens(const Token &token) { void Source::ClangViewRefactor::tag_similar_tokens(const Token &token) {
if(parsed) { if(parsed) {
if(token && last_tagged_token!=token) { if(token && last_tagged_token!=token) {

1
src/source_clang.h

@ -109,6 +109,7 @@ namespace Source {
sigc::connection delayed_tag_similar_tokens_connection; sigc::connection delayed_tag_similar_tokens_connection;
private: private:
Token get_token(); Token get_token();
void wait_parsing(const std::vector<Source::View*> &views);
std::list<std::pair<Glib::RefPtr<Gtk::TextMark>, Glib::RefPtr<Gtk::TextMark> > > similar_token_marks; std::list<std::pair<Glib::RefPtr<Gtk::TextMark>, Glib::RefPtr<Gtk::TextMark> > > similar_token_marks;
void tag_similar_tokens(const Token &token); void tag_similar_tokens(const Token &token);

3
src/window.cc

@ -471,7 +471,6 @@ void Window::set_menu_actions() {
view->scroll_to_cursor_delayed(view, true, false); view->scroll_to_cursor_delayed(view, true, false);
return; return;
} }
Info::get().print("Could not find implementation");
} }
} }
}); });
@ -1073,7 +1072,7 @@ void Window::rename_token_entry() {
EntryBox::get().labels.emplace_back(); EntryBox::get().labels.emplace_back();
auto label_it=EntryBox::get().labels.begin(); auto label_it=EntryBox::get().labels.begin();
label_it->update=[label_it](int state, const std::string& message){ label_it->update=[label_it](int state, const std::string& message){
label_it->set_text("Warning: only opened and parsed tabs will have its content renamed, and modified files will be saved"); label_it->set_text("Warning: only opened files will be refactored, and altered files will be saved");
}; };
label_it->update(0, ""); label_it->update(0, "");
auto iter=std::make_shared<Gtk::TextIter>(view->get_buffer()->get_insert()->get_iter()); auto iter=std::make_shared<Gtk::TextIter>(view->get_buffer()->get_insert()->get_iter());

Loading…
Cancel
Save