mirror of
https://github.com/MaskRay/ccls.git
synced 2024-12-01 11:57:09 +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) {
|
for (auto [sym, refcnt] : symbol2refcnt) {
|
||||||
if (refcnt <= 0) continue;
|
if (refcnt <= 0) continue;
|
||||||
if (std::optional<lsSymbolInformation> info =
|
if (std::optional<lsSymbolInformation> info =
|
||||||
GetSymbolInfo(db, working_files, sym, false)) {
|
GetSymbolInfo(db, sym, false)) {
|
||||||
if (sym.kind == SymbolKind::Var) {
|
if (sym.kind == SymbolKind::Var) {
|
||||||
QueryVar &var = db->GetVar(sym);
|
QueryVar &var = db->GetVar(sym);
|
||||||
auto *def = var.AnyDef();
|
auto *def = var.AnyDef();
|
||||||
|
@ -19,8 +19,7 @@ MethodType kMethodType = "workspace/symbol";
|
|||||||
bool AddSymbol(
|
bool AddSymbol(
|
||||||
DB *db, WorkingFiles *working_files, SymbolIdx sym, bool use_detailed,
|
DB *db, WorkingFiles *working_files, SymbolIdx sym, bool use_detailed,
|
||||||
std::vector<std::tuple<lsSymbolInformation, int, SymbolIdx>> *result) {
|
std::vector<std::tuple<lsSymbolInformation, int, SymbolIdx>> *result) {
|
||||||
std::optional<lsSymbolInformation> info =
|
std::optional<lsSymbolInformation> info = GetSymbolInfo(db, sym, true);
|
||||||
GetSymbolInfo(db, working_files, sym, true);
|
|
||||||
if (!info)
|
if (!info)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -274,11 +274,8 @@ lsSymbolKind GetSymbolKind(DB *db, SymbolIdx sym) {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns a symbol. The symbol will have *NOT* have a location assigned.
|
std::optional<lsSymbolInformation> GetSymbolInfo(DB *db, SymbolIdx sym,
|
||||||
std::optional<lsSymbolInformation> GetSymbolInfo(DB *db,
|
bool detailed) {
|
||||||
WorkingFiles *working_files,
|
|
||||||
SymbolIdx sym,
|
|
||||||
bool detailed_name) {
|
|
||||||
switch (sym.kind) {
|
switch (sym.kind) {
|
||||||
case SymbolKind::Invalid:
|
case SymbolKind::Invalid:
|
||||||
break;
|
break;
|
||||||
@ -295,12 +292,11 @@ std::optional<lsSymbolInformation> GetSymbolInfo(DB *db,
|
|||||||
default: {
|
default: {
|
||||||
lsSymbolInformation info;
|
lsSymbolInformation info;
|
||||||
EachEntityDef(db, sym, [&](const auto &def) {
|
EachEntityDef(db, sym, [&](const auto &def) {
|
||||||
if (detailed_name)
|
if (detailed)
|
||||||
info.name = def.detailed_name;
|
info.name = def.detailed_name;
|
||||||
else
|
else
|
||||||
info.name = def.Name(true);
|
info.name = def.Name(true);
|
||||||
info.kind = def.kind;
|
info.kind = def.kind;
|
||||||
info.containerName = def.detailed_name;
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
return info;
|
return info;
|
||||||
|
@ -35,11 +35,9 @@ std::optional<lsLocationEx> GetLsLocationEx(DB *db, WorkingFiles *working_files,
|
|||||||
Use use, bool container);
|
Use use, bool container);
|
||||||
std::vector<lsLocationEx> GetLsLocationExs(DB *db, WorkingFiles *working_files,
|
std::vector<lsLocationEx> GetLsLocationExs(DB *db, WorkingFiles *working_files,
|
||||||
const std::vector<Use> &refs);
|
const std::vector<Use> &refs);
|
||||||
// Returns a symbol. The symbol will have *NOT* have a location assigned.
|
// Returns a symbol. The symbol will *NOT* have a location assigned.
|
||||||
std::optional<lsSymbolInformation> GetSymbolInfo(DB *db,
|
std::optional<lsSymbolInformation> GetSymbolInfo(DB *db, SymbolIdx sym,
|
||||||
WorkingFiles *working_files,
|
bool detailed);
|
||||||
SymbolIdx sym,
|
|
||||||
bool detailed_name);
|
|
||||||
|
|
||||||
std::vector<SymbolRef> FindSymbolsAtLocation(WorkingFile *working_file,
|
std::vector<SymbolRef> FindSymbolsAtLocation(WorkingFile *working_file,
|
||||||
QueryFile *file,
|
QueryFile *file,
|
||||||
|
@ -64,6 +64,6 @@ struct lsSymbolInformation {
|
|||||||
std::string_view name;
|
std::string_view name;
|
||||||
lsSymbolKind kind;
|
lsSymbolKind kind;
|
||||||
lsLocation location;
|
lsLocation location;
|
||||||
std::string_view containerName;
|
std::optional<std::string_view> containerName;
|
||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(lsSymbolInformation, name, kind, location, containerName);
|
MAKE_REFLECT_STRUCT(lsSymbolInformation, name, kind, location, containerName);
|
||||||
|
Loading…
Reference in New Issue
Block a user