2017-05-16 17:38:59 +08:00
|
|
|
//===--- DraftStore.cpp - File contents container ---------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "DraftStore.h"
|
|
|
|
|
2017-05-16 18:06:20 +08:00
|
|
|
using namespace clang;
|
2017-05-16 17:38:59 +08:00
|
|
|
using namespace clang::clangd;
|
|
|
|
|
|
|
|
VersionedDraft DraftStore::getDraft(PathRef File) const {
|
|
|
|
std::lock_guard<std::mutex> Lock(Mutex);
|
|
|
|
|
|
|
|
auto It = Drafts.find(File);
|
|
|
|
if (It == Drafts.end())
|
|
|
|
return {0, llvm::None};
|
|
|
|
return It->second;
|
|
|
|
}
|
|
|
|
|
[clangd] DidChangeConfiguration Notification
Summary:
Implementation of DidChangeConfiguration notification handling in
clangd. This currently only supports changing one setting: the path of
the compilation database to be used for the current project. In other
words, it is no longer necessary to restart clangd with a different
command line argument in order to change the compilation database.
Reviewers: malaperle, krasimir, bkramer, ilya-biryukov
Subscribers: jkorous-apple, ioeric, simark, klimek, ilya-biryukov, arphaman, rwols, cfe-commits
Differential Revision: https://reviews.llvm.org/D39571
Signed-off-by: Simon Marchi <simon.marchi@ericsson.com>
Signed-off-by: William Enright <william.enright@polymtl.ca>
llvm-svn: 325784
2018-02-22 22:00:39 +08:00
|
|
|
std::vector<Path> DraftStore::getActiveFiles() const {
|
|
|
|
std::lock_guard<std::mutex> Lock(Mutex);
|
|
|
|
std::vector<Path> ResultVector;
|
|
|
|
|
|
|
|
for (auto DraftIt = Drafts.begin(); DraftIt != Drafts.end(); DraftIt++)
|
|
|
|
if (DraftIt->second.Draft)
|
|
|
|
ResultVector.push_back(DraftIt->getKey());
|
|
|
|
|
|
|
|
return ResultVector;
|
|
|
|
}
|
|
|
|
|
2017-05-16 17:38:59 +08:00
|
|
|
DocVersion DraftStore::getVersion(PathRef File) const {
|
|
|
|
std::lock_guard<std::mutex> Lock(Mutex);
|
|
|
|
|
|
|
|
auto It = Drafts.find(File);
|
|
|
|
if (It == Drafts.end())
|
|
|
|
return 0;
|
|
|
|
return It->second.Version;
|
|
|
|
}
|
|
|
|
|
|
|
|
DocVersion DraftStore::updateDraft(PathRef File, StringRef Contents) {
|
|
|
|
std::lock_guard<std::mutex> Lock(Mutex);
|
|
|
|
|
|
|
|
auto &Entry = Drafts[File];
|
|
|
|
DocVersion NewVersion = ++Entry.Version;
|
|
|
|
Entry.Draft = Contents;
|
|
|
|
return NewVersion;
|
|
|
|
}
|
|
|
|
|
|
|
|
DocVersion DraftStore::removeDraft(PathRef File) {
|
|
|
|
std::lock_guard<std::mutex> Lock(Mutex);
|
|
|
|
|
|
|
|
auto &Entry = Drafts[File];
|
|
|
|
DocVersion NewVersion = ++Entry.Version;
|
|
|
|
Entry.Draft = llvm::None;
|
|
|
|
return NewVersion;
|
|
|
|
}
|