21 const auto BackingDataSize = Slab.
bytes() + Refs.
bytes();
22 auto Data = std::make_pair(std::move(Slab), std::move(Refs));
23 return llvm::make_unique<MemIndex>(Data.first, Data.second, std::move(Data),
30 assert(!StringRef(Req.
Query).contains(
"::") &&
31 "There must be no :: in query.");
35 Req.
Limit ? *Req.
Limit : std::numeric_limits<size_t>::max());
38 for (
const auto Pair : Index) {
39 const Symbol *Sym = Pair.second;
49 if (Top.
push({*Score * quality(*Sym), Sym}))
52 auto Results = std::move(Top).items();
54 for (
const auto &Item :
Results)
62 for (
const auto &ID : Req.
IDs) {
63 auto I = Index.find(ID);
70 llvm::function_ref<
void(
const Ref &)>
Callback)
const {
73 Req.
Limit.getValueOr(std::numeric_limits<uint32_t>::max());
74 for (
const auto &ReqID : Req.
IDs) {
75 auto SymRefs = Refs.find(ReqID);
76 if (SymRefs == Refs.end())
78 for (
const auto &O : SymRefs->second) {
79 if (Remaining > 0 && static_cast<int>(Req.
Filter & O.Kind)) {
88 return Index.getMemorySize() + Refs.getMemorySize() + BackingDataSize;
llvm::DenseSet< SymbolID > IDs
bool AnyScope
If set to true, allow symbols from any scope.
bool RestrictForCodeCompletion
If set to true, only symbols for completion support will be considered.
void refs(const RefsRequest &Req, llvm::function_ref< void(const Ref &)> Callback) const override
Finds all occurrences (e.g.
llvm::DenseSet< SymbolID > IDs
static std::unique_ptr< SymbolIndex > build(SymbolSlab Symbols, RefSlab Refs)
Builds an index from slabs. The index takes ownership of the data.
std::vector< CodeCompletionResult > Results
llvm::unique_function< void(llvm::Expected< T >)> Callback
A Callback<T> is a void function that accepts Expected<T>.
std::vector< std::string > Scopes
If this is non-empty, symbols must be in at least one of the scopes (e.g.
size_t estimateMemoryUsage() const override
Returns estimated size of index (in bytes).
Whether or not this symbol is meant to be used for the code completion.
std::string Query
A query string for the fuzzy find.
llvm::Optional< float > match(llvm::StringRef Word)
bool push(value_type &&V)
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
llvm::Optional< uint32_t > Limit
If set, limit the number of refers returned from the index.
llvm::Optional< uint32_t > Limit
The number of top candidates to return.
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...
Records an event whose duration is the lifetime of the Span object.
#define SPAN_ATTACH(S, Name, Expr)
Attach a key-value pair to a Span event.
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...
TopN<T> is a lossy container that preserves only the "best" N elements.