| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_DRAFTSTORE_H |
| 10 |
#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_DRAFTSTORE_H |
| 11 |
|
| 12 |
#include "support/Path.h" |
| 13 |
#include "clang/Basic/LLVM.h" |
| 14 |
#include "llvm/ADT/StringMap.h" |
| 15 |
#include "llvm/Support/VirtualFileSystem.h" |
| 16 |
#include <mutex> |
| 17 |
#include <optional> |
| 18 |
#include <string> |
| 19 |
#include <vector> |
| 20 |
|
| 21 |
namespace clang { |
| 22 |
namespace clangd { |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
class DraftStore { |
| 29 |
public: |
| 30 |
struct Draft { |
| 31 |
std::shared_ptr<const std::string> Contents; |
| 32 |
std::string Version; |
| 33 |
}; |
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
std::optional<Draft> getDraft(PathRef File) const; |
| 38 |
|
| 39 |
|
| 40 |
std::vector<Path> getActiveFiles() const; |
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
std::string addDraft(PathRef File, llvm::StringRef Version, |
| 46 |
StringRef Contents); |
| 47 |
|
| 48 |
|
| 49 |
void removeDraft(PathRef File); |
| 50 |
|
| 51 |
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> asVFS() const; |
| 52 |
|
| 53 |
private: |
| 54 |
struct DraftAndTime { |
| 55 |
Draft D; |
| 56 |
std::time_t MTime; |
| 57 |
}; |
| 58 |
mutable std::mutex Mutex; |
| 59 |
llvm::StringMap<DraftAndTime> Drafts; |
| 60 |
}; |
| 61 |
|
| 62 |
} |
| 63 |
} |
| 64 |
|
| 65 |
#endif |