mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-28 18:41:57 +00:00
fac5c56682
Remove on_id_map, IndexMergeIndexUpdates
51 lines
1.5 KiB
C++
51 lines
1.5 KiB
C++
#include "message_handler.h"
|
|
#include "query_utils.h"
|
|
#include "queue_manager.h"
|
|
|
|
namespace {
|
|
|
|
MethodType kMethodType = "$ccls/base";
|
|
|
|
struct In_CclsBase : public RequestInMessage {
|
|
MethodType GetMethodType() const override { return kMethodType; }
|
|
|
|
lsTextDocumentPositionParams params;
|
|
};
|
|
MAKE_REFLECT_STRUCT(In_CclsBase, id, params);
|
|
REGISTER_IN_MESSAGE(In_CclsBase);
|
|
|
|
struct Handler_CclsBase : BaseMessageHandler<In_CclsBase> {
|
|
MethodType GetMethodType() const override { return kMethodType; }
|
|
|
|
void Run(In_CclsBase* 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::Type) {
|
|
if (const auto* def = db->GetType(sym).AnyDef())
|
|
out.result = GetLsLocationExs(
|
|
db, working_files, GetDeclarations(db->usr2type, def->bases));
|
|
break;
|
|
} else if (sym.kind == SymbolKind::Func) {
|
|
if (const auto* def = db->GetFunc(sym).AnyDef())
|
|
out.result = GetLsLocationExs(
|
|
db, working_files, GetDeclarations(db->usr2func, def->bases));
|
|
break;
|
|
}
|
|
}
|
|
QueueManager::WriteStdout(kMethodType, out);
|
|
}
|
|
};
|
|
REGISTER_MESSAGE_HANDLER(Handler_CclsBase);
|
|
} // namespace
|