[clang-tools-extra] r309585 - [clangd] Allow to get vfs::FileSystem used inside codeComplete.
Ilya Biryukov via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 31 10:09:29 PDT 2017
Author: ibiryukov
Date: Mon Jul 31 10:09:29 2017
New Revision: 309585
URL: http://llvm.org/viewvc/llvm-project?rev=309585&view=rev
Log:
[clangd] Allow to get vfs::FileSystem used inside codeComplete.
Summary: This is useful for managing lifetime of VFS-based caches.
Reviewers: bkramer, krasimir
Reviewed By: bkramer
Subscribers: klimek, cfe-commits
Differential Revision: https://reviews.llvm.org/D36095
Modified:
clang-tools-extra/trunk/clangd/ClangdServer.cpp
clang-tools-extra/trunk/clangd/ClangdServer.h
Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=309585&r1=309584&r2=309585&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Mon Jul 31 10:09:29 2017
@@ -192,7 +192,8 @@ void ClangdServer::forceReparse(PathRef
Tagged<std::vector<CompletionItem>>
ClangdServer::codeComplete(PathRef File, Position Pos,
- llvm::Optional<StringRef> OverridenContents) {
+ llvm::Optional<StringRef> OverridenContents,
+ IntrusiveRefCntPtr<vfs::FileSystem> *UsedFS) {
std::string DraftStorage;
if (!OverridenContents) {
auto FileContents = DraftMgr.getDraft(File);
@@ -203,8 +204,11 @@ ClangdServer::codeComplete(PathRef File,
OverridenContents = DraftStorage;
}
- std::vector<CompletionItem> Result;
auto TaggedFS = FSProvider.getTaggedFileSystem(File);
+ if (UsedFS)
+ *UsedFS = TaggedFS.Value;
+
+ std::vector<CompletionItem> Result;
Units.runOnUnitWithoutReparse(File, *OverridenContents, ResourceDir, CDB,
PCHs, TaggedFS.Value, [&](ClangdUnit &Unit) {
Result = Unit.codeComplete(
Modified: clang-tools-extra/trunk/clangd/ClangdServer.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.h?rev=309585&r1=309584&r2=309585&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/ClangdServer.h (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.h Mon Jul 31 10:09:29 2017
@@ -175,10 +175,14 @@ public:
/// will be scheduled and a draft for \p File will not be updated.
/// If \p OverridenContents is None, contents of the current draft for \p File
/// will be used.
- /// This method should only be called for currently tracked files.
+ /// If \p UsedFS is non-null, it will be overwritten by vfs::FileSystem used
+ /// for completion.
+ /// This method should only be called for currently tracked
+ /// files.
Tagged<std::vector<CompletionItem>>
codeComplete(PathRef File, Position Pos,
- llvm::Optional<StringRef> OverridenContents = llvm::None);
+ llvm::Optional<StringRef> OverridenContents = llvm::None,
+ IntrusiveRefCntPtr<vfs::FileSystem> *UsedFS = nullptr);
/// Get definition of symbol at a specified \p Line and \p Column in \p File.
Tagged<std::vector<Location>> findDefinitions(PathRef File, Position Pos);
More information about the cfe-commits
mailing list