Go to the documentation of this file.
15 #include "llvm/ADT/STLExtras.h"
16 #include "llvm/ADT/StringRef.h"
17 #include "llvm/ADT/StringSet.h"
18 #include "llvm/Support/raw_ostream.h"
42 unsigned DynamicCount = 0;
43 unsigned StaticCount = 0;
44 unsigned MergedCount = 0;
51 llvm::DenseSet<SymbolID> SeenDynamicSymbols;
53 auto DynS = Dyn.
find(S.
ID);
55 if (DynS == Dyn.
end())
58 SeenDynamicSymbols.insert(S.
ID);
64 for (
const Symbol &S : Dyn)
65 if (!SeenDynamicSymbols.count(S.
ID))
78 auto RemainingIDs = Req.
IDs;
81 RemainingIDs.erase(S.
ID);
87 for (
const auto &ID : RemainingIDs)
93 llvm::function_ref<
void(
const Ref &)>
Callback)
const {
97 Req.
Limit.getValueOr(std::numeric_limits<uint32_t>::max());
106 llvm::StringSet<> DynamicIndexFileURIs;
107 More |= Dynamic->
refs(Req, [&](
const Ref &O) {
110 assert(Remaining != 0);
113 if (Remaining == 0 && More)
117 bool StaticHadMore = Static->
refs(Req, [&](
const Ref &O) {
120 if (Remaining == 0) {
127 return More || StaticHadMore;
134 Req.
Limit.getValueOr(std::numeric_limits<uint32_t>::max());
138 llvm::DenseSet<std::pair<SymbolID, SymbolID>> SeenRelations;
141 SeenRelations.insert(std::make_pair(Subject,
Object.ID));
148 !SeenRelations.count(std::make_pair(Subject,
Object.ID))) {
163 constexpr
static const char *CodegenSuffixes[] = {
".proto"};
164 return std::any_of(std::begin(CodegenSuffixes), std::end(CodegenSuffixes),
165 [&](llvm::StringRef
Suffix) {
166 return llvm::StringRef(
Loc.FileURI).endswith(
Suffix);
169 return HasCodeGenSuffix(L) && !HasCodeGenSuffix(R);
173 assert(L.
ID == R.
ID);
183 Symbol S = PreferR ? R : L;
184 const Symbol &O = PreferR ? L : R;
201 bool IsClass = S.
SymInfo.Kind == index::SymbolKind::Class ||
202 S.
SymInfo.Kind == index::SymbolKind::Struct ||
203 S.
SymInfo.Kind == index::SymbolKind::Union;
214 if (SI.IncludeHeader == OI.IncludeHeader) {
216 SI.References += OI.References;
220 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.
const Symbol * find(const SymbolID &ID)
Returns the symbol with an ID, if it exists. Valid until insert/remove.
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
index::SymbolInfo SymInfo
The symbol information, like symbol kind.
bool prefer(const SymbolLocation &L, const SymbolLocation &R)
#define SPAN_ATTACH(S, Name, Expr)
Attach a key-value pair to a Span event.
Symbol mergeSymbol(const Symbol &L, const Symbol &R)
SymbolLocation CanonicalDeclaration
The location of the preferred declaration of the symbol.
llvm::DenseSet< SymbolID > IDs
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.
===– 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.
SourceLocation Loc
'#' location in the include directive
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.