From 76785105ed8976a37aa85d983c999ff2f099d975 Mon Sep 17 00:00:00 2001 From: Josh Elsasser Date: Sun, 26 Nov 2017 14:20:43 -0800 Subject: [PATCH] Add an option to disable EmitProgress methods during indexing --- src/command_line.cc | 24 +++++++++++++----------- src/config.h | 4 ++++ 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/command_line.cc b/src/command_line.cc index 02f2db29..bd9e4129 100644 --- a/src/command_line.cc +++ b/src/command_line.cc @@ -796,16 +796,18 @@ struct IndexManager { } }; -// Sends indexing progress to client. -void EmitProgress(QueueManager* queue) { - Out_Progress out; - out.params.indexRequestCount = queue->index_request.Size(); - out.params.doIdMapCount = queue->do_id_map.Size(); - out.params.loadPreviousIndexCount = queue->load_previous_index.Size(); - out.params.onIdMappedCount = queue->on_id_mapped.Size(); - out.params.onIndexedCount = queue->on_indexed.Size(); +// Send indexing progress to client if reporting is enabled. +void EmitProgress(Config *config, QueueManager* queue) { + if (config->enableProgressReports) { + Out_Progress out; + out.params.indexRequestCount = queue->index_request.Size(); + out.params.doIdMapCount = queue->do_id_map.Size(); + out.params.loadPreviousIndexCount = queue->load_previous_index.Size(); + out.params.onIdMappedCount = queue->on_id_mapped.Size(); + out.params.onIndexedCount = queue->on_indexed.Size(); - IpcManager::instance()->SendOutMessageToClient(IpcId::Cout, out); + IpcManager::instance()->SendOutMessageToClient(IpcId::Cout, out); + } } } // namespace @@ -1211,7 +1213,7 @@ WorkThread::Result IndexMain(Config* config, WorkingFiles* working_files, MultiQueueWaiter* waiter, QueueManager* queue) { - EmitProgress(queue); + EmitProgress(config, queue); // TODO: dispose of index after it is not used for a while. ClangIndex index; @@ -1256,7 +1258,7 @@ bool QueryDb_ImportMain(Config* config, ImportManager* import_manager, QueueManager* queue, WorkingFiles* working_files) { - EmitProgress(queue); + EmitProgress(config, queue); bool did_work = false; diff --git a/src/config.h b/src/config.h index f72c7153..d8d2b2af 100644 --- a/src/config.h +++ b/src/config.h @@ -36,6 +36,9 @@ struct Config { // If false, the index will not be loaded from a previous run. bool enableCacheRead = true; + // If true, cquery will send progress reports while indexing + bool enableProgressReports = true; + // If true, document links are reported for #include directives. bool showDocumentLinksOnIncludes = true; @@ -87,6 +90,7 @@ MAKE_REFLECT_STRUCT(Config, enableIndexing, enableCacheWrite, enableCacheRead, + enableProgressReports, includeCompletionMaximumPathLength, includeCompletionWhitelistLiteralEnding,