Browse Source

Language protocol: can no longer edit text while waiting for capabilities during initialization, and some cleanups

merge-requests/398/head
eidheim 7 years ago
parent
commit
44a99fdbc4
  1. 8
      src/source_language_protocol.cc
  2. 26
      src/source_language_protocol.h

8
src/source_language_protocol.cc

@ -15,7 +15,7 @@
#include <regex>
#include <unordered_map>
const std::string flow_coverage_message = "Not covered by Flow";
const std::string type_coverage_message = "Un-type checked code. Consider adding type annotations.";
LanguageProtocol::Offset::Offset(const boost::property_tree::ptree &pt) : line(pt.get<int>("line")), character(pt.get<int>("character")) {}
@ -397,11 +397,13 @@ void Source::LanguageProtocolView::initialize(bool setup) {
if(update_status_state)
update_status_state(this);
set_sensitive(false);
initialize_thread = std::thread([this, setup] {
auto capabilities = client->initialize(this);
dispatcher.post([this, capabilities, setup] {
this->capabilities = capabilities;
set_sensitive(true);
std::string text = get_buffer()->get_text();
escape_text(text);
@ -965,7 +967,7 @@ void Source::LanguageProtocolView::update_diagnostics(std::vector<LanguageProtoc
for(auto &mark : type_coverage_marks)
add_diagnostic_tooltip(mark.first->get_iter(), mark.second->get_iter(), false, [](const Glib::RefPtr<Gtk::TextBuffer> &buffer) {
buffer->insert_at_cursor(flow_coverage_message);
buffer->insert_at_cursor(type_coverage_message);
});
status_diagnostics = std::make_tuple(num_warnings, num_errors, num_fix_its);
@ -1506,7 +1508,7 @@ void Source::LanguageProtocolView::update_type_coverage() {
auto start = get_iter_at_line_offset(range.start.line, range.start.character);
auto end = get_iter_at_line_offset(range.end.line, range.end.character);
add_diagnostic_tooltip(start, end, false, [](const Glib::RefPtr<Gtk::TextBuffer> &buffer) {
buffer->insert_at_cursor(flow_coverage_message);
buffer->insert_at_cursor(type_coverage_message);
});
type_coverage_marks.emplace_back(get_buffer()->create_mark(start), get_buffer()->create_mark(end));

26
src/source_language_protocol.h

@ -83,19 +83,19 @@ namespace LanguageProtocol {
enum class TextDocumentSync { NONE = 0,
FULL,
INCREMENTAL };
TextDocumentSync text_document_sync;
bool hover;
bool completion;
bool signature_help;
bool definition;
bool references;
bool document_highlight;
bool workspace_symbol;
bool document_symbol;
bool document_formatting;
bool document_range_formatting;
bool rename;
bool type_coverage;
TextDocumentSync text_document_sync = TextDocumentSync::NONE;
bool hover = false;
bool completion = false;
bool signature_help = false;
bool definition = false;
bool references = false;
bool document_highlight = false;
bool workspace_symbol = false;
bool document_symbol = false;
bool document_formatting = false;
bool document_range_formatting = false;
bool rename = false;
bool type_coverage = false;
};
class Client {

Loading…
Cancel
Save