[PATCH] D54106: [clangd] Limit the index-returned results in dexp.

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 5 08:47:58 PST 2018


hokein updated this revision to Diff 172598.
hokein added a comment.

Address review comment.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54106

Files:
  clangd/index/dex/dexp/Dexp.cpp


Index: clangd/index/dex/dexp/Dexp.cpp
===================================================================
--- clangd/index/dex/dexp/Dexp.cpp
+++ clangd/index/dex/dexp/Dexp.cpp
@@ -50,8 +50,10 @@
 }
 
 std::vector<SymbolID> getSymbolIDsFromIndex(StringRef QualifiedName,
-                                            const SymbolIndex *Index) {
+                                            const SymbolIndex *Index,
+                                            unsigned Limit) {
   FuzzyFindRequest Request;
+  Request.Limit = Limit;
   // Remove leading "::" qualifier as FuzzyFind doesn't need leading "::"
   // qualifier for global scope.
   bool IsGlobalScope = QualifiedName.consume_front("::");
@@ -158,6 +160,11 @@
   cl::opt<std::string> Name{
       "name", cl::desc("Qualified name to look up."),
   };
+  cl::opt<unsigned> Limit{
+      "limit",
+      cl::init(10),
+      cl::desc("Max results to display"),
+  };
 
   void run() override {
     if (ID.getNumOccurrences() == 0 && Name.getNumOccurrences() == 0) {
@@ -173,7 +180,7 @@
       }
       IDs.push_back(*SID);
     } else {
-      IDs = getSymbolIDsFromIndex(Name, Index);
+      IDs = getSymbolIDsFromIndex(Name, Index, Limit);
     }
 
     LookupRequest Request;
@@ -216,7 +223,7 @@
       }
       IDs.push_back(*SID);
     } else {
-      IDs = getSymbolIDsFromIndex(Name, Index);
+      IDs = getSymbolIDsFromIndex(Name, Index, /*Limit=*/10);
     }
     RefsRequest RefRequest;
     RefRequest.IDs.insert(IDs.begin(), IDs.end());


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54106.172598.patch
Type: text/x-patch
Size: 1510 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181105/520c9512/attachment-0001.bin>


More information about the cfe-commits mailing list