nixd
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | List of all members
lspserver::DraftStore Class Reference

#include <DraftStore.h>

Classes

struct  Draft
 

Public Member Functions

std::optional< DraftgetDraft (PathRef File) const
 
std::vector< PathgetActiveFiles () const
 
std::string addDraft (PathRef File, llvm::StringRef Version, llvm::StringRef Contents)
 
void removeDraft (PathRef File)
 Remove the draft from the store.
 
llvm::IntrusiveRefCntPtr< llvm::vfs::FileSystem > asVFS () const
 

Static Public Member Functions

static std::string encodeVersion (std::optional< int64_t > LSPVersion)
 
static std::optional< int64_tdecodeVersion (llvm::StringRef Encoded)
 

Detailed Description

A thread-safe container for files opened in a workspace, addressed by filenames. The contents are owned by the DraftStore. Each time a draft is updated, it is assigned a version. This can be specified by the caller or incremented from the previous version.

Definition at line 25 of file DraftStore.h.

Member Function Documentation

◆ addDraft()

std::string lspserver::DraftStore::addDraft ( PathRef File,
llvm::StringRef Version,
llvm::StringRef Contents )

Replace contents of the draft for File with Contents. If version is empty, one will be automatically assigned. Returns the version.

Definition at line 88 of file DraftStore.cpp.

References lspserver::DraftStore::Draft::Contents, lspserver::File, lspserver::fromJSON(), and lspserver::DraftStore::Draft::Version.

◆ asVFS()

llvm::IntrusiveRefCntPtr< llvm::vfs::FileSystem > lspserver::DraftStore::asVFS ( ) const

◆ decodeVersion()

std::optional< int64_t > lspserver::DraftStore::decodeVersion ( llvm::StringRef Encoded)
static

Definition at line 61 of file DraftStore.cpp.

References lspserver::elog(), and lspserver::fromJSON().

◆ encodeVersion()

std::string lspserver::DraftStore::encodeVersion ( std::optional< int64_t > LSPVersion)
static

LSP defines file versions as numbers that increase. treats them as opaque and therefore uses strings instead.

Definition at line 84 of file DraftStore.cpp.

References lspserver::fromJSON().

◆ getActiveFiles()

std::vector< Path > lspserver::DraftStore::getActiveFiles ( ) const
Returns
List of names of the drafts in this store.

Definition at line 28 of file DraftStore.cpp.

References lspserver::fromJSON().

◆ getDraft()

std::optional< DraftStore::Draft > lspserver::DraftStore::getDraft ( PathRef File) const
Returns
Contents of the stored document. For untracked files, a std::nullopt is returned.

Definition at line 18 of file DraftStore.cpp.

References lspserver::File, and lspserver::fromJSON().

◆ removeDraft()

void lspserver::DraftStore::removeDraft ( PathRef File)

Remove the draft from the store.

Definition at line 99 of file DraftStore.cpp.

References lspserver::File, and lspserver::fromJSON().


The documentation for this class was generated from the following files: