From 3c0b2ff0423e9d9bdb45d3df4d87f67fd0091799 Mon Sep 17 00:00:00 2001 From: Jacob Dufault Date: Fri, 29 Dec 2017 10:45:10 -0600 Subject: [PATCH] Move most of import_pipeline.cc into anonymous namespace --- src/import_pipeline.cc | 77 ++++++++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 37 deletions(-) diff --git a/src/import_pipeline.cc b/src/import_pipeline.cc index b027f56a..bbbee454 100644 --- a/src/import_pipeline.cc +++ b/src/import_pipeline.cc @@ -20,8 +20,7 @@ #include #include -ImportPipelineStatus::ImportPipelineStatus() : num_active_threads(0) {} - +namespace { // Send indexing progress to client if reporting is enabled. void EmitProgress(Config* config) { if (config->enableProgressReports) { @@ -218,41 +217,6 @@ std::vector DoParseFile( return result; } -// Index a file using an already-parsed translation unit from code completion. -// Since most of the time for indexing a file comes from parsing, we can do -// real-time indexing. -// TODO: add option to disable this. -void IndexWithTuFromCodeCompletion( - FileConsumerSharedState* file_consumer_shared, - ClangTranslationUnit* tu, - const std::vector& file_contents, - const std::string& path, - const std::vector& args) { - file_consumer_shared->Reset(path); - - PerformanceImportFile perf; - ClangIndex index; - std::vector> indexes = ParseWithTu( - file_consumer_shared, &perf, tu, &index, path, args, file_contents); - - std::vector result; - for (std::unique_ptr& new_index : indexes) { - Timer time; - - // When main thread does IdMap request it will request the previous index if - // needed. - LOG_S(INFO) << "Emitting index result for " << new_index->path; - result.push_back(Index_DoIdMap(std::move(new_index), perf, - true /*is_interactive*/, - true /*write_to_disk*/)); - } - - LOG_IF_S(WARNING, result.size() > 1) - << "Code completion index update generated more than one index"; - - QueueManager::instance()->do_id_map.EnqueueAll(std::move(result)); -} - std::vector ParseFile( Config* config, WorkingFiles* working_files, @@ -412,6 +376,45 @@ bool IndexMergeIndexUpdates() { } } +} // namespace + +ImportPipelineStatus::ImportPipelineStatus() : num_active_threads(0) {} + +// Index a file using an already-parsed translation unit from code completion. +// Since most of the time for indexing a file comes from parsing, we can do +// real-time indexing. +// TODO: add option to disable this. +void IndexWithTuFromCodeCompletion( + FileConsumerSharedState* file_consumer_shared, + ClangTranslationUnit* tu, + const std::vector& file_contents, + const std::string& path, + const std::vector& args) { + file_consumer_shared->Reset(path); + + PerformanceImportFile perf; + ClangIndex index; + std::vector> indexes = ParseWithTu( + file_consumer_shared, &perf, tu, &index, path, args, file_contents); + + std::vector result; + for (std::unique_ptr& new_index : indexes) { + Timer time; + + // When main thread does IdMap request it will request the previous index if + // needed. + LOG_S(INFO) << "Emitting index result for " << new_index->path; + result.push_back(Index_DoIdMap(std::move(new_index), perf, + true /*is_interactive*/, + true /*write_to_disk*/)); + } + + LOG_IF_S(WARNING, result.size() > 1) + << "Code completion index update generated more than one index"; + + QueueManager::instance()->do_id_map.EnqueueAll(std::move(result)); +} + void Indexer_Main(Config* config, FileConsumerSharedState* file_consumer_shared, TimestampManager* timestamp_manager,