11 #include "../FuzzyMatch.h" 12 #include "../Logger.h" 19 llvm::DenseMap<SymbolID, const Symbol *> TempIndex;
20 for (
const Symbol *Sym : *Syms)
21 TempIndex[Sym->ID] = Sym;
25 std::lock_guard<std::mutex> Lock(Mutex);
26 Index = std::move(TempIndex);
27 Symbols = std::move(Syms);
34 assert(!StringRef(Req.
Query).contains(
"::") &&
35 "There must be no :: in query.");
37 std::priority_queue<std::pair<float, const Symbol *>> Top;
41 std::lock_guard<std::mutex> Lock(Mutex);
42 for (
const auto Pair : Index) {
43 const Symbol *Sym = Pair.second;
51 if (
auto Score = Filter.
match(Sym->
Name)) {
52 Top.emplace(-*Score *
quality(*Sym), Sym);
59 for (; !Top.empty(); Top.pop())
67 for (
const auto &ID : Req.
IDs) {
68 auto I = Index.find(ID);
77 std::vector<const Symbol *> Pointers;
79 auto Snap = std::make_shared<Snapshot>();
80 Snap->Slab = std::move(Slab);
81 for (
auto &Sym : Snap->Slab)
82 Snap->Pointers.push_back(&Sym);
83 auto S = std::shared_ptr<std::vector<const Symbol *>>(std::move(Snap),
85 auto MemIdx = llvm::make_unique<MemIndex>();
86 MemIdx->build(std::move(S));
87 return std::move(MemIdx);
void build(std::shared_ptr< std::vector< const Symbol *>> Symbols)
(Re-)Build index for Symbols.
bool IsIndexedForCodeCompletion
Whether or not this symbol is meant to be used for the code completion.
size_t MaxCandidateCount
The number of top candidates to return.
bool RestrictForCodeCompletion
If set to true, only symbols for completion support will be considered.
llvm::DenseSet< SymbolID > IDs
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.
std::string Query
A query string for the fuzzy find.
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
llvm::Optional< float > match(llvm::StringRef Word)
double quality(const Symbol &S)
virtual 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...