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 An immutable symbol container that stores a set of symbols.
An efficient structure of storing large set of symbol references in memory.
Interface for symbol indexes that can be used for searching or matching symbols among a set of symbol...
Represents a symbol occurrence in the source file.
llvm::unique_function< void(llvm::Expected< T >)> Callback
A Callback<T> is a void function that accepts Expected<T>.
bool fuzzyFind(const FuzzyFindRequest &Req, llvm::function_ref< void(const Symbol &)> Callback) const override
Constructs iterators over tokens extracted from the query and exhausts it while applying Callback to ...
Dex(SymbolRange &&Symbols, RefsRange &&Refs, RelationsRange &&Relations)
std::vector< std::string > generateProximityURIs(llvm::StringRef URIPath)
Returns Search Token for a number of parent directories of given Path.
static std::unique_ptr< SymbolIndex > build(SymbolSlab, RefSlab, RelationSlab)
Builds an index from slabs. The index takes ownership of the slab.
void relations(const RelationsRequest &Req, llvm::function_ref< void(const SymbolID &, const Symbol &)> Callback) const override
void lookup(const LookupRequest &Req, llvm::function_ref< void(const Symbol &)> Callback) const override
Looks up symbols with any of the given symbol IDs and applies Callback on each matched symbol...
This defines posting list interface: a storage for identifiers of symbols which can be characterized ...
The class presents a C++ symbol, e.g.
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Trigrams are attributes of the symbol unqualified name used to effectively extract symbols which can ...
Symbol index queries consist of specific requirements for the requested symbol, such as high fuzzy ma...
Dex(SymbolRange &&Symbols, RefsRange &&Refs, RelationsRange &&Relations, Payload &&BackingData, size_t BackingDataSize)
In-memory Dex trigram-based index implementation.
A Token represents an attribute of a symbol, such as a particular trigram present in the name (used f...
size_t estimateMemoryUsage() const override
Returns estimated size of index (in bytes).
bool refs(const RefsRequest &Req, llvm::function_ref< void(const Ref &)> Callback) const override
Finds all occurrences (e.g.
Token objects represent a characteristic of a symbol, which can be used to perform efficient search...