Add config->diagnostics.{blacklist,whitelist}

This commit is contained in:
Fangrui Song 2018-03-05 19:03:39 -08:00
parent df55e79e4e
commit e6c4d32a6b
5 changed files with 12 additions and 10 deletions

View File

@ -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,

View File

@ -4,8 +4,11 @@
#include <chrono>
DiagnosticsEngine::DiagnosticsEngine(Config* config)
: match_(config->diagnostics.whitelist, config->diagnostics.blacklist) {}
void DiagnosticsEngine::Init(Config* config) {
frequencyMs_ = config->diagnostics.frequencyMs;
match_ = MakeUnique<GroupMatch>(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::milliseconds>(
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;

View File

@ -4,13 +4,12 @@
#include "working_files.h"
class DiagnosticsEngine {
int frequencyMs_ = 0;
GroupMatch match_;
std::unique_ptr<GroupMatch> 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<lsDiagnostic> diagnostics);

View File

@ -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;

View File

@ -582,7 +582,7 @@ struct InitializeHandler : BaseMessageHandler<Ipc_InitializeRequest> {
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,