2018-08-21 05:27:52 +00:00
|
|
|
// Copyright 2017-2018 ccls Authors
|
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
2017-12-24 01:30:52 +00:00
|
|
|
#pragma once
|
|
|
|
|
2019-01-09 07:19:17 +00:00
|
|
|
#include "lsp.h"
|
2018-05-28 00:50:02 +00:00
|
|
|
#include "query.h"
|
2018-05-13 16:52:19 +00:00
|
|
|
|
2018-09-24 06:02:19 +00:00
|
|
|
#include <atomic>
|
2018-09-21 01:04:55 +00:00
|
|
|
#include <mutex>
|
2018-05-28 00:50:02 +00:00
|
|
|
#include <string>
|
2018-05-13 16:52:19 +00:00
|
|
|
#include <unordered_map>
|
2018-05-28 00:50:02 +00:00
|
|
|
#include <vector>
|
2017-12-24 01:30:52 +00:00
|
|
|
|
2018-09-08 19:07:43 +00:00
|
|
|
struct CompletionManager;
|
2018-06-08 04:53:41 +00:00
|
|
|
struct GroupMatch;
|
2018-05-05 22:29:17 +00:00
|
|
|
struct VFS;
|
2017-12-29 15:52:43 +00:00
|
|
|
struct Project;
|
2017-12-24 01:30:52 +00:00
|
|
|
struct WorkingFiles;
|
|
|
|
|
2018-09-21 01:04:55 +00:00
|
|
|
struct VFS {
|
|
|
|
struct State {
|
|
|
|
int64_t timestamp;
|
|
|
|
int step;
|
|
|
|
bool loaded;
|
|
|
|
};
|
|
|
|
std::unordered_map<std::string, State> state;
|
|
|
|
std::mutex mutex;
|
|
|
|
|
|
|
|
void Clear();
|
|
|
|
bool Loaded(const std::string &path);
|
|
|
|
bool Stamp(const std::string &path, int64_t ts, int step);
|
|
|
|
};
|
|
|
|
|
2018-09-08 06:40:22 +00:00
|
|
|
namespace ccls {
|
|
|
|
enum class IndexMode {
|
|
|
|
NonInteractive,
|
|
|
|
OnChange,
|
|
|
|
Normal,
|
|
|
|
};
|
2018-05-28 00:50:02 +00:00
|
|
|
|
2018-09-08 06:40:22 +00:00
|
|
|
namespace pipeline {
|
2018-10-01 05:54:48 +00:00
|
|
|
extern std::atomic<int64_t> loaded_ts, pending_index_requests;
|
2018-09-24 06:02:19 +00:00
|
|
|
extern int64_t tick;
|
2018-05-28 00:50:02 +00:00
|
|
|
void Init();
|
2018-06-01 03:06:09 +00:00
|
|
|
void LaunchStdin();
|
|
|
|
void LaunchStdout();
|
2018-09-08 23:00:14 +00:00
|
|
|
void Indexer_Main(CompletionManager *completion, VFS *vfs, Project *project,
|
|
|
|
WorkingFiles *wfiles);
|
2018-05-28 00:50:02 +00:00
|
|
|
void MainLoop();
|
2018-10-23 05:01:10 +00:00
|
|
|
void Standalone(const std::string &root);
|
2018-05-28 00:50:02 +00:00
|
|
|
|
2018-09-19 16:31:45 +00:00
|
|
|
void Index(const std::string &path, const std::vector<const char *> &args,
|
2018-09-08 06:40:22 +00:00
|
|
|
IndexMode mode, lsRequestId id = {});
|
2017-12-29 15:52:43 +00:00
|
|
|
|
2018-09-08 17:37:48 +00:00
|
|
|
std::optional<std::string> LoadIndexedContent(const std::string& path);
|
2019-01-09 07:19:17 +00:00
|
|
|
|
|
|
|
void Notify(const char *method, const std::function<void(Writer &)> &fn);
|
|
|
|
template <typename T> void Notify(const char *method, T &result) {
|
|
|
|
Notify(method, [&](Writer &w) { Reflect(w, result); });
|
|
|
|
}
|
|
|
|
|
|
|
|
void Reply(lsRequestId id, const std::function<void(Writer &)> &fn);
|
|
|
|
template <typename T> void Reply(lsRequestId id, T &result) {
|
|
|
|
Reply(id, [&](Writer &w) { Reflect(w, result); });
|
|
|
|
}
|
|
|
|
|
|
|
|
void ReplyError(lsRequestId id, const std::function<void(Writer &)> &fn);
|
|
|
|
template <typename T> void ReplyError(lsRequestId id, T &result) {
|
|
|
|
ReplyError(id, [&](Writer &w) { Reflect(w, result); });
|
|
|
|
}
|
2018-09-08 17:37:48 +00:00
|
|
|
} // namespace pipeline
|
|
|
|
} // namespace ccls
|