LCOV - code coverage report
Current view: top level - clang/tools/extra/clangd - DraftStore.h (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 0 1 0.0 %
Date: 2018-10-17 09:37:48 Functions: 0 0 -
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===--- DraftStore.h - File contents container -----------------*- C++ -*-===//
       2             : //
       3             : //                     The LLVM Compiler Infrastructure
       4             : //
       5             : // This file is distributed under the University of Illinois Open Source
       6             : // License. See LICENSE.TXT for details.
       7             : //
       8             : //===----------------------------------------------------------------------===//
       9             : 
      10             : #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_DRAFTSTORE_H
      11             : #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_DRAFTSTORE_H
      12             : 
      13             : #include "Path.h"
      14             : #include "Protocol.h"
      15             : #include "clang/Basic/LLVM.h"
      16             : #include "llvm/ADT/StringMap.h"
      17             : #include <mutex>
      18             : #include <string>
      19             : #include <vector>
      20             : 
      21             : namespace clang {
      22             : namespace clangd {
      23             : 
      24             : /// A thread-safe container for files opened in a workspace, addressed by
      25             : /// filenames. The contents are owned by the DraftStore. This class supports
      26             : /// both whole and incremental updates of the documents.
      27           0 : class DraftStore {
      28             : public:
      29             :   /// \return Contents of the stored document.
      30             :   /// For untracked files, a llvm::None is returned.
      31             :   llvm::Optional<std::string> getDraft(PathRef File) const;
      32             : 
      33             :   /// \return List of names of the drafts in this store.
      34             :   std::vector<Path> getActiveFiles() const;
      35             : 
      36             :   /// Replace contents of the draft for \p File with \p Contents.
      37             :   void addDraft(PathRef File, StringRef Contents);
      38             : 
      39             :   /// Update the contents of the draft for \p File based on \p Changes.
      40             :   /// If a position in \p Changes is invalid (e.g. out-of-range), the
      41             :   /// draft is not modified.
      42             :   ///
      43             :   /// \return The new version of the draft for \p File, or an error if the
      44             :   /// changes couldn't be applied.
      45             :   llvm::Expected<std::string>
      46             :   updateDraft(PathRef File,
      47             :               llvm::ArrayRef<TextDocumentContentChangeEvent> Changes);
      48             : 
      49             :   /// Remove the draft from the store.
      50             :   void removeDraft(PathRef File);
      51             : 
      52             : private:
      53             :   mutable std::mutex Mutex;
      54             :   llvm::StringMap<std::string> Drafts;
      55             : };
      56             : 
      57             : } // namespace clangd
      58             : } // namespace clang
      59             : 
      60             : #endif

Generated by: LCOV version 1.13