mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-22 07:35:08 +00:00
Response "being indexed" instead of "not found".
This commit is contained in:
parent
77e9ea1b77
commit
4c2dff39ef
@ -19,6 +19,7 @@ MessageHandler::MessageHandler() {
|
||||
std::vector<MessageHandler*>* MessageHandler::message_handlers = nullptr;
|
||||
|
||||
bool FindFileOrFail(QueryDatabase* db,
|
||||
const Project *project,
|
||||
optional<lsRequestId> id,
|
||||
const std::string& absolute_path,
|
||||
QueryFile** out_query_file,
|
||||
@ -39,7 +40,12 @@ bool FindFileOrFail(QueryDatabase* db,
|
||||
if (out_file_id)
|
||||
*out_file_id = QueryFileId((size_t)-1);
|
||||
|
||||
LOG_S(INFO) << "Unable to find file \"" << absolute_path << "\"";
|
||||
bool indexing = project->absolute_path_to_entry_index_.find(absolute_path) !=
|
||||
project->absolute_path_to_entry_index_.end();
|
||||
if (indexing)
|
||||
LOG_S(INFO) << "\"" << absolute_path << "\" is being indexed.";
|
||||
else
|
||||
LOG_S(INFO) << "Unable to find file \"" << absolute_path << "\"";
|
||||
/*
|
||||
LOG_S(INFO) << "Files (size=" << db->usr_to_file.size() << "): "
|
||||
<< StringJoinMap(db->usr_to_file,
|
||||
@ -51,8 +57,13 @@ bool FindFileOrFail(QueryDatabase* db,
|
||||
if (id) {
|
||||
Out_Error out;
|
||||
out.id = *id;
|
||||
out.error.code = lsErrorCodes::InternalError;
|
||||
out.error.message = "Unable to find file " + absolute_path;
|
||||
if (indexing) {
|
||||
out.error.code = lsErrorCodes::ServerNotInitialized;
|
||||
out.error.message = absolute_path + " is being indexed.";
|
||||
} else {
|
||||
out.error.code = lsErrorCodes::InternalError;
|
||||
out.error.message = "Unable to find file " + absolute_path;
|
||||
}
|
||||
QueueManager::WriteStdout(IpcId::Unknown, out);
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "ipc.h"
|
||||
#include "language_server_api.h"
|
||||
#include "query.h"
|
||||
#include "project.h"
|
||||
|
||||
#include <optional.h>
|
||||
|
||||
@ -17,7 +18,6 @@ struct ImportManager;
|
||||
struct ImportPipelineStatus;
|
||||
struct IncludeComplete;
|
||||
struct MultiQueueWaiter;
|
||||
struct Project;
|
||||
struct QueryDatabase;
|
||||
struct SemanticHighlightSymbolCache;
|
||||
struct TimestampManager;
|
||||
@ -75,6 +75,7 @@ struct BaseMessageHandler : MessageHandler {
|
||||
};
|
||||
|
||||
bool FindFileOrFail(QueryDatabase* db,
|
||||
const Project *project,
|
||||
optional<lsRequestId> id,
|
||||
const std::string& absolute_path,
|
||||
QueryFile** out_query_file,
|
||||
|
@ -14,7 +14,7 @@ REGISTER_IPC_MESSAGE(Ipc_CqueryBase);
|
||||
struct CqueryBaseHandler : BaseMessageHandler<Ipc_CqueryBase> {
|
||||
void Run(Ipc_CqueryBase* request) override {
|
||||
QueryFile* file;
|
||||
if (!FindFileOrFail(db, request->id,
|
||||
if (!FindFileOrFail(db, project, request->id,
|
||||
request->params.textDocument.uri.GetPath(), &file)) {
|
||||
return;
|
||||
}
|
||||
@ -44,4 +44,4 @@ struct CqueryBaseHandler : BaseMessageHandler<Ipc_CqueryBase> {
|
||||
}
|
||||
};
|
||||
REGISTER_MESSAGE_HANDLER(CqueryBaseHandler);
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
@ -178,7 +178,7 @@ struct CqueryCallTreeInitialHandler
|
||||
: BaseMessageHandler<Ipc_CqueryCallTreeInitial> {
|
||||
void Run(Ipc_CqueryCallTreeInitial* request) override {
|
||||
QueryFile* file;
|
||||
if (!FindFileOrFail(db, request->id,
|
||||
if (!FindFileOrFail(db, project, request->id,
|
||||
request->params.textDocument.uri.GetPath(), &file)) {
|
||||
return;
|
||||
}
|
||||
@ -217,4 +217,4 @@ struct CqueryCallTreeExpandHandler
|
||||
}
|
||||
};
|
||||
REGISTER_MESSAGE_HANDLER(CqueryCallTreeExpandHandler);
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
@ -14,7 +14,7 @@ REGISTER_IPC_MESSAGE(Ipc_CqueryCallers);
|
||||
struct CqueryCallersHandler : BaseMessageHandler<Ipc_CqueryCallers> {
|
||||
void Run(Ipc_CqueryCallers* request) override {
|
||||
QueryFile* file;
|
||||
if (!FindFileOrFail(db, request->id,
|
||||
if (!FindFileOrFail(db, project, request->id,
|
||||
request->params.textDocument.uri.GetPath(), &file)) {
|
||||
return;
|
||||
}
|
||||
@ -42,4 +42,4 @@ struct CqueryCallersHandler : BaseMessageHandler<Ipc_CqueryCallers> {
|
||||
}
|
||||
};
|
||||
REGISTER_MESSAGE_HANDLER(CqueryCallersHandler);
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
@ -14,7 +14,7 @@ REGISTER_IPC_MESSAGE(Ipc_CqueryDerived);
|
||||
struct CqueryDerivedHandler : BaseMessageHandler<Ipc_CqueryDerived> {
|
||||
void Run(Ipc_CqueryDerived* request) override {
|
||||
QueryFile* file;
|
||||
if (!FindFileOrFail(db, request->id,
|
||||
if (!FindFileOrFail(db, project, request->id,
|
||||
request->params.textDocument.uri.GetPath(), &file)) {
|
||||
return;
|
||||
}
|
||||
@ -42,4 +42,4 @@ struct CqueryDerivedHandler : BaseMessageHandler<Ipc_CqueryDerived> {
|
||||
}
|
||||
};
|
||||
REGISTER_MESSAGE_HANDLER(CqueryDerivedHandler);
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
@ -25,7 +25,7 @@ struct CqueryDidViewHandler
|
||||
if (!working_file)
|
||||
return;
|
||||
QueryFile* file = nullptr;
|
||||
if (!FindFileOrFail(db, nullopt, path, &file))
|
||||
if (!FindFileOrFail(db, project, nullopt, path, &file))
|
||||
return;
|
||||
|
||||
clang_complete->NotifyView(path);
|
||||
@ -36,4 +36,4 @@ struct CqueryDidViewHandler
|
||||
}
|
||||
};
|
||||
REGISTER_MESSAGE_HANDLER(CqueryDidViewHandler);
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
@ -61,4 +61,4 @@ struct CqueryFreshenIndexHandler : MessageHandler {
|
||||
}
|
||||
};
|
||||
REGISTER_MESSAGE_HANDLER(CqueryFreshenIndexHandler);
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
@ -33,4 +33,4 @@ struct CqueryIndexFileHandler : BaseMessageHandler<Ipc_CqueryIndexFile> {
|
||||
}
|
||||
};
|
||||
REGISTER_MESSAGE_HANDLER(CqueryIndexFileHandler);
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
@ -167,7 +167,7 @@ struct CqueryTypeHierarchyTreeHandler
|
||||
: BaseMessageHandler<Ipc_CqueryTypeHierarchyTree> {
|
||||
void Run(Ipc_CqueryTypeHierarchyTree* request) override {
|
||||
QueryFile* file;
|
||||
if (!FindFileOrFail(db, request->id,
|
||||
if (!FindFileOrFail(db, project, request->id,
|
||||
request->params.textDocument.uri.GetPath(), &file))
|
||||
return;
|
||||
|
||||
@ -195,4 +195,4 @@ struct CqueryTypeHierarchyTreeHandler
|
||||
}
|
||||
};
|
||||
REGISTER_MESSAGE_HANDLER(CqueryTypeHierarchyTreeHandler);
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
@ -14,7 +14,7 @@ REGISTER_IPC_MESSAGE(Ipc_CqueryVars);
|
||||
struct CqueryVarsHandler : BaseMessageHandler<Ipc_CqueryVars> {
|
||||
void Run(Ipc_CqueryVars* request) override {
|
||||
QueryFile* file;
|
||||
if (!FindFileOrFail(db, request->id,
|
||||
if (!FindFileOrFail(db, project, request->id,
|
||||
request->params.textDocument.uri.GetPath(), &file)) {
|
||||
return;
|
||||
}
|
||||
@ -37,4 +37,4 @@ struct CqueryVarsHandler : BaseMessageHandler<Ipc_CqueryVars> {
|
||||
}
|
||||
};
|
||||
REGISTER_MESSAGE_HANDLER(CqueryVarsHandler);
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
@ -41,4 +41,4 @@ struct CqueryWaitHandler : MessageHandler {
|
||||
}
|
||||
};
|
||||
REGISTER_MESSAGE_HANDLER(CqueryWaitHandler);
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
@ -18,4 +18,4 @@ struct ExitHandler : MessageHandler {
|
||||
}
|
||||
};
|
||||
REGISTER_MESSAGE_HANDLER(ExitHandler);
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
@ -209,4 +209,4 @@ struct InitializeHandler : BaseMessageHandler<Ipc_InitializeRequest> {
|
||||
}
|
||||
};
|
||||
REGISTER_MESSAGE_HANDLER(InitializeHandler);
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
@ -312,7 +312,7 @@ struct TextDocumentCodeActionHandler
|
||||
|
||||
QueryFileId file_id;
|
||||
QueryFile* file;
|
||||
if (!FindFileOrFail(db, request->id,
|
||||
if (!FindFileOrFail(db, project, request->id,
|
||||
request->params.textDocument.uri.GetPath(), &file,
|
||||
&file_id)) {
|
||||
return;
|
||||
@ -593,4 +593,4 @@ TEST_SUITE("FindIncludeLine") {
|
||||
REQUIRE(FindIncludeLine(lines, "#include <e>") == 7);
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
@ -131,7 +131,7 @@ struct TextDocumentCodeLensHandler
|
||||
clang_complete->NotifyView(path);
|
||||
|
||||
QueryFile* file;
|
||||
if (!FindFileOrFail(db, request->id,
|
||||
if (!FindFileOrFail(db, project, request->id,
|
||||
request->params.textDocument.uri.GetPath(), &file)) {
|
||||
return;
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ struct TextDocumentDefinitionHandler
|
||||
void Run(Ipc_TextDocumentDefinition* request) override {
|
||||
QueryFileId file_id;
|
||||
QueryFile* file;
|
||||
if (!FindFileOrFail(db, request->id,
|
||||
if (!FindFileOrFail(db, project, request->id,
|
||||
request->params.textDocument.uri.GetPath(), &file,
|
||||
&file_id)) {
|
||||
return;
|
||||
|
@ -23,4 +23,4 @@ struct TextDocumentDidChangeHandler
|
||||
}
|
||||
};
|
||||
REGISTER_MESSAGE_HANDLER(TextDocumentDidChangeHandler);
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
@ -32,4 +32,4 @@ struct TextDocumentDidCloseHandler
|
||||
}
|
||||
};
|
||||
REGISTER_MESSAGE_HANDLER(TextDocumentDidCloseHandler);
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
@ -43,7 +43,7 @@ struct TextDocumentDidOpenHandler
|
||||
working_file->SetIndexContent(working_file->buffer_content);
|
||||
|
||||
QueryFile* file = nullptr;
|
||||
FindFileOrFail(db, nullopt, path, &file);
|
||||
FindFileOrFail(db, project, nullopt, path, &file);
|
||||
if (file && file->def) {
|
||||
EmitInactiveLines(working_file, file->def->inactive_regions);
|
||||
EmitSemanticHighlighting(db, semantic_cache, working_file, file);
|
||||
|
@ -48,7 +48,7 @@ struct TextDocumentDocumentLinkHandler
|
||||
|
||||
if (config->showDocumentLinksOnIncludes) {
|
||||
QueryFile* file;
|
||||
if (!FindFileOrFail(db, request->id,
|
||||
if (!FindFileOrFail(db, project, request->id,
|
||||
request->params.textDocument.uri.GetPath(), &file)) {
|
||||
return;
|
||||
}
|
||||
@ -86,4 +86,4 @@ struct TextDocumentDocumentLinkHandler
|
||||
}
|
||||
};
|
||||
REGISTER_MESSAGE_HANDLER(TextDocumentDocumentLinkHandler);
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
@ -32,7 +32,7 @@ struct TextDocumentDocumentSymbolHandler
|
||||
out.id = request->id;
|
||||
|
||||
QueryFile* file;
|
||||
if (!FindFileOrFail(db, request->id,
|
||||
if (!FindFileOrFail(db, project, request->id,
|
||||
request->params.textDocument.uri.GetPath(), &file)) {
|
||||
return;
|
||||
}
|
||||
@ -54,4 +54,4 @@ struct TextDocumentDocumentSymbolHandler
|
||||
}
|
||||
};
|
||||
REGISTER_MESSAGE_HANDLER(TextDocumentDocumentSymbolHandler);
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
@ -25,7 +25,7 @@ struct TextDocumentDocumentHighlightHandler
|
||||
void Run(Ipc_TextDocumentDocumentHighlight* request) override {
|
||||
QueryFileId file_id;
|
||||
QueryFile* file;
|
||||
if (!FindFileOrFail(db, request->id,
|
||||
if (!FindFileOrFail(db, project, request->id,
|
||||
request->params.textDocument.uri.GetPath(), &file,
|
||||
&file_id)) {
|
||||
return;
|
||||
@ -63,4 +63,4 @@ struct TextDocumentDocumentHighlightHandler
|
||||
}
|
||||
};
|
||||
REGISTER_MESSAGE_HANDLER(TextDocumentDocumentHighlightHandler);
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
@ -75,7 +75,7 @@ void Reflect(Writer& visitor, Out_TextDocumentHover& value) {
|
||||
struct TextDocumentHoverHandler : BaseMessageHandler<Ipc_TextDocumentHover> {
|
||||
void Run(Ipc_TextDocumentHover* request) override {
|
||||
QueryFile* file;
|
||||
if (!FindFileOrFail(db, request->id,
|
||||
if (!FindFileOrFail(db, project, request->id,
|
||||
request->params.textDocument.uri.GetPath(), &file)) {
|
||||
return;
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ struct TextDocumentReferencesHandler
|
||||
: BaseMessageHandler<Ipc_TextDocumentReferences> {
|
||||
void Run(Ipc_TextDocumentReferences* request) override {
|
||||
QueryFile* file;
|
||||
if (!FindFileOrFail(db, request->id,
|
||||
if (!FindFileOrFail(db, project, request->id,
|
||||
request->params.textDocument.uri.GetPath(), &file)) {
|
||||
return;
|
||||
}
|
||||
@ -80,4 +80,4 @@ struct TextDocumentReferencesHandler
|
||||
}
|
||||
};
|
||||
REGISTER_MESSAGE_HANDLER(TextDocumentReferencesHandler);
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
@ -84,7 +84,7 @@ struct TextDocumentRenameHandler : BaseMessageHandler<Ipc_TextDocumentRename> {
|
||||
void Run(Ipc_TextDocumentRename* request) override {
|
||||
QueryFileId file_id;
|
||||
QueryFile* file;
|
||||
if (!FindFileOrFail(db, request->id,
|
||||
if (!FindFileOrFail(db, project, request->id,
|
||||
request->params.textDocument.uri.GetPath(), &file,
|
||||
&file_id)) {
|
||||
return;
|
||||
@ -109,4 +109,4 @@ struct TextDocumentRenameHandler : BaseMessageHandler<Ipc_TextDocumentRename> {
|
||||
}
|
||||
};
|
||||
REGISTER_MESSAGE_HANDLER(TextDocumentRenameHandler);
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
Loading…
Reference in New Issue
Block a user