kbobyrev created this revision.
kbobyrev added reviewers: ioeric, sammccall, ilya-biryukov.
kbobyrev added a project: clang-tools-extra.
Herald added subscribers: kadircet, arphaman, jkorous, MaskRay, mgorny.
kbobyrev updated this revision to Diff 164367.
kbobyrev added a comment.

`%s/DexIndex/Dex`


Since Dex is no longer independent and experimental index implementation, it 
might be reasonable to move it to the rest of Clangd index sources.


https://reviews.llvm.org/D51774

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/index/Dex.cpp
  clang-tools-extra/clangd/index/Dex.h
  clang-tools-extra/clangd/index/Iterator.cpp
  clang-tools-extra/clangd/index/Iterator.h
  clang-tools-extra/clangd/index/SymbolYAML.cpp
  clang-tools-extra/clangd/index/Token.h
  clang-tools-extra/clangd/index/Trigram.cpp
  clang-tools-extra/clangd/index/Trigram.h
  clang-tools-extra/clangd/tool/ClangdMain.cpp
  clang-tools-extra/unittests/clangd/DexIndexTests.cpp
  clang-tools-extra/unittests/clangd/TestIndex.cpp
  clang-tools-extra/unittests/clangd/TestIndex.h

Index: clang-tools-extra/unittests/clangd/TestIndex.h
===================================================================
--- clang-tools-extra/unittests/clangd/TestIndex.h
+++ clang-tools-extra/unittests/clangd/TestIndex.h
@@ -1,4 +1,4 @@
-//===-- IndexHelpers.h ------------------------------------------*- C++ -*-===//
+//===-- TestIndex.h ---------------------------------------------*- C++ -*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -12,10 +12,6 @@
 
 #include "index/Index.h"
 #include "index/Merge.h"
-#include "index/dex/DexIndex.h"
-#include "index/dex/Iterator.h"
-#include "index/dex/Token.h"
-#include "index/dex/Trigram.h"
 
 namespace clang {
 namespace clangd {
Index: clang-tools-extra/unittests/clangd/TestIndex.cpp
===================================================================
--- clang-tools-extra/unittests/clangd/TestIndex.cpp
+++ clang-tools-extra/unittests/clangd/TestIndex.cpp
@@ -1,4 +1,4 @@
-//===-- IndexHelpers.cpp ----------------------------------------*- C++ -*-===//
+//===-- TestIndex.cpp -------------------------------------------*- C++ -*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
Index: clang-tools-extra/unittests/clangd/DexIndexTests.cpp
===================================================================
--- clang-tools-extra/unittests/clangd/DexIndexTests.cpp
+++ clang-tools-extra/unittests/clangd/DexIndexTests.cpp
@@ -1,4 +1,4 @@
-//===-- DexIndexTests.cpp  ----------------------------*- C++ -*-----------===//
+//===-- DexTests.cpp  ----------------------------*- C++ -*-----------===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -10,12 +10,12 @@
 #include "FuzzyMatch.h"
 #include "TestFS.h"
 #include "TestIndex.h"
+#include "index/Dex.h"
 #include "index/Index.h"
+#include "index/Iterator.h"
 #include "index/Merge.h"
-#include "index/dex/DexIndex.h"
-#include "index/dex/Iterator.h"
-#include "index/dex/Token.h"
-#include "index/dex/Trigram.h"
+#include "index/Token.h"
+#include "index/Trigram.h"
 #include "llvm/Support/ScopedPrinter.h"
 #include "llvm/Support/raw_ostream.h"
 #include "gmock/gmock.h"
@@ -29,7 +29,6 @@
 
 namespace clang {
 namespace clangd {
-namespace dex {
 namespace {
 
 std::vector<std::string> URISchemes = {"unittest"};
@@ -46,7 +45,7 @@
   return IDs;
 }
 
-TEST(DexIndexIterators, DocumentIterator) {
+TEST(DexIterators, DocumentIterator) {
   const PostingList L = {4, 7, 8, 20, 42, 100};
   auto DocIterator = create(L);
 
@@ -69,7 +68,7 @@
   EXPECT_TRUE(DocIterator->reachedEnd());
 }
 
-TEST(DexIndexIterators, AndWithEmpty) {
+TEST(DexIterators, AndWithEmpty) {
   const PostingList L0;
   const PostingList L1 = {0, 5, 7, 10, 42, 320, 9000};
 
@@ -82,7 +81,7 @@
   EXPECT_THAT(consumeIDs(*AndWithEmpty), ElementsAre());
 }
 
-TEST(DexIndexIterators, AndTwoLists) {
+TEST(DexIterators, AndTwoLists) {
   const PostingList L0 = {0, 5, 7, 10, 42, 320, 9000};
   const PostingList L1 = {0, 4, 7, 10, 30, 60, 320, 9000};
 
@@ -106,7 +105,7 @@
   And->advanceTo(9001);
 }
 
-TEST(DexIndexIterators, AndThreeLists) {
+TEST(DexIterators, AndThreeLists) {
   const PostingList L0 = {0, 5, 7, 10, 42, 320, 9000};
   const PostingList L1 = {0, 4, 7, 10, 30, 60, 320, 9000};
   const PostingList L2 = {1, 4, 7, 11, 30, 60, 320, 9000};
@@ -120,7 +119,7 @@
   EXPECT_TRUE(And->reachedEnd());
 }
 
-TEST(DexIndexIterators, OrWithEmpty) {
+TEST(DexIterators, OrWithEmpty) {
   const PostingList L0;
   const PostingList L1 = {0, 5, 7, 10, 42, 320, 9000};
 
@@ -134,7 +133,7 @@
               ElementsAre(0U, 5U, 7U, 10U, 42U, 320U, 9000U));
 }
 
-TEST(DexIndexIterators, OrTwoLists) {
+TEST(DexIterators, OrTwoLists) {
   const PostingList L0 = {0, 5, 7, 10, 42, 320, 9000};
   const PostingList L1 = {0, 4, 7, 10, 30, 60, 320, 9000};
 
@@ -167,7 +166,7 @@
               ElementsAre(0U, 4U, 5U, 7U, 10U, 30U, 42U, 60U, 320U, 9000U));
 }
 
-TEST(DexIndexIterators, OrThreeLists) {
+TEST(DexIterators, OrThreeLists) {
   const PostingList L0 = {0, 5, 7, 10, 42, 320, 9000};
   const PostingList L1 = {0, 4, 7, 10, 30, 60, 320, 9000};
   const PostingList L2 = {1, 4, 7, 11, 30, 60, 320, 9000};
@@ -197,7 +196,7 @@
 // etc iterators) appear. However, it is not exhaustive and it would be
 // beneficial to implement automatic generation (e.g. fuzzing) of query trees
 // for more comprehensive testing.
-TEST(DexIndexIterators, QueryTree) {
+TEST(DexIterators, QueryTree) {
   //
   //                      +-----------------+
   //                      |And Iterator:1, 5|
@@ -254,7 +253,7 @@
   EXPECT_TRUE(Root->reachedEnd());
 }
 
-TEST(DexIndexIterators, StringRepresentation) {
+TEST(DexIterators, StringRepresentation) {
   const PostingList L0 = {4, 7, 8, 20, 42, 100};
   const PostingList L1 = {1, 3, 5, 8, 9};
   const PostingList L2 = {1, 5, 7, 9};
@@ -272,7 +271,7 @@
             "END] [{1}, 3, 5, 8, 9, END]))");
 }
 
-TEST(DexIndexIterators, Limit) {
+TEST(DexIterators, Limit) {
   const PostingList L0 = {3, 6, 7, 20, 42, 100};
   const PostingList L1 = {1, 3, 5, 6, 7, 30, 100};
   const PostingList L2 = {0, 3, 5, 7, 8, 100};
@@ -292,7 +291,7 @@
   EXPECT_THAT(consumeIDs(*AndIterator), ElementsAre(3, 7));
 }
 
-TEST(DexIndexIterators, True) {
+TEST(DexIterators, True) {
   auto TrueIterator = createTrue(0U);
   EXPECT_TRUE(TrueIterator->reachedEnd());
   EXPECT_THAT(consumeIDs(*TrueIterator), ElementsAre());
@@ -305,7 +304,7 @@
   EXPECT_THAT(consumeIDs(*AndIterator), ElementsAre(1, 2, 5));
 }
 
-TEST(DexIndexIterators, Boost) {
+TEST(DexIterators, Boost) {
   auto BoostIterator = createBoost(createTrue(5U), 42U);
   EXPECT_FALSE(BoostIterator->reachedEnd());
   auto ElementBoost = BoostIterator->consume();
@@ -351,7 +350,7 @@
   return tokensAre(Trigrams, Token::Kind::Trigram);
 }
 
-TEST(DexIndexTrigrams, IdentifierTrigrams) {
+TEST(DexTrigrams, IdentifierTrigrams) {
   EXPECT_THAT(generateIdentifierTrigrams("X86"),
               trigramsAre({"x86", "x$$", "x8$"}));
 
@@ -392,7 +391,7 @@
                    "hkl", "ijk", "ikl", "jkl", "klm", "ab$", "ad$"}));
 }
 
-TEST(DexIndexTrigrams, QueryTrigrams) {
+TEST(DexTrigrams, QueryTrigrams) {
   EXPECT_THAT(generateQueryTrigrams("c"), trigramsAre({"c$$"}));
   EXPECT_THAT(generateQueryTrigrams("cl"), trigramsAre({"cl$"}));
   EXPECT_THAT(generateQueryTrigrams("cla"), trigramsAre({"cla"}));
@@ -442,21 +441,21 @@
 // Index tests.
 //===----------------------------------------------------------------------===//
 
-TEST(DexIndex, Lookup) {
-  auto I = DexIndex::build(generateSymbols({"ns::abc", "ns::xyz"}), URISchemes);
+TEST(Dex, Lookup) {
+  auto I = Dex::build(generateSymbols({"ns::abc", "ns::xyz"}), URISchemes);
   EXPECT_THAT(lookup(*I, SymbolID("ns::abc")), UnorderedElementsAre("ns::abc"));
   EXPECT_THAT(lookup(*I, {SymbolID("ns::abc"), SymbolID("ns::xyz")}),
               UnorderedElementsAre("ns::abc", "ns::xyz"));
   EXPECT_THAT(lookup(*I, {SymbolID("ns::nonono"), SymbolID("ns::xyz")}),
               UnorderedElementsAre("ns::xyz"));
   EXPECT_THAT(lookup(*I, SymbolID("ns::nonono")), UnorderedElementsAre());
 }
 
-TEST(DexIndex, FuzzyFind) {
-  auto Index = DexIndex::build(
-      generateSymbols({"ns::ABC", "ns::BCD", "::ABC", "ns::nested::ABC",
-                       "other::ABC", "other::A"}),
-      URISchemes);
+TEST(Dex, FuzzyFind) {
+  auto Index =
+      Dex::build(generateSymbols({"ns::ABC", "ns::BCD", "::ABC",
+                                  "ns::nested::ABC", "other::ABC", "other::A"}),
+                 URISchemes);
   FuzzyFindRequest Req;
   Req.Query = "ABC";
   Req.Scopes = {"ns::"};
@@ -476,8 +475,8 @@
                                    "other::A"));
 }
 
-TEST(DexIndexTest, FuzzyMatchQ) {
-  auto I = DexIndex::build(
+TEST(DexTest, FuzzyMatchQ) {
+  auto I = Dex::build(
       generateSymbols({"LaughingOutLoud", "LionPopulation", "LittleOldLady"}),
       URISchemes);
   FuzzyFindRequest Req;
@@ -487,22 +486,22 @@
               UnorderedElementsAre("LaughingOutLoud", "LittleOldLady"));
 }
 
-// FIXME(kbobyrev): This test is different for DexIndex and MemIndex: while
-// MemIndex manages response deduplication, DexIndex simply returns all matched
+// FIXME(kbobyrev): This test is different for Dex and MemIndex: while
+// MemIndex manages response deduplication, Dex simply returns all matched
 // symbols which means there might be equivalent symbols in the response.
-// Before drop-in replacement of MemIndex with DexIndex happens, FileIndex
+// Before drop-in replacement of MemIndex with Dex happens, FileIndex
 // should handle deduplication instead.
-TEST(DexIndexTest, DexIndexDeduplicate) {
+TEST(DexTest, DexDeduplicate) {
   std::vector<Symbol> Symbols = {symbol("1"), symbol("2"), symbol("3"),
                                  symbol("2") /* duplicate */};
   FuzzyFindRequest Req;
   Req.Query = "2";
-  DexIndex I(Symbols, URISchemes);
+  Dex I(Symbols, URISchemes);
   EXPECT_THAT(match(I, Req), ElementsAre("2", "2"));
 }
 
-TEST(DexIndexTest, DexIndexLimitedNumMatches) {
-  auto I = DexIndex::build(generateNumSymbols(0, 100), URISchemes);
+TEST(DexTest, DexLimitedNumMatches) {
+  auto I = Dex::build(generateNumSymbols(0, 100), URISchemes);
   FuzzyFindRequest Req;
   Req.Query = "5";
   Req.MaxCandidateCount = 3;
@@ -512,8 +511,8 @@
   EXPECT_TRUE(Incomplete);
 }
 
-TEST(DexIndexTest, FuzzyMatch) {
-  auto I = DexIndex::build(
+TEST(DexTest, FuzzyMatch) {
+  auto I = Dex::build(
       generateSymbols({"LaughingOutLoud", "LionPopulation", "LittleOldLady"}),
       URISchemes);
   FuzzyFindRequest Req;
@@ -523,75 +522,73 @@
               UnorderedElementsAre("LaughingOutLoud", "LittleOldLady"));
 }
 
-TEST(DexIndexTest, MatchQualifiedNamesWithoutSpecificScope) {
-  auto I =
-      DexIndex::build(generateSymbols({"a::y1", "b::y2", "y3"}), URISchemes);
+TEST(DexTest, MatchQualifiedNamesWithoutSpecificScope) {
+  auto I = Dex::build(generateSymbols({"a::y1", "b::y2", "y3"}), URISchemes);
   FuzzyFindRequest Req;
   Req.Query = "y";
   EXPECT_THAT(match(*I, Req), UnorderedElementsAre("a::y1", "b::y2", "y3"));
 }
 
-TEST(DexIndexTest, MatchQualifiedNamesWithGlobalScope) {
-  auto I =
-      DexIndex::build(generateSymbols({"a::y1", "b::y2", "y3"}), URISchemes);
+TEST(DexTest, MatchQualifiedNamesWithGlobalScope) {
+  auto I = Dex::build(generateSymbols({"a::y1", "b::y2", "y3"}), URISchemes);
   FuzzyFindRequest Req;
   Req.Query = "y";
   Req.Scopes = {""};
   EXPECT_THAT(match(*I, Req), UnorderedElementsAre("y3"));
 }
 
-TEST(DexIndexTest, MatchQualifiedNamesWithOneScope) {
-  auto I = DexIndex::build(
+TEST(DexTest, MatchQualifiedNamesWithOneScope) {
+  auto I = Dex::build(
       generateSymbols({"a::y1", "a::y2", "a::x", "b::y2", "y3"}), URISchemes);
   FuzzyFindRequest Req;
   Req.Query = "y";
   Req.Scopes = {"a::"};
   EXPECT_THAT(match(*I, Req), UnorderedElementsAre("a::y1", "a::y2"));
 }
 
-TEST(DexIndexTest, MatchQualifiedNamesWithMultipleScopes) {
-  auto I = DexIndex::build(
+TEST(DexTest, MatchQualifiedNamesWithMultipleScopes) {
+  auto I = Dex::build(
       generateSymbols({"a::y1", "a::y2", "a::x", "b::y3", "y3"}), URISchemes);
   FuzzyFindRequest Req;
   Req.Query = "y";
   Req.Scopes = {"a::", "b::"};
   EXPECT_THAT(match(*I, Req), UnorderedElementsAre("a::y1", "a::y2", "b::y3"));
 }
 
-TEST(DexIndexTest, NoMatchNestedScopes) {
-  auto I = DexIndex::build(generateSymbols({"a::y1", "a::b::y2"}), URISchemes);
+TEST(DexTest, NoMatchNestedScopes) {
+  auto I = Dex::build(generateSymbols({"a::y1", "a::b::y2"}), URISchemes);
   FuzzyFindRequest Req;
   Req.Query = "y";
   Req.Scopes = {"a::"};
   EXPECT_THAT(match(*I, Req), UnorderedElementsAre("a::y1"));
 }
 
-TEST(DexIndexTest, IgnoreCases) {
-  auto I = DexIndex::build(generateSymbols({"ns::ABC", "ns::abc"}), URISchemes);
+TEST(DexTest, IgnoreCases) {
+  auto I = Dex::build(generateSymbols({"ns::ABC", "ns::abc"}), URISchemes);
   FuzzyFindRequest Req;
   Req.Query = "AB";
   Req.Scopes = {"ns::"};
   EXPECT_THAT(match(*I, Req), UnorderedElementsAre("ns::ABC", "ns::abc"));
 }
 
-TEST(DexIndexTest, Lookup) {
-  auto I = DexIndex::build(generateSymbols({"ns::abc", "ns::xyz"}), URISchemes);
+TEST(DexTest, Lookup) {
+  auto I = Dex::build(generateSymbols({"ns::abc", "ns::xyz"}), URISchemes);
   EXPECT_THAT(lookup(*I, SymbolID("ns::abc")), UnorderedElementsAre("ns::abc"));
   EXPECT_THAT(lookup(*I, {SymbolID("ns::abc"), SymbolID("ns::xyz")}),
               UnorderedElementsAre("ns::abc", "ns::xyz"));
   EXPECT_THAT(lookup(*I, {SymbolID("ns::nonono"), SymbolID("ns::xyz")}),
               UnorderedElementsAre("ns::xyz"));
   EXPECT_THAT(lookup(*I, SymbolID("ns::nonono")), UnorderedElementsAre());
 }
 
-TEST(DexIndexTest, ProximityPathsBoosting) {
+TEST(DexTest, ProximityPathsBoosting) {
   auto RootSymbol = symbol("root::abc");
   RootSymbol.CanonicalDeclaration.FileURI = "unittest:///file.h";
   auto CloseSymbol = symbol("close::abc");
   CloseSymbol.CanonicalDeclaration.FileURI = "unittest:///a/b/c/d/e/f/file.h";
 
   std::vector<Symbol> Symbols{CloseSymbol, RootSymbol};
-  DexIndex I(Symbols, URISchemes);
+  Dex I(Symbols, URISchemes);
 
   FuzzyFindRequest Req;
   Req.Query = "abc";
@@ -610,6 +607,5 @@
 }
 
 } // namespace
-} // namespace dex
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===================================================================
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -13,7 +13,6 @@
 #include "RIFF.h"
 #include "Trace.h"
 #include "index/SymbolYAML.h"
-#include "index/dex/DexIndex.h"
 #include "clang/Basic/Version.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileSystem.h"
Index: clang-tools-extra/clangd/index/Trigram.h
===================================================================
--- clang-tools-extra/clangd/index/Trigram.h
+++ clang-tools-extra/clangd/index/Trigram.h
@@ -29,7 +29,6 @@
 
 namespace clang {
 namespace clangd {
-namespace dex {
 
 /// Returns list of unique fuzzy-search trigrams from unqualified symbol.
 ///
@@ -65,7 +64,6 @@
 /// characters (up to 3) to perform prefix match.
 std::vector<Token> generateQueryTrigrams(llvm::StringRef Query);
 
-} // namespace dex
 } // namespace clangd
 } // namespace clang
 
Index: clang-tools-extra/clangd/index/Trigram.cpp
===================================================================
--- clang-tools-extra/clangd/index/Trigram.cpp
+++ clang-tools-extra/clangd/index/Trigram.cpp
@@ -8,7 +8,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "Trigram.h"
-#include "../../FuzzyMatch.h"
+#include "../FuzzyMatch.h"
 #include "Token.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseSet.h"
@@ -21,7 +21,6 @@
 
 namespace clang {
 namespace clangd {
-namespace dex {
 
 /// This is used to mark unigrams and bigrams and distinct them from complete
 /// trigrams. Since '$' is not present in valid identifier names, it is safe to
@@ -154,6 +153,5 @@
   return Result;
 }
 
-} // namespace dex
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/index/Token.h
===================================================================
--- clang-tools-extra/clangd/index/Token.h
+++ clang-tools-extra/clangd/index/Token.h
@@ -19,18 +19,17 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_DEX_TOKEN_H
-#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_DEX_TOKEN_H
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_TOKEN_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_TOKEN_H
 
-#include "../Index.h"
+#include "Index.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/Support/raw_ostream.h"
 #include <string>
 #include <vector>
 
 namespace clang {
 namespace clangd {
-namespace dex {
 
 /// A Token represents an attribute of a symbol, such as a particular trigram
 /// present in the name (used for fuzzy search).
@@ -90,32 +89,31 @@
   }
 };
 
-} // namespace dex
 } // namespace clangd
 } // namespace clang
 
 namespace llvm {
 
 // Support Tokens as DenseMap keys.
-template <> struct DenseMapInfo<clang::clangd::dex::Token> {
-  static inline clang::clangd::dex::Token getEmptyKey() {
-    return {clang::clangd::dex::Token::Kind::Sentinel, "EmptyKey"};
+template <> struct DenseMapInfo<clang::clangd::Token> {
+  static inline clang::clangd::Token getEmptyKey() {
+    return {clang::clangd::Token::Kind::Sentinel, "EmptyKey"};
   }
 
-  static inline clang::clangd::dex::Token getTombstoneKey() {
-    return {clang::clangd::dex::Token::Kind::Sentinel, "TombstoneKey"};
+  static inline clang::clangd::Token getTombstoneKey() {
+    return {clang::clangd::Token::Kind::Sentinel, "TombstoneKey"};
   }
 
-  static unsigned getHashValue(const clang::clangd::dex::Token &Tag) {
+  static unsigned getHashValue(const clang::clangd::Token &Tag) {
     return hash_value(Tag);
   }
 
-  static bool isEqual(const clang::clangd::dex::Token &LHS,
-                      const clang::clangd::dex::Token &RHS) {
+  static bool isEqual(const clang::clangd::Token &LHS,
+                      const clang::clangd::Token &RHS) {
     return LHS == RHS;
   }
 };
 
 } // namespace llvm
 
-#endif // LLVM_CLANG_TOOLS_EXTRA_CLANGD_DEX_TOKEN_H
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANGD_TOKEN_H
Index: clang-tools-extra/clangd/index/SymbolYAML.cpp
===================================================================
--- clang-tools-extra/clangd/index/SymbolYAML.cpp
+++ clang-tools-extra/clangd/index/SymbolYAML.cpp
@@ -9,9 +9,9 @@
 
 #include "SymbolYAML.h"
 #include "../Trace.h"
+#include "Dex.h"
 #include "Index.h"
 #include "Serialization.h"
-#include "dex/DexIndex.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/Errc.h"
@@ -225,7 +225,7 @@
   if (!Slab)
     return nullptr;
   trace::Span Tracer("BuildIndex");
-  return UseDex ? dex::DexIndex::build(std::move(*Slab), URISchemes)
+  return UseDex ? Dex::build(std::move(*Slab), URISchemes)
                 : MemIndex::build(std::move(*Slab), RefSlab());
 }
 
Index: clang-tools-extra/clangd/index/Iterator.h
===================================================================
--- clang-tools-extra/clangd/index/Iterator.h
+++ clang-tools-extra/clangd/index/Iterator.h
@@ -28,8 +28,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_DEX_ITERATOR_H
-#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_DEX_ITERATOR_H
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_ITERATOR_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_ITERATOR_H
 
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/Support/raw_ostream.h"
@@ -39,7 +39,6 @@
 
 namespace clang {
 namespace clangd {
-namespace dex {
 
 /// Symbol position in the list of all index symbols sorted by a pre-computed
 /// symbol quality.
@@ -200,7 +199,6 @@
   Children.push_back(move(Head));
 }
 
-} // namespace dex
 } // namespace clangd
 } // namespace clang
 
Index: clang-tools-extra/clangd/index/Iterator.cpp
===================================================================
--- clang-tools-extra/clangd/index/Iterator.cpp
+++ clang-tools-extra/clangd/index/Iterator.cpp
@@ -14,7 +14,6 @@
 
 namespace clang {
 namespace clangd {
-namespace dex {
 
 namespace {
 
@@ -424,6 +423,5 @@
   return llvm::make_unique<LimitIterator>(move(Child), Limit);
 }
 
-} // namespace dex
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/index/Dex.h
===================================================================
--- clang-tools-extra/clangd/index/Dex.h
+++ clang-tools-extra/clangd/index/Dex.h
@@ -1,4 +1,4 @@
-//===--- DexIndex.h - Dex Symbol Index Implementation -----------*- C++ -*-===//
+//===--- Dex.h - Efficient Symbol Index Implementation ----------*- C++ -*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -17,31 +17,30 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_DEX_DEXINDEX_H
-#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_DEX_DEXINDEX_H
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_DEXINDEX_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_DEXINDEX_H
 
-#include "../Index.h"
-#include "../MemIndex.h"
-#include "../SymbolCollector.h"
+#include "Index.h"
 #include "Iterator.h"
+#include "MemIndex.h"
+#include "SymbolCollector.h"
 #include "Token.h"
 #include "Trigram.h"
 
 namespace clang {
 namespace clangd {
-namespace dex {
 
 /// In-memory Dex trigram-based index implementation.
 // FIXME(kbobyrev): Introduce serialization and deserialization of the symbol
 // index so that it can be loaded from the disk. Since static index is not
 // changed frequently, it's safe to assume that it has to be built only once
 // (when the clangd process starts). Therefore, it can be easier to store built
 // index on disk and then load it if available.
-class DexIndex : public SymbolIndex {
+class Dex : public SymbolIndex {
 public:
   // All symbols must outlive this index.
   template <typename Range>
-  DexIndex(Range &&Symbols, llvm::ArrayRef<std::string> Schemes)
+  Dex(Range &&Symbols, llvm::ArrayRef<std::string> Schemes)
       : URISchemes(Schemes) {
     // If Schemes don't contain any items, fall back to SymbolCollector's
     // default URI schemes.
@@ -55,17 +54,17 @@
   }
   // Symbols are owned by BackingData, Index takes ownership.
   template <typename Range, typename Payload>
-  DexIndex(Range &&Symbols, Payload &&BackingData,
-           llvm::ArrayRef<std::string> URISchemes)
-      : DexIndex(std::forward<Range>(Symbols), URISchemes) {
+  Dex(Range &&Symbols, Payload &&BackingData,
+      llvm::ArrayRef<std::string> URISchemes)
+      : Dex(std::forward<Range>(Symbols), URISchemes) {
     KeepAlive = std::shared_ptr<void>(
         std::make_shared<Payload>(std::move(BackingData)), nullptr);
   }
 
   /// Builds an index from a slab. The index takes ownership of the slab.
   static std::unique_ptr<SymbolIndex>
   build(SymbolSlab Slab, llvm::ArrayRef<std::string> URISchemes) {
-    return llvm::make_unique<DexIndex>(Slab, std::move(Slab), URISchemes);
+    return llvm::make_unique<Dex>(Slab, std::move(Slab), URISchemes);
   }
 
   bool
@@ -106,8 +105,7 @@
 /// This function is exposed for testing only.
 std::vector<std::string> generateProximityURIs(llvm::StringRef URIPath);
 
-} // namespace dex
 } // namespace clangd
 } // namespace clang
 
-#endif // LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_DEX_DEXINDEX_H
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_DEXINDEX_H
Index: clang-tools-extra/clangd/index/Dex.cpp
===================================================================
--- clang-tools-extra/clangd/index/Dex.cpp
+++ clang-tools-extra/clangd/index/Dex.cpp
@@ -1,24 +1,23 @@
-//===--- DexIndex.cpp - Dex Symbol Index Implementation ---------*- C++ -*-===//
+//===--- Dex.cpp - Efficient Symbol Index Implementation --------*- C++ -*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
 // This file is distributed under the University of Illinois Open Source
 // License. See LICENSE.TXT for details.
 //
 //===----------------------------------------------------------------------===//
 
-#include "DexIndex.h"
-#include "../../FileDistance.h"
-#include "../../FuzzyMatch.h"
-#include "../../Logger.h"
-#include "../../Quality.h"
+#include "Dex.h"
+#include "../FileDistance.h"
+#include "../FuzzyMatch.h"
+#include "../Logger.h"
+#include "../Quality.h"
 #include "llvm/ADT/StringSet.h"
 #include <algorithm>
 #include <queue>
 
 namespace clang {
 namespace clangd {
-namespace dex {
 
 namespace {
 
@@ -90,7 +89,7 @@
 
 } // namespace
 
-void DexIndex::buildIndex() {
+void Dex::buildIndex() {
   std::vector<std::pair<float, const Symbol *>> ScoredSymbols(Symbols.size());
 
   for (size_t I = 0; I < Symbols.size(); ++I) {
@@ -119,14 +118,14 @@
       InvertedIndex[Token].push_back(SymbolRank);
   }
 
-  vlog("Built DexIndex with estimated memory usage {0} bytes.",
+  vlog("Built Dex with estimated memory usage {0} bytes.",
        estimateMemoryUsage());
 }
 
 /// Constructs iterators over tokens extracted from the query and exhausts it
 /// while applying Callback to each symbol in the order of decreasing quality
 /// of the matched symbols.
-bool DexIndex::fuzzyFind(
+bool Dex::fuzzyFind(
     const FuzzyFindRequest &Req,
     llvm::function_ref<void(const Symbol &)> Callback) const {
   assert(!StringRef(Req.Query).contains("::") &&
@@ -213,21 +212,21 @@
   return More;
 }
 
-void DexIndex::lookup(const LookupRequest &Req,
+void Dex::lookup(const LookupRequest &Req,
                       llvm::function_ref<void(const Symbol &)> Callback) const {
   for (const auto &ID : Req.IDs) {
     auto I = LookupTable.find(ID);
     if (I != LookupTable.end())
       Callback(*I->second);
   }
 }
 
-void DexIndex::refs(const RefsRequest &Req,
+void Dex::refs(const RefsRequest &Req,
                     llvm::function_ref<void(const Ref &)> Callback) const {
   log("refs is not implemented.");
 }
 
-size_t DexIndex::estimateMemoryUsage() const {
+size_t Dex::estimateMemoryUsage() const {
   size_t Bytes =
       LookupTable.size() * sizeof(std::pair<SymbolID, const Symbol *>);
   Bytes += SymbolQuality.size() * sizeof(std::pair<const Symbol *, float>);
@@ -266,6 +265,5 @@
   return Result;
 }
 
-} // namespace dex
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/CMakeLists.txt
===================================================================
--- clang-tools-extra/clangd/CMakeLists.txt
+++ clang-tools-extra/clangd/CMakeLists.txt
@@ -38,17 +38,16 @@
   XRefs.cpp
 
   index/CanonicalIncludes.cpp
+  index/Dex.cpp
   index/FileIndex.cpp
   index/Index.cpp
+  index/Iterator.cpp
   index/MemIndex.cpp
   index/Merge.cpp
   index/Serialization.cpp
   index/SymbolCollector.cpp
   index/SymbolYAML.cpp
-
-  index/dex/DexIndex.cpp
-  index/dex/Iterator.cpp
-  index/dex/Trigram.cpp
+  index/Trigram.cpp
 
   LINK_LIBS
   clangAST
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to