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-03-19 20:28:11 +00:00
|
|
|
#include "project.h"
|
2017-12-29 16:29:47 +00:00
|
|
|
#include "working_files.h"
|
2018-05-28 00:50:02 +00:00
|
|
|
#include "pipeline.hh"
|
|
|
|
using namespace ccls;
|
2018-03-19 20:28:11 +00:00
|
|
|
|
2017-12-06 05:03:38 +00:00
|
|
|
namespace {
|
2018-03-22 04:05:25 +00:00
|
|
|
MethodType kMethodType = "textDocument/didChange";
|
|
|
|
|
2018-03-22 05:01:21 +00:00
|
|
|
struct In_TextDocumentDidChange : public NotificationInMessage {
|
2018-03-22 04:05:25 +00:00
|
|
|
MethodType GetMethodType() const override { return kMethodType; }
|
2017-12-06 04:39:44 +00:00
|
|
|
lsTextDocumentDidChangeParams params;
|
|
|
|
};
|
|
|
|
|
2018-03-22 04:05:25 +00:00
|
|
|
MAKE_REFLECT_STRUCT(In_TextDocumentDidChange, params);
|
|
|
|
REGISTER_IN_MESSAGE(In_TextDocumentDidChange);
|
|
|
|
|
|
|
|
struct Handler_TextDocumentDidChange
|
|
|
|
: BaseMessageHandler<In_TextDocumentDidChange> {
|
|
|
|
MethodType GetMethodType() const override { return kMethodType; }
|
2017-12-06 04:39:44 +00:00
|
|
|
|
2018-03-22 04:05:25 +00:00
|
|
|
void Run(In_TextDocumentDidChange* request) override {
|
2017-12-06 03:32:33 +00:00
|
|
|
std::string path = request->params.textDocument.uri.GetPath();
|
|
|
|
working_files->OnChange(request->params);
|
2018-04-04 06:05:41 +00:00
|
|
|
if (g_config->index.onDidChange) {
|
2018-05-26 05:48:58 +00:00
|
|
|
Project::Entry entry = project->FindCompilationEntryForFile(path);
|
2018-05-28 00:50:02 +00:00
|
|
|
pipeline::Index(entry.filename, entry.args, true);
|
2018-03-19 20:28:11 +00:00
|
|
|
}
|
2017-12-06 03:32:33 +00:00
|
|
|
clang_complete->NotifyEdit(path);
|
|
|
|
clang_complete->DiagnosticsUpdate(
|
|
|
|
request->params.textDocument.AsTextDocumentIdentifier());
|
|
|
|
}
|
|
|
|
};
|
2018-03-22 04:05:25 +00:00
|
|
|
REGISTER_MESSAGE_HANDLER(Handler_TextDocumentDidChange);
|
2017-12-31 03:18:33 +00:00
|
|
|
} // namespace
|