// Copyright 2017-2018 ccls Authors // SPDX-License-Identifier: Apache-2.0 #pragma once #include "lsp.hh" #include "query.hh" #include #include #include #include #include namespace ccls { struct SemaManager; struct GroupMatch; struct Project; struct WorkingFiles; struct VFS { struct State { int64_t timestamp; int step; int loaded; }; std::unordered_map 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 { Delete, Background, OnChange, Normal, }; namespace pipeline { extern std::atomic g_quit; extern std::atomic 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 &args, IndexMode mode, bool must_exist, RequestId id = {}); void removeCache(const std::string &path); std::optional loadIndexedContent(const std::string &path); void notifyOrRequest(const char *method, bool request, const std::function &fn); template void notify(const char *method, T &result) { notifyOrRequest(method, false, [&](JsonWriter &w) { reflect(w, result); }); } template void request(const char *method, T &result) { notifyOrRequest(method, true, [&](JsonWriter &w) { reflect(w, result); }); } void reply(RequestId id, const std::function &fn); void replyError(RequestId id, const std::function &fn); template void replyError(RequestId id, T &result) { replyError(id, [&](JsonWriter &w) { reflect(w, result); }); } } // namespace pipeline } // namespace ccls