mirror of
https://github.com/Gericom/teak-llvm.git
synced 2025-06-19 03:25:54 -04:00

to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
60 lines
1.9 KiB
C++
60 lines
1.9 KiB
C++
//===--- DraftStore.h - File contents container -----------------*- C++ -*-===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_DRAFTSTORE_H
|
|
#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_DRAFTSTORE_H
|
|
|
|
#include "Path.h"
|
|
#include "Protocol.h"
|
|
#include "clang/Basic/LLVM.h"
|
|
#include "llvm/ADT/StringMap.h"
|
|
#include <mutex>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace clang {
|
|
namespace clangd {
|
|
|
|
/// 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.
|
|
class DraftStore {
|
|
public:
|
|
/// \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 the drafts in this store.
|
|
std::vector<Path> getActiveFiles() const;
|
|
|
|
/// Replace contents of the draft for \p File with \p Contents.
|
|
void addDraft(PathRef File, StringRef Contents);
|
|
|
|
/// Update the contents of the draft for \p File based on \p Changes.
|
|
/// If a position in \p Changes is invalid (e.g. out-of-range), the
|
|
/// draft is not modified.
|
|
///
|
|
/// \return The new version of the draft for \p File, or an error if the
|
|
/// changes couldn't be applied.
|
|
llvm::Expected<std::string>
|
|
updateDraft(PathRef File,
|
|
llvm::ArrayRef<TextDocumentContentChangeEvent> Changes);
|
|
|
|
/// Remove the draft from the store.
|
|
void removeDraft(PathRef File);
|
|
|
|
private:
|
|
mutable std::mutex Mutex;
|
|
llvm::StringMap<std::string> Drafts;
|
|
};
|
|
|
|
} // namespace clangd
|
|
} // namespace clang
|
|
|
|
#endif
|