From a24fe5a3863abd1a0583b89634f82d5e13e81b44 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Sat, 10 Nov 2018 19:50:35 -0800 Subject: [PATCH] hierarchicalDocumentSymbol: display member function declarations --- src/messages/textDocument_document.cc | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/messages/textDocument_document.cc b/src/messages/textDocument_document.cc index 8b8599d9..9135ce76 100644 --- a/src/messages/textDocument_document.cc +++ b/src/messages/textDocument_document.cc @@ -174,21 +174,20 @@ void MessageHandler::textDocument_documentSymbol(Reader &reader, continue; auto &ds = r.first->second; ds = std::make_unique(); + 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 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; @@ -196,11 +195,14 @@ void MessageHandler::textDocument_documentSymbol(Reader &reader, def_ptrs.push_back(&def); } }); - if (def_ptrs.empty() || !(param.all || sym.role & Role::Definition || - ds->kind == SymbolKind::Namespace)) { + 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)