Author: Kadir Cetinkaya Date: 2021-03-03T15:41:39+01:00 New Revision: 188373fb46979d8141e9f844f13a85157b1ce5dd
URL: https://github.com/llvm/llvm-project/commit/188373fb46979d8141e9f844f13a85157b1ce5dd DIFF: https://github.com/llvm/llvm-project/commit/188373fb46979d8141e9f844f13a85157b1ce5dd.diff LOG: [clangd] Make WorkspaceSymbols request work with empty queries Clangd uses codecompletion limit as the limit for workspacesymbols, so in theory this should only be an order of magnitude slower than a codecompletion request with empty identifier (as code completion limits the available symbols). This is also what LSP suggests "Clients may send an empty string here to request all symbols.". Clangd doesn't really fulfill the "all" part of that statement, but we never do unless user set the index query limit to zero explicitly. Differential Revision: https://reviews.llvm.org/D97773 Added: Modified: clang-tools-extra/clangd/FindSymbols.cpp clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp Removed: ################################################################################ diff --git a/clang-tools-extra/clangd/FindSymbols.cpp b/clang-tools-extra/clangd/FindSymbols.cpp index cf517717a27a..bda5dcadf12e 100644 --- a/clang-tools-extra/clangd/FindSymbols.cpp +++ b/clang-tools-extra/clangd/FindSymbols.cpp @@ -88,7 +88,7 @@ llvm::Expected<std::vector<SymbolInformation>> getWorkspaceSymbols(llvm::StringRef Query, int Limit, const SymbolIndex *const Index, llvm::StringRef HintPath) { std::vector<SymbolInformation> Result; - if (Query.empty() || !Index) + if (!Index) return Result; // Lookup for qualified names are performed as: diff --git a/clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp b/clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp index fa9af8637304..30aca71a0570 100644 --- a/clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp +++ b/clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp @@ -216,7 +216,9 @@ TEST(WorkspaceSymbols, GlobalNamespaceQueries) { AllOf(QName("foo"), WithKind(SymbolKind::Function)), AllOf(QName("ns"), WithKind(SymbolKind::Namespace)))); EXPECT_THAT(getSymbols(TU, ":"), IsEmpty()); - EXPECT_THAT(getSymbols(TU, ""), IsEmpty()); + EXPECT_THAT(getSymbols(TU, ""), + UnorderedElementsAre(QName("foo"), QName("Foo"), QName("Foo::a"), + QName("ns"), QName("ns::foo2"))); } TEST(WorkspaceSymbols, Enums) { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits