Skip to content

Commit

Permalink
textDocument/documentSymbol: support unopened files (MaskRay#548)
Browse files Browse the repository at this point in the history
  • Loading branch information
jlahoda authored and MaskRay committed Dec 22, 2019
1 parent 06a04d5 commit a2ecd9a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/message_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,9 @@ QueryFile *MessageHandler::findFile(const std::string &path, int *out_file_id) {

std::pair<QueryFile *, WorkingFile *>
MessageHandler::findOrFail(const std::string &path, ReplyOnce &reply,
int *out_file_id) {
int *out_file_id, bool allow_unopened) {
WorkingFile *wf = wfiles->getFile(path);
if (!wf) {
if (!wf && !allow_unopened) {
reply.notOpened(path);
return {nullptr, nullptr};
}
Expand Down
3 changes: 2 additions & 1 deletion src/message_handler.hh
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,8 @@ struct MessageHandler {
QueryFile *findFile(const std::string &path, int *out_file_id = nullptr);
std::pair<QueryFile *, WorkingFile *> findOrFail(const std::string &path,
ReplyOnce &reply,
int *out_file_id = nullptr);
int *out_file_id = nullptr,
bool allow_unopened = false);

private:
void bind(const char *method, void (MessageHandler::*handler)(JsonReader &));
Expand Down
4 changes: 2 additions & 2 deletions src/messages/textDocument_document.cc
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ void MessageHandler::textDocument_documentSymbol(JsonReader &reader,

int file_id;
auto [file, wf] =
findOrFail(param.textDocument.uri.getPath(), reply, &file_id);
if (!wf)
findOrFail(param.textDocument.uri.getPath(), reply, &file_id, true);
if (!file)
return;
auto allows = [&](SymbolRef sym) { return !(sym.role & param.excludeRole); };

Expand Down

0 comments on commit a2ecd9a

Please sign in to comment.