Rename hierarchies to $ccls/{call,inheritance,member}

bool flat = false; -> bool hierarchy = false; (set it to true to enable hierarchical view)

Delete $ccls/callers (which is what $ccls/call does now)
This commit is contained in:
Fangrui Song 2018-09-13 00:18:37 -07:00
parent 71f2aee644
commit 62d0c49b0a
8 changed files with 125 additions and 196 deletions

View File

@ -209,11 +209,10 @@ target_sources(ccls PRIVATE
)
target_sources(ccls PRIVATE
src/messages/ccls_callHierarchy.cc
src/messages/ccls_callers.cc
src/messages/ccls_call.cc
src/messages/ccls_fileInfo.cc
src/messages/ccls_inheritanceHierarchy.cc
src/messages/ccls_memberHierarchy.cc
src/messages/ccls_inheritance.cc
src/messages/ccls_member.cc
src/messages/ccls_navigate.cc
src/messages/ccls_reload.cc
src/messages/ccls_vars.cc

27
src/hierarchy.hh Normal file
View File

@ -0,0 +1,27 @@
// Copyright 2017-2018 ccls Authors
// SPDX-License-Identifier: Apache-2.0
#pragma once
#include "lsp.h"
#include <algorithm>
#include <queue>
template <typename Node>
void FlattenHierarchy(const Node &root, Out_LocationList &out) {
std::queue<const Node *> q;
for (auto &entry : root.children)
q.push(&entry);
while (q.size()) {
auto *entry = q.front();
q.pop();
if (entry->location.uri.raw_uri.size())
out.result.push_back({entry->location});
for (auto &entry1 : entry->children)
q.push(&entry1);
}
std::sort(out.result.begin(), out.result.end());
out.result.erase(std::unique(out.result.begin(), out.result.end()),
out.result.end());
}

View File

@ -1,6 +1,7 @@
// Copyright 2017-2018 ccls Authors
// SPDX-License-Identifier: Apache-2.0
#include "hierarchy.hh"
#include "message_handler.h"
#include "pipeline.hh"
#include "query_utils.h"
@ -10,7 +11,7 @@ using namespace ccls;
namespace {
MethodType kMethodType = "$ccls/callHierarchy";
MethodType kMethodType = "$ccls/call";
enum class CallType : uint8_t {
Direct = 0,
@ -24,7 +25,7 @@ bool operator&(CallType lhs, CallType rhs) {
return uint8_t(lhs) & uint8_t(rhs);
}
struct In_CclsCallHierarchy : public RequestInMessage {
struct In_CclsCall : public RequestInMessage {
MethodType GetMethodType() const override { return kMethodType; }
struct Params {
@ -44,15 +45,16 @@ struct In_CclsCallHierarchy : public RequestInMessage {
CallType callType = CallType::All;
bool qualified = true;
int levels = 1;
bool hierarchy = false;
};
Params params;
};
MAKE_REFLECT_STRUCT(In_CclsCallHierarchy::Params, textDocument, position, id,
callee, callType, qualified, levels);
MAKE_REFLECT_STRUCT(In_CclsCallHierarchy, id, params);
REGISTER_IN_MESSAGE(In_CclsCallHierarchy);
MAKE_REFLECT_STRUCT(In_CclsCall::Params, textDocument, position, id,
callee, callType, qualified, levels, hierarchy);
MAKE_REFLECT_STRUCT(In_CclsCall, id, params);
REGISTER_IN_MESSAGE(In_CclsCall);
struct Out_CclsCallHierarchy : public lsOutMessage<Out_CclsCallHierarchy> {
struct Out_CclsCall : public lsOutMessage<Out_CclsCall> {
struct Entry {
Usr usr;
std::string id;
@ -67,12 +69,12 @@ struct Out_CclsCallHierarchy : public lsOutMessage<Out_CclsCallHierarchy> {
lsRequestId id;
std::optional<Entry> result;
};
MAKE_REFLECT_STRUCT(Out_CclsCallHierarchy::Entry, id, name, location, callType,
MAKE_REFLECT_STRUCT(Out_CclsCall::Entry, id, name, location, callType,
numChildren, children);
MAKE_REFLECT_STRUCT_MANDATORY_OPTIONAL(Out_CclsCallHierarchy, jsonrpc, id,
MAKE_REFLECT_STRUCT_MANDATORY_OPTIONAL(Out_CclsCall, jsonrpc, id,
result);
bool Expand(MessageHandler *m, Out_CclsCallHierarchy::Entry *entry, bool callee,
bool Expand(MessageHandler *m, Out_CclsCall::Entry *entry, bool callee,
CallType call_type, bool qualified, int levels) {
const QueryFunc &func = m->db->Func(entry->usr);
const QueryFunc::Def *def = func.AnyDef();
@ -82,7 +84,7 @@ bool Expand(MessageHandler *m, Out_CclsCallHierarchy::Entry *entry, bool callee,
auto handle = [&](Use use, CallType call_type1) {
entry->numChildren++;
if (levels > 0) {
Out_CclsCallHierarchy::Entry entry1;
Out_CclsCall::Entry entry1;
entry1.id = std::to_string(use.usr);
entry1.usr = use.usr;
if (auto loc = GetLsLocation(m->db, m->working_files, use))
@ -148,17 +150,17 @@ bool Expand(MessageHandler *m, Out_CclsCallHierarchy::Entry *entry, bool callee,
return true;
}
struct Handler_CclsCallHierarchy : BaseMessageHandler<In_CclsCallHierarchy> {
struct Handler_CclsCall : BaseMessageHandler<In_CclsCall> {
MethodType GetMethodType() const override { return kMethodType; }
std::optional<Out_CclsCallHierarchy::Entry>
std::optional<Out_CclsCall::Entry>
BuildInitial(Usr root_usr, bool callee, CallType call_type, bool qualified,
int levels) {
const auto *def = db->Func(root_usr).AnyDef();
if (!def)
return {};
Out_CclsCallHierarchy::Entry entry;
Out_CclsCall::Entry entry;
entry.id = std::to_string(root_usr);
entry.usr = root_usr;
entry.callType = CallType::Direct;
@ -171,9 +173,9 @@ struct Handler_CclsCallHierarchy : BaseMessageHandler<In_CclsCallHierarchy> {
return entry;
}
void Run(In_CclsCallHierarchy *request) override {
void Run(In_CclsCall *request) override {
auto &params = request->params;
Out_CclsCallHierarchy out;
Out_CclsCall out;
out.id = request->id;
if (params.id.size()) {
@ -182,7 +184,7 @@ struct Handler_CclsCallHierarchy : BaseMessageHandler<In_CclsCallHierarchy> {
} catch (...) {
return;
}
Out_CclsCallHierarchy::Entry entry;
Out_CclsCall::Entry entry;
entry.id = std::to_string(params.usr);
entry.usr = params.usr;
entry.callType = CallType::Direct;
@ -207,9 +209,17 @@ struct Handler_CclsCallHierarchy : BaseMessageHandler<In_CclsCallHierarchy> {
}
}
pipeline::WriteStdout(kMethodType, out);
if (params.hierarchy) {
pipeline::WriteStdout(kMethodType, out);
return;
}
Out_LocationList out1;
out1.id = request->id;
if (out.result)
FlattenHierarchy<Out_CclsCall::Entry>(*out.result, out1);
pipeline::WriteStdout(kMethodType, out1);
}
};
REGISTER_MESSAGE_HANDLER(Handler_CclsCallHierarchy);
REGISTER_MESSAGE_HANDLER(Handler_CclsCall);
} // namespace

View File

@ -1,50 +0,0 @@
// Copyright 2017-2018 ccls Authors
// SPDX-License-Identifier: Apache-2.0
#include "message_handler.h"
#include "pipeline.hh"
#include "query_utils.h"
using namespace ccls;
namespace {
MethodType kMethodType = "$ccls/callers";
struct In_CclsCallers : public RequestInMessage {
MethodType GetMethodType() const override { return kMethodType; }
lsTextDocumentPositionParams params;
};
MAKE_REFLECT_STRUCT(In_CclsCallers, id, params);
REGISTER_IN_MESSAGE(In_CclsCallers);
struct Handler_CclsCallers : BaseMessageHandler<In_CclsCallers> {
MethodType GetMethodType() const override { return kMethodType; }
void Run(In_CclsCallers *request) override {
QueryFile *file;
if (!FindFileOrFail(db, project, request->id,
request->params.textDocument.uri.GetPath(), &file)) {
return;
}
WorkingFile *working_file =
working_files->GetFileByFilename(file->def->path);
Out_LocationList out;
out.id = request->id;
for (SymbolRef sym :
FindSymbolsAtLocation(working_file, file, request->params.position)) {
if (sym.kind == SymbolKind::Func) {
QueryFunc &func = db->GetFunc(sym);
std::vector<Use> uses = func.uses;
for (Use func_ref : GetUsesForAllBases(db, func))
uses.push_back(func_ref);
for (Use func_ref : GetUsesForAllDerived(db, func))
uses.push_back(func_ref);
out.result = GetLsLocationExs(db, working_files, uses);
break;
}
}
pipeline::WriteStdout(kMethodType, out);
}
};
REGISTER_MESSAGE_HANDLER(Handler_CclsCallers);
} // namespace

View File

@ -1,18 +1,18 @@
// Copyright 2017-2018 ccls Authors
// SPDX-License-Identifier: Apache-2.0
#include "hierarchy.hh"
#include "message_handler.h"
#include "pipeline.hh"
#include "query_utils.h"
using namespace ccls;
#include <queue>
#include <unordered_set>
namespace {
MethodType kMethodType = "$ccls/inheritanceHierarchy";
MethodType kMethodType = "$ccls/inheritance";
struct In_CclsInheritanceHierarchy : public RequestInMessage {
struct In_CclsInheritance : public RequestInMessage {
MethodType GetMethodType() const override { return kMethodType; }
struct Params {
// If id+kind are specified, expand a node; otherwise textDocument+position
@ -28,17 +28,17 @@ struct In_CclsInheritanceHierarchy : public RequestInMessage {
bool derived = false;
bool qualified = true;
int levels = 1;
bool flat = false;
bool hierarchy = false;
} params;
};
MAKE_REFLECT_STRUCT(In_CclsInheritanceHierarchy::Params, textDocument, position,
id, kind, derived, qualified, levels, flat);
MAKE_REFLECT_STRUCT(In_CclsInheritanceHierarchy, id, params);
REGISTER_IN_MESSAGE(In_CclsInheritanceHierarchy);
MAKE_REFLECT_STRUCT(In_CclsInheritance::Params, textDocument, position,
id, kind, derived, qualified, levels, hierarchy);
MAKE_REFLECT_STRUCT(In_CclsInheritance, id, params);
REGISTER_IN_MESSAGE(In_CclsInheritance);
struct Out_CclsInheritanceHierarchy
: public lsOutMessage<Out_CclsInheritanceHierarchy> {
struct Out_CclsInheritance
: public lsOutMessage<Out_CclsInheritance> {
struct Entry {
Usr usr;
std::string id;
@ -54,16 +54,16 @@ struct Out_CclsInheritanceHierarchy
lsRequestId id;
std::optional<Entry> result;
};
MAKE_REFLECT_STRUCT(Out_CclsInheritanceHierarchy::Entry, id, kind, name,
MAKE_REFLECT_STRUCT(Out_CclsInheritance::Entry, id, kind, name,
location, numChildren, children);
MAKE_REFLECT_STRUCT_MANDATORY_OPTIONAL(Out_CclsInheritanceHierarchy, jsonrpc,
MAKE_REFLECT_STRUCT_MANDATORY_OPTIONAL(Out_CclsInheritance, jsonrpc,
id, result);
bool Expand(MessageHandler *m, Out_CclsInheritanceHierarchy::Entry *entry,
bool Expand(MessageHandler *m, Out_CclsInheritance::Entry *entry,
bool derived, bool qualified, int levels);
template <typename Q>
bool ExpandHelper(MessageHandler *m, Out_CclsInheritanceHierarchy::Entry *entry,
bool ExpandHelper(MessageHandler *m, Out_CclsInheritance::Entry *entry,
bool derived, bool qualified, int levels, Q &entity) {
const auto *def = entity.AnyDef();
if (def) {
@ -85,7 +85,7 @@ bool ExpandHelper(MessageHandler *m, Out_CclsInheritanceHierarchy::Entry *entry,
for (auto usr : entity.derived) {
if (!seen.insert(usr).second)
continue;
Out_CclsInheritanceHierarchy::Entry entry1;
Out_CclsInheritance::Entry entry1;
entry1.id = std::to_string(usr);
entry1.usr = usr;
entry1.kind = entry->kind;
@ -100,7 +100,7 @@ bool ExpandHelper(MessageHandler *m, Out_CclsInheritanceHierarchy::Entry *entry,
for (auto usr : def->bases) {
if (!seen.insert(usr).second)
continue;
Out_CclsInheritanceHierarchy::Entry entry1;
Out_CclsInheritance::Entry entry1;
entry1.id = std::to_string(usr);
entry1.usr = usr;
entry1.kind = entry->kind;
@ -114,7 +114,7 @@ bool ExpandHelper(MessageHandler *m, Out_CclsInheritanceHierarchy::Entry *entry,
return true;
}
bool Expand(MessageHandler *m, Out_CclsInheritanceHierarchy::Entry *entry,
bool Expand(MessageHandler *m, Out_CclsInheritance::Entry *entry,
bool derived, bool qualified, int levels) {
if (entry->kind == SymbolKind::Func)
return ExpandHelper(m, entry, derived, qualified, levels,
@ -124,13 +124,13 @@ bool Expand(MessageHandler *m, Out_CclsInheritanceHierarchy::Entry *entry,
m->db->Type(entry->usr));
}
struct Handler_CclsInheritanceHierarchy
: BaseMessageHandler<In_CclsInheritanceHierarchy> {
struct Handler_CclsInheritance
: BaseMessageHandler<In_CclsInheritance> {
MethodType GetMethodType() const override { return kMethodType; }
std::optional<Out_CclsInheritanceHierarchy::Entry>
std::optional<Out_CclsInheritance::Entry>
BuildInitial(SymbolRef sym, bool derived, bool qualified, int levels) {
Out_CclsInheritanceHierarchy::Entry entry;
Out_CclsInheritance::Entry entry;
entry.id = std::to_string(sym.usr);
entry.usr = sym.usr;
entry.kind = sym.kind;
@ -138,18 +138,18 @@ struct Handler_CclsInheritanceHierarchy
return entry;
}
void Run(In_CclsInheritanceHierarchy *request) override {
void Run(In_CclsInheritance *request) override {
auto &params = request->params;
Out_CclsInheritanceHierarchy out;
Out_CclsInheritance out;
out.id = request->id;
if (!params.flat && params.id.size()) {
if (params.id.size()) {
try {
params.usr = std::stoull(params.id);
} catch (...) {
return;
}
Out_CclsInheritanceHierarchy::Entry entry;
Out_CclsInheritance::Entry entry;
entry.id = std::to_string(params.usr);
entry.usr = params.usr;
entry.kind = params.kind;
@ -172,31 +172,17 @@ struct Handler_CclsInheritanceHierarchy
}
}
if (!params.flat) {
if (params.hierarchy) {
pipeline::WriteStdout(kMethodType, out);
return;
}
Out_LocationList out1;
out1.id = request->id;
if (out.result) {
std::queue<Out_CclsInheritanceHierarchy::Entry *> q;
for (auto &entry1 : out.result->children)
q.push(&entry1);
while (q.size()) {
auto *entry = q.front();
q.pop();
if (entry->location.uri.raw_uri.size())
out1.result.push_back({entry->location});
for (auto &entry1 : entry->children)
q.push(&entry1);
}
std::sort(out1.result.begin(), out1.result.end());
out1.result.erase(std::unique(out1.result.begin(), out1.result.end()),
out1.result.end());
}
if (out.result)
FlattenHierarchy<Out_CclsInheritance::Entry>(*out.result, out1);
pipeline::WriteStdout(kMethodType, out1);
}
};
REGISTER_MESSAGE_HANDLER(Handler_CclsInheritanceHierarchy);
REGISTER_MESSAGE_HANDLER(Handler_CclsInheritance);
} // namespace

View File

@ -1,6 +1,7 @@
// Copyright 2017-2018 ccls Authors
// SPDX-License-Identifier: Apache-2.0
#include "hierarchy.hh"
#include "message_handler.h"
#include "pipeline.hh"
#include "query_utils.h"
@ -9,13 +10,12 @@ using namespace ccls;
#include <clang/AST/Type.h>
using namespace clang;
#include <queue>
#include <unordered_set>
namespace {
MethodType kMethodType = "$ccls/memberHierarchy";
MethodType kMethodType = "$ccls/member";
struct In_CclsMemberHierarchy : public RequestInMessage {
struct In_CclsMember : public RequestInMessage {
MethodType GetMethodType() const override { return kMethodType; }
struct Params {
@ -30,16 +30,16 @@ struct In_CclsMemberHierarchy : public RequestInMessage {
bool qualified = false;
int levels = 1;
bool flat = false;
bool hierarchy = false;
} params;
};
MAKE_REFLECT_STRUCT(In_CclsMemberHierarchy::Params, textDocument, position, id,
qualified, levels, flat);
MAKE_REFLECT_STRUCT(In_CclsMemberHierarchy, id, params);
REGISTER_IN_MESSAGE(In_CclsMemberHierarchy);
MAKE_REFLECT_STRUCT(In_CclsMember::Params, textDocument, position, id,
qualified, levels, hierarchy);
MAKE_REFLECT_STRUCT(In_CclsMember, id, params);
REGISTER_IN_MESSAGE(In_CclsMember);
struct Out_CclsMemberHierarchy : public lsOutMessage<Out_CclsMemberHierarchy> {
struct Out_CclsMember : public lsOutMessage<Out_CclsMember> {
struct Entry {
Usr usr;
std::string id;
@ -55,21 +55,21 @@ struct Out_CclsMemberHierarchy : public lsOutMessage<Out_CclsMemberHierarchy> {
lsRequestId id;
std::optional<Entry> result;
};
MAKE_REFLECT_STRUCT(Out_CclsMemberHierarchy::Entry, id, name, fieldName,
MAKE_REFLECT_STRUCT(Out_CclsMember::Entry, id, name, fieldName,
location, numChildren, children);
MAKE_REFLECT_STRUCT_MANDATORY_OPTIONAL(Out_CclsMemberHierarchy, jsonrpc, id,
MAKE_REFLECT_STRUCT_MANDATORY_OPTIONAL(Out_CclsMember, jsonrpc, id,
result);
bool Expand(MessageHandler *m, Out_CclsMemberHierarchy::Entry *entry,
bool Expand(MessageHandler *m, Out_CclsMember::Entry *entry,
bool qualified, int levels);
// Add a field to |entry| which is a Func/Type.
void DoField(MessageHandler *m, Out_CclsMemberHierarchy::Entry *entry,
void DoField(MessageHandler *m, Out_CclsMember::Entry *entry,
const QueryVar &var, int64_t offset, bool qualified, int levels) {
const QueryVar::Def *def1 = var.AnyDef();
if (!def1)
return;
Out_CclsMemberHierarchy::Entry entry1;
Out_CclsMember::Entry entry1;
// With multiple inheritance, the offset is incorrect.
if (offset >= 0) {
if (offset / 8 < 10)
@ -106,7 +106,7 @@ void DoField(MessageHandler *m, Out_CclsMemberHierarchy::Entry *entry,
}
// Expand a type node by adding members recursively to it.
bool Expand(MessageHandler *m, Out_CclsMemberHierarchy::Entry *entry,
bool Expand(MessageHandler *m, Out_CclsMember::Entry *entry,
bool qualified, int levels) {
if (0 < entry->usr && entry->usr <= BuiltinType::LastKind) {
entry->name = ClangBuiltinTypeName(int(entry->usr));
@ -127,15 +127,16 @@ bool Expand(MessageHandler *m, Out_CclsMemberHierarchy::Entry *entry,
const auto *def = stack.back()->AnyDef();
stack.pop_back();
if (def) {
EachDefinedType(m->db, def->bases, [&](QueryType &type1) {
if (!seen.count(type1.usr)) {
for (Usr usr : def->bases) {
auto &type1 = m->db->Type(usr);
if (type1.def.size()) {
seen.insert(type1.usr);
stack.push_back(&type1);
}
});
}
if (def->alias_of) {
const QueryType::Def *def1 = m->db->Type(def->alias_of).AnyDef();
Out_CclsMemberHierarchy::Entry entry1;
Out_CclsMember::Entry entry1;
entry1.id = std::to_string(def->alias_of);
entry1.usr = def->alias_of;
if (def1 && def1->spell) {
@ -173,11 +174,11 @@ bool Expand(MessageHandler *m, Out_CclsMemberHierarchy::Entry *entry,
return true;
}
struct Handler_CclsMemberHierarchy
: BaseMessageHandler<In_CclsMemberHierarchy> {
struct Handler_CclsMember
: BaseMessageHandler<In_CclsMember> {
MethodType GetMethodType() const override { return kMethodType; }
std::optional<Out_CclsMemberHierarchy::Entry>
std::optional<Out_CclsMember::Entry>
BuildInitial(SymbolKind kind, Usr root_usr, bool qualified, int levels) {
switch (kind) {
default:
@ -187,7 +188,7 @@ struct Handler_CclsMemberHierarchy
if (!def)
return {};
Out_CclsMemberHierarchy::Entry entry;
Out_CclsMember::Entry entry;
// Not type, |id| is invalid.
entry.name = def->Name(qualified);
if (def->spell) {
@ -195,9 +196,11 @@ struct Handler_CclsMemberHierarchy
GetLsLocation(db, working_files, *def->spell))
entry.location = *loc;
}
EachDefinedVar(db, def->vars, [&](QueryVar &var) {
DoField(this, &entry, var, -1, qualified, levels - 1);
});
for (Usr usr : def->vars) {
auto &var = db->Var(usr);
if (var.def.size())
DoField(this, &entry, var, -1, qualified, levels - 1);
}
return entry;
}
case SymbolKind::Type: {
@ -205,7 +208,7 @@ struct Handler_CclsMemberHierarchy
if (!def)
return {};
Out_CclsMemberHierarchy::Entry entry;
Out_CclsMember::Entry entry;
entry.id = std::to_string(root_usr);
entry.usr = root_usr;
if (def->spell) {
@ -219,9 +222,9 @@ struct Handler_CclsMemberHierarchy
}
}
void Run(In_CclsMemberHierarchy *request) override {
void Run(In_CclsMember *request) override {
auto &params = request->params;
Out_CclsMemberHierarchy out;
Out_CclsMember out;
out.id = request->id;
if (params.id.size()) {
@ -230,7 +233,7 @@ struct Handler_CclsMemberHierarchy
} catch (...) {
return;
}
Out_CclsMemberHierarchy::Entry entry;
Out_CclsMember::Entry entry;
entry.id = std::to_string(params.usr);
entry.usr = params.usr;
// entry.name is empty as it is known by the client.
@ -265,31 +268,17 @@ struct Handler_CclsMemberHierarchy
}
}
if (!params.flat) {
if (params.hierarchy) {
pipeline::WriteStdout(kMethodType, out);
return;
}
Out_LocationList out1;
out1.id = request->id;
if (out.result) {
std::queue<Out_CclsMemberHierarchy::Entry *> q;
for (auto &entry1 : out.result->children)
q.push(&entry1);
while (q.size()) {
auto *entry = q.front();
q.pop();
if (entry->location.uri.raw_uri.size())
out1.result.push_back({entry->location});
for (auto &entry1 : entry->children)
q.push(&entry1);
}
std::sort(out1.result.begin(), out1.result.end());
out1.result.erase(std::unique(out1.result.begin(), out1.result.end()),
out1.result.end());
}
if (out.result)
FlattenHierarchy<Out_CclsMember::Entry>(*out.result, out1);
pipeline::WriteStdout(kMethodType, out1);
}
};
REGISTER_MESSAGE_HANDLER(Handler_CclsMemberHierarchy);
REGISTER_MESSAGE_HANDLER(Handler_CclsMember);
} // namespace

View File

@ -155,18 +155,6 @@ std::vector<Use> GetUsesForAllDerived(DB *db, QueryFunc &root) {
return ret;
}
std::optional<lsPosition> GetLsPosition(WorkingFile *wfile,
const Position &position) {
if (!wfile || wfile->index_lines.empty())
return lsPosition{position.line, position.column};
int column = position.column;
if (std::optional<int> start =
wfile->GetBufferPosFromIndexPos(position.line, &column, false))
return lsPosition{*start, column};
return std::nullopt;
}
std::optional<lsRange> GetLsRange(WorkingFile *wfile,
const Range &location) {
if (!wfile || wfile->index_lines.empty())

View File

@ -22,8 +22,6 @@ std::vector<Use> GetNonDefDeclarations(DB *db, SymbolIdx sym);
std::vector<Use> GetUsesForAllBases(DB *db, QueryFunc &root);
std::vector<Use> GetUsesForAllDerived(DB *db, QueryFunc &root);
std::optional<lsPosition> GetLsPosition(WorkingFile *working_file,
const Position &position);
std::optional<lsRange> GetLsRange(WorkingFile *working_file,
const Range &location);
lsDocumentUri GetLsDocumentUri(DB *db, int file_id, std::string *path);
@ -93,21 +91,3 @@ void EachDefinedFunc(DB *db, const std::vector<Usr> &usrs, Fn &&fn) {
fn(obj);
}
}
template <typename Fn>
void EachDefinedType(DB *db, const std::vector<Usr> &usrs, Fn &&fn) {
for (Usr usr : usrs) {
auto &obj = db->Type(usr);
if (!obj.def.empty())
fn(obj);
}
}
template <typename Fn>
void EachDefinedVar(DB *db, const std::vector<Usr> &usrs, Fn &&fn) {
for (Usr usr : usrs) {
auto &obj = db->Var(usr);
if (!obj.def.empty())
fn(obj);
}
}