Browse Source

Language server: made show methods and symbol rows similar to the ctag and libclang variants

pipelines/235045657
eidheim 6 years ago
parent
commit
b20237d5ba
  1. 19
      src/project.cc
  2. 14
      src/source_language_protocol.cc

19
src/project.cc

@ -731,13 +731,11 @@ void Project::LanguageProtocol::show_symbols() {
try { try {
::LanguageProtocol::Location location(it->second.get_child("location")); ::LanguageProtocol::Location location(it->second.get_child("location"));
if(filesystem::file_in_path(location.file, *project_path)) { if(filesystem::file_in_path(location.file, *project_path)) {
::LanguageProtocol::Location location(it->second.get_child("location")); auto container = it->second.get<std::string>("containerName", "");
if(container == "null")
container.clear();
std::string row = filesystem::get_relative_path(location.file, *project_path).string() + ':'; auto row = filesystem::get_relative_path(location.file, *project_path).string() + ':' + std::to_string(location.range.start.line + 1) + ": " + (!container.empty() ? container + "::" : "") + "<b>" + it->second.get<std::string>("name") + "</b>";
auto container_name = it->second.get<std::string>("containerName", "");
if(!container_name.empty() && container_name != "null")
row += container_name + ':';
row += std::to_string(location.range.start.line + 1) + ": <b>" + it->second.get<std::string>("name") + "</b>";
locations_rows.emplace(std::move(location), std::move(row)); locations_rows.emplace(std::move(location), std::move(row));
} }
@ -766,11 +764,10 @@ void Project::LanguageProtocol::show_symbols() {
try { try {
::LanguageProtocol::Location location(it->second.get_child("location")); ::LanguageProtocol::Location location(it->second.get_child("location"));
std::string row; auto container = it->second.get<std::string>("containerName", "");
auto container_name = it->second.get<std::string>("containerName", ""); if(container == "null")
if(!container_name.empty() && container_name != "null") container.clear();
row += container_name + ':'; auto row = std::to_string(location.range.start.line + 1) + ": " + (!container.empty() ? container + "::" : "") + "<b>" + it->second.get<std::string>("name") + "</b>";
row += std::to_string(location.range.start.line + 1) + ": <b>" + it->second.get<std::string>("name") + "</b>";
locations_rows.emplace(std::move(location), std::move(row)); locations_rows.emplace(std::move(location), std::move(row));
} }

14
src/source_language_protocol.cc

@ -150,6 +150,8 @@ LanguageProtocol::Capabilities LanguageProtocol::Client::initialize(Source::Lang
capabilities.document_formatting = capabilities_pt->second.get<bool>("documentFormattingProvider", false); capabilities.document_formatting = capabilities_pt->second.get<bool>("documentFormattingProvider", false);
capabilities.document_range_formatting = capabilities_pt->second.get<bool>("documentRangeFormattingProvider", false); capabilities.document_range_formatting = capabilities_pt->second.get<bool>("documentRangeFormattingProvider", false);
capabilities.rename = capabilities_pt->second.get<bool>("renameProvider", false); capabilities.rename = capabilities_pt->second.get<bool>("renameProvider", false);
if(!capabilities.rename)
capabilities.rename = capabilities_pt->second.get<bool>("renameProvider.prepareProvider", false);
capabilities.type_coverage = capabilities_pt->second.get<bool>("typeCoverageProvider", false); capabilities.type_coverage = capabilities_pt->second.get<bool>("typeCoverageProvider", false);
} }
@ -848,22 +850,20 @@ void Source::LanguageProtocolView::setup_navigation_and_refactoring() {
try { try {
auto kind = it->second.get<int>("kind"); auto kind = it->second.get<int>("kind");
if(kind == 6 || kind == 9 || kind == 12) { if(kind == 6 || kind == 9 || kind == 12) {
std::string row;
std::unique_ptr<LanguageProtocol::Range> range; std::unique_ptr<LanguageProtocol::Range> range;
std::string container;
auto location_pt = it->second.get_child_optional("location"); auto location_pt = it->second.get_child_optional("location");
if(location_pt) { if(location_pt) {
LanguageProtocol::Location location(*location_pt); LanguageProtocol::Location location(*location_pt);
auto container_name = it->second.get<std::string>("containerName", ""); container = it->second.get<std::string>("containerName", "");
if(!container_name.empty() && container_name != "null") if(container == "null")
row += container_name + ':'; container.clear();
range = std::make_unique<LanguageProtocol::Range>(location.range); range = std::make_unique<LanguageProtocol::Range>(location.range);
} }
else else
range = std::make_unique<LanguageProtocol::Range>(it->second.get_child("range")); range = std::make_unique<LanguageProtocol::Range>(it->second.get_child("range"));
row += std::to_string(range->start.line + 1) + ": <b>" + it->second.get<std::string>("name") + "</b>"; methods.emplace_back(Offset(range->start.line, range->start.character), std::to_string(range->start.line + 1) + ": " + (!container.empty() ? container + "::" : "") + "<b>" + it->second.get<std::string>("name") + "</b>");
methods.emplace_back(Offset(range->start.line, range->start.character), std::move(row));
} }
} }
catch(...) { catch(...) {

Loading…
Cancel
Save