mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-30 03:17:08 +00:00
WIP DidChangeWatchedFiles
This commit is contained in:
parent
1aec53621f
commit
3ef0abec14
@ -1,5 +1,10 @@
|
|||||||
|
#include "clang_complete.h"
|
||||||
#include "message_handler.h"
|
#include "message_handler.h"
|
||||||
|
#include "project.h"
|
||||||
#include "queue_manager.h"
|
#include "queue_manager.h"
|
||||||
|
#include "working_files.h"
|
||||||
|
|
||||||
|
#include <loguru/loguru.hpp>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
enum class lsFileChangeType {
|
enum class lsFileChangeType {
|
||||||
@ -33,16 +38,27 @@ struct WorkspaceDidChangeWatchedFilesHandler
|
|||||||
: BaseMessageHandler<Ipc_WorkspaceDidChangeWatchedFiles> {
|
: BaseMessageHandler<Ipc_WorkspaceDidChangeWatchedFiles> {
|
||||||
void Run(Ipc_WorkspaceDidChangeWatchedFiles* request) override {
|
void Run(Ipc_WorkspaceDidChangeWatchedFiles* request) override {
|
||||||
for (lsFileEvent& event : request->params.changes) {
|
for (lsFileEvent& event : request->params.changes) {
|
||||||
|
std::string path = event.uri.GetPath();
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case lsFileChangeType::Created:
|
case lsFileChangeType::Created:
|
||||||
// TODO
|
// TODO
|
||||||
|
case lsFileChangeType::Changed: {
|
||||||
|
Project::Entry entry = project->FindCompilationEntryForFile(path);
|
||||||
|
optional<std::string> content = ReadContent(path);
|
||||||
|
if (!content)
|
||||||
|
LOG_S(ERROR) << "Unable to read file content after saving " << path;
|
||||||
|
else {
|
||||||
|
bool is_interactive =
|
||||||
|
working_files->GetFileByFilename(entry.filename) != nullptr;
|
||||||
|
QueueManager::instance()->index_request.Enqueue(
|
||||||
|
Index_Request(path, entry.args, is_interactive, *content));
|
||||||
|
clang_complete->NotifySave(path);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case lsFileChangeType::Deleted:
|
case lsFileChangeType::Deleted:
|
||||||
// TODO
|
// TODO
|
||||||
break;
|
break;
|
||||||
case lsFileChangeType::Changed:
|
|
||||||
// TODO
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user