Skip to content

Commit d9a31a7

Browse files
committed
hierarchicalDocumentSymbol: display member function declarations
1 parent aaa5008 commit d9a31a7

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

src/messages/textDocument_document.cc

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -162,33 +162,35 @@ void MessageHandler::textDocument_documentSymbol(Reader &reader,
162162
continue;
163163
auto &ds = r.first->second;
164164
ds = std::make_unique<DocumentSymbol>();
165+
if (auto range = GetLsRange(wfile, sym.range)) {
166+
ds->selectionRange = *range;
167+
ds->range = ds->selectionRange;
168+
if (sym.extent.Valid())
169+
if (auto range1 = GetLsRange(wfile, sym.extent))
170+
ds->range = *range1;
171+
}
165172
std::vector<const void *> def_ptrs;
166-
WithEntity(db, sym, [&, sym = sym](const auto &entity) {
173+
WithEntity(db, sym, [&](const auto &entity) {
167174
auto *def = entity.AnyDef();
168175
if (!def)
169176
return;
170177
ds->name = def->Name(false);
171178
ds->detail = def->Name(true);
172-
if (auto ls_range = GetLsRange(wfile, sym.range)) {
173-
ds->selectionRange = *ls_range;
174-
ds->range = ds->selectionRange;
175-
if (sym.extent.Valid())
176-
if (auto ls_range1 = GetLsRange(wfile, sym.extent))
177-
ds->range = *ls_range1;
178-
}
179-
180179
for (auto &def : entity.def)
181180
if (def.file_id == file_id && !Ignore(&def)) {
182181
ds->kind = def.kind;
183182
if (def.spell || def.kind == SymbolKind::Namespace)
184183
def_ptrs.push_back(&def);
185184
}
186185
});
187-
if (def_ptrs.empty() || !(param.all || sym.role & Role::Definition ||
188-
ds->kind == SymbolKind::Namespace)) {
186+
if (!(param.all || sym.role & Role::Definition ||
187+
ds->kind == SymbolKind::Method ||
188+
ds->kind == SymbolKind::Namespace)) {
189189
ds.reset();
190190
continue;
191191
}
192+
if (def_ptrs.empty())
193+
continue;
192194
if (sym.kind == Kind::Func)
193195
funcs.emplace_back(std::move(def_ptrs), ds.get());
194196
else if (sym.kind == Kind::Type)

0 commit comments

Comments
 (0)