|
|
|
|
@ -829,18 +829,26 @@ void Source::LanguageProtocolView::show_type_tooltips(const Gdk::Rectangle &rect
|
|
|
|
|
auto offset=iter.get_offset(); |
|
|
|
|
client->write_request("textDocument/hover", "\"textDocument\": {\"uri\":\"file://"+file_path.string()+"\"}, \"position\": {\"line\": "+std::to_string(iter.get_line())+", \"character\": "+std::to_string(iter.get_line_offset())+"}", [this, offset](const boost::property_tree::ptree &result, bool error) { |
|
|
|
|
if(!error) { |
|
|
|
|
auto contents=result.get_child("contents", boost::property_tree::ptree()); |
|
|
|
|
auto it=contents.begin(); |
|
|
|
|
if(it!=contents.end()) { |
|
|
|
|
auto value=it->second.get<std::string>("value", ""); |
|
|
|
|
if(!value.empty()) { |
|
|
|
|
dispatcher.post([this, offset, value=std::move(value)] { |
|
|
|
|
std::string content; |
|
|
|
|
{ |
|
|
|
|
auto contents_pt=result.get_child("contents", boost::property_tree::ptree()); |
|
|
|
|
auto contents_it=contents_pt.begin(); |
|
|
|
|
if(contents_it!=contents_pt.end()) |
|
|
|
|
content=contents_it->second.get<std::string>("value", ""); |
|
|
|
|
} |
|
|
|
|
if(content.empty()) { |
|
|
|
|
auto contents_it=result.find("contents"); |
|
|
|
|
if(contents_it!=result.not_found()) |
|
|
|
|
content=contents_it->second.get_value<std::string>(""); |
|
|
|
|
} |
|
|
|
|
if(!content.empty()) { |
|
|
|
|
dispatcher.post([this, offset, content=std::move(content)] { |
|
|
|
|
if(offset>=get_buffer()->get_char_count()) |
|
|
|
|
return; |
|
|
|
|
type_tooltips.clear(); |
|
|
|
|
auto create_tooltip_buffer=[this, offset, value=std::move(value)]() { |
|
|
|
|
auto create_tooltip_buffer=[this, offset, content=std::move(content)]() { |
|
|
|
|
auto tooltip_buffer=Gtk::TextBuffer::create(get_buffer()->get_tag_table()); |
|
|
|
|
tooltip_buffer->insert_with_tag(tooltip_buffer->get_insert()->get_iter(), "Type: "+value, "def:note"); |
|
|
|
|
tooltip_buffer->insert_with_tag(tooltip_buffer->get_insert()->get_iter(), content, "def:note"); |
|
|
|
|
|
|
|
|
|
#ifdef JUCI_ENABLE_DEBUG |
|
|
|
|
if(language_id=="rust" && capabilities.definition) { |
|
|
|
|
@ -888,7 +896,6 @@ void Source::LanguageProtocolView::show_type_tooltips(const Gdk::Rectangle &rect
|
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -1072,10 +1079,16 @@ void Source::LanguageProtocolView::setup_autocomplete() {
|
|
|
|
|
for(auto it=begin;it!=end;++it) { |
|
|
|
|
auto label=it->second.get<std::string>("label", ""); |
|
|
|
|
auto detail=it->second.get<std::string>("detail", ""); |
|
|
|
|
auto documentation=it->second.get<std::string>("documentation", ""); |
|
|
|
|
auto insert=it->second.get<std::string>("insertText", label); |
|
|
|
|
if(!label.empty()) { |
|
|
|
|
autocomplete.rows.emplace_back(std::move(label)); |
|
|
|
|
autocomplete_comment.emplace_back(std::move(detail)); |
|
|
|
|
if(!documentation.empty()) { |
|
|
|
|
if(!autocomplete_comment.back().empty()) |
|
|
|
|
autocomplete_comment.back()+="\n\n"; |
|
|
|
|
autocomplete_comment.back()+=documentation; |
|
|
|
|
} |
|
|
|
|
autocomplete_insert.emplace_back(std::move(insert)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|