Hide all function declarations in documentSymbol.

This commit is contained in:
forest93 2019-03-07 22:26:25 +08:00
parent 5e15f51681
commit 317a9b793e
3 changed files with 6 additions and 3 deletions

View File

@ -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 {

View File

@ -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;

View File

@ -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);