mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-28 18:41:57 +00:00
pipeline
This commit is contained in:
parent
8e4d62212b
commit
f9befbd5fb
@ -30,7 +30,7 @@ using llvm::Timer;
|
|||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
struct IndexParam {
|
struct IndexParam {
|
||||||
std::map<llvm::sys::fs::UniqueID, std::string> SeenUniqueID;
|
std::unordered_map<llvm::sys::fs::UniqueID, std::string> SeenUniqueID;
|
||||||
std::unordered_map<std::string, FileContents> file_contents;
|
std::unordered_map<std::string, FileContents> file_contents;
|
||||||
std::unordered_map<std::string, int64_t> file2write_time;
|
std::unordered_map<std::string, int64_t> file2write_time;
|
||||||
llvm::DenseMap<const Decl*, Usr> Decl2usr;
|
llvm::DenseMap<const Decl*, Usr> Decl2usr;
|
||||||
|
@ -79,35 +79,22 @@ ThreadedQueue<Index_Request>* index_request;
|
|||||||
ThreadedQueue<IndexUpdate>* on_indexed;
|
ThreadedQueue<IndexUpdate>* on_indexed;
|
||||||
ThreadedQueue<Stdout_Request>* for_stdout;
|
ThreadedQueue<Stdout_Request>* for_stdout;
|
||||||
|
|
||||||
// Checks if |path| needs to be reparsed. This will modify cached state
|
bool CacheInvalid(VFS *vfs, IndexFile *prev, const std::string &path,
|
||||||
// such that calling this function twice with the same path may return true
|
|
||||||
// the first time but will return false the second.
|
|
||||||
//
|
|
||||||
// |from|: The file which generated the parse request for this file.
|
|
||||||
bool FileNeedsParse(int64_t write_time,
|
|
||||||
VFS* vfs,
|
|
||||||
bool is_interactive,
|
|
||||||
IndexFile* opt_previous_index,
|
|
||||||
const std::string& path,
|
|
||||||
const std::vector<std::string> &args,
|
const std::vector<std::string> &args,
|
||||||
const std::optional<std::string> &from) {
|
const std::optional<std::string> &from) {
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(vfs->mutex);
|
std::lock_guard<std::mutex> lock(vfs->mutex);
|
||||||
if (vfs->state[path].timestamp < write_time) {
|
if (prev->last_write_time < vfs->state[path].timestamp) {
|
||||||
LOG_S(INFO) << "timestamp changed for " << path
|
LOG_S(INFO) << "timestamp changed for " << path
|
||||||
<< (from ? " (via " + *from + ")" : std::string());
|
<< (from ? " (via " + *from + ")" : std::string());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Command-line arguments changed.
|
if (prev->args != args) {
|
||||||
if (opt_previous_index) {
|
|
||||||
auto& prev_args = opt_previous_index->args;
|
|
||||||
if (prev_args != args) {
|
|
||||||
LOG_S(INFO) << "args changed for " << path << (from ? " (via " + *from + ")" : std::string());
|
LOG_S(INFO) << "args changed for " << path << (from ? " (via " + *from + ")" : std::string());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
@ -184,18 +171,15 @@ bool Indexer_Parse(DiagnosticsPublisher* diag_pub,
|
|||||||
std::optional<int64_t> write_time = LastWriteTime(path_to_index);
|
std::optional<int64_t> write_time = LastWriteTime(path_to_index);
|
||||||
if (!write_time)
|
if (!write_time)
|
||||||
return true;
|
return true;
|
||||||
// FIXME Don't drop
|
int reparse = vfs->Stamp(path_to_index, *write_time);
|
||||||
if (!vfs->Mark(path_to_index, g_thread_id, 1))
|
if (!vfs->Mark(path_to_index, g_thread_id, 1) && !reparse)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
int reparse; // request.is_interactive;
|
|
||||||
prev = RawCacheLoad(path_to_index);
|
prev = RawCacheLoad(path_to_index);
|
||||||
if (!prev)
|
if (!prev)
|
||||||
reparse = 2;
|
reparse = 2;
|
||||||
else {
|
else {
|
||||||
reparse = vfs->Stamp(path_to_index, prev->last_write_time);
|
if (CacheInvalid(vfs, prev.get(), path_to_index, entry.args, std::nullopt))
|
||||||
if (FileNeedsParse(*write_time, vfs, request.is_interactive, &*prev,
|
|
||||||
path_to_index, entry.args, std::nullopt))
|
|
||||||
reparse = 2;
|
reparse = 2;
|
||||||
int reparseForDep = g_config->index.reparseForDependency;
|
int reparseForDep = g_config->index.reparseForDependency;
|
||||||
if (reparseForDep > 1 || (reparseForDep == 1 && !Project::loaded))
|
if (reparseForDep > 1 || (reparseForDep == 1 && !Project::loaded))
|
||||||
@ -273,7 +257,7 @@ bool Indexer_Parse(DiagnosticsPublisher* diag_pub,
|
|||||||
timer.stopTimer();
|
timer.stopTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
vfs->Reset(path_to_index);
|
vfs->Reset(path);
|
||||||
if (entry.id >= 0) {
|
if (entry.id >= 0) {
|
||||||
std::lock_guard<std::mutex> lock(project->mutex_);
|
std::lock_guard<std::mutex> lock(project->mutex_);
|
||||||
for (auto& dep : curr->dependencies)
|
for (auto& dep : curr->dependencies)
|
||||||
|
Loading…
Reference in New Issue
Block a user