From 317a9b793e0c941b4e1e665502ccd113b26f0128 Mon Sep 17 00:00:00 2001 From: forest93 Date: Thu, 7 Mar 2019 22:26:25 +0800 Subject: [PATCH] Hide all function declarations in documentSymbol. --- src/indexer.hh | 2 +- src/messages/textDocument_document.cc | 3 +++ src/query.cc | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/indexer.hh b/src/indexer.hh index fb762ac1..a3e51218 100644 --- a/src/indexer.hh +++ b/src/indexer.hh @@ -45,7 +45,7 @@ using Usr = uint64_t; // The order matters. In FindSymbolsAtLocation, we want Var/Func ordered in // front of others. -enum class Kind : uint8_t { Invalid, File, Type, Func, Var }; +enum class Kind : uint8_t { Invalid, File, Type, Func, FuncDecl, Var }; REFLECT_UNDERLYING_B(Kind); enum class Role : uint16_t { diff --git a/src/messages/textDocument_document.cc b/src/messages/textDocument_document.cc index e4e5d72c..d491380f 100644 --- a/src/messages/textDocument_document.cc +++ b/src/messages/textDocument_document.cc @@ -182,6 +182,9 @@ void MessageHandler::textDocument_documentSymbol(JsonReader &reader, for (auto [sym, refcnt] : file->symbol2refcnt) { if (refcnt <= 0 || !sym.extent.Valid()) continue; + // For now we do not show function decl because there can be multiple items. + if (sym.kind == Kind::FuncDecl) + continue; auto r = sym2ds.try_emplace(SymbolIdx{sym.usr, sym.kind}); if (!r.second) continue; diff --git a/src/query.cc b/src/query.cc index 6a2d1b5b..3f39f238 100644 --- a/src/query.cc +++ b/src/query.cc @@ -310,9 +310,9 @@ void DB::ApplyIndexUpdate(IndexUpdate *u) { Update(lid2file_id, u->file_id, std::move(u->funcs_def_update)); for (auto &[usr, del_add]: u->funcs_declarations) { for (DeclRef &dr : del_add.first) - RefDecl(prev_lid2file_id, usr, Kind::Func, dr, -1); + RefDecl(prev_lid2file_id, usr, Kind::FuncDecl, dr, -1); for (DeclRef &dr : del_add.second) - RefDecl(lid2file_id, usr, Kind::Func, dr, 1); + RefDecl(lid2file_id, usr, Kind::FuncDecl, dr, 1); } REMOVE_ADD(func, declarations); REMOVE_ADD(func, derived);