mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-25 09:05:10 +00:00
textDocument/documentSymbol
This commit is contained in:
parent
d758b78635
commit
db50943cd7
@ -72,7 +72,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();
|
||||
|
@ -19,8 +19,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;
|
||||
|
||||
|
@ -274,11 +274,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;
|
||||
@ -295,12 +292,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;
|
||||
|
@ -35,11 +35,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,
|
||||
|
@ -64,6 +64,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