9#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_INDEX_H
10#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_INDEX_H
16#include "llvm/ADT/DenseSet.h"
17#include "llvm/ADT/FunctionExtras.h"
18#include "llvm/Support/JSON.h"
60bool fromJSON(
const llvm::json::Value &
Value, FuzzyFindRequest &Request,
62llvm::json::Value
toJSON(
const FuzzyFindRequest &Request);
65 llvm::DenseSet<SymbolID>
IDs;
69 llvm::DenseSet<SymbolID>
IDs;
124 static_cast<uint8_t
>(R));
129 static_cast<uint8_t
>(R));
163 llvm::function_ref<
void(
const Ref &)>
Callback)
const = 0;
199 : Index(std::move(Index)) {}
200 void reset(std::unique_ptr<SymbolIndex>);
205 llvm::function_ref<
void(
const Symbol &)>)
const override;
207 llvm::function_ref<
void(
const Symbol &)>)
const override;
209 llvm::function_ref<
void(
const Ref &)>)
const override;
223 std::shared_ptr<SymbolIndex> snapshot()
const;
224 mutable std::mutex Mutex;
225 std::shared_ptr<SymbolIndex> Index;
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.
SwapIndex(std::unique_ptr< SymbolIndex > Index=nullptr)
Interface for symbol indexes that can be used for searching or matching symbols among a set of symbol...
virtual bool fuzzyFind(const FuzzyFindRequest &Req, llvm::function_ref< void(const Symbol &)> Callback) const =0
Matches symbols in the index fuzzily and applies Callback on each matched symbol before returning.
virtual bool containedRefs(const ContainedRefsRequest &Req, llvm::function_ref< void(const ContainedRefsResult &)> Callback) const =0
Find all symbols that are referenced by a symbol and apply Callback on each result.
virtual void relations(const RelationsRequest &Req, llvm::function_ref< void(const SymbolID &Subject, const Symbol &Object)> Callback) const =0
Finds all relations (S, P, O) stored in the index such that S is among Req.Subjects and P is Req....
virtual bool refs(const RefsRequest &Req, llvm::function_ref< void(const Ref &)> Callback) const =0
Finds all occurrences (e.g.
virtual size_t estimateMemoryUsage() const =0
Returns estimated size of index (in bytes).
virtual void lookup(const LookupRequest &Req, llvm::function_ref< void(const Symbol &)> Callback) const =0
Looks up symbols with any of the given symbol IDs and applies Callback on each matched symbol.
virtual ~SymbolIndex()=default
llvm::unique_function< IndexContents(llvm::StringRef) const > IndexedFiles
Returns function which checks if the specified file was used to build this index or not.
virtual IndexedFiles indexedFiles() const =0
IndexContents
Describes what data is covered by an index.
DeclRelationSet operator&(DeclRelation L, DeclRelation R)
DeclRelationSet operator|(DeclRelation L, DeclRelation R)
llvm::unique_function< void(llvm::Expected< T >)> Callback
A Callback<T> is a void function that accepts Expected<T>.
llvm::json::Value toJSON(const FuzzyFindRequest &Request)
RefKind
Describes the kind of a cross-reference.
bool fromJSON(const llvm::json::Value &Parameters, FuzzyFindRequest &Request, llvm::json::Path P)
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
std::optional< uint32_t > Limit
If set, limit the number of refers returned from the index.
static const RefKind SupportedRefKinds
Note that RefKind::Call just restricts the matched SymbolKind to functions, not the form of the refer...
SymbolID Symbol
The ID of the symbol which is referred to.
SymbolLocation Location
The source location where the symbol is named.
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.
bool operator!=(const FuzzyFindRequest &Req) const
std::string Query
A query string for the fuzzy find.
std::vector< std::string > ProximityPaths
Contextually relevant files (e.g.
bool operator==(const FuzzyFindRequest &Req) const
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.
llvm::DenseSet< SymbolID > IDs
Represents a symbol occurrence in the source file.
bool WantContainer
If set, populates the container of the reference.
llvm::DenseSet< SymbolID > IDs
std::optional< uint32_t > Limit
If set, limit the number of refers returned from the index.
std::optional< uint32_t > Limit
If set, limit the number of relations returned from the index.
llvm::DenseSet< SymbolID > Subjects
The class presents a C++ symbol, e.g.