mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-25 09:05:10 +00:00
Merge $cquery/*Hierarchy{Initial,Expand}
This commit is contained in:
parent
214eded2cb
commit
ba87714e92
@ -342,12 +342,9 @@ void LaunchStdinLoop(Config* config,
|
|||||||
case IpcId::WorkspaceSymbol:
|
case IpcId::WorkspaceSymbol:
|
||||||
case IpcId::CqueryFileInfo:
|
case IpcId::CqueryFileInfo:
|
||||||
case IpcId::CqueryFreshenIndex:
|
case IpcId::CqueryFreshenIndex:
|
||||||
case IpcId::CqueryCallHierarchyInitial:
|
case IpcId::CqueryCallHierarchy:
|
||||||
case IpcId::CqueryCallHierarchyExpand:
|
case IpcId::CqueryInheritanceHierarchy:
|
||||||
case IpcId::CqueryInheritanceHierarchyInitial:
|
case IpcId::CqueryMemberHierarchy:
|
||||||
case IpcId::CqueryInheritanceHierarchyExpand:
|
|
||||||
case IpcId::CqueryMemberHierarchyInitial:
|
|
||||||
case IpcId::CqueryMemberHierarchyExpand:
|
|
||||||
case IpcId::CqueryVars:
|
case IpcId::CqueryVars:
|
||||||
case IpcId::CqueryCallers:
|
case IpcId::CqueryCallers:
|
||||||
case IpcId::CqueryBase:
|
case IpcId::CqueryBase:
|
||||||
|
18
src/ipc.cc
18
src/ipc.cc
@ -70,18 +70,12 @@ const char* IpcIdToString(IpcId id) {
|
|||||||
return "$cquery/fileInfo";
|
return "$cquery/fileInfo";
|
||||||
case IpcId::CqueryFreshenIndex:
|
case IpcId::CqueryFreshenIndex:
|
||||||
return "$cquery/freshenIndex";
|
return "$cquery/freshenIndex";
|
||||||
case IpcId::CqueryCallHierarchyInitial:
|
case IpcId::CqueryCallHierarchy:
|
||||||
return "$cquery/callHierarchyInitial";
|
return "$cquery/callHierarchy";
|
||||||
case IpcId::CqueryCallHierarchyExpand:
|
case IpcId::CqueryInheritanceHierarchy:
|
||||||
return "$cquery/callHierarchyExpand";
|
return "$cquery/inheritanceHierarchy";
|
||||||
case IpcId::CqueryInheritanceHierarchyInitial:
|
case IpcId::CqueryMemberHierarchy:
|
||||||
return "$cquery/inheritanceHierarchyInitial";
|
return "$cquery/memberHierarchy";
|
||||||
case IpcId::CqueryInheritanceHierarchyExpand:
|
|
||||||
return "$cquery/inheritanceHierarchyExpand";
|
|
||||||
case IpcId::CqueryMemberHierarchyInitial:
|
|
||||||
return "$cquery/memberHierarchyInitial";
|
|
||||||
case IpcId::CqueryMemberHierarchyExpand:
|
|
||||||
return "$cquery/memberHierarchyExpand";
|
|
||||||
case IpcId::CqueryVars:
|
case IpcId::CqueryVars:
|
||||||
return "$cquery/vars";
|
return "$cquery/vars";
|
||||||
case IpcId::CqueryCallers:
|
case IpcId::CqueryCallers:
|
||||||
|
@ -48,12 +48,9 @@ enum class IpcId : int {
|
|||||||
CqueryFileInfo,
|
CqueryFileInfo,
|
||||||
CqueryFreshenIndex,
|
CqueryFreshenIndex,
|
||||||
// Messages used in tree views.
|
// Messages used in tree views.
|
||||||
CqueryCallHierarchyInitial,
|
CqueryCallHierarchy,
|
||||||
CqueryCallHierarchyExpand,
|
CqueryInheritanceHierarchy,
|
||||||
CqueryInheritanceHierarchyInitial,
|
CqueryMemberHierarchy,
|
||||||
CqueryInheritanceHierarchyExpand,
|
|
||||||
CqueryMemberHierarchyInitial,
|
|
||||||
CqueryMemberHierarchyExpand,
|
|
||||||
// These are like DocumentReferences but show different types of data.
|
// These are like DocumentReferences but show different types of data.
|
||||||
CqueryVars, // Show all variables of a type.
|
CqueryVars, // Show all variables of a type.
|
||||||
CqueryCallers, // Show all callers of a function.
|
CqueryCallers, // Show all callers of a function.
|
||||||
|
@ -12,12 +12,17 @@ bool operator&(CallType lhs, CallType rhs) {
|
|||||||
return uint8_t(lhs) & uint8_t(rhs);
|
return uint8_t(lhs) & uint8_t(rhs);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Ipc_CqueryCallHierarchyInitial
|
struct Ipc_CqueryCallHierarchy
|
||||||
: public RequestMessage<Ipc_CqueryCallHierarchyInitial> {
|
: public RequestMessage<Ipc_CqueryCallHierarchy> {
|
||||||
const static IpcId kIpcId = IpcId::CqueryCallHierarchyInitial;
|
const static IpcId kIpcId = IpcId::CqueryCallHierarchy;
|
||||||
struct Params {
|
struct Params {
|
||||||
|
// If id is specified, expand a node; otherwise textDocument+position should
|
||||||
|
// be specified for building the root and |levels| of nodes below.
|
||||||
lsTextDocumentIdentifier textDocument;
|
lsTextDocumentIdentifier textDocument;
|
||||||
lsPosition position;
|
lsPosition position;
|
||||||
|
|
||||||
|
Maybe<QueryFuncId> id;
|
||||||
|
|
||||||
// true: callee tree (functions called by this function); false: caller tree
|
// true: callee tree (functions called by this function); false: caller tree
|
||||||
// (where this function is called)
|
// (where this function is called)
|
||||||
bool callee = false;
|
bool callee = false;
|
||||||
@ -29,36 +34,16 @@ struct Ipc_CqueryCallHierarchyInitial
|
|||||||
};
|
};
|
||||||
Params params;
|
Params params;
|
||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(Ipc_CqueryCallHierarchyInitial::Params,
|
MAKE_REFLECT_STRUCT(Ipc_CqueryCallHierarchy::Params,
|
||||||
textDocument,
|
textDocument,
|
||||||
position,
|
position,
|
||||||
callee,
|
|
||||||
callType,
|
|
||||||
detailedName,
|
|
||||||
levels);
|
|
||||||
MAKE_REFLECT_STRUCT(Ipc_CqueryCallHierarchyInitial, id, params);
|
|
||||||
REGISTER_IPC_MESSAGE(Ipc_CqueryCallHierarchyInitial);
|
|
||||||
|
|
||||||
struct Ipc_CqueryCallHierarchyExpand
|
|
||||||
: public RequestMessage<Ipc_CqueryCallHierarchyExpand> {
|
|
||||||
const static IpcId kIpcId = IpcId::CqueryCallHierarchyExpand;
|
|
||||||
struct Params {
|
|
||||||
Maybe<QueryFuncId> id;
|
|
||||||
bool callee = false;
|
|
||||||
CallType callType = CallType::Direct;
|
|
||||||
bool detailedName = false;
|
|
||||||
int levels = 1;
|
|
||||||
};
|
|
||||||
Params params;
|
|
||||||
};
|
|
||||||
MAKE_REFLECT_STRUCT(Ipc_CqueryCallHierarchyExpand::Params,
|
|
||||||
id,
|
id,
|
||||||
callee,
|
callee,
|
||||||
callType,
|
callType,
|
||||||
detailedName,
|
detailedName,
|
||||||
levels);
|
levels);
|
||||||
MAKE_REFLECT_STRUCT(Ipc_CqueryCallHierarchyExpand, id, params);
|
MAKE_REFLECT_STRUCT(Ipc_CqueryCallHierarchy, id, params);
|
||||||
REGISTER_IPC_MESSAGE(Ipc_CqueryCallHierarchyExpand);
|
REGISTER_IPC_MESSAGE(Ipc_CqueryCallHierarchy);
|
||||||
|
|
||||||
struct Out_CqueryCallHierarchy : public lsOutMessage<Out_CqueryCallHierarchy> {
|
struct Out_CqueryCallHierarchy : public lsOutMessage<Out_CqueryCallHierarchy> {
|
||||||
struct Entry {
|
struct Entry {
|
||||||
@ -167,8 +152,8 @@ bool Expand(MessageHandler* m,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct CqueryCallHierarchyInitialHandler
|
struct CqueryCallHierarchyHandler
|
||||||
: BaseMessageHandler<Ipc_CqueryCallHierarchyInitial> {
|
: BaseMessageHandler<Ipc_CqueryCallHierarchy> {
|
||||||
optional<Out_CqueryCallHierarchy::Entry> BuildInitial(QueryFuncId root_id,
|
optional<Out_CqueryCallHierarchy::Entry> BuildInitial(QueryFuncId root_id,
|
||||||
bool callee,
|
bool callee,
|
||||||
CallType call_type,
|
CallType call_type,
|
||||||
@ -185,18 +170,26 @@ struct CqueryCallHierarchyInitialHandler
|
|||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Run(Ipc_CqueryCallHierarchyInitial* request) override {
|
void Run(Ipc_CqueryCallHierarchy* request) override {
|
||||||
QueryFile* file;
|
|
||||||
const auto& params = request->params;
|
const auto& params = request->params;
|
||||||
if (!FindFileOrFail(db, project, request->id,
|
|
||||||
params.textDocument.uri.GetPath(), &file))
|
|
||||||
return;
|
|
||||||
|
|
||||||
WorkingFile* working_file =
|
|
||||||
working_files->GetFileByFilename(file->def->path);
|
|
||||||
Out_CqueryCallHierarchy out;
|
Out_CqueryCallHierarchy out;
|
||||||
out.id = request->id;
|
out.id = request->id;
|
||||||
|
|
||||||
|
if (params.id) {
|
||||||
|
Out_CqueryCallHierarchy::Entry entry;
|
||||||
|
entry.id = *params.id;
|
||||||
|
entry.callType = CallType::Direct;
|
||||||
|
if (entry.id.id < db->funcs.size())
|
||||||
|
Expand(this, &entry, params.callee, params.callType,
|
||||||
|
params.detailedName, params.levels);
|
||||||
|
out.result = std::move(entry);
|
||||||
|
} else {
|
||||||
|
QueryFile* file;
|
||||||
|
if (!FindFileOrFail(db, project, request->id,
|
||||||
|
params.textDocument.uri.GetPath(), &file))
|
||||||
|
return;
|
||||||
|
WorkingFile* working_file =
|
||||||
|
working_files->GetFileByFilename(file->def->path);
|
||||||
for (SymbolRef sym :
|
for (SymbolRef sym :
|
||||||
FindSymbolsAtLocation(working_file, file, params.position)) {
|
FindSymbolsAtLocation(working_file, file, params.position)) {
|
||||||
if (sym.kind == SymbolKind::Func) {
|
if (sym.kind == SymbolKind::Func) {
|
||||||
@ -206,30 +199,11 @@ struct CqueryCallHierarchyInitialHandler
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QueueManager::WriteStdout(IpcId::CqueryCallHierarchyInitial, out);
|
QueueManager::WriteStdout(IpcId::CqueryCallHierarchy, out);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
REGISTER_MESSAGE_HANDLER(CqueryCallHierarchyInitialHandler);
|
REGISTER_MESSAGE_HANDLER(CqueryCallHierarchyHandler);
|
||||||
|
|
||||||
struct CqueryCallHierarchyExpandHandler
|
|
||||||
: BaseMessageHandler<Ipc_CqueryCallHierarchyExpand> {
|
|
||||||
void Run(Ipc_CqueryCallHierarchyExpand* request) override {
|
|
||||||
const auto& params = request->params;
|
|
||||||
Out_CqueryCallHierarchy out;
|
|
||||||
out.id = request->id;
|
|
||||||
if (params.id) {
|
|
||||||
Out_CqueryCallHierarchy::Entry entry;
|
|
||||||
entry.id = *params.id;
|
|
||||||
entry.callType = CallType::Direct;
|
|
||||||
if (entry.id.id < db->funcs.size())
|
|
||||||
Expand(this, &entry, params.callee, params.callType,
|
|
||||||
params.detailedName, params.levels);
|
|
||||||
out.result = std::move(entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
QueueManager::WriteStdout(IpcId::CqueryCallHierarchyExpand, out);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
REGISTER_MESSAGE_HANDLER(CqueryCallHierarchyExpandHandler);
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -3,12 +3,18 @@
|
|||||||
#include "queue_manager.h"
|
#include "queue_manager.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
struct Ipc_CqueryInheritanceHierarchyInitial
|
struct Ipc_CqueryInheritanceHierarchy
|
||||||
: public RequestMessage<Ipc_CqueryInheritanceHierarchyInitial> {
|
: public RequestMessage<Ipc_CqueryInheritanceHierarchy> {
|
||||||
const static IpcId kIpcId = IpcId::CqueryInheritanceHierarchyInitial;
|
const static IpcId kIpcId = IpcId::CqueryInheritanceHierarchy;
|
||||||
struct Params {
|
struct Params {
|
||||||
|
// If id+kind are specified, expand a node; otherwise textDocument+position should
|
||||||
|
// be specified for building the root and |levels| of nodes below.
|
||||||
lsTextDocumentIdentifier textDocument;
|
lsTextDocumentIdentifier textDocument;
|
||||||
lsPosition position;
|
lsPosition position;
|
||||||
|
|
||||||
|
Maybe<Id<void>> id;
|
||||||
|
SymbolKind kind = SymbolKind::Invalid;
|
||||||
|
|
||||||
// true: derived classes/functions; false: base classes/functions
|
// true: derived classes/functions; false: base classes/functions
|
||||||
bool derived = false;
|
bool derived = false;
|
||||||
bool detailedName = false;
|
bool detailedName = false;
|
||||||
@ -17,35 +23,16 @@ struct Ipc_CqueryInheritanceHierarchyInitial
|
|||||||
Params params;
|
Params params;
|
||||||
};
|
};
|
||||||
|
|
||||||
MAKE_REFLECT_STRUCT(Ipc_CqueryInheritanceHierarchyInitial::Params,
|
MAKE_REFLECT_STRUCT(Ipc_CqueryInheritanceHierarchy::Params,
|
||||||
textDocument,
|
textDocument,
|
||||||
position,
|
position,
|
||||||
derived,
|
|
||||||
detailedName,
|
|
||||||
levels);
|
|
||||||
MAKE_REFLECT_STRUCT(Ipc_CqueryInheritanceHierarchyInitial, id, params);
|
|
||||||
REGISTER_IPC_MESSAGE(Ipc_CqueryInheritanceHierarchyInitial);
|
|
||||||
|
|
||||||
struct Ipc_CqueryInheritanceHierarchyExpand
|
|
||||||
: public RequestMessage<Ipc_CqueryInheritanceHierarchyExpand> {
|
|
||||||
const static IpcId kIpcId = IpcId::CqueryInheritanceHierarchyExpand;
|
|
||||||
struct Params {
|
|
||||||
Maybe<Id<void>> id;
|
|
||||||
SymbolKind kind = SymbolKind::Invalid;
|
|
||||||
bool derived = false;
|
|
||||||
bool detailedName = false;
|
|
||||||
int levels = 1;
|
|
||||||
};
|
|
||||||
Params params;
|
|
||||||
};
|
|
||||||
MAKE_REFLECT_STRUCT(Ipc_CqueryInheritanceHierarchyExpand::Params,
|
|
||||||
id,
|
id,
|
||||||
kind,
|
kind,
|
||||||
derived,
|
derived,
|
||||||
detailedName,
|
detailedName,
|
||||||
levels);
|
levels);
|
||||||
MAKE_REFLECT_STRUCT(Ipc_CqueryInheritanceHierarchyExpand, id, params);
|
MAKE_REFLECT_STRUCT(Ipc_CqueryInheritanceHierarchy, id, params);
|
||||||
REGISTER_IPC_MESSAGE(Ipc_CqueryInheritanceHierarchyExpand);
|
REGISTER_IPC_MESSAGE(Ipc_CqueryInheritanceHierarchy);
|
||||||
|
|
||||||
struct Out_CqueryInheritanceHierarchy
|
struct Out_CqueryInheritanceHierarchy
|
||||||
: public lsOutMessage<Out_CqueryInheritanceHierarchy> {
|
: public lsOutMessage<Out_CqueryInheritanceHierarchy> {
|
||||||
@ -140,8 +127,8 @@ bool Expand(MessageHandler* m,
|
|||||||
m->db->types[entry->id.id]);
|
m->db->types[entry->id.id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct CqueryInheritanceHierarchyInitialHandler
|
struct CqueryInheritanceHierarchyHandler
|
||||||
: BaseMessageHandler<Ipc_CqueryInheritanceHierarchyInitial> {
|
: BaseMessageHandler<Ipc_CqueryInheritanceHierarchy> {
|
||||||
optional<Out_CqueryInheritanceHierarchy::Entry>
|
optional<Out_CqueryInheritanceHierarchy::Entry>
|
||||||
BuildInitial(SymbolRef sym, bool derived, bool detailed_name, int levels) {
|
BuildInitial(SymbolRef sym, bool derived, bool detailed_name, int levels) {
|
||||||
Out_CqueryInheritanceHierarchy::Entry entry;
|
Out_CqueryInheritanceHierarchy::Entry entry;
|
||||||
@ -151,38 +138,11 @@ struct CqueryInheritanceHierarchyInitialHandler
|
|||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Run(Ipc_CqueryInheritanceHierarchyInitial* request) override {
|
void Run(Ipc_CqueryInheritanceHierarchy* request) override {
|
||||||
const auto& params = request->params;
|
|
||||||
QueryFile* file;
|
|
||||||
if (!FindFileOrFail(db, project, request->id,
|
|
||||||
params.textDocument.uri.GetPath(), &file))
|
|
||||||
return;
|
|
||||||
|
|
||||||
WorkingFile* working_file =
|
|
||||||
working_files->GetFileByFilename(file->def->path);
|
|
||||||
Out_CqueryInheritanceHierarchy out;
|
|
||||||
out.id = request->id;
|
|
||||||
|
|
||||||
for (SymbolRef sym :
|
|
||||||
FindSymbolsAtLocation(working_file, file, request->params.position)) {
|
|
||||||
if (sym.kind == SymbolKind::Func || sym.kind == SymbolKind::Type) {
|
|
||||||
out.result = BuildInitial(sym, params.derived, params.detailedName,
|
|
||||||
params.levels);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QueueManager::WriteStdout(IpcId::CqueryInheritanceHierarchyInitial, out);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
REGISTER_MESSAGE_HANDLER(CqueryInheritanceHierarchyInitialHandler);
|
|
||||||
|
|
||||||
struct CqueryInheritanceHierarchyExpandHandler
|
|
||||||
: BaseMessageHandler<Ipc_CqueryInheritanceHierarchyExpand> {
|
|
||||||
void Run(Ipc_CqueryInheritanceHierarchyExpand* request) override {
|
|
||||||
const auto& params = request->params;
|
const auto& params = request->params;
|
||||||
Out_CqueryInheritanceHierarchy out;
|
Out_CqueryInheritanceHierarchy out;
|
||||||
out.id = request->id;
|
out.id = request->id;
|
||||||
|
|
||||||
if (params.id) {
|
if (params.id) {
|
||||||
Out_CqueryInheritanceHierarchy::Entry entry;
|
Out_CqueryInheritanceHierarchy::Entry entry;
|
||||||
entry.id = *params.id;
|
entry.id = *params.id;
|
||||||
@ -193,10 +153,27 @@ struct CqueryInheritanceHierarchyExpandHandler
|
|||||||
Expand(this, &entry, params.derived, params.detailedName,
|
Expand(this, &entry, params.derived, params.detailedName,
|
||||||
params.levels))
|
params.levels))
|
||||||
out.result = std::move(entry);
|
out.result = std::move(entry);
|
||||||
|
} else {
|
||||||
|
QueryFile* file;
|
||||||
|
if (!FindFileOrFail(db, project, request->id,
|
||||||
|
params.textDocument.uri.GetPath(), &file))
|
||||||
|
return;
|
||||||
|
WorkingFile* working_file =
|
||||||
|
working_files->GetFileByFilename(file->def->path);
|
||||||
|
|
||||||
|
for (SymbolRef sym :
|
||||||
|
FindSymbolsAtLocation(working_file, file, request->params.position)) {
|
||||||
|
if (sym.kind == SymbolKind::Func || sym.kind == SymbolKind::Type) {
|
||||||
|
out.result = BuildInitial(sym, params.derived, params.detailedName,
|
||||||
|
params.levels);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QueueManager::WriteStdout(IpcId::CqueryInheritanceHierarchyExpand, out);
|
QueueManager::WriteStdout(IpcId::CqueryInheritanceHierarchy, out);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
REGISTER_MESSAGE_HANDLER(CqueryInheritanceHierarchyExpandHandler);
|
REGISTER_MESSAGE_HANDLER(CqueryInheritanceHierarchyHandler);
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -3,39 +3,31 @@
|
|||||||
#include "queue_manager.h"
|
#include "queue_manager.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
struct Ipc_CqueryMemberHierarchyInitial
|
struct Ipc_CqueryMemberHierarchy
|
||||||
: public RequestMessage<Ipc_CqueryMemberHierarchyInitial> {
|
: public RequestMessage<Ipc_CqueryMemberHierarchy> {
|
||||||
const static IpcId kIpcId = IpcId::CqueryMemberHierarchyInitial;
|
const static IpcId kIpcId = IpcId::CqueryMemberHierarchy;
|
||||||
struct Params {
|
struct Params {
|
||||||
|
// If id is specified, expand a node; otherwise textDocument+position should
|
||||||
|
// be specified for building the root and |levels| of nodes below.
|
||||||
lsTextDocumentIdentifier textDocument;
|
lsTextDocumentIdentifier textDocument;
|
||||||
lsPosition position;
|
lsPosition position;
|
||||||
|
|
||||||
|
Maybe<QueryTypeId> id;
|
||||||
|
|
||||||
bool detailedName = false;
|
bool detailedName = false;
|
||||||
int levels = 1;
|
int levels = 1;
|
||||||
};
|
};
|
||||||
Params params;
|
Params params;
|
||||||
};
|
};
|
||||||
|
|
||||||
MAKE_REFLECT_STRUCT(Ipc_CqueryMemberHierarchyInitial::Params,
|
MAKE_REFLECT_STRUCT(Ipc_CqueryMemberHierarchy::Params,
|
||||||
textDocument,
|
textDocument,
|
||||||
position,
|
position,
|
||||||
|
id,
|
||||||
detailedName,
|
detailedName,
|
||||||
levels);
|
levels);
|
||||||
MAKE_REFLECT_STRUCT(Ipc_CqueryMemberHierarchyInitial, id, params);
|
MAKE_REFLECT_STRUCT(Ipc_CqueryMemberHierarchy, id, params);
|
||||||
REGISTER_IPC_MESSAGE(Ipc_CqueryMemberHierarchyInitial);
|
REGISTER_IPC_MESSAGE(Ipc_CqueryMemberHierarchy);
|
||||||
|
|
||||||
struct Ipc_CqueryMemberHierarchyExpand
|
|
||||||
: public RequestMessage<Ipc_CqueryMemberHierarchyExpand> {
|
|
||||||
const static IpcId kIpcId = IpcId::CqueryMemberHierarchyExpand;
|
|
||||||
struct Params {
|
|
||||||
Maybe<QueryTypeId> id;
|
|
||||||
bool detailedName = false;
|
|
||||||
int levels = 1;
|
|
||||||
};
|
|
||||||
Params params;
|
|
||||||
};
|
|
||||||
MAKE_REFLECT_STRUCT(Ipc_CqueryMemberHierarchyExpand::Params, id, detailedName, levels);
|
|
||||||
MAKE_REFLECT_STRUCT(Ipc_CqueryMemberHierarchyExpand, id, params);
|
|
||||||
REGISTER_IPC_MESSAGE(Ipc_CqueryMemberHierarchyExpand);
|
|
||||||
|
|
||||||
struct Out_CqueryMemberHierarchy
|
struct Out_CqueryMemberHierarchy
|
||||||
: public lsOutMessage<Out_CqueryMemberHierarchy> {
|
: public lsOutMessage<Out_CqueryMemberHierarchy> {
|
||||||
@ -166,8 +158,8 @@ bool Expand(MessageHandler* m,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct CqueryMemberHierarchyInitialHandler
|
struct CqueryMemberHierarchyHandler
|
||||||
: BaseMessageHandler<Ipc_CqueryMemberHierarchyInitial> {
|
: BaseMessageHandler<Ipc_CqueryMemberHierarchy> {
|
||||||
optional<Out_CqueryMemberHierarchy::Entry> BuildInitial(QueryFuncId root_id,
|
optional<Out_CqueryMemberHierarchy::Entry> BuildInitial(QueryFuncId root_id,
|
||||||
bool detailed_name,
|
bool detailed_name,
|
||||||
int levels) {
|
int levels) {
|
||||||
@ -210,18 +202,25 @@ struct CqueryMemberHierarchyInitialHandler
|
|||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Run(Ipc_CqueryMemberHierarchyInitial* request) override {
|
void Run(Ipc_CqueryMemberHierarchy* request) override {
|
||||||
QueryFile* file;
|
|
||||||
const auto& params = request->params;
|
const auto& params = request->params;
|
||||||
if (!FindFileOrFail(db, project, request->id,
|
|
||||||
params.textDocument.uri.GetPath(), &file))
|
|
||||||
return;
|
|
||||||
|
|
||||||
WorkingFile* working_file =
|
|
||||||
working_files->GetFileByFilename(file->def->path);
|
|
||||||
Out_CqueryMemberHierarchy out;
|
Out_CqueryMemberHierarchy out;
|
||||||
out.id = request->id;
|
out.id = request->id;
|
||||||
|
|
||||||
|
if (params.id) {
|
||||||
|
Out_CqueryMemberHierarchy::Entry entry;
|
||||||
|
entry.id = *request->params.id;
|
||||||
|
// entry.name is empty as it is known by the client.
|
||||||
|
if (entry.id.id < db->types.size() &&
|
||||||
|
Expand(this, &entry, params.detailedName, params.levels))
|
||||||
|
out.result = std::move(entry);
|
||||||
|
} else {
|
||||||
|
QueryFile* file;
|
||||||
|
if (!FindFileOrFail(db, project, request->id,
|
||||||
|
params.textDocument.uri.GetPath(), &file))
|
||||||
|
return;
|
||||||
|
WorkingFile* working_file =
|
||||||
|
working_files->GetFileByFilename(file->def->path);
|
||||||
for (SymbolRef sym :
|
for (SymbolRef sym :
|
||||||
FindSymbolsAtLocation(working_file, file, params.position)) {
|
FindSymbolsAtLocation(working_file, file, params.position)) {
|
||||||
switch (sym.kind) {
|
switch (sym.kind) {
|
||||||
@ -236,8 +235,8 @@ struct CqueryMemberHierarchyInitialHandler
|
|||||||
case SymbolKind::Var: {
|
case SymbolKind::Var: {
|
||||||
const QueryVar::Def* def = db->GetVar(sym).AnyDef();
|
const QueryVar::Def* def = db->GetVar(sym).AnyDef();
|
||||||
if (def && def->type)
|
if (def && def->type)
|
||||||
out.result = BuildInitial(QueryTypeId(*def->type),
|
out.result = BuildInitial(QueryTypeId(*def->type), params.detailedName,
|
||||||
params.detailedName, params.levels);
|
params.levels);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@ -245,29 +244,11 @@ struct CqueryMemberHierarchyInitialHandler
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QueueManager::WriteStdout(IpcId::CqueryMemberHierarchyInitial, out);
|
QueueManager::WriteStdout(IpcId::CqueryMemberHierarchy, out);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
REGISTER_MESSAGE_HANDLER(CqueryMemberHierarchyInitialHandler);
|
REGISTER_MESSAGE_HANDLER(CqueryMemberHierarchyHandler);
|
||||||
|
|
||||||
struct CqueryMemberHierarchyExpandHandler
|
|
||||||
: BaseMessageHandler<Ipc_CqueryMemberHierarchyExpand> {
|
|
||||||
void Run(Ipc_CqueryMemberHierarchyExpand* request) override {
|
|
||||||
const auto& params = request->params;
|
|
||||||
Out_CqueryMemberHierarchy out;
|
|
||||||
out.id = request->id;
|
|
||||||
if (params.id) {
|
|
||||||
Out_CqueryMemberHierarchy::Entry entry;
|
|
||||||
entry.id = *request->params.id;
|
|
||||||
// entry.name is empty as it is known by the client.
|
|
||||||
if (entry.id.id < db->types.size() &&
|
|
||||||
Expand(this, &entry, params.detailedName, params.levels))
|
|
||||||
out.result = std::move(entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
QueueManager::WriteStdout(IpcId::CqueryMemberHierarchyExpand, out);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
REGISTER_MESSAGE_HANDLER(CqueryMemberHierarchyExpandHandler);
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
Loading…
Reference in New Issue
Block a user