@@ -162,33 +162,35 @@ void MessageHandler::textDocument_documentSymbol(Reader &reader,
162
162
continue ;
163
163
auto &ds = r.first ->second ;
164
164
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
+ }
165
172
std::vector<const void *> def_ptrs;
166
- WithEntity (db, sym, [&, sym = sym ](const auto &entity) {
173
+ WithEntity (db, sym, [&](const auto &entity) {
167
174
auto *def = entity.AnyDef ();
168
175
if (!def)
169
176
return ;
170
177
ds->name = def->Name (false );
171
178
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
-
180
179
for (auto &def : entity.def )
181
180
if (def.file_id == file_id && !Ignore (&def)) {
182
181
ds->kind = def.kind ;
183
182
if (def.spell || def.kind == SymbolKind::Namespace)
184
183
def_ptrs.push_back (&def);
185
184
}
186
185
});
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)) {
189
189
ds.reset ();
190
190
continue ;
191
191
}
192
+ if (def_ptrs.empty ())
193
+ continue ;
192
194
if (sym.kind == Kind::Func)
193
195
funcs.emplace_back (std::move (def_ptrs), ds.get ());
194
196
else if (sym.kind == Kind::Type)
0 commit comments