11 #include "llvm/ADT/StringExtras.h" 12 #include "llvm/ADT/StringRef.h" 13 #include "llvm/Support/Error.h" 14 #include "llvm/Support/raw_ostream.h" 22 std::shared_ptr<SymbolIndex> Pin;
24 std::lock_guard<std::mutex> Lock(Mutex);
25 Pin = std::move(this->Index);
26 this->Index = std::move(Index);
29 std::shared_ptr<SymbolIndex> SwapIndex::snapshot()
const {
30 std::lock_guard<std::mutex> Lock(Mutex);
35 llvm::json::ObjectMapper O(Parameters);
38 O && O.map(
"Query", Request.
Query) && O.map(
"Scopes", Request.
Scopes) &&
39 O.map(
"AnyScope", Request.
AnyScope) && O.map(
"Limit", Limit) &&
43 if (OK && Limit <= std::numeric_limits<uint32_t>::max())
49 return llvm::json::Object{
50 {
"Query", Request.
Query},
51 {
"Scopes", llvm::json::Array{Request.
Scopes}},
53 {
"Limit", Request.
Limit},
61 llvm::function_ref<
void(
const Symbol &)> CB)
const {
62 return snapshot()->fuzzyFind(R, CB);
65 llvm::function_ref<
void(
const Symbol &)> CB)
const {
66 return snapshot()->lookup(R, CB);
69 llvm::function_ref<
void(
const Ref &)> CB)
const {
70 return snapshot()->refs(R, CB);
74 llvm::function_ref<
void(
const SymbolID &,
const Symbol &)> CB)
const {
75 return snapshot()->relations(R, CB);
79 return snapshot()->estimateMemoryUsage();
llvm::json::Value toJSON(const FuzzyFindRequest &Request)
bool AnyScope
If set to true, allow symbols from any scope.
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 RestrictForCodeCompletion
If set to true, only symbols for completion support will be considered.
Represents a symbol occurrence in the source file.
std::vector< std::string > PreferredTypes
Preferred types of symbols. These are raw representation of OpaqueType.
std::vector< std::string > Scopes
If this is non-empty, symbols must be in at least one of the scopes (e.g.
void refs(const RefsRequest &, llvm::function_ref< void(const Ref &)>) const override
Finds all occurrences (e.g.
void relations(const RelationsRequest &, llvm::function_ref< void(const SymbolID &, const Symbol &)>) const override
std::string Query
A query string for the fuzzy find.
bool fromJSON(const llvm::json::Value &Parameters, FuzzyFindRequest &Request)
The class presents a C++ symbol, e.g.
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
std::vector< std::string > ProximityPaths
Contextually relevant files (e.g.
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...
size_t estimateMemoryUsage() const override
Returns estimated size of index (in bytes).
llvm::Optional< uint32_t > Limit
The number of top candidates to return.
void reset(std::unique_ptr< SymbolIndex >)
const SymbolIndex * Index