mirror of
https://github.com/MaskRay/ccls.git
synced 2024-12-02 04:17:08 +00:00
f700ac7b4c
cache.hierarchicalPath: store cache files as $directory/a/b/c.cc.blob to work around NAME_MAX limitation. cache.retainInMemory: after this number of loads, keep a copy of file index in memory. If set to 1, it avoids cache corruption if the index file is changed after the initial load, which may happen if several language clients open the same project and share the same cache directory. Also rename cacheDirectory cacheFormat to cache.{directory,format}
78 lines
2.0 KiB
C++
78 lines
2.0 KiB
C++
// Copyright 2017-2018 ccls Authors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
#pragma once
|
|
|
|
#include "lsp.hh"
|
|
#include "query.hh"
|
|
|
|
#include <atomic>
|
|
#include <mutex>
|
|
#include <string>
|
|
#include <unordered_map>
|
|
#include <vector>
|
|
|
|
namespace ccls {
|
|
struct SemaManager;
|
|
struct GroupMatch;
|
|
struct Project;
|
|
struct WorkingFiles;
|
|
|
|
struct VFS {
|
|
struct State {
|
|
int64_t timestamp;
|
|
int step;
|
|
int loaded;
|
|
};
|
|
std::unordered_map<std::string, State> state;
|
|
std::mutex mutex;
|
|
|
|
void Clear();
|
|
int Loaded(const std::string &path);
|
|
bool Stamp(const std::string &path, int64_t ts, int step);
|
|
};
|
|
|
|
enum class IndexMode {
|
|
NonInteractive,
|
|
OnChange,
|
|
Normal,
|
|
};
|
|
|
|
namespace pipeline {
|
|
extern std::atomic<bool> quit;
|
|
extern std::atomic<int64_t> loaded_ts, pending_index_requests;
|
|
extern int64_t tick;
|
|
|
|
void ThreadEnter();
|
|
void ThreadLeave();
|
|
void Init();
|
|
void LaunchStdin();
|
|
void LaunchStdout();
|
|
void Indexer_Main(SemaManager *manager, VFS *vfs, Project *project,
|
|
WorkingFiles *wfiles);
|
|
void MainLoop();
|
|
void Standalone(const std::string &root);
|
|
|
|
void Index(const std::string &path, const std::vector<const char *> &args,
|
|
IndexMode mode, bool must_exist, RequestId id = {});
|
|
void RemoveCache(const std::string &path);
|
|
std::optional<std::string> LoadIndexedContent(const std::string& path);
|
|
|
|
void NotifyOrRequest(const char *method, bool request,
|
|
const std::function<void(JsonWriter &)> &fn);
|
|
template <typename T> void Notify(const char *method, T &result) {
|
|
NotifyOrRequest(method, false, [&](JsonWriter &w) { Reflect(w, result); });
|
|
}
|
|
template <typename T> void Request(const char *method, T &result) {
|
|
NotifyOrRequest(method, true, [&](JsonWriter &w) { Reflect(w, result); });
|
|
}
|
|
|
|
void Reply(RequestId id, const std::function<void(JsonWriter &)> &fn);
|
|
|
|
void ReplyError(RequestId id, const std::function<void(JsonWriter &)> &fn);
|
|
template <typename T> void ReplyError(RequestId id, T &result) {
|
|
ReplyError(id, [&](JsonWriter &w) { Reflect(w, result); });
|
|
}
|
|
} // namespace pipeline
|
|
} // namespace ccls
|