2018-01-30 05:34:28 +00:00
|
|
|
#include "cache_manager.h"
|
2017-12-06 03:32:33 +00:00
|
|
|
#include "message_handler.h"
|
|
|
|
#include "platform.h"
|
2017-12-29 16:29:47 +00:00
|
|
|
#include "queue_manager.h"
|
2017-12-06 03:32:33 +00:00
|
|
|
|
2017-12-28 16:55:46 +00:00
|
|
|
#include <loguru/loguru.hpp>
|
|
|
|
|
2017-12-06 05:03:38 +00:00
|
|
|
namespace {
|
2018-03-31 03:16:33 +00:00
|
|
|
MethodType kMethodType = "$ccls/indexFile";
|
2018-03-22 04:05:25 +00:00
|
|
|
|
2018-03-31 03:16:33 +00:00
|
|
|
struct In_CclsIndexFile : public NotificationInMessage {
|
2018-03-22 04:05:25 +00:00
|
|
|
MethodType GetMethodType() const override { return kMethodType; }
|
2017-12-06 04:39:44 +00:00
|
|
|
struct Params {
|
|
|
|
std::string path;
|
|
|
|
std::vector<std::string> args;
|
|
|
|
bool is_interactive = false;
|
|
|
|
std::string contents;
|
|
|
|
};
|
|
|
|
Params params;
|
|
|
|
};
|
2018-03-31 03:16:33 +00:00
|
|
|
MAKE_REFLECT_STRUCT(In_CclsIndexFile::Params,
|
2017-12-06 04:39:44 +00:00
|
|
|
path,
|
|
|
|
args,
|
|
|
|
is_interactive,
|
|
|
|
contents);
|
2018-03-31 03:16:33 +00:00
|
|
|
MAKE_REFLECT_STRUCT(In_CclsIndexFile, params);
|
|
|
|
REGISTER_IN_MESSAGE(In_CclsIndexFile);
|
2017-12-06 04:39:44 +00:00
|
|
|
|
2018-03-31 03:16:33 +00:00
|
|
|
struct Handler_CclsIndexFile : BaseMessageHandler<In_CclsIndexFile> {
|
2018-03-22 04:05:25 +00:00
|
|
|
MethodType GetMethodType() const override { return kMethodType; }
|
2018-03-31 03:16:33 +00:00
|
|
|
void Run(In_CclsIndexFile* request) override {
|
2017-12-28 16:55:46 +00:00
|
|
|
LOG_S(INFO) << "Indexing file " << request->params.path;
|
2018-02-22 07:34:32 +00:00
|
|
|
QueueManager::instance()->index_request.PushBack(
|
|
|
|
Index_Request(NormalizePath(request->params.path), request->params.args,
|
|
|
|
request->params.is_interactive, request->params.contents,
|
2018-04-01 00:49:32 +00:00
|
|
|
ICacheManager::Make()));
|
2017-12-06 03:32:33 +00:00
|
|
|
}
|
|
|
|
};
|
2018-03-31 03:16:33 +00:00
|
|
|
REGISTER_MESSAGE_HANDLER(Handler_CclsIndexFile);
|
2017-12-31 03:18:33 +00:00
|
|
|
} // namespace
|