9 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_MEMINDEX_H 10 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_MEMINDEX_H 23 template <
typename SymbolRange,
typename RefRange,
typename RelationRange>
27 for (
const std::pair<
SymbolID, llvm::ArrayRef<Ref>> &R : Refs)
28 this->Refs.try_emplace(R.first, R.second.begin(), R.second.end());
30 this->Relations[std::make_pair(R.Subject, R.Predicate)].push_back(
34 template <
typename SymbolRange,
typename RefRange,
typename RelationRange,
37 Payload &&BackingData,
size_t BackingDataSize)
39 std::forward<RefRange>(Refs),
40 std::forward<RelationRange>(Relations)) {
41 KeepAlive = std::shared_ptr<void>(
42 std::make_shared<Payload>(std::move(BackingData)),
nullptr);
43 this->BackingDataSize = BackingDataSize;
58 llvm::function_ref<
void(
const Ref &)>
Callback)
const override;
68 llvm::DenseMap<SymbolID, const Symbol *> Index;
70 llvm::DenseMap<SymbolID, llvm::ArrayRef<Ref>> Refs;
72 llvm::DenseMap<std::pair<SymbolID, index::SymbolRole>, std::vector<SymbolID>>
74 std::shared_ptr<void> KeepAlive;
76 size_t BackingDataSize = 0;
82 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_MEMINDEX_H An immutable symbol container that stores a set of symbols.
Represents a relation between two symbols.
MemIndex(SymbolRange &&Symbols, RefRange &&Refs, RelationRange &&Relations, Payload &&BackingData, size_t BackingDataSize)
An efficient structure of storing large set of symbol references in memory.
void refs(const RefsRequest &Req, llvm::function_ref< void(const Ref &)> Callback) const override
Finds all occurrences (e.g.
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>.
size_t estimateMemoryUsage() const override
Returns estimated size of index (in bytes).
void relations(const RelationsRequest &Req, llvm::function_ref< void(const SymbolID &, const Symbol &)> Callback) const override
static std::unique_ptr< SymbolIndex > build(SymbolSlab Symbols, RefSlab Refs, RelationSlab Relations)
Builds an index from slabs. The index takes ownership of the data.
MemIndex is a naive in-memory index suitable for a small set of symbols.
MemIndex(SymbolRange &&Symbols, RefRange &&Refs, RelationRange &&Relations)
The class presents a C++ symbol, e.g.
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
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...
bool fuzzyFind(const FuzzyFindRequest &Req, llvm::function_ref< void(const Symbol &)> Callback) const override
Matches symbols in the index fuzzily and applies Callback on each matched symbol before returning...