[PATCH] D130011: Use pseudoparser-based folding ranges in ClangdServer.

Utkarsh Saxena via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 18 09:39:31 PDT 2022


usaxena95 updated this revision to Diff 445547.
usaxena95 added a comment.

Removed option to fallback to AST based implementation.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D130011/new/

https://reviews.llvm.org/D130011

Files:
  clang-tools-extra/clangd/ClangdServer.cpp


Index: clang-tools-extra/clangd/ClangdServer.cpp
===================================================================
--- clang-tools-extra/clangd/ClangdServer.cpp
+++ clang-tools-extra/clangd/ClangdServer.cpp
@@ -834,14 +834,17 @@
 
 void ClangdServer::foldingRanges(llvm::StringRef File,
                                  Callback<std::vector<FoldingRange>> CB) {
-  auto Action =
-      [CB = std::move(CB)](llvm::Expected<InputsAndAST> InpAST) mutable {
-        if (!InpAST)
-          return CB(InpAST.takeError());
-        CB(clangd::getFoldingRanges(InpAST->AST));
-      };
-  WorkScheduler->runWithAST("FoldingRanges", File, std::move(Action),
-                            Transient);
+  auto Code = getDraft(File);
+  if (!Code)
+    return CB(llvm::make_error<LSPError>(
+        "trying to compute folding ranges for non-added document",
+        ErrorCode::InvalidParams));
+  auto Action = [CB = std::move(CB), Code = std::move(*Code)]() mutable {
+    CB(clangd::getFoldingRanges(Code));
+  };
+  // We want to make sure folding ranges are always available for all the open
+  // files, hence prefer runQuick to not wait for operations on other files.
+  WorkScheduler->runQuick("FoldingRanges", File, std::move(Action));
 }
 
 void ClangdServer::findType(llvm::StringRef File, Position Pos,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D130011.445547.patch
Type: text/x-patch
Size: 1308 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220718/7e8c4d8a/attachment.bin>


More information about the cfe-commits mailing list