hierarchicalDocumentSymbol: display member function declarations

This commit is contained in:
Fangrui Song 2018-11-10 19:50:35 -08:00
parent aaa5008ec6
commit d9a31a72bd

View File

@ -162,21 +162,20 @@ void MessageHandler::textDocument_documentSymbol(Reader &reader,
continue;
auto &ds = r.first->second;
ds = std::make_unique<DocumentSymbol>();
if (auto range = GetLsRange(wfile, sym.range)) {
ds->selectionRange = *range;
ds->range = ds->selectionRange;
if (sym.extent.Valid())
if (auto range1 = GetLsRange(wfile, sym.extent))
ds->range = *range1;
}
std::vector<const void *> def_ptrs;
WithEntity(db, sym, [&, sym = sym](const auto &entity) {
WithEntity(db, sym, [&](const auto &entity) {
auto *def = entity.AnyDef();
if (!def)
return;
ds->name = def->Name(false);
ds->detail = def->Name(true);
if (auto ls_range = GetLsRange(wfile, sym.range)) {
ds->selectionRange = *ls_range;
ds->range = ds->selectionRange;
if (sym.extent.Valid())
if (auto ls_range1 = GetLsRange(wfile, sym.extent))
ds->range = *ls_range1;
}
for (auto &def : entity.def)
if (def.file_id == file_id && !Ignore(&def)) {
ds->kind = def.kind;
@ -184,11 +183,14 @@ void MessageHandler::textDocument_documentSymbol(Reader &reader,
def_ptrs.push_back(&def);
}
});
if (def_ptrs.empty() || !(param.all || sym.role & Role::Definition ||
if (!(param.all || sym.role & Role::Definition ||
ds->kind == SymbolKind::Method ||
ds->kind == SymbolKind::Namespace)) {
ds.reset();
continue;
}
if (def_ptrs.empty())
continue;
if (sym.kind == Kind::Func)
funcs.emplace_back(std::move(def_ptrs), ds.get());
else if (sym.kind == Kind::Type)