ccls/src/messages/text_document_did_close.cc

39 lines
1.2 KiB
C++
Raw Normal View History

2017-12-29 16:29:47 +00:00
#include "clang_complete.h"
2017-12-06 03:32:33 +00:00
#include "message_handler.h"
2017-12-29 16:29:47 +00:00
#include "queue_manager.h"
#include "working_files.h"
2017-12-06 03:32:33 +00:00
namespace {
MethodType kMethodType = "textDocument/didClose";
struct In_TextDocumentDidClose : public NotificationMessage {
MethodType GetMethodType() const override { return kMethodType; }
2017-12-06 04:39:44 +00:00
struct Params {
lsTextDocumentIdentifier textDocument;
2017-12-06 04:39:44 +00:00
};
Params params;
};
MAKE_REFLECT_STRUCT(In_TextDocumentDidClose::Params, textDocument);
MAKE_REFLECT_STRUCT(In_TextDocumentDidClose, params);
REGISTER_IN_MESSAGE(In_TextDocumentDidClose);
struct Handler_TextDocumentDidClose
: BaseMessageHandler<In_TextDocumentDidClose> {
MethodType GetMethodType() const override { return kMethodType; }
2017-12-06 04:39:44 +00:00
void Run(In_TextDocumentDidClose* request) override {
2017-12-06 03:32:33 +00:00
std::string path = request->params.textDocument.uri.GetPath();
// Clear any diagnostics for the file.
Out_TextDocumentPublishDiagnostics out;
out.params.uri = request->params.textDocument.uri;
QueueManager::WriteStdout(kMethodType, out);
2017-12-06 03:32:33 +00:00
// Remove internal state.
2017-12-06 04:39:44 +00:00
working_files->OnClose(request->params.textDocument);
2017-12-06 03:32:33 +00:00
clang_complete->NotifyClose(path);
}
};
REGISTER_MESSAGE_HANDLER(Handler_TextDocumentDidClose);
} // namespace