mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-29 19:07:08 +00:00
Fix spurious "Failed to index" errors
This commit is contained in:
parent
bf698b85d4
commit
4ea0dee1c9
@ -1220,15 +1220,18 @@ std::vector<std::unique_ptr<IndexFile>>
|
|||||||
Index(CompletionManager *completion, WorkingFiles *wfiles, VFS *vfs,
|
Index(CompletionManager *completion, WorkingFiles *wfiles, VFS *vfs,
|
||||||
const std::string &opt_wdir, const std::string &file,
|
const std::string &opt_wdir, const std::string &file,
|
||||||
const std::vector<const char *> &args,
|
const std::vector<const char *> &args,
|
||||||
const std::vector<std::pair<std::string, std::string>> &remapped) {
|
const std::vector<std::pair<std::string, std::string>> &remapped, bool &ok) {
|
||||||
|
ok = true;
|
||||||
if (!g_config->index.enabled)
|
if (!g_config->index.enabled)
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
auto PCH = std::make_shared<PCHContainerOperations>();
|
auto PCH = std::make_shared<PCHContainerOperations>();
|
||||||
llvm::IntrusiveRefCntPtr<vfs::FileSystem> FS = vfs::getRealFileSystem();
|
llvm::IntrusiveRefCntPtr<vfs::FileSystem> FS = vfs::getRealFileSystem();
|
||||||
std::shared_ptr<CompilerInvocation> CI = BuildCompilerInvocation(args, FS);
|
std::shared_ptr<CompilerInvocation> CI = BuildCompilerInvocation(args, FS);
|
||||||
|
// e.g. .s
|
||||||
if (!CI)
|
if (!CI)
|
||||||
return {};
|
return {};
|
||||||
|
ok = false;
|
||||||
// -fparse-all-comments enables documentation in the indexer and in
|
// -fparse-all-comments enables documentation in the indexer and in
|
||||||
// code completion.
|
// code completion.
|
||||||
CI->getLangOpts()->CommentOpts.ParseAllComments =
|
CI->getLangOpts()->CommentOpts.ParseAllComments =
|
||||||
@ -1288,7 +1291,6 @@ Index(CompletionManager *completion, WorkingFiles *wfiles, VFS *vfs,
|
|||||||
std::unique_ptr<FrontendAction> Action = createIndexingAction(
|
std::unique_ptr<FrontendAction> Action = createIndexingAction(
|
||||||
DataConsumer, IndexOpts, std::make_unique<IndexFrontendAction>(param));
|
DataConsumer, IndexOpts, std::make_unique<IndexFrontendAction>(param));
|
||||||
|
|
||||||
bool ok = false;
|
|
||||||
{
|
{
|
||||||
llvm::CrashRecoveryContext CRC;
|
llvm::CrashRecoveryContext CRC;
|
||||||
auto parse = [&]() {
|
auto parse = [&]() {
|
||||||
|
@ -292,5 +292,6 @@ std::vector<std::unique_ptr<IndexFile>>
|
|||||||
Index(CompletionManager *complete, WorkingFiles *wfiles, VFS *vfs,
|
Index(CompletionManager *complete, WorkingFiles *wfiles, VFS *vfs,
|
||||||
const std::string &opt_wdir, const std::string &file,
|
const std::string &opt_wdir, const std::string &file,
|
||||||
const std::vector<const char *> &args,
|
const std::vector<const char *> &args,
|
||||||
const std::vector<std::pair<std::string, std::string>> &remapped);
|
const std::vector<std::pair<std::string, std::string>> &remapped,
|
||||||
}
|
bool &ok);
|
||||||
|
} // namespace ccls::idx
|
||||||
|
@ -266,10 +266,11 @@ bool Indexer_Parse(CompletionManager *completion, WorkingFiles *wfiles,
|
|||||||
if (content.size())
|
if (content.size())
|
||||||
remapped.emplace_back(path_to_index, content);
|
remapped.emplace_back(path_to_index, content);
|
||||||
}
|
}
|
||||||
|
bool ok;
|
||||||
auto indexes = idx::Index(completion, wfiles, vfs, entry.directory,
|
auto indexes = idx::Index(completion, wfiles, vfs, entry.directory,
|
||||||
path_to_index, entry.args, remapped);
|
path_to_index, entry.args, remapped, ok);
|
||||||
|
|
||||||
if (indexes.empty()) {
|
if (!ok) {
|
||||||
if (g_config->index.enabled && request.id.Valid()) {
|
if (g_config->index.enabled && request.id.Valid()) {
|
||||||
Out_Error out;
|
Out_Error out;
|
||||||
out.id = request.id;
|
out.id = request.id;
|
||||||
|
@ -305,7 +305,8 @@ bool RunIndexTests(const std::string &filter_path, bool enable_update) {
|
|||||||
std::vector<const char *> cargs;
|
std::vector<const char *> cargs;
|
||||||
for (auto &arg : flags)
|
for (auto &arg : flags)
|
||||||
cargs.push_back(arg.c_str());
|
cargs.push_back(arg.c_str());
|
||||||
auto dbs = ccls::idx::Index(&completion, &wfiles, &vfs, "", path, cargs, {});
|
bool ok;
|
||||||
|
auto dbs = ccls::idx::Index(&completion, &wfiles, &vfs, "", path, cargs, {}, ok);
|
||||||
|
|
||||||
for (const auto &entry : all_expected_output) {
|
for (const auto &entry : all_expected_output) {
|
||||||
const std::string &expected_path = entry.first;
|
const std::string &expected_path = entry.first;
|
||||||
|
Loading…
Reference in New Issue
Block a user