mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-24 08:35:08 +00:00
Support indexing non-existent files in index.onChange:true mode
This commit is contained in:
parent
0e8c9db44d
commit
cdc24e9731
@ -54,11 +54,11 @@ void MessageHandler::workspace_didChangeWatchedFiles(
|
|||||||
if (cur[0] == '.')
|
if (cur[0] == '.')
|
||||||
return;
|
return;
|
||||||
|
|
||||||
IndexMode mode =
|
|
||||||
wfiles->GetFile(path) ? IndexMode::Normal : IndexMode::Background;
|
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case FileChangeType::Created:
|
case FileChangeType::Created:
|
||||||
case FileChangeType::Changed: {
|
case FileChangeType::Changed: {
|
||||||
|
IndexMode mode =
|
||||||
|
wfiles->GetFile(path) ? IndexMode::Normal : IndexMode::Background;
|
||||||
pipeline::Index(path, {}, mode, true);
|
pipeline::Index(path, {}, mode, true);
|
||||||
if (event.type == FileChangeType::Changed) {
|
if (event.type == FileChangeType::Changed) {
|
||||||
if (mode == IndexMode::Normal)
|
if (mode == IndexMode::Normal)
|
||||||
@ -69,7 +69,7 @@ void MessageHandler::workspace_didChangeWatchedFiles(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case FileChangeType::Deleted:
|
case FileChangeType::Deleted:
|
||||||
pipeline::Index(path, {}, mode, false);
|
pipeline::Index(path, {}, IndexMode::Delete, false);
|
||||||
manager->OnClose(path);
|
manager->OnClose(path);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -224,7 +224,6 @@ bool Indexer_Parse(SemaManager *completion, WorkingFiles *wfiles,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// must_exist is currently unused.
|
|
||||||
Project::Entry entry =
|
Project::Entry entry =
|
||||||
project->FindEntry(request.path, true, request.must_exist);
|
project->FindEntry(request.path, true, request.must_exist);
|
||||||
if (request.must_exist && entry.filename.empty())
|
if (request.must_exist && entry.filename.empty())
|
||||||
@ -234,25 +233,28 @@ bool Indexer_Parse(SemaManager *completion, WorkingFiles *wfiles,
|
|||||||
std::string path_to_index = entry.filename;
|
std::string path_to_index = entry.filename;
|
||||||
std::unique_ptr<IndexFile> prev;
|
std::unique_ptr<IndexFile> prev;
|
||||||
|
|
||||||
bool deleted = false, no_linkage = g_config->index.initialNoLinkage ||
|
bool deleted = request.mode == IndexMode::Delete,
|
||||||
request.mode != IndexMode::Background;
|
no_linkage = g_config->index.initialNoLinkage ||
|
||||||
|
request.mode != IndexMode::Background;
|
||||||
int reparse = 0;
|
int reparse = 0;
|
||||||
std::optional<int64_t> write_time = LastWriteTime(path_to_index);
|
|
||||||
if (!write_time) {
|
|
||||||
deleted = true;
|
|
||||||
} else {
|
|
||||||
if (vfs->Stamp(path_to_index, *write_time, no_linkage ? 2 : 0))
|
|
||||||
reparse = no_linkage ? 2 : 1;
|
|
||||||
if (request.path != path_to_index) {
|
|
||||||
std::optional<int64_t> mtime1 = LastWriteTime(request.path);
|
|
||||||
if (!mtime1)
|
|
||||||
deleted = true;
|
|
||||||
else if (vfs->Stamp(request.path, *mtime1, no_linkage ? 2 : 0))
|
|
||||||
reparse = 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (deleted)
|
if (deleted)
|
||||||
reparse = 2;
|
reparse = 2;
|
||||||
|
else if (!(g_config->index.onChange && wfiles->GetFile(path_to_index))) {
|
||||||
|
std::optional<int64_t> write_time = LastWriteTime(path_to_index);
|
||||||
|
if (!write_time) {
|
||||||
|
deleted = true;
|
||||||
|
} else {
|
||||||
|
if (vfs->Stamp(path_to_index, *write_time, no_linkage ? 2 : 0))
|
||||||
|
reparse = no_linkage ? 2 : 1;
|
||||||
|
if (request.path != path_to_index) {
|
||||||
|
std::optional<int64_t> mtime1 = LastWriteTime(request.path);
|
||||||
|
if (!mtime1)
|
||||||
|
deleted = true;
|
||||||
|
else if (vfs->Stamp(request.path, *mtime1, no_linkage ? 2 : 0))
|
||||||
|
reparse = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (g_config->index.onChange) {
|
if (g_config->index.onChange) {
|
||||||
reparse = 2;
|
reparse = 2;
|
||||||
|
@ -30,6 +30,7 @@ struct VFS {
|
|||||||
};
|
};
|
||||||
|
|
||||||
enum class IndexMode {
|
enum class IndexMode {
|
||||||
|
Delete,
|
||||||
Background,
|
Background,
|
||||||
OnChange,
|
OnChange,
|
||||||
Normal,
|
Normal,
|
||||||
|
Loading…
Reference in New Issue
Block a user