20 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_DEX_DEX_H
21 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_DEX_DEX_H
45 template <
typename SymbolRange,
typename RefsRange,
typename RelationsRange>
46 Dex(SymbolRange &&Symbols, RefsRange &&Refs, RelationsRange &&Relations)
48 for (
auto &&Sym : Symbols)
49 this->Symbols.push_back(&Sym);
50 for (
auto &&
Ref : Refs)
51 this->Refs.try_emplace(
Ref.first,
Ref.second);
52 for (
auto &&Rel : Relations)
53 this->Relations[std::make_pair(Rel.Subject,
54 static_cast<uint8_t>(Rel.Predicate))]
55 .push_back(Rel.Object);
59 template <
typename SymbolRange,
typename RefsRange,
typename RelationsRange,
61 Dex(SymbolRange &&Symbols, RefsRange &&Refs, RelationsRange &&Relations,
62 Payload &&BackingData,
size_t BackingDataSize)
63 :
Dex(std::forward<SymbolRange>(Symbols), std::forward<RefsRange>(Refs),
64 std::forward<RelationsRange>(Relations)) {
65 KeepAlive = std::shared_ptr<void>(
66 std::make_shared<Payload>(std::move(BackingData)),
nullptr);
67 this->BackingDataSize = BackingDataSize;
81 llvm::function_ref<
void(
const Ref &)>
Callback)
const override;
91 std::unique_ptr<Iterator> iterator(
const Token &Tok)
const;
92 std::unique_ptr<Iterator>
93 createFileProximityIterator(llvm::ArrayRef<std::string> ProximityPaths)
const;
94 std::unique_ptr<Iterator>
95 createTypeBoostingIterator(llvm::ArrayRef<std::string> Types)
const;
98 std::vector<const Symbol *> Symbols;
100 std::vector<float> SymbolQuality;
101 llvm::DenseMap<SymbolID, const Symbol *> LookupTable;
108 llvm::DenseMap<Token, PostingList> InvertedIndex;
110 llvm::DenseMap<SymbolID, llvm::ArrayRef<Ref>> Refs;
112 "RelationKind should be of same size as a uint8_t");
113 llvm::DenseMap<std::pair<SymbolID, uint8_t>, std::vector<SymbolID>> Relations;
114 std::shared_ptr<void> KeepAlive;
116 size_t BackingDataSize = 0;
129 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_DEX_DEX_H