Skip to content

Commit df17175

Browse files
scturtleMaskRay
authored andcommitted
Filter deps with index.blacklist. (#64)
1 parent 5c0a146 commit df17175

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/pipeline.cc

+14-2
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ std::unique_ptr<IndexFile> RawCacheLoad(const std::string &path) {
141141
}
142142

143143
bool Indexer_Parse(DiagnosticsPublisher *diag_pub, WorkingFiles *working_files,
144-
Project *project, VFS *vfs) {
144+
Project *project, VFS *vfs, const GroupMatch &matcher) {
145145
std::optional<Index_Request> opt_request = index_request->TryPopFront();
146146
if (!opt_request)
147147
return false;
@@ -155,6 +155,11 @@ bool Indexer_Parse(DiagnosticsPublisher *diag_pub, WorkingFiles *working_files,
155155
return false;
156156
}
157157

158+
if (std::string reason; !matcher.IsMatch(request.path, &reason)) {
159+
LOG_S(INFO) << "skip " << request.path << " for " << reason;
160+
return false;
161+
}
162+
158163
Project::Entry entry;
159164
{
160165
std::lock_guard<std::mutex> lock(project->mutex_);
@@ -247,6 +252,12 @@ bool Indexer_Parse(DiagnosticsPublisher *diag_pub, WorkingFiles *working_files,
247252
std::string path = curr->path;
248253
if (!(vfs->Stamp(path, curr->last_write_time) || path == path_to_index))
249254
continue;
255+
if (std::string reason; !matcher.IsMatch(path, &reason)) {
256+
LOG_S(INFO) << "skip emitting and storing index of " << path << " for "
257+
<< reason;
258+
continue;
259+
}
260+
250261
LOG_S(INFO) << "emit index for " << path;
251262
prev = RawCacheLoad(path);
252263

@@ -295,8 +306,9 @@ void Init() {
295306

296307
void Indexer_Main(DiagnosticsPublisher *diag_pub, VFS *vfs, Project *project,
297308
WorkingFiles *working_files) {
309+
GroupMatch matcher(g_config->index.whitelist, g_config->index.blacklist);
298310
while (true)
299-
if (!Indexer_Parse(diag_pub, working_files, project, vfs))
311+
if (!Indexer_Parse(diag_pub, working_files, project, vfs, matcher))
300312
indexer_waiter->Wait(index_request);
301313
}
302314

0 commit comments

Comments
 (0)