Go to the documentation of this file.
14 #include "llvm/ADT/StringRef.h"
28 const char *OwningFile =
29 S.Definition ? S.Definition.FileURI : S.CanonicalDeclaration.FileURI;
46 unsigned DynamicCount = 0;
47 unsigned StaticCount = 0;
48 unsigned MergedCount = 0;
50 unsigned StaticDropped = 0;
57 llvm::DenseSet<SymbolID> ReportedDynSymbols;
62 auto DynS = Dyn.
find(S.
ID);
64 if (DynS != Dyn.
end()) {
66 ReportedDynSymbols.insert(S.ID);
67 return Callback(mergeSymbol(*DynS, S));
72 if (isIndexAuthoritative(DynamicContainsFile, S)) {
85 for (
const Symbol &S : Dyn)
86 if (!ReportedDynSymbols.count(S.
ID))
99 auto RemainingIDs = Req.
IDs;
105 RemainingIDs.erase(S.ID);
106 return Callback(mergeSymbol(*Sym, S));
111 if (isIndexAuthoritative(DynamicContainsFile, S))
116 RemainingIDs.erase(S.
ID);
120 for (
const auto &
ID : RemainingIDs)
126 llvm::function_ref<
void(
const Ref &)>
Callback)
const {
129 uint32_t Remaining = Req.
Limit.value_or(std::numeric_limits<uint32_t>::max());
134 More |= Dynamic->
refs(Req, [&](
const Ref &O) {
136 assert(Remaining != 0);
139 if (Remaining == 0 && More)
144 bool StaticHadMore = Static->
refs(Req, [&](
const Ref &O) {
148 if (Remaining == 0) {
155 return More || StaticHadMore;
161 StaticContainsFile{Static->
indexedFiles()}](llvm::StringRef FileURI) {
162 return DynamicContainsFile(FileURI) | StaticContainsFile(FileURI);
169 uint32_t Remaining = Req.
Limit.value_or(std::numeric_limits<uint32_t>::max());
173 llvm::DenseSet<std::pair<SymbolID, SymbolID>> SeenRelations;
176 SeenRelations.insert(std::make_pair(Subject,
Object.ID));
183 !SeenRelations.count(std::make_pair(Subject,
Object.ID))) {
198 constexpr
static const char *CodegenSuffixes[] = {
".proto"};
199 return std::any_of(std::begin(CodegenSuffixes), std::end(CodegenSuffixes),
200 [&](llvm::StringRef
Suffix) {
201 return llvm::StringRef(
Loc.FileURI).endswith(
Suffix);
204 return HasCodeGenSuffix(L) && !HasCodeGenSuffix(R);
208 assert(L.ID == R.
ID);
218 Symbol S = PreferR ? R : L;
219 const Symbol &O = PreferR ? L : R;
236 bool IsClass = S.
SymInfo.Kind == index::SymbolKind::Class ||
237 S.
SymInfo.Kind == index::SymbolKind::Struct ||
238 S.
SymInfo.Kind == index::SymbolKind::Union;
249 if (SI.IncludeHeader == OI.IncludeHeader) {
251 SI.References += OI.References;
255 if (!Found && MergeIncludes)
const_iterator end() const
SymbolID ID
The ID of the symbol.
std::unique_ptr< trace::EventTracer > Tracer
llvm::Optional< uint32_t > Limit
If set, limit the number of relations returned from the index.
virtual IndexedFiles indexedFiles() const =0
llvm::unique_function< IndexContents(llvm::StringRef) const > IndexedFiles
Returns function which checks if the specified file was used to build this index or not.
unsigned References
The number of translation units that reference this symbol from their main file.
void relations(const RelationsRequest &, llvm::function_ref< void(const SymbolID &, const Symbol &)>) const override
llvm::StringRef ReturnType
Type when this symbol is used in an expression.
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.
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 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....
SymbolLocation Location
The source location where the symbol is named.
bool refs(const RefsRequest &, llvm::function_ref< void(const Ref &)>) const override
Finds all occurrences (e.g.
SymbolOrigin Origin
Where this symbol came from. Usually an index provides a constant value.
The class presents a C++ symbol, e.g.
const_iterator find(const SymbolID &SymID) const
IndexContents
Describes what data is covered by an index.
index::SymbolInfo SymInfo
The symbol information, like symbol kind.
#define SPAN_ATTACH(S, Name, Expr)
Attach a key-value pair to a Span event.
Symbol mergeSymbol(const Symbol &L, const Symbol &R)
static bool prefer(const SymbolLocation &L, const SymbolLocation &R)
SymbolLocation CanonicalDeclaration
The location of the preferred declaration of the symbol.
llvm::DenseSet< SymbolID > IDs
const SymbolIndex * Index
virtual bool refs(const RefsRequest &Req, llvm::function_ref< void(const Ref &)> Callback) const =0
Finds all occurrences (e.g.
llvm::StringRef CompletionSnippetSuffix
What to insert when completing this symbol, after the symbol name.
Represents a symbol occurrence in the source file.
llvm::unique_function< IndexContents(llvm::StringRef) const > indexedFiles() const override
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
llvm::Optional< uint32_t > Limit
If set, limit the number of refers returned from the index.
SymbolLocation Definition
The location of the symbol's definition, if one was found.
llvm::unique_function< void(llvm::Expected< T >)> Callback
A Callback<T> is a void function that accepts Expected<T>.
SymbolSlab::Builder is a mutable container that can 'freeze' to SymbolSlab.
An immutable symbol container that stores a set of symbols.
llvm::StringRef Signature
A brief description of the symbol that can be appended in the completion candidate list.
llvm::StringRef Type
Raw representation of the OpaqueType of the symbol, used for scoring purposes.
llvm::SmallVector< IncludeHeaderWithReferences, 1 > IncludeHeaders
One Symbol can potentially be included via different headers.
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.
llvm::StringRef Documentation
Documentation including comment for the symbol declaration.
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.
void insert(const Symbol &S)
Adds a symbol, overwriting any existing one with the same ID.
Records an event whose duration is the lifetime of the Span object.