ccls/src/messages/text_document_did_close.cc

40 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"
2018-05-28 00:50:02 +00:00
#include "pipeline.hh"
2017-12-29 16:29:47 +00:00
#include "working_files.h"
2018-05-28 00:50:02 +00:00
using namespace ccls;
2017-12-06 03:32:33 +00:00
namespace {
MethodType kMethodType = "textDocument/didClose";
2018-03-22 05:01:21 +00:00
struct In_TextDocumentDidClose : public NotificationInMessage {
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;
2018-05-28 00:50:02 +00:00
pipeline::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