Browse Source

SourceClang: moved retrieving diagnostics away from main thread, since large number of warnings (>100) would lead to temporary nonresponsive application

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

2
src/source_clang.cc

@ -122,6 +122,7 @@ void Source::ClangViewParse::parse_initialize() {
auto expected=ParseProcessState::PROCESSING; auto expected=ParseProcessState::PROCESSING;
if(parse_process_state.compare_exchange_strong(expected, ParseProcessState::POSTPROCESSING)) { if(parse_process_state.compare_exchange_strong(expected, ParseProcessState::POSTPROCESSING)) {
clang_tokens=clang_tu->get_tokens(0, parse_thread_buffer.bytes()-1); clang_tokens=clang_tu->get_tokens(0, parse_thread_buffer.bytes()-1);
diagnostics=clang_tu->get_diagnostics();
parse_lock.unlock(); parse_lock.unlock();
dispatcher.post([this] { dispatcher.post([this] {
std::unique_lock<std::mutex> parse_lock(parse_mutex, std::defer_lock); std::unique_lock<std::mutex> parse_lock(parse_mutex, std::defer_lock);
@ -257,7 +258,6 @@ void Source::ClangViewParse::update_diagnostics() {
fix_its.clear(); fix_its.clear();
get_buffer()->remove_tag_by_name("def:warning_underline", get_buffer()->begin(), get_buffer()->end()); get_buffer()->remove_tag_by_name("def:warning_underline", get_buffer()->begin(), get_buffer()->end());
get_buffer()->remove_tag_by_name("def:error_underline", get_buffer()->begin(), get_buffer()->end()); get_buffer()->remove_tag_by_name("def:error_underline", get_buffer()->begin(), get_buffer()->end());
auto diagnostics=clang_tu->get_diagnostics();
size_t num_warnings=0; size_t num_warnings=0;
size_t num_errors=0; size_t num_errors=0;
size_t num_fix_its=0; size_t num_fix_its=0;

2
src/source_clang.h

@ -53,7 +53,9 @@ namespace Source {
void update_syntax(); void update_syntax();
std::set<std::string> last_syntax_tags; std::set<std::string> last_syntax_tags;
void update_diagnostics(); void update_diagnostics();
std::vector<clang::Diagnostic> diagnostics;
static clang::Index clang_index; static clang::Index clang_index;
std::vector<std::string> get_compilation_commands(); std::vector<std::string> get_compilation_commands();

Loading…
Cancel
Save