[PATCH] D52084: [clangd] Improve PostingList iterator string representation
Kirill Bobyrev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 18 07:21:57 PDT 2018
kbobyrev updated this revision to Diff 165973.
kbobyrev marked an inline comment as done.
https://reviews.llvm.org/D52084
Files:
clang-tools-extra/clangd/index/dex/Iterator.h
clang-tools-extra/clangd/index/dex/PostingList.cpp
clang-tools-extra/unittests/clangd/DexTests.cpp
Index: clang-tools-extra/unittests/clangd/DexTests.cpp
===================================================================
--- clang-tools-extra/unittests/clangd/DexTests.cpp
+++ clang-tools-extra/unittests/clangd/DexTests.cpp
@@ -262,13 +262,15 @@
const PostingList L4({0, 1, 5});
const PostingList L5({});
- EXPECT_EQ(llvm::to_string(*(L0.iterator())), "[4]");
+ EXPECT_EQ(llvm::to_string(*(L0.iterator())), "[4 ...]");
auto Nested =
createAnd(createAnd(L1.iterator(), L2.iterator()),
createOr(L3.iterator(), L4.iterator(), L5.iterator()));
- EXPECT_EQ(llvm::to_string(*Nested), "(& (| [5] [1] [END]) (& [1] [1]))");
+ EXPECT_EQ(
+ llvm::to_string(*Nested),
+ "(& (| [... 5] [... 1 ...] [END]) (& [1 ...] [1 ...]))");
}
TEST(DexIterators, Limit) {
Index: clang-tools-extra/clangd/index/dex/PostingList.cpp
===================================================================
--- clang-tools-extra/clangd/index/dex/PostingList.cpp
+++ clang-tools-extra/clangd/index/dex/PostingList.cpp
@@ -61,10 +61,14 @@
private:
llvm::raw_ostream &dump(llvm::raw_ostream &OS) const override {
OS << '[';
+ if (Index != std::begin(Documents))
+ OS << "... ";
if (Index != std::end(Documents))
OS << *Index;
else
OS << "END";
+ if (Index != std::end(Documents) && Index != std::end(Documents) - 1)
+ OS << " ...";
OS << ']';
return OS;
}
Index: clang-tools-extra/clangd/index/dex/Iterator.h
===================================================================
--- clang-tools-extra/clangd/index/dex/Iterator.h
+++ clang-tools-extra/clangd/index/dex/Iterator.h
@@ -93,9 +93,8 @@
///
/// Where Type is the iterator type representation: "&" for And, "|" for Or,
/// ChildN is N-th iterator child. Raw iterators over PostingList are
- /// represented as "[ID1, ID2, ..., {IDN}, ... END]" where IDN is N-th
- /// PostingList entry and the element which is pointed to by the PostingList
- /// iterator is enclosed in {} braces.
+ /// represented as "[... ID ...]" where ID is the element under iterator
+ /// cursor.
friend llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
const Iterator &Iterator) {
return Iterator.dump(OS);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52084.165973.patch
Type: text/x-patch
Size: 2289 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180918/8c16f457/attachment-0001.bin>
More information about the cfe-commits
mailing list