|
|
|
@ -935,15 +935,20 @@ void Source::LanguageProtocolView::escape_text(std::string &text) { |
|
|
|
|
|
|
|
|
|
|
|
void Source::LanguageProtocolView::update_diagnostics(std::vector<LanguageProtocol::Diagnostic> &&diagnostics) { |
|
|
|
void Source::LanguageProtocolView::update_diagnostics(std::vector<LanguageProtocol::Diagnostic> &&diagnostics) { |
|
|
|
dispatcher.post([this, diagnostics = std::move(diagnostics)]() { |
|
|
|
dispatcher.post([this, diagnostics = std::move(diagnostics)]() { |
|
|
|
|
|
|
|
update_diagnostics(diagnostics); |
|
|
|
|
|
|
|
last_diagnostics = std::move(diagnostics); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Source::LanguageProtocolView::update_diagnostics(const std::vector<LanguageProtocol::Diagnostic> &diagnostics) { |
|
|
|
diagnostic_offsets.clear(); |
|
|
|
diagnostic_offsets.clear(); |
|
|
|
diagnostic_tooltips.clear(); |
|
|
|
diagnostic_tooltips.clear(); |
|
|
|
if(!capabilities.type_coverage) |
|
|
|
|
|
|
|
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()); |
|
|
|
if(!capabilities.type_coverage) |
|
|
|
|
|
|
|
num_warnings = 0; |
|
|
|
num_warnings = 0; |
|
|
|
num_errors = 0; |
|
|
|
num_errors = 0; |
|
|
|
num_fix_its = 0; |
|
|
|
num_fix_its = 0; |
|
|
|
|
|
|
|
|
|
|
|
for(auto &diagnostic : diagnostics) { |
|
|
|
for(auto &diagnostic : diagnostics) { |
|
|
|
auto start = get_iter_at_line_pos(diagnostic.range.start.line, diagnostic.range.start.character); |
|
|
|
auto start = get_iter_at_line_pos(diagnostic.range.start.line, diagnostic.range.start.character); |
|
|
|
auto end = get_iter_at_line_pos(diagnostic.range.end.line, diagnostic.range.end.character); |
|
|
|
auto end = get_iter_at_line_pos(diagnostic.range.end.line, diagnostic.range.end.character); |
|
|
|
@ -988,15 +993,16 @@ void Source::LanguageProtocolView::update_diagnostics(std::vector<LanguageProtoc |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for(auto &mark : type_coverage_marks) |
|
|
|
for(auto &mark : type_coverage_marks) { |
|
|
|
add_diagnostic_tooltip(mark.first->get_iter(), mark.second->get_iter(), false, [](const Glib::RefPtr<Gtk::TextBuffer> &buffer) { |
|
|
|
add_diagnostic_tooltip(mark.first->get_iter(), mark.second->get_iter(), false, [](const Glib::RefPtr<Gtk::TextBuffer> &buffer) { |
|
|
|
buffer->insert_at_cursor(type_coverage_message); |
|
|
|
buffer->insert_at_cursor(type_coverage_message); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
num_warnings++; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
status_diagnostics = std::make_tuple(num_warnings, num_errors, num_fix_its); |
|
|
|
status_diagnostics = std::make_tuple(num_warnings, num_errors, num_fix_its); |
|
|
|
if(update_status_diagnostics) |
|
|
|
if(update_status_diagnostics) |
|
|
|
update_status_diagnostics(this); |
|
|
|
update_status_diagnostics(this); |
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Gtk::TextIter Source::LanguageProtocolView::get_iter_at_line_pos(int line, int pos) { |
|
|
|
Gtk::TextIter Source::LanguageProtocolView::get_iter_at_line_pos(int line, int pos) { |
|
|
|
@ -1535,27 +1541,18 @@ void Source::LanguageProtocolView::update_type_coverage() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
dispatcher.post([this, ranges = std::move(ranges)] { |
|
|
|
dispatcher.post([this, ranges = std::move(ranges)] { |
|
|
|
num_warnings = 0; |
|
|
|
|
|
|
|
for(auto &mark : type_coverage_marks) { |
|
|
|
for(auto &mark : type_coverage_marks) { |
|
|
|
get_buffer()->delete_mark(mark.first); |
|
|
|
get_buffer()->delete_mark(mark.first); |
|
|
|
get_buffer()->delete_mark(mark.second); |
|
|
|
get_buffer()->delete_mark(mark.second); |
|
|
|
} |
|
|
|
} |
|
|
|
type_coverage_marks.clear(); |
|
|
|
type_coverage_marks.clear(); |
|
|
|
get_buffer()->remove_tag_by_name("def:warning_underline", get_buffer()->begin(), get_buffer()->end()); |
|
|
|
|
|
|
|
for(auto &range : ranges) { |
|
|
|
for(auto &range : ranges) { |
|
|
|
auto start = get_iter_at_line_pos(range.start.line, range.start.character); |
|
|
|
auto start = get_iter_at_line_pos(range.start.line, range.start.character); |
|
|
|
auto end = get_iter_at_line_pos(range.end.line, range.end.character); |
|
|
|
auto end = get_iter_at_line_pos(range.end.line, range.end.character); |
|
|
|
add_diagnostic_tooltip(start, end, false, [](const Glib::RefPtr<Gtk::TextBuffer> &buffer) { |
|
|
|
|
|
|
|
buffer->insert_at_cursor(type_coverage_message); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
type_coverage_marks.emplace_back(get_buffer()->create_mark(start), get_buffer()->create_mark(end)); |
|
|
|
type_coverage_marks.emplace_back(get_buffer()->create_mark(start), get_buffer()->create_mark(end)); |
|
|
|
|
|
|
|
|
|
|
|
++num_warnings; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
status_diagnostics = std::make_tuple(num_warnings, num_errors, num_fix_its); |
|
|
|
update_diagnostics(last_diagnostics); |
|
|
|
if(update_status_diagnostics) |
|
|
|
|
|
|
|
update_status_diagnostics(this); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|