Go to the documentation of this file.
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,
31 static_cast<uint8_t>(R.Predicate))]
35 template <
typename SymbolRange,
typename RefRange,
typename RelationRange,
38 Payload &&BackingData,
size_t BackingDataSize)
40 std::forward<RefRange>(Refs),
41 std::forward<RelationRange>(Relations)) {
42 KeepAlive = std::shared_ptr<void>(
43 std::make_shared<Payload>(std::move(BackingData)),
nullptr);
44 this->BackingDataSize = BackingDataSize;
59 llvm::function_ref<
void(
const Ref &)>
Callback)
const override;
69 llvm::DenseMap<SymbolID, const Symbol *> Index;
71 llvm::DenseMap<SymbolID, llvm::ArrayRef<Ref>> Refs;
74 "RelationKind should be of same size as a uint8_t");
75 llvm::DenseMap<std::pair<SymbolID, uint8_t>, std::vector<SymbolID>> Relations;
76 std::shared_ptr<void> KeepAlive;
78 size_t BackingDataSize = 0;
84 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_MEMINDEX_H
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.
Represents a relation between two symbols.
void relations(const RelationsRequest &Req, llvm::function_ref< void(const SymbolID &, const Symbol &)> Callback) const override
MemIndex(SymbolRange &&Symbols, RefRange &&Refs, RelationRange &&Relations, Payload &&BackingData, size_t BackingDataSize)
An efficient structure of storing large set of symbol references in memory.
The class presents a C++ symbol, e.g.
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.
Interface for symbol indexes that can be used for searching or matching symbols among a set of symbol...
size_t estimateMemoryUsage() const override
Returns estimated size of index (in bytes).
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.
Represents a symbol occurrence in the source file.
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
bool refs(const RefsRequest &Req, llvm::function_ref< void(const Ref &)> Callback) const override
Finds all occurrences (e.g.
llvm::unique_function< void(llvm::Expected< T >)> Callback
A Callback<T> is a void function that accepts Expected<T>.
An immutable symbol container that stores a set of symbols.
MemIndex(SymbolRange &&Symbols, RefRange &&Refs, RelationRange &&Relations)