diff --git a/src/command_line.cc b/src/command_line.cc index 803967f4..52414460 100644 --- a/src/command_line.cc +++ b/src/command_line.cc @@ -178,7 +178,7 @@ void RunQueryDbThread(const std::string& bin_name, SemanticHighlightSymbolCache semantic_cache; WorkingFiles working_files; FileConsumerSharedState file_consumer_shared; - DiagnosticsEngine diag_engine(config); + DiagnosticsEngine diag_engine; ClangCompleteManager clang_complete( config, &project, &working_files, diff --git a/src/diagnostics_engine.cc b/src/diagnostics_engine.cc index cd77eb96..2c2fa92f 100644 --- a/src/diagnostics_engine.cc +++ b/src/diagnostics_engine.cc @@ -4,8 +4,11 @@ #include -DiagnosticsEngine::DiagnosticsEngine(Config* config) - : match_(config->diagnostics.whitelist, config->diagnostics.blacklist) {} +void DiagnosticsEngine::Init(Config* config) { + frequencyMs_ = config->diagnostics.frequencyMs; + match_ = MakeUnique(config->diagnostics.whitelist, config->diagnostics.blacklist); +} + void DiagnosticsEngine::Publish(WorkingFiles* working_files, std::string path, @@ -19,7 +22,7 @@ void DiagnosticsEngine::Publish(WorkingFiles* working_files, int64_t now = std::chrono::duration_cast( std::chrono::high_resolution_clock::now().time_since_epoch()).count(); if (frequencyMs_ >= 0 && (nextPublish_ <= now || diagnostics.empty()) && - match_.IsMatch(path)) { + match_->IsMatch(path)) { nextPublish_ = now + frequencyMs_; Out_TextDocumentPublishDiagnostics out; diff --git a/src/diagnostics_engine.h b/src/diagnostics_engine.h index 40562e26..ec1066fb 100644 --- a/src/diagnostics_engine.h +++ b/src/diagnostics_engine.h @@ -4,13 +4,12 @@ #include "working_files.h" class DiagnosticsEngine { - int frequencyMs_ = 0; - GroupMatch match_; + std::unique_ptr match_; int64_t nextPublish_ = 0; + int frequencyMs_; public: - DiagnosticsEngine(Config* config); - void SetFrequencyMs(int ms) { frequencyMs_ = ms; } + void Init(Config*); void Publish(WorkingFiles* working_files, std::string path, std::vector diagnostics); diff --git a/src/import_pipeline.cc b/src/import_pipeline.cc index 0c3f1a7e..88e19583 100644 --- a/src/import_pipeline.cc +++ b/src/import_pipeline.cc @@ -792,7 +792,7 @@ TEST_SUITE("ImportPipeline") { QueueManager* queue = nullptr; Config config; - DiagnosticsEngine diag_engine{&config}; + DiagnosticsEngine diag_engine; WorkingFiles working_files; FileConsumerSharedState file_consumer_shared; TimestampManager timestamp_manager; diff --git a/src/messages/initialize.cc b/src/messages/initialize.cc index 9ff5b740..27352ffc 100644 --- a/src/messages/initialize.cc +++ b/src/messages/initialize.cc @@ -582,7 +582,7 @@ struct InitializeHandler : BaseMessageHandler { EscapeFileName(config->projectRoot)); Timer time; - diag_engine->SetFrequencyMs(config->diagnostics.frequencyMs); + diag_engine->Init(config); // Open up / load the project. project->Load(config, config->extraClangArguments,