summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/ClangdServer.cpp
diff options
context:
space:
mode:
authorIlya Biryukov <ibiryukov@google.com>2017-05-30 15:11:02 +0000
committerIlya Biryukov <ibiryukov@google.com>2017-05-30 15:11:02 +0000
commit2260299830012fbf5264dd048f0c544dc8a2a4e1 (patch)
tree2df2182d32115104d1fc79bfd066f22eaa9b03e8 /clang-tools-extra/clangd/ClangdServer.cpp
parent346066b68cacc3aea124b9765bd8723ae73c66dd (diff)
downloadbcm5719-llvm-2260299830012fbf5264dd048f0c544dc8a2a4e1.tar.gz
bcm5719-llvm-2260299830012fbf5264dd048f0c544dc8a2a4e1.zip
[clangd] Mark results of clangd requests with a tag provided by the FileSystemProvider.
Summary: This allows an implementation of FileSystemProvider that can track which vfs::FileSystem were used for each of the requests. Reviewers: bkramer, krasimir Reviewed By: bkramer Subscribers: klimek, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D33678 llvm-svn: 304214
Diffstat (limited to 'clang-tools-extra/clangd/ClangdServer.cpp')
-rw-r--r--clang-tools-extra/clangd/ClangdServer.cpp29
1 files changed, 16 insertions, 13 deletions
diff --git a/clang-tools-extra/clangd/ClangdServer.cpp b/clang-tools-extra/clangd/ClangdServer.cpp
index feadf71fabc..459b6a64217 100644
--- a/clang-tools-extra/clangd/ClangdServer.cpp
+++ b/clang-tools-extra/clangd/ClangdServer.cpp
@@ -58,8 +58,9 @@ Position clangd::offsetToPosition(StringRef Code, size_t Offset) {
return {Lines, Cols};
}
-IntrusiveRefCntPtr<vfs::FileSystem> RealFileSystemProvider::getFileSystem() {
- return vfs::getRealFileSystem();
+Tagged<IntrusiveRefCntPtr<vfs::FileSystem>>
+RealFileSystemProvider::getTaggedFileSystem() {
+ return make_tagged(vfs::getRealFileSystem(), VFSTag());
}
ClangdScheduler::ClangdScheduler(bool RunSynchronously)
@@ -156,11 +157,13 @@ void ClangdServer::addDocument(PathRef File, StringRef Contents) {
assert(FileContents.Draft &&
"No contents inside a file that was scheduled for reparse");
- Units.runOnUnit(FileStr, *FileContents.Draft, *CDB, PCHs,
- FSProvider->getFileSystem(), [&](ClangdUnit const &Unit) {
- DiagConsumer->onDiagnosticsReady(
- FileStr, Unit.getLocalDiagnostics());
- });
+ auto TaggedFS = FSProvider->getTaggedFileSystem();
+ Units.runOnUnit(
+ FileStr, *FileContents.Draft, *CDB, PCHs, TaggedFS.Value,
+ [&](ClangdUnit const &Unit) {
+ DiagConsumer->onDiagnosticsReady(
+ FileStr, make_tagged(Unit.getLocalDiagnostics(), TaggedFS.Tag));
+ });
});
}
@@ -181,18 +184,18 @@ void ClangdServer::forceReparse(PathRef File) {
addDocument(File, getDocument(File));
}
-std::vector<CompletionItem> ClangdServer::codeComplete(PathRef File,
- Position Pos) {
+Tagged<std::vector<CompletionItem>> ClangdServer::codeComplete(PathRef File,
+ Position Pos) {
auto FileContents = DraftMgr.getDraft(File);
assert(FileContents.Draft && "codeComplete is called for non-added document");
std::vector<CompletionItem> Result;
- auto VFS = FSProvider->getFileSystem();
+ auto TaggedFS = FSProvider->getTaggedFileSystem();
Units.runOnUnitWithoutReparse(
- File, *FileContents.Draft, *CDB, PCHs, VFS, [&](ClangdUnit &Unit) {
- Result = Unit.codeComplete(*FileContents.Draft, Pos, VFS);
+ File, *FileContents.Draft, *CDB, PCHs, TaggedFS.Value, [&](ClangdUnit &Unit) {
+ Result = Unit.codeComplete(*FileContents.Draft, Pos, TaggedFS.Value);
});
- return Result;
+ return make_tagged(std::move(Result), TaggedFS.Tag);
}
std::vector<tooling::Replacement> ClangdServer::formatRange(PathRef File,
OpenPOWER on IntegriCloud