clang-tools 10.0.0

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>`

## Public Member Functions
llvm::Optional< std::string > | getDraft (PathRef File) const
std::vector< Path > | getActiveFiles () const
void | addDraft (PathRef File, StringRef Contents)
| Replace contents of the draft for `File` with `Contents`. More...
llvm::Expected< std::string > | updateDraft (PathRef File, llvm::ArrayRef< TextDocumentContentChangeEvent > Changes)
| Update the contents of the draft for `File` based on `Changes`. More...
void | removeDraft (PathRef File)
| Remove the draft from the store. More...

## Detailed Description

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

The contents are owned by the DraftStore. This class supports both whole and incremental updates of the documents.

Definition at line 26 of file DraftStore.h.

## Member Function Documentation

## ◆ addDraft()

void clang::clangd::DraftStore::addDraft | ( | PathRef | File,
|  | StringRef | Contents
| ) |  |

Replace contents of the draft for `File` with `Contents`.

Definition at line 36 of file DraftStore.cpp.

References Contents, and clang::clangd::File.

## ◆ getActiveFiles()

std::vector< Path > clang::clangd::DraftStore::getActiveFiles | ( |  | ) | const

Returns
  List of names of the drafts in this store.

Definition at line 26 of file DraftStore.cpp.

## ◆ getDraft()

llvm::Optional< std::string > clang::clangd::DraftStore::getDraft | ( | PathRef | File | ) | const

Returns
  Contents of the stored document. For untracked files, a llvm::None is returned.

Definition at line 16 of file DraftStore.cpp.

References clang::clangd::None.

## ◆ removeDraft()

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

Remove the draft from the store.

Definition at line 111 of file DraftStore.cpp.

## ◆ updateDraft()

llvm::Expected< std::string > clang::clangd::DraftStore::updateDraft | ( | PathRef | File,
|  | llvm::ArrayRef< TextDocumentContentChangeEvent > | Changes
| ) |  |

Update the contents of the draft for `File` based on `Changes`.

If a position in `Changes` is invalid (e.g. out-of-range), the draft is not modified.

Returns
  The new version of the draft for `File`, or an error if the changes couldn't be applied.

Definition at line 42 of file DraftStore.cpp.

References Contents, and clang::clangd::File.

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

- DraftStore.h
- DraftStore.cpp