Add ReplyOnce::NotReady and error if didOpen is not seen

Use IgnoringDiagConsumer to override default TextDiagnosticPrinter
This commit is contained in:
Fangrui Song 2018-12-01 16:55:51 -08:00
parent d49119b364
commit 1a7e463553
19 changed files with 95 additions and 75 deletions

View File

@ -86,7 +86,8 @@ BuildCompilerInvocation(std::vector<const char *> args,
std::string save = "-resource-dir=" + g_config->clang.resourceDir; std::string save = "-resource-dir=" + g_config->clang.resourceDir;
args.push_back(save.c_str()); args.push_back(save.c_str());
IntrusiveRefCntPtr<DiagnosticsEngine> Diags( IntrusiveRefCntPtr<DiagnosticsEngine> Diags(
CompilerInstance::createDiagnostics(new DiagnosticOptions)); CompilerInstance::createDiagnostics(new DiagnosticOptions,
new IgnoringDiagConsumer, true));
std::unique_ptr<CompilerInvocation> CI = std::unique_ptr<CompilerInvocation> CI =
createInvocationFromCommandLine(args, Diags, VFS); createInvocationFromCommandLine(args, Diags, VFS);
if (CI) { if (CI) {

View File

@ -95,6 +95,13 @@ struct ScanLineEvent {
}; };
} // namespace } // namespace
void ReplyOnce::NotReady(bool file) {
if (file)
Error(ErrorCode::InvalidRequest, "not opened");
else
Error(ErrorCode::InternalError, "not indexed");
}
void MessageHandler::Bind(const char *method, void (MessageHandler::*handler)(Reader &)) { void MessageHandler::Bind(const char *method, void (MessageHandler::*handler)(Reader &)) {
method2notification[method] = [this, handler](Reader &reader) { method2notification[method] = [this, handler](Reader &reader) {
(this->*handler)(reader); (this->*handler)(reader);
@ -208,14 +215,14 @@ void MessageHandler::Run(InMessage &msg) {
try { try {
it->second(reader); it->second(reader);
} catch (...) { } catch (...) {
LOG_S(ERROR) << "failed to process " << msg.method; ShowMessageParam param{MessageType::Error,
std::string("failed to process ") + msg.method};
pipeline::Notify(window_showMessage, param);
} }
} }
} }
QueryFile *MessageHandler::FindFile(ReplyOnce &reply, QueryFile *MessageHandler::FindFile(const std::string &path, int *out_file_id) {
const std::string &path,
int *out_file_id) {
QueryFile *ret = nullptr; QueryFile *ret = nullptr;
auto it = db->name2file_id.find(LowerPathIfInsensitive(path)); auto it = db->name2file_id.find(LowerPathIfInsensitive(path));
if (it != db->name2file_id.end()) { if (it != db->name2file_id.end()) {
@ -227,24 +234,8 @@ QueryFile *MessageHandler::FindFile(ReplyOnce &reply,
return ret; return ret;
} }
} }
if (out_file_id) if (out_file_id)
*out_file_id = -1; *out_file_id = -1;
if (reply.id.Valid()) {
bool has_entry = false;
{
std::lock_guard<std::mutex> lock(project->mutex_);
for (auto &[root, folder] : project->root2folder)
has_entry |= folder.path2entry_index.count(path);
}
ResponseError err;
if (has_entry)
reply.Error(ErrorCode::ServerNotInitialized, path + " is being indexed");
else
reply.Error(ErrorCode::InternalError, "unable to find " + path);
}
return ret; return ret;
} }

View File

@ -202,6 +202,7 @@ struct ReplyOnce {
if (id.Valid()) if (id.Valid())
pipeline::ReplyError(id, [&](Writer &w) { Reflect(w, err); }); pipeline::ReplyError(id, [&](Writer &w) { Reflect(w, err); });
} }
void NotReady(bool file);
}; };
struct MessageHandler { struct MessageHandler {
@ -217,8 +218,7 @@ struct MessageHandler {
MessageHandler(); MessageHandler();
void Run(InMessage &msg); void Run(InMessage &msg);
QueryFile *FindFile(ReplyOnce &reply, const std::string &path, QueryFile *FindFile(const std::string &path, int *out_file_id = nullptr);
int *out_file_id = nullptr);
private: private:
void Bind(const char *method, void (MessageHandler::*handler)(Reader &)); void Bind(const char *method, void (MessageHandler::*handler)(Reader &));

View File

@ -188,7 +188,7 @@ void MessageHandler::ccls_call(Reader &reader, ReplyOnce &reply) {
Expand(this, &*result, param.callee, param.callType, param.qualified, Expand(this, &*result, param.callee, param.callType, param.qualified,
param.levels); param.levels);
} else { } else {
QueryFile *file = FindFile(reply, param.textDocument.uri.GetPath()); QueryFile *file = FindFile(param.textDocument.uri.GetPath());
WorkingFile *wf = file ? wfiles->GetFile(file->def->path) : nullptr; WorkingFile *wf = file ? wfiles->GetFile(file->def->path) : nullptr;
if (!wf) if (!wf)
return; return;

View File

@ -54,7 +54,7 @@ void MessageHandler::ccls_info(EmptyParam &, ReplyOnce &reply) {
} }
void MessageHandler::ccls_fileInfo(TextDocumentParam &param, ReplyOnce &reply) { void MessageHandler::ccls_fileInfo(TextDocumentParam &param, ReplyOnce &reply) {
QueryFile *file = FindFile(reply, param.textDocument.uri.GetPath()); QueryFile *file = FindFile(param.textDocument.uri.GetPath());
if (!file) if (!file)
return; return;

View File

@ -134,7 +134,7 @@ void Inheritance(MessageHandler *m, Param &param, ReplyOnce &reply) {
Expand(m, &*result, param.derived, param.qualified, param.levels))) Expand(m, &*result, param.derived, param.qualified, param.levels)))
result.reset(); result.reset();
} else { } else {
QueryFile *file = m->FindFile(reply, param.textDocument.uri.GetPath()); QueryFile *file = m->FindFile(param.textDocument.uri.GetPath());
if (!file) if (!file)
return; return;
WorkingFile *wf = m->wfiles->GetFile(file->def->path); WorkingFile *wf = m->wfiles->GetFile(file->def->path);

View File

@ -269,10 +269,12 @@ void MessageHandler::ccls_member(Reader &reader, ReplyOnce &reply) {
param.levels, param.kind))) param.levels, param.kind)))
result.reset(); result.reset();
} else { } else {
QueryFile *file = FindFile(reply, param.textDocument.uri.GetPath()); QueryFile *file = FindFile(param.textDocument.uri.GetPath());
WorkingFile *wf = file ? wfiles->GetFile(file->def->path) : nullptr; WorkingFile *wf = file ? wfiles->GetFile(file->def->path) : nullptr;
if (!wf) if (!wf) {
reply.NotReady(file);
return; return;
}
for (SymbolRef sym : FindSymbolsAtLocation(wf, file, param.position)) { for (SymbolRef sym : FindSymbolsAtLocation(wf, file, param.position)) {
switch (sym.kind) { switch (sym.kind) {
case Kind::Func: case Kind::Func:

View File

@ -42,10 +42,12 @@ void MessageHandler::ccls_navigate(Reader &reader,
ReplyOnce &reply) { ReplyOnce &reply) {
Param param; Param param;
Reflect(reader, param); Reflect(reader, param);
QueryFile *file = FindFile(reply, param.textDocument.uri.GetPath()); QueryFile *file = FindFile(param.textDocument.uri.GetPath());
WorkingFile *wf = file ? wfiles->GetFile(file->def->path) : nullptr; WorkingFile *wf = file ? wfiles->GetFile(file->def->path) : nullptr;
if (!wf) if (!wf) {
reply.NotReady(file);
return; return;
}
Position ls_pos = param.position; Position ls_pos = param.position;
if (wf->index_lines.size()) if (wf->index_lines.size())
if (auto line = if (auto line =

View File

@ -19,10 +19,12 @@ MAKE_REFLECT_STRUCT(Param, textDocument, position, kind);
void MessageHandler::ccls_vars(Reader &reader, ReplyOnce &reply) { void MessageHandler::ccls_vars(Reader &reader, ReplyOnce &reply) {
Param param; Param param;
Reflect(reader, param); Reflect(reader, param);
QueryFile *file = FindFile(reply, param.textDocument.uri.GetPath()); QueryFile *file = FindFile(param.textDocument.uri.GetPath());
WorkingFile *wf = file ? wfiles->GetFile(file->def->path) : nullptr; WorkingFile *wf = file ? wfiles->GetFile(file->def->path) : nullptr;
if (!wf) if (!wf) {
reply.NotReady(file);
return; return;
}
std::vector<Location> result; std::vector<Location> result;
for (SymbolRef sym : FindSymbolsAtLocation(wf, file, param.position)) { for (SymbolRef sym : FindSymbolsAtLocation(wf, file, param.position)) {

View File

@ -34,8 +34,10 @@ MAKE_REFLECT_STRUCT(CodeAction, title, kind, edit);
void MessageHandler::textDocument_codeAction(CodeActionParam &param, void MessageHandler::textDocument_codeAction(CodeActionParam &param,
ReplyOnce &reply) { ReplyOnce &reply) {
WorkingFile *wf = wfiles->GetFile(param.textDocument.uri.GetPath()); WorkingFile *wf = wfiles->GetFile(param.textDocument.uri.GetPath());
if (!wf) if (!wf) {
reply.NotReady(true);
return; return;
}
std::vector<CodeAction> result; std::vector<CodeAction> result;
std::vector<Diagnostic> diagnostics; std::vector<Diagnostic> diagnostics;
wfiles->WithLock([&]() { diagnostics = wf->diagnostics; }); wfiles->WithLock([&]() { diagnostics = wf->diagnostics; });
@ -92,15 +94,14 @@ struct CommonCodeLensParams {
void MessageHandler::textDocument_codeLens(TextDocumentParam &param, void MessageHandler::textDocument_codeLens(TextDocumentParam &param,
ReplyOnce &reply) { ReplyOnce &reply) {
std::vector<CodeLens> result; QueryFile *file = FindFile(param.textDocument.uri.GetPath());
std::string path = param.textDocument.uri.GetPath();
QueryFile *file = FindFile(reply, path);
WorkingFile *wf = file ? wfiles->GetFile(file->def->path) : nullptr; WorkingFile *wf = file ? wfiles->GetFile(file->def->path) : nullptr;
if (!wf) { if (!wf) {
reply.NotReady(file);
return; return;
} }
std::vector<CodeLens> result;
auto Add = [&](const char *singular, Cmd_xref show, Range range, int num, auto Add = [&](const char *singular, Cmd_xref show, Range range, int num,
bool force_display = false) { bool force_display = false) {
if (!num && !force_display) if (!num && !force_display)

View File

@ -437,13 +437,15 @@ public:
void MessageHandler::textDocument_completion(CompletionParam &param, void MessageHandler::textDocument_completion(CompletionParam &param,
ReplyOnce &reply) { ReplyOnce &reply) {
static CompleteConsumerCache<std::vector<CompletionItem>> cache; static CompleteConsumerCache<std::vector<CompletionItem>> cache;
CompletionList result;
std::string path = param.textDocument.uri.GetPath(); std::string path = param.textDocument.uri.GetPath();
WorkingFile *file = wfiles->GetFile(path); WorkingFile *file = wfiles->GetFile(path);
if (!file) { if (!file) {
reply.NotReady(true);
return; return;
} }
CompletionList result;
// It shouldn't be possible, but sometimes vscode will send queries out // It shouldn't be possible, but sometimes vscode will send queries out
// of order, ie, we get completion request before buffer content update. // of order, ie, we get completion request before buffer content update.
std::string buffer_line; std::string buffer_line;

View File

@ -36,10 +36,12 @@ std::vector<DeclRef> GetNonDefDeclarationTargets(DB *db, SymbolRef sym) {
void MessageHandler::textDocument_definition(TextDocumentPositionParam &param, void MessageHandler::textDocument_definition(TextDocumentPositionParam &param,
ReplyOnce &reply) { ReplyOnce &reply) {
int file_id; int file_id;
QueryFile *file = FindFile(reply, param.textDocument.uri.GetPath(), &file_id); QueryFile *file = FindFile(param.textDocument.uri.GetPath(), &file_id);
WorkingFile *wf = file ? wfiles->GetFile(file->def->path) : nullptr; WorkingFile *wf = file ? wfiles->GetFile(file->def->path) : nullptr;
if (!wf) if (!wf) {
reply.NotReady(file);
return; return;
}
std::vector<Location> result; std::vector<Location> result;
Maybe<Use> on_def; Maybe<Use> on_def;
@ -157,10 +159,12 @@ void MessageHandler::textDocument_definition(TextDocumentPositionParam &param,
void MessageHandler::textDocument_typeDefinition( void MessageHandler::textDocument_typeDefinition(
TextDocumentPositionParam &param, ReplyOnce &reply) { TextDocumentPositionParam &param, ReplyOnce &reply) {
QueryFile *file = FindFile(reply, param.textDocument.uri.GetPath()); QueryFile *file = FindFile(param.textDocument.uri.GetPath());
if (!file) WorkingFile *wf = file ? wfiles->GetFile(file->def->path) : nullptr;
if (!file) {
reply.NotReady(file);
return; return;
WorkingFile *working_file = wfiles->GetFile(file->def->path); }
std::vector<Location> result; std::vector<Location> result;
auto Add = [&](const QueryType &type) { auto Add = [&](const QueryType &type) {
@ -174,8 +178,7 @@ void MessageHandler::textDocument_typeDefinition(
if (auto ls_loc = GetLsLocation(db, wfiles, dr)) if (auto ls_loc = GetLsLocation(db, wfiles, dr))
result.push_back(*ls_loc); result.push_back(*ls_loc);
}; };
for (SymbolRef sym : for (SymbolRef sym : FindSymbolsAtLocation(wf, file, param.position)) {
FindSymbolsAtLocation(working_file, file, param.position)) {
switch (sym.kind) { switch (sym.kind) {
case Kind::Var: { case Kind::Var: {
const QueryVar::Def *def = db->GetVar(sym).AnyDef(); const QueryVar::Def *def = db->GetVar(sym).AnyDef();

View File

@ -44,8 +44,7 @@ void MessageHandler::textDocument_didOpen(DidOpenTextDocumentParam &param) {
pipeline::LoadIndexedContent(path)) pipeline::LoadIndexedContent(path))
wf->SetIndexContent(*cached_file_contents); wf->SetIndexContent(*cached_file_contents);
ReplyOnce reply; QueryFile *file = FindFile(path);
QueryFile *file = FindFile(reply, path);
if (file) { if (file) {
EmitSkippedRanges(wf, *file); EmitSkippedRanges(wf, *file);
EmitSemanticHighlight(db, wf, *file); EmitSemanticHighlight(db, wf, *file);

View File

@ -32,10 +32,12 @@ MAKE_REFLECT_STRUCT(DocumentHighlight, range, kind, role);
void MessageHandler::textDocument_documentHighlight( void MessageHandler::textDocument_documentHighlight(
TextDocumentPositionParam &param, ReplyOnce &reply) { TextDocumentPositionParam &param, ReplyOnce &reply) {
int file_id; int file_id;
QueryFile *file = FindFile(reply, param.textDocument.uri.GetPath(), &file_id); QueryFile *file = FindFile(param.textDocument.uri.GetPath(), &file_id);
WorkingFile *wf = file ? wfiles->GetFile(file->def->path) : nullptr; WorkingFile *wf = file ? wfiles->GetFile(file->def->path) : nullptr;
if (!wf) if (!wf) {
reply.NotReady(file);
return; return;
}
std::vector<DocumentHighlight> result; std::vector<DocumentHighlight> result;
std::vector<SymbolRef> syms = std::vector<SymbolRef> syms =
@ -76,10 +78,10 @@ MAKE_REFLECT_STRUCT(DocumentLink, range, target);
void MessageHandler::textDocument_documentLink(TextDocumentParam &param, void MessageHandler::textDocument_documentLink(TextDocumentParam &param,
ReplyOnce &reply) { ReplyOnce &reply) {
QueryFile *file = FindFile(reply, param.textDocument.uri.GetPath()); QueryFile *file = FindFile(param.textDocument.uri.GetPath());
WorkingFile *wf = file ? wfiles->GetFile(file->def->path) : nullptr; WorkingFile *wf = file ? wfiles->GetFile(file->def->path) : nullptr;
if (!wf) { if (!wf) {
reply.Error(ErrorCode::InternalError, "not opened"); reply.NotReady(file);
return; return;
} }
@ -151,10 +153,12 @@ void MessageHandler::textDocument_documentSymbol(Reader &reader,
Reflect(reader, param); Reflect(reader, param);
int file_id; int file_id;
QueryFile *file = FindFile(reply, param.textDocument.uri.GetPath(), &file_id); QueryFile *file = FindFile(param.textDocument.uri.GetPath(), &file_id);
WorkingFile *wf = file ? wfiles->GetFile(file->def->path) : nullptr; WorkingFile *wf = file ? wfiles->GetFile(file->def->path) : nullptr;
if (!wf) if (!wf) {
reply.NotReady(file);
return; return;
}
if (param.startLine >= 0) { if (param.startLine >= 0) {
std::vector<lsRange> result; std::vector<lsRange> result;

View File

@ -31,19 +31,19 @@ MAKE_REFLECT_STRUCT(FoldingRange, startLine, startCharacter, endLine,
void MessageHandler::textDocument_foldingRange(TextDocumentParam &param, void MessageHandler::textDocument_foldingRange(TextDocumentParam &param,
ReplyOnce &reply) { ReplyOnce &reply) {
QueryFile *file = FindFile(reply, param.textDocument.uri.GetPath()); QueryFile *file = FindFile(param.textDocument.uri.GetPath());
if (!file) WorkingFile *wf = file ? wfiles->GetFile(file->def->path) : nullptr;
return; if (!wf) {
WorkingFile *wfile = wfiles->GetFile(file->def->path); reply.NotReady(file);
if (!wfile)
return; return;
}
std::vector<FoldingRange> result; std::vector<FoldingRange> result;
std::optional<lsRange> ls_range; std::optional<lsRange> ls_range;
for (auto [sym, refcnt] : file->symbol2refcnt) for (auto [sym, refcnt] : file->symbol2refcnt)
if (refcnt > 0 && sym.extent.Valid() && if (refcnt > 0 && sym.extent.Valid() &&
(sym.kind == Kind::Func || sym.kind == Kind::Type) && (sym.kind == Kind::Func || sym.kind == Kind::Type) &&
(ls_range = GetLsRange(wfile, sym.extent))) { (ls_range = GetLsRange(wf, sym.extent))) {
FoldingRange &fold = result.emplace_back(); FoldingRange &fold = result.emplace_back();
fold.startLine = ls_range->start.line; fold.startLine = ls_range->start.line;
fold.startCharacter = ls_range->start.character; fold.startCharacter = ls_range->start.character;

View File

@ -80,19 +80,23 @@ void Format(ReplyOnce &reply, WorkingFile *wfile, tooling::Range range) {
void MessageHandler::textDocument_formatting(DocumentFormattingParam &param, void MessageHandler::textDocument_formatting(DocumentFormattingParam &param,
ReplyOnce &reply) { ReplyOnce &reply) {
QueryFile *file = FindFile(reply, param.textDocument.uri.GetPath()); QueryFile *file = FindFile(param.textDocument.uri.GetPath());
WorkingFile *wf = file ? wfiles->GetFile(file->def->path) : nullptr; WorkingFile *wf = file ? wfiles->GetFile(file->def->path) : nullptr;
if (!wf) if (!wf) {
reply.NotReady(file);
return; return;
}
Format(reply, wf, {0, (unsigned)wf->buffer_content.size()}); Format(reply, wf, {0, (unsigned)wf->buffer_content.size()});
} }
void MessageHandler::textDocument_onTypeFormatting( void MessageHandler::textDocument_onTypeFormatting(
DocumentOnTypeFormattingParam &param, ReplyOnce &reply) { DocumentOnTypeFormattingParam &param, ReplyOnce &reply) {
QueryFile *file = FindFile(reply, param.textDocument.uri.GetPath()); QueryFile *file = FindFile(param.textDocument.uri.GetPath());
WorkingFile *wf = file ? wfiles->GetFile(file->def->path) : nullptr; WorkingFile *wf = file ? wfiles->GetFile(file->def->path) : nullptr;
if (!wf) if (!wf) {
reply.NotReady(file);
return; return;
}
std::string_view code = wf->buffer_content; std::string_view code = wf->buffer_content;
int pos = GetOffsetForPosition(param.position, code); int pos = GetOffsetForPosition(param.position, code);
auto lbrace = code.find_last_of('{', pos); auto lbrace = code.find_last_of('{', pos);
@ -103,10 +107,12 @@ void MessageHandler::textDocument_onTypeFormatting(
void MessageHandler::textDocument_rangeFormatting( void MessageHandler::textDocument_rangeFormatting(
DocumentRangeFormattingParam &param, ReplyOnce &reply) { DocumentRangeFormattingParam &param, ReplyOnce &reply) {
QueryFile *file = FindFile(reply, param.textDocument.uri.GetPath()); QueryFile *file = FindFile(param.textDocument.uri.GetPath());
WorkingFile *wf = file ? wfiles->GetFile(file->def->path) : nullptr; WorkingFile *wf = file ? wfiles->GetFile(file->def->path) : nullptr;
if (!wf) if (!wf) {
reply.NotReady(file);
return; return;
}
std::string_view code = wf->buffer_content; std::string_view code = wf->buffer_content;
int begin = GetOffsetForPosition(param.range.start, code), int begin = GetOffsetForPosition(param.range.start, code),
end = GetOffsetForPosition(param.range.end, code); end = GetOffsetForPosition(param.range.end, code);

View File

@ -81,12 +81,14 @@ GetHover(DB *db, LanguageId lang, SymbolRef sym, int file_id) {
void MessageHandler::textDocument_hover(TextDocumentPositionParam &param, void MessageHandler::textDocument_hover(TextDocumentPositionParam &param,
ReplyOnce &reply) { ReplyOnce &reply) {
QueryFile *file = FindFile(reply, param.textDocument.uri.GetPath()); QueryFile *file = FindFile(param.textDocument.uri.GetPath());
WorkingFile *wf = file ? wfiles->GetFile(file->def->path) : nullptr; WorkingFile *wf = file ? wfiles->GetFile(file->def->path) : nullptr;
if (!wf) if (!wf) {
reply.NotReady(file);
return; return;
Hover result; }
Hover result;
for (SymbolRef sym : FindSymbolsAtLocation(wf, file, param.position)) { for (SymbolRef sym : FindSymbolsAtLocation(wf, file, param.position)) {
std::optional<lsRange> ls_range = std::optional<lsRange> ls_range =
GetLsRange(wfiles->GetFile(file->def->path), sym.range); GetLsRange(wfiles->GetFile(file->def->path), sym.range);

View File

@ -32,10 +32,13 @@ MAKE_REFLECT_STRUCT(ReferenceParam, textDocument, position, context, folders,
void MessageHandler::textDocument_references(Reader &reader, ReplyOnce &reply) { void MessageHandler::textDocument_references(Reader &reader, ReplyOnce &reply) {
ReferenceParam param; ReferenceParam param;
Reflect(reader, param); Reflect(reader, param);
QueryFile *file = FindFile(reply, param.textDocument.uri.GetPath()); QueryFile *file = FindFile(param.textDocument.uri.GetPath());
WorkingFile *wf = file ? wfiles->GetFile(file->def->path) : nullptr; WorkingFile *wf = file ? wfiles->GetFile(file->def->path) : nullptr;
if (!wf) if (!wf) {
reply.NotReady(file);
return; return;
}
for (auto &folder : param.folders) for (auto &folder : param.folders)
EnsureEndsInSlash(folder); EnsureEndsInSlash(folder);
std::vector<uint8_t> file_set = db->GetFileSet(param.folders); std::vector<uint8_t> file_set = db->GetFileSet(param.folders);

View File

@ -26,9 +26,9 @@ WorkspaceEdit BuildWorkspaceEdit(DB *db, WorkingFiles *wfiles, SymbolRef sym,
const std::string &path = file.def->path; const std::string &path = file.def->path;
path_to_edit[file_id].textDocument.uri = DocumentUri::FromPath(path); path_to_edit[file_id].textDocument.uri = DocumentUri::FromPath(path);
WorkingFile *working_file = wfiles->GetFile(path); WorkingFile *wf = wfiles->GetFile(path);
if (working_file) if (wf)
path_to_edit[file_id].textDocument.version = working_file->version; path_to_edit[file_id].textDocument.version = wf->version;
} }
TextEdit &edit = path_to_edit[file_id].edits.emplace_back(); TextEdit &edit = path_to_edit[file_id].edits.emplace_back();
@ -44,10 +44,12 @@ WorkspaceEdit BuildWorkspaceEdit(DB *db, WorkingFiles *wfiles, SymbolRef sym,
} // namespace } // namespace
void MessageHandler::textDocument_rename(RenameParam &param, ReplyOnce &reply) { void MessageHandler::textDocument_rename(RenameParam &param, ReplyOnce &reply) {
QueryFile *file = FindFile(reply, param.textDocument.uri.GetPath()); QueryFile *file = FindFile(param.textDocument.uri.GetPath());
WorkingFile *wf = file ? wfiles->GetFile(file->def->path) : nullptr; WorkingFile *wf = file ? wfiles->GetFile(file->def->path) : nullptr;
if (!wf) if (!wf) {
reply.NotReady(file);
return; return;
}
WorkspaceEdit result; WorkspaceEdit result;
for (SymbolRef sym : FindSymbolsAtLocation(wf, file, param.position)) { for (SymbolRef sym : FindSymbolsAtLocation(wf, file, param.position)) {