mirror of
https://github.com/MaskRay/ccls.git
synced 2024-12-03 13:07:10 +00:00
textDocument/documentSymbol
This commit is contained in:
parent
6bca153ee3
commit
1969731781
@ -84,7 +84,7 @@ struct Handler_TextDocumentDocumentSymbol
|
||||
for (auto [sym, refcnt] : symbol2refcnt) {
|
||||
if (refcnt <= 0) continue;
|
||||
if (std::optional<lsSymbolInformation> info =
|
||||
GetSymbolInfo(db, working_files, sym, false)) {
|
||||
GetSymbolInfo(db, sym, false)) {
|
||||
if (sym.kind == SymbolKind::Var) {
|
||||
QueryVar &var = db->GetVar(sym);
|
||||
auto *def = var.AnyDef();
|
||||
|
@ -31,8 +31,7 @@ MethodType kMethodType = "workspace/symbol";
|
||||
bool AddSymbol(
|
||||
DB *db, WorkingFiles *working_files, SymbolIdx sym, bool use_detailed,
|
||||
std::vector<std::tuple<lsSymbolInformation, int, SymbolIdx>> *result) {
|
||||
std::optional<lsSymbolInformation> info =
|
||||
GetSymbolInfo(db, working_files, sym, true);
|
||||
std::optional<lsSymbolInformation> info = GetSymbolInfo(db, sym, true);
|
||||
if (!info)
|
||||
return false;
|
||||
|
||||
|
@ -286,11 +286,8 @@ lsSymbolKind GetSymbolKind(DB *db, SymbolIdx sym) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Returns a symbol. The symbol will have *NOT* have a location assigned.
|
||||
std::optional<lsSymbolInformation> GetSymbolInfo(DB *db,
|
||||
WorkingFiles *working_files,
|
||||
SymbolIdx sym,
|
||||
bool detailed_name) {
|
||||
std::optional<lsSymbolInformation> GetSymbolInfo(DB *db, SymbolIdx sym,
|
||||
bool detailed) {
|
||||
switch (sym.kind) {
|
||||
case SymbolKind::Invalid:
|
||||
break;
|
||||
@ -307,12 +304,11 @@ std::optional<lsSymbolInformation> GetSymbolInfo(DB *db,
|
||||
default: {
|
||||
lsSymbolInformation info;
|
||||
EachEntityDef(db, sym, [&](const auto &def) {
|
||||
if (detailed_name)
|
||||
if (detailed)
|
||||
info.name = def.detailed_name;
|
||||
else
|
||||
info.name = def.Name(true);
|
||||
info.kind = def.kind;
|
||||
info.containerName = def.detailed_name;
|
||||
return false;
|
||||
});
|
||||
return info;
|
||||
|
@ -47,11 +47,9 @@ std::optional<lsLocationEx> GetLsLocationEx(DB *db, WorkingFiles *working_files,
|
||||
Use use, bool container);
|
||||
std::vector<lsLocationEx> GetLsLocationExs(DB *db, WorkingFiles *working_files,
|
||||
const std::vector<Use> &refs);
|
||||
// Returns a symbol. The symbol will have *NOT* have a location assigned.
|
||||
std::optional<lsSymbolInformation> GetSymbolInfo(DB *db,
|
||||
WorkingFiles *working_files,
|
||||
SymbolIdx sym,
|
||||
bool detailed_name);
|
||||
// Returns a symbol. The symbol will *NOT* have a location assigned.
|
||||
std::optional<lsSymbolInformation> GetSymbolInfo(DB *db, SymbolIdx sym,
|
||||
bool detailed);
|
||||
|
||||
std::vector<SymbolRef> FindSymbolsAtLocation(WorkingFile *working_file,
|
||||
QueryFile *file,
|
||||
|
@ -76,6 +76,6 @@ struct lsSymbolInformation {
|
||||
std::string_view name;
|
||||
lsSymbolKind kind;
|
||||
lsLocation location;
|
||||
std::string_view containerName;
|
||||
std::optional<std::string_view> containerName;
|
||||
};
|
||||
MAKE_REFLECT_STRUCT(lsSymbolInformation, name, kind, location, containerName);
|
||||
|
Loading…
Reference in New Issue
Block a user