diff options
Diffstat (limited to 'clang-tools-extra/clangd/DraftStore.h')
| -rw-r--r-- | clang-tools-extra/clangd/DraftStore.h | 40 |
1 files changed, 10 insertions, 30 deletions
diff --git a/clang-tools-extra/clangd/DraftStore.h b/clang-tools-extra/clangd/DraftStore.h index 4757768a377..c84b0c1391a 100644 --- a/clang-tools-extra/clangd/DraftStore.h +++ b/clang-tools-extra/clangd/DraftStore.h @@ -13,7 +13,6 @@ #include "Path.h" #include "clang/Basic/LLVM.h" #include "llvm/ADT/StringMap.h" -#include <cstdint> #include <mutex> #include <string> #include <vector> @@ -21,45 +20,26 @@ namespace clang { namespace clangd { -/// Using unsigned int type here to avoid undefined behaviour on overflow. -typedef uint64_t DocVersion; - -/// Document draft with a version of this draft. -struct VersionedDraft { - DocVersion Version; - /// If the value of the field is None, draft is now deleted - llvm::Optional<std::string> Draft; -}; - /// A thread-safe container for files opened in a workspace, addressed by -/// filenames. The contents are owned by the DraftStore. Versions are mantained -/// for the all added documents, including removed ones. The document version is -/// incremented on each update and removal of the document. +/// filenames. The contents are owned by the DraftStore. class DraftStore { public: - /// \return version and contents of the stored document. - /// For untracked files, a (0, None) pair is returned. - VersionedDraft getDraft(PathRef File) const; + /// \return Contents of the stored document. + /// For untracked files, a llvm::None is returned. + llvm::Optional<std::string> getDraft(PathRef File) const; - /// \return List of names of active drafts in this store. Drafts that were - /// removed (which still have an entry in the Drafts map) are not returned by - /// this function. + /// \return List of names of the drafts in this store. std::vector<Path> getActiveFiles() const; - /// \return version of the tracked document. - /// For untracked files, 0 is returned. - DocVersion getVersion(PathRef File) const; - /// Replace contents of the draft for \p File with \p Contents. - /// \return The new version of the draft for \p File. - DocVersion updateDraft(PathRef File, StringRef Contents); - /// Remove the contents of the draft - /// \return The new version of the draft for \p File. - DocVersion removeDraft(PathRef File); + void updateDraft(PathRef File, StringRef Contents); + + /// Remove the draft from the store. + void removeDraft(PathRef File); private: mutable std::mutex Mutex; - llvm::StringMap<VersionedDraft> Drafts; + llvm::StringMap<std::string> Drafts; }; } // namespace clangd |

