|
|
|
@ -186,14 +186,17 @@ parse_thread_go(true), parse_thread_mapped(false), parse_thread_stop(false) { |
|
|
|
parsing_in_progress=this->terminal.print_in_progress("Parsing "+file_path); |
|
|
|
parsing_in_progress=this->terminal.print_in_progress("Parsing "+file_path); |
|
|
|
parse_done.connect([this](){ |
|
|
|
parse_done.connect([this](){ |
|
|
|
if(parse_thread_mapped) { |
|
|
|
if(parse_thread_mapped) { |
|
|
|
|
|
|
|
if(parsing_mutex.try_lock()) { |
|
|
|
INFO("Updating syntax"); |
|
|
|
INFO("Updating syntax"); |
|
|
|
update_syntax(extract_tokens(0, get_source_buffer()->get_text().size())); |
|
|
|
update_syntax(extract_tokens(0, get_source_buffer()->get_text().size())); |
|
|
|
update_diagnostics(); |
|
|
|
update_diagnostics(); |
|
|
|
update_types(); |
|
|
|
update_types(); |
|
|
|
clang_updated=true; |
|
|
|
clang_updated=true; |
|
|
|
parsing_in_progress->done("done"); |
|
|
|
parsing_mutex.unlock(); |
|
|
|
INFO("Syntax updated"); |
|
|
|
INFO("Syntax updated"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
parsing_in_progress->done("done"); |
|
|
|
|
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
parse_thread_go=true; |
|
|
|
parse_thread_go=true; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -219,7 +222,13 @@ parse_thread_go(true), parse_thread_mapped(false), parse_thread_stop(false) { |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
autocomplete_done.connect([this](){ |
|
|
|
|
|
|
|
if(autocomplete_done_function) |
|
|
|
|
|
|
|
autocomplete_done_function(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
get_source_buffer()->signal_changed().connect([this]() { |
|
|
|
get_source_buffer()->signal_changed().connect([this]() { |
|
|
|
|
|
|
|
autocomplete_cancel=true; |
|
|
|
parse_thread_mapped=false; |
|
|
|
parse_thread_mapped=false; |
|
|
|
clang_updated=false; |
|
|
|
clang_updated=false; |
|
|
|
parse_thread_go=true; |
|
|
|
parse_thread_go=true; |
|
|
|
@ -269,13 +278,9 @@ reparse(const std::map<std::string, std::string> &buffer) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
std::vector<Source::AutoCompleteData> Source::ClangView:: |
|
|
|
std::vector<Source::AutoCompleteData> Source::ClangView:: |
|
|
|
get_autocomplete_suggestions(int line_number, int column) { |
|
|
|
get_autocomplete_suggestions(int line_number, int column, std::map<std::string, std::string>& buffer_map) { |
|
|
|
INFO("Getting auto complete suggestions"); |
|
|
|
INFO("Getting auto complete suggestions"); |
|
|
|
std::vector<Source::AutoCompleteData> suggestions; |
|
|
|
std::vector<Source::AutoCompleteData> suggestions; |
|
|
|
std::map<std::string, std::string> buffer_map; |
|
|
|
|
|
|
|
buffer_map[file_path]=get_source_buffer()->get_text(get_source_buffer()->begin(), get_source_buffer()->get_insert()->get_iter()); |
|
|
|
|
|
|
|
buffer_map[file_path]+="\n"; |
|
|
|
|
|
|
|
parsing_mutex.lock(); |
|
|
|
|
|
|
|
clang::CodeCompleteResults results(clang_tu.get(), |
|
|
|
clang::CodeCompleteResults results(clang_tu.get(), |
|
|
|
file_path, |
|
|
|
file_path, |
|
|
|
buffer_map, |
|
|
|
buffer_map, |
|
|
|
@ -289,7 +294,6 @@ get_autocomplete_suggestions(int line_number, int column) { |
|
|
|
} |
|
|
|
} |
|
|
|
suggestions.emplace_back(chunks); |
|
|
|
suggestions.emplace_back(chunks); |
|
|
|
} |
|
|
|
} |
|
|
|
parsing_mutex.unlock(); |
|
|
|
|
|
|
|
DEBUG("Number of suggestions"); |
|
|
|
DEBUG("Number of suggestions"); |
|
|
|
DEBUG_VAR(suggestions.size()); |
|
|
|
DEBUG_VAR(suggestions.size()); |
|
|
|
return suggestions; |
|
|
|
return suggestions; |
|
|
|
@ -561,11 +565,15 @@ bool Source::ClangView::on_key_release(GdkEventKey* key) { |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if(!autocomplete_running) { |
|
|
|
|
|
|
|
autocomplete_running=true; |
|
|
|
|
|
|
|
autocomplete_cancel=false; |
|
|
|
INFO("Source::ClangView::on_key_release getting autocompletions"); |
|
|
|
INFO("Source::ClangView::on_key_release getting autocompletions"); |
|
|
|
std::vector<Source::AutoCompleteData> acdata=get_autocomplete_suggestions(beg.get_line()+1, |
|
|
|
std::shared_ptr<std::vector<Source::AutoCompleteData> > ac_data=std::make_shared<std::vector<Source::AutoCompleteData> >(); |
|
|
|
beg.get_line_offset()+2); |
|
|
|
autocomplete_done_function=[this, ac_data](){ |
|
|
|
|
|
|
|
if(!autocomplete_cancel) { |
|
|
|
std::map<std::string, std::string> rows; |
|
|
|
std::map<std::string, std::string> rows; |
|
|
|
for (auto &data : acdata) { |
|
|
|
for (auto &data : *ac_data) { |
|
|
|
std::stringstream ss; |
|
|
|
std::stringstream ss; |
|
|
|
std::string return_value; |
|
|
|
std::string return_value; |
|
|
|
for (auto &chunk : data.chunks) { |
|
|
|
for (auto &chunk : data.chunks) { |
|
|
|
@ -586,8 +594,33 @@ bool Source::ClangView::on_key_release(GdkEventKey* key) { |
|
|
|
} |
|
|
|
} |
|
|
|
selection_dialog.rows=std::move(rows); |
|
|
|
selection_dialog.rows=std::move(rows); |
|
|
|
selection_dialog.show(); |
|
|
|
selection_dialog.show(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
autocomplete_running=false; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
std::shared_ptr<std::map<std::string, std::string> > buffer_map=std::make_shared<std::map<std::string, std::string> >(); |
|
|
|
|
|
|
|
(*buffer_map)[file_path]=get_buffer()->get_text(get_buffer()->begin(), get_buffer()->get_insert()->get_iter()); |
|
|
|
|
|
|
|
(*buffer_map)[file_path]+="\n"; |
|
|
|
|
|
|
|
auto line_nr=beg.get_line()+1; |
|
|
|
|
|
|
|
auto column_nr=beg.get_line_offset()+2; |
|
|
|
|
|
|
|
std::thread autocomplete_thread([this, ac_data, line_nr, column_nr, buffer_map](){ |
|
|
|
|
|
|
|
parsing_mutex.lock(); |
|
|
|
|
|
|
|
*ac_data=move(get_autocomplete_suggestions(line_nr, column_nr, *buffer_map)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
autocomplete_done(); |
|
|
|
|
|
|
|
parsing_mutex.unlock(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
autocomplete_thread.detach(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
std::map<std::string, std::string> rows; |
|
|
|
|
|
|
|
rows["Autocomplete already running, try again."] = ""; |
|
|
|
|
|
|
|
selection_dialog.rows=std::move(rows); |
|
|
|
|
|
|
|
selection_dialog.show(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//Clang indentation
|
|
|
|
//Clang indentation
|
|
|
|
|