This revision was automatically updated to reflect the committed changes. Closed by commit rL309585: [clangd] Allow to get vfs::FileSystem used inside codeComplete. (authored by ibiryukov).
Repository: rL LLVM https://reviews.llvm.org/D36095 Files: clang-tools-extra/trunk/clangd/ClangdServer.cpp clang-tools-extra/trunk/clangd/ClangdServer.h Index: clang-tools-extra/trunk/clangd/ClangdServer.h =================================================================== --- clang-tools-extra/trunk/clangd/ClangdServer.h +++ clang-tools-extra/trunk/clangd/ClangdServer.h @@ -175,10 +175,14 @@ /// 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); Index: clang-tools-extra/trunk/clangd/ClangdServer.cpp =================================================================== --- clang-tools-extra/trunk/clangd/ClangdServer.cpp +++ clang-tools-extra/trunk/clangd/ClangdServer.cpp @@ -192,7 +192,8 @@ 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 @@ 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(
Index: clang-tools-extra/trunk/clangd/ClangdServer.h =================================================================== --- clang-tools-extra/trunk/clangd/ClangdServer.h +++ clang-tools-extra/trunk/clangd/ClangdServer.h @@ -175,10 +175,14 @@ /// 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); Index: clang-tools-extra/trunk/clangd/ClangdServer.cpp =================================================================== --- clang-tools-extra/trunk/clangd/ClangdServer.cpp +++ clang-tools-extra/trunk/clangd/ClangdServer.cpp @@ -192,7 +192,8 @@ 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 @@ 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(
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits