ccls/src/pipeline.hh

70 lines
1.7 KiB
C++
Raw Normal View History

2018-08-21 05:27:52 +00:00
// Copyright 2017-2018 ccls Authors
// SPDX-License-Identifier: Apache-2.0
#pragma once
#include "lsp.hh"
2018-10-29 04:21:21 +00:00
#include "query.hh"
#include <atomic>
2018-09-21 01:04:55 +00:00
#include <mutex>
2018-05-28 00:50:02 +00:00
#include <string>
#include <unordered_map>
2018-05-28 00:50:02 +00:00
#include <vector>
namespace ccls {
struct SemaManager;
struct GroupMatch;
struct Project;
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);
};
enum class IndexMode {
NonInteractive,
OnChange,
Normal,
};
2018-05-28 00:50:02 +00:00
namespace pipeline {
extern std::atomic<int64_t> loaded_ts, pending_index_requests;
extern int64_t tick;
2018-05-28 00:50:02 +00:00
void Init();
void LaunchStdin();
void LaunchStdout();
void Indexer_Main(SemaManager *manager, VFS *vfs, Project *project,
2018-09-08 23:00:14 +00:00
WorkingFiles *wfiles);
2018-05-28 00:50:02 +00:00
void MainLoop();
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,
IndexMode mode, RequestId id = {});
std::optional<std::string> LoadIndexedContent(const std::string& path);
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(RequestId id, const std::function<void(Writer &)> &fn);
void ReplyError(RequestId id, const std::function<void(Writer &)> &fn);
template <typename T> void ReplyError(RequestId id, T &result) {
ReplyError(id, [&](Writer &w) { Reflect(w, result); });
}
} // namespace pipeline
} // namespace ccls