[clang-tools-extra] r321157 - [clangd] Igore cases in index fuzzy find.
Eric Liu via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 20 01:29:55 PST 2017
Author: ioeric
Date: Wed Dec 20 01:29:54 2017
New Revision: 321157
URL: http://llvm.org/viewvc/llvm-project?rev=321157&view=rev
Log:
[clangd] Igore cases in index fuzzy find.
Modified:
clang-tools-extra/trunk/clangd/index/MemIndex.cpp
clang-tools-extra/trunk/unittests/clangd/IndexTests.cpp
Modified: clang-tools-extra/trunk/clangd/index/MemIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/MemIndex.cpp?rev=321157&r1=321156&r2=321157&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/index/MemIndex.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/MemIndex.cpp Wed Dec 20 01:29:54 2017
@@ -49,7 +49,7 @@ bool MemIndex::fuzzyFind(const Context &
continue;
// FIXME(ioeric): use fuzzy matcher.
- if (StringRef(StringRef(Sym->Name).lower()).contains(Req.Query)) {
+ if (StringRef(Sym->Name).find_lower(Req.Query) != StringRef::npos) {
if (++Matched > Req.MaxCandidateCount)
return false;
Callback(*Sym);
Modified: clang-tools-extra/trunk/unittests/clangd/IndexTests.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/IndexTests.cpp?rev=321157&r1=321156&r2=321157&view=diff
==============================================================================
--- clang-tools-extra/trunk/unittests/clangd/IndexTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/IndexTests.cpp Wed Dec 20 01:29:54 2017
@@ -178,6 +178,16 @@ TEST(MemIndexTest, NoMatchNestedScopes)
EXPECT_THAT(match(I, Req), UnorderedElementsAre("a::xyz"));
}
+TEST(MemIndexTest, IgnoreCases) {
+ MemIndex I;
+ I.build(generateSymbols({"ns::ABC", "ns::abc"}));
+ FuzzyFindRequest Req;
+ Req.Query = "AB";
+ Req.Scopes = {"ns"};
+ auto Matches = match(I, Req);
+ EXPECT_THAT(match(I, Req), UnorderedElementsAre("ns::ABC", "ns::abc"));
+}
+
} // namespace
} // namespace clangd
} // namespace clang
More information about the cfe-commits
mailing list