mirror of
https://github.com/MaskRay/ccls.git
synced 2025-04-14 21:02:14 +00:00
Add whitelist/blacklist to $cquery/freshenIndex
This commit is contained in:
parent
273af8306f
commit
2e0f14bef8
@ -35,8 +35,6 @@ template <typename T>
|
|||||||
struct Id {
|
struct Id {
|
||||||
size_t id;
|
size_t id;
|
||||||
|
|
||||||
static constexpr size_t INVALID_ID = static_cast<size_t>(-1);
|
|
||||||
|
|
||||||
Id() : id(0) {} // Needed for containers. Do not use directly.
|
Id() : id(0) {} // Needed for containers. Do not use directly.
|
||||||
explicit Id(size_t id) : id(id) {}
|
explicit Id(size_t id) : id(id) {}
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include "cache_manager.h"
|
#include "cache_manager.h"
|
||||||
|
#include "match.h"
|
||||||
#include "message_handler.h"
|
#include "message_handler.h"
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
#include "project.h"
|
#include "project.h"
|
||||||
@ -11,23 +12,23 @@
|
|||||||
namespace {
|
namespace {
|
||||||
struct Ipc_CqueryFreshenIndex : public RequestMessage<Ipc_CqueryFreshenIndex> {
|
struct Ipc_CqueryFreshenIndex : public RequestMessage<Ipc_CqueryFreshenIndex> {
|
||||||
const static IpcId kIpcId = IpcId::CqueryFreshenIndex;
|
const static IpcId kIpcId = IpcId::CqueryFreshenIndex;
|
||||||
// FIXME fresh partial files
|
std::vector<std::string> whitelist;
|
||||||
|
std::vector<std::string> blacklist;
|
||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(Ipc_CqueryFreshenIndex, id);
|
MAKE_REFLECT_STRUCT(Ipc_CqueryFreshenIndex, id, whitelist, blacklist);
|
||||||
REGISTER_IPC_MESSAGE(Ipc_CqueryFreshenIndex);
|
REGISTER_IPC_MESSAGE(Ipc_CqueryFreshenIndex);
|
||||||
|
|
||||||
struct CqueryFreshenIndexHandler : MessageHandler {
|
struct CqueryFreshenIndexHandler : BaseMessageHandler<Ipc_CqueryFreshenIndex> {
|
||||||
IpcId GetId() const override { return IpcId::CqueryFreshenIndex; }
|
void Run(Ipc_CqueryFreshenIndex* request) override {
|
||||||
|
|
||||||
void Run(std::unique_ptr<BaseIpcMessage> request) override {
|
|
||||||
LOG_S(INFO) << "Freshening " << project->entries.size() << " files";
|
LOG_S(INFO) << "Freshening " << project->entries.size() << " files";
|
||||||
|
|
||||||
// TODO: think about this flow and test it more.
|
// TODO: think about this flow and test it more.
|
||||||
|
GroupMatch matcher(request->whitelist, request->blacklist);
|
||||||
|
|
||||||
// Unmark all files whose timestamp has changed.
|
// Unmark all files whose timestamp has changed.
|
||||||
std::unique_ptr<ICacheManager> cache_manager = ICacheManager::Make(config);
|
std::unique_ptr<ICacheManager> cache_manager = ICacheManager::Make(config);
|
||||||
for (const auto& file : db->files) {
|
for (const auto& file : db->files) {
|
||||||
if (!file.def)
|
if (!file.def || !matcher.IsMatch(file.def->path))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
optional<int64_t> modification_timestamp =
|
optional<int64_t> modification_timestamp =
|
||||||
@ -47,6 +48,8 @@ struct CqueryFreshenIndexHandler : MessageHandler {
|
|||||||
// Send index requests for every file.
|
// Send index requests for every file.
|
||||||
project->ForAllFilteredFiles(
|
project->ForAllFilteredFiles(
|
||||||
config, [&](int i, const Project::Entry& entry) {
|
config, [&](int i, const Project::Entry& entry) {
|
||||||
|
if (!matcher.IsMatch(entry.filename))
|
||||||
|
return;
|
||||||
optional<std::string> content = ReadContent(entry.filename);
|
optional<std::string> content = ReadContent(entry.filename);
|
||||||
if (!content) {
|
if (!content) {
|
||||||
LOG_S(ERROR) << "When freshening index, cannot read file "
|
LOG_S(ERROR) << "When freshening index, cannot read file "
|
||||||
|
Loading…
Reference in New Issue
Block a user