2018-02-15 06:41:07 +00:00
|
|
|
#include "message_handler.h"
|
|
|
|
#include "query_utils.h"
|
|
|
|
#include "queue_manager.h"
|
|
|
|
|
|
|
|
namespace {
|
2018-03-22 04:05:25 +00:00
|
|
|
MethodType kMethodType = "$cquery/fileInfo";
|
|
|
|
|
2018-02-15 06:41:07 +00:00
|
|
|
struct lsDocumentSymbolParams {
|
|
|
|
lsTextDocumentIdentifier textDocument;
|
|
|
|
};
|
|
|
|
MAKE_REFLECT_STRUCT(lsDocumentSymbolParams, textDocument);
|
|
|
|
|
2018-03-22 04:05:25 +00:00
|
|
|
struct In_CqueryFileInfo : public RequestMessage {
|
|
|
|
MethodType GetMethodType() const override { return kMethodType; }
|
2018-02-15 06:41:07 +00:00
|
|
|
lsDocumentSymbolParams params;
|
|
|
|
};
|
2018-03-22 04:05:25 +00:00
|
|
|
MAKE_REFLECT_STRUCT(In_CqueryFileInfo, id, params);
|
|
|
|
REGISTER_IN_MESSAGE(In_CqueryFileInfo);
|
2018-02-15 06:41:07 +00:00
|
|
|
|
|
|
|
struct Out_CqueryFileInfo : public lsOutMessage<Out_CqueryFileInfo> {
|
|
|
|
lsRequestId id;
|
|
|
|
QueryFile::Def result;
|
|
|
|
};
|
|
|
|
MAKE_REFLECT_STRUCT(Out_CqueryFileInfo, jsonrpc, id, result);
|
|
|
|
|
2018-03-22 04:05:25 +00:00
|
|
|
struct Handler_CqueryFileInfo : BaseMessageHandler<In_CqueryFileInfo> {
|
|
|
|
MethodType GetMethodType() const override { return kMethodType; }
|
|
|
|
void Run(In_CqueryFileInfo* request) override {
|
2018-02-15 06:41:07 +00:00
|
|
|
QueryFile* file;
|
|
|
|
if (!FindFileOrFail(db, project, request->id,
|
|
|
|
request->params.textDocument.uri.GetPath(), &file)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Out_CqueryFileInfo out;
|
|
|
|
out.id = request->id;
|
|
|
|
// Expose some fields of |QueryFile::Def|.
|
|
|
|
out.result.path = file->def->path;
|
|
|
|
out.result.args = file->def->args;
|
|
|
|
out.result.language = file->def->language;
|
|
|
|
out.result.includes = file->def->includes;
|
|
|
|
out.result.inactive_regions = file->def->inactive_regions;
|
2018-03-22 04:05:25 +00:00
|
|
|
QueueManager::WriteStdout(kMethodType, out);
|
2018-02-15 06:41:07 +00:00
|
|
|
}
|
|
|
|
};
|
2018-03-22 04:05:25 +00:00
|
|
|
REGISTER_MESSAGE_HANDLER(Handler_CqueryFileInfo);
|
2018-02-15 06:41:07 +00:00
|
|
|
} // namespace
|