10#include "llvm/ADT/StringRef.h"
18 std::shared_ptr<SymbolIndex> Pin;
20 std::lock_guard<std::mutex> Lock(Mutex);
21 Pin = std::move(this->Index);
22 this->Index = std::move(Index);
25std::shared_ptr<SymbolIndex> SwapIndex::snapshot()
const {
26 std::lock_guard<std::mutex> Lock(Mutex);
35 O && O.map(
"Query", Request.
Query) && O.map(
"Scopes", Request.
Scopes) &&
36 O.map(
"AnyScope", Request.
AnyScope) && O.map(
"Limit", Limit) &&
40 if (OK && Limit <= std::numeric_limits<uint32_t>::max())
41 Request.
Limit = Limit;
46 return llvm::json::Object{
47 {
"Query", Request.
Query},
48 {
"Scopes", Request.
Scopes},
50 {
"Limit", Request.
Limit},
58 llvm::function_ref<
void(
const Symbol &)> CB)
const {
59 return snapshot()->fuzzyFind(R, CB);
62 llvm::function_ref<
void(
const Symbol &)> CB)
const {
63 return snapshot()->lookup(R, CB);
66 llvm::function_ref<
void(
const Ref &)> CB)
const {
67 return snapshot()->refs(R, CB);
72 return snapshot()->containedRefs(R, CB);
76 llvm::function_ref<
void(
const SymbolID &,
const Symbol &)> CB)
const {
77 return snapshot()->relations(R, CB);
83 auto SnapShot = snapshot();
85 return [KeepAlive{std::move(SnapShot)},
87 return IndexContainsFile(
File);
92 return snapshot()->estimateMemoryUsage();
ArrayRef< const ParmVarDecl * > Parameters
void relations(const RelationsRequest &, llvm::function_ref< void(const SymbolID &, const Symbol &)>) const override
bool containedRefs(const ContainedRefsRequest &, llvm::function_ref< void(const ContainedRefsResult &)>) const override
Find all symbols that are referenced by a symbol and apply Callback on each result.
bool refs(const RefsRequest &, llvm::function_ref< void(const Ref &)>) const override
Finds all occurrences (e.g.
void reset(std::unique_ptr< SymbolIndex >)
llvm::unique_function< IndexContents(llvm::StringRef) const > indexedFiles() const override
size_t estimateMemoryUsage() const override
Returns estimated size of index (in bytes).
void lookup(const LookupRequest &, llvm::function_ref< void(const Symbol &)>) const override
Looks up symbols with any of the given symbol IDs and applies Callback on each matched symbol.
bool fuzzyFind(const FuzzyFindRequest &, llvm::function_ref< void(const Symbol &)>) const override
Matches symbols in the index fuzzily and applies Callback on each matched symbol before returning.
llvm::unique_function< IndexContents(llvm::StringRef) const > IndexedFiles
Returns function which checks if the specified file was used to build this index or not.
IndexContents
Describes what data is covered by an index.
llvm::json::Value toJSON(const FuzzyFindRequest &Request)
bool fromJSON(const llvm::json::Value &Parameters, FuzzyFindRequest &Request, llvm::json::Path P)
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
std::vector< std::string > Scopes
If this is non-empty, symbols must be in at least one of the scopes (e.g.
bool RestrictForCodeCompletion
If set to true, only symbols for completion support will be considered.
std::string Query
A query string for the fuzzy find.
std::vector< std::string > ProximityPaths
Contextually relevant files (e.g.
bool AnyScope
If set to true, allow symbols from any scope.
std::optional< uint32_t > Limit
The number of top candidates to return.
std::vector< std::string > PreferredTypes
Preferred types of symbols. These are raw representation of OpaqueType.
Represents a symbol occurrence in the source file.
The class presents a C++ symbol, e.g.