Move most of import_pipeline.cc into anonymous namespace

This commit is contained in:
Jacob Dufault 2017-12-29 10:45:10 -06:00
parent c596e55dcc
commit 3c0b2ff042

View File

@ -20,8 +20,7 @@
#include <string> #include <string>
#include <vector> #include <vector>
ImportPipelineStatus::ImportPipelineStatus() : num_active_threads(0) {} namespace {
// Send indexing progress to client if reporting is enabled. // Send indexing progress to client if reporting is enabled.
void EmitProgress(Config* config) { void EmitProgress(Config* config) {
if (config->enableProgressReports) { if (config->enableProgressReports) {
@ -218,41 +217,6 @@ std::vector<Index_DoIdMap> DoParseFile(
return result; 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<CXUnsavedFile>& file_contents,
const std::string& path,
const std::vector<std::string>& args) {
file_consumer_shared->Reset(path);
PerformanceImportFile perf;
ClangIndex index;
std::vector<std::unique_ptr<IndexFile>> indexes = ParseWithTu(
file_consumer_shared, &perf, tu, &index, path, args, file_contents);
std::vector<Index_DoIdMap> result;
for (std::unique_ptr<IndexFile>& 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<Index_DoIdMap> ParseFile( std::vector<Index_DoIdMap> ParseFile(
Config* config, Config* config,
WorkingFiles* working_files, 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<CXUnsavedFile>& file_contents,
const std::string& path,
const std::vector<std::string>& args) {
file_consumer_shared->Reset(path);
PerformanceImportFile perf;
ClangIndex index;
std::vector<std::unique_ptr<IndexFile>> indexes = ParseWithTu(
file_consumer_shared, &perf, tu, &index, path, args, file_contents);
std::vector<Index_DoIdMap> result;
for (std::unique_ptr<IndexFile>& 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, void Indexer_Main(Config* config,
FileConsumerSharedState* file_consumer_shared, FileConsumerSharedState* file_consumer_shared,
TimestampManager* timestamp_manager, TimestampManager* timestamp_manager,