From df1717538f24d37ac6be3abab5dab21c16a0620a Mon Sep 17 00:00:00 2001 From: scturtle Date: Thu, 30 Aug 2018 23:47:48 +0800 Subject: [PATCH] Filter deps with `index.blacklist`. (#64) --- src/pipeline.cc | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/pipeline.cc b/src/pipeline.cc index 0a875c71..2f7e08cf 100644 --- a/src/pipeline.cc +++ b/src/pipeline.cc @@ -141,7 +141,7 @@ std::unique_ptr RawCacheLoad(const std::string &path) { } bool Indexer_Parse(DiagnosticsPublisher *diag_pub, WorkingFiles *working_files, - Project *project, VFS *vfs) { + Project *project, VFS *vfs, const GroupMatch &matcher) { std::optional opt_request = index_request->TryPopFront(); if (!opt_request) return false; @@ -155,6 +155,11 @@ bool Indexer_Parse(DiagnosticsPublisher *diag_pub, WorkingFiles *working_files, return false; } + if (std::string reason; !matcher.IsMatch(request.path, &reason)) { + LOG_S(INFO) << "skip " << request.path << " for " << reason; + return false; + } + Project::Entry entry; { std::lock_guard lock(project->mutex_); @@ -247,6 +252,12 @@ bool Indexer_Parse(DiagnosticsPublisher *diag_pub, WorkingFiles *working_files, std::string path = curr->path; if (!(vfs->Stamp(path, curr->last_write_time) || path == path_to_index)) continue; + if (std::string reason; !matcher.IsMatch(path, &reason)) { + LOG_S(INFO) << "skip emitting and storing index of " << path << " for " + << reason; + continue; + } + LOG_S(INFO) << "emit index for " << path; prev = RawCacheLoad(path); @@ -295,8 +306,9 @@ void Init() { void Indexer_Main(DiagnosticsPublisher *diag_pub, VFS *vfs, Project *project, WorkingFiles *working_files) { + GroupMatch matcher(g_config->index.whitelist, g_config->index.blacklist); while (true) - if (!Indexer_Parse(diag_pub, working_files, project, vfs)) + if (!Indexer_Parse(diag_pub, working_files, project, vfs, matcher)) indexer_waiter->Wait(index_request); }