[PATCH] D36095: [clangd] Allow to get vfs::FileSystem used inside codeComplete.

Phabricator via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 31 10:10:13 PDT 2017


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(


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36095.108949.patch
Type: text/x-patch
Size: 2273 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170731/0fc7693d/attachment-0001.bin>


More information about the cfe-commits mailing list