clang-tools 20.0.0git
Classes | Public Member Functions | List of all members
clang::clangd::DraftStore Class Reference

A thread-safe container for files opened in a workspace, addressed by filenames. More...

#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, StringRef Contents)
 Replace contents of the draft for File with Contents.
 
void removeDraft (PathRef File)
 Remove the draft from the store.
 
llvm::IntrusiveRefCntPtr< llvm::vfs::FileSystem > asVFS () const
 

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 28 of file DraftStore.h.

Member Function Documentation

◆ addDraft()

std::string clang::clangd::DraftStore::addDraft ( PathRef  File,
llvm::StringRef  Version,
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 75 of file DraftStore.cpp.

References clang::clangd::File, and clang::clangd::updateVersion().

Referenced by clang::clangd::ClangdServer::addDocument().

◆ asVFS()

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

Definition at line 117 of file DraftStore.cpp.

References clang::clangd::DraftStore::Draft::Contents.

◆ getActiveFiles()

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

Definition at line 29 of file DraftStore.cpp.

Referenced by clang::clangd::ClangdServer::reparseOpenFilesIfNeeded().

◆ getDraft()

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

Definition at line 19 of file DraftStore.cpp.

References clang::clangd::File.

Referenced by clang::clangd::ClangdServer::getDraft(), and clang::clangd::ClangdServer::reparseOpenFilesIfNeeded().

◆ removeDraft()

void clang::clangd::DraftStore::removeDraft ( PathRef  File)

Remove the draft from the store.

Definition at line 86 of file DraftStore.cpp.

References clang::clangd::File.

Referenced by clang::clangd::ClangdServer::removeDocument().


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