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 {
96 Req.
Limit.getValueOr(std::numeric_limits<uint32_t>::max());
105 llvm::StringSet<> DynamicIndexFileURIs;
106 Dynamic->
refs(Req, [&](
const Ref &O) {
115 Static->
refs(Req, [&](
const Ref &O) {
116 if (Remaining > 0 && !DynamicIndexFileURIs.count(O.
Location.
FileURI)) {
127 Req.
Limit.getValueOr(std::numeric_limits<uint32_t>::max());
131 llvm::DenseSet<std::pair<SymbolID, SymbolID>> SeenRelations;
134 SeenRelations.insert(std::make_pair(Subject, Object.
ID));
141 !SeenRelations.count(std::make_pair(Subject, Object.
ID))) {
156 constexpr
static const char *CodegenSuffixes[] = {
".proto"};
157 return std::any_of(std::begin(CodegenSuffixes), std::end(CodegenSuffixes),
158 [&](llvm::StringRef Suffix) {
159 return llvm::StringRef(
Loc.FileURI).endswith(Suffix);
162 return HasCodeGenSuffix(L) && !HasCodeGenSuffix(R);
166 assert(L.
ID == R.
ID);
176 Symbol S = PreferR ? R : L;
177 const Symbol &O = PreferR ? L : R;
198 if (SI.IncludeHeader == OI.IncludeHeader) {
200 SI.References += OI.References;
204 if (!Found && MergeIncludes)
SourceLocation Loc
'#' location in the include directive
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...
An immutable symbol container that stores a set of symbols.
const Symbol * find(const SymbolID &ID)
Returns the symbol with an ID, if it exists. Valid until insert/remove.
llvm::Optional< uint32_t > Limit
If set, limit the number of relations returned from the index.
const_iterator find(const SymbolID &SymID) const
llvm::DenseSet< SymbolID > IDs
Represents a symbol occurrence in the source file.
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.
llvm::unique_function< void(llvm::Expected< T >)> Callback
A Callback<T> is a void function that accepts Expected<T>.
unsigned References
The number of translation units that reference this symbol from their main file.
SymbolSlab::Builder is a mutable container that can 'freeze' to SymbolSlab.
SymbolID ID
The ID of the symbol.
SymbolLocation Definition
The location of the symbol's definition, if one was found.
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 prefer(const SymbolLocation &L, const SymbolLocation &R)
llvm::SmallVector< IncludeHeaderWithReferences, 1 > IncludeHeaders
One Symbol can potentially be incuded via different headers.
llvm::StringRef Signature
A brief description of the symbol that can be appended in the completion candidate list...
SymbolLocation Location
The source location where the symbol is named.
llvm::StringRef Documentation
Documentation including comment for the symbol declaration.
SymbolLocation CanonicalDeclaration
The location of the preferred declaration of the symbol.
Symbol mergeSymbol(const Symbol &L, const Symbol &R)
virtual void refs(const RefsRequest &Req, llvm::function_ref< void(const Ref &)> Callback) const =0
Finds all occurrences (e.g.
void relations(const RelationsRequest &, llvm::function_ref< void(const SymbolID &, const Symbol &)>) const override
The class presents a C++ symbol, e.g.
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
llvm::Optional< uint32_t > Limit
If set, limit the number of refers returned from the index.
void refs(const RefsRequest &, llvm::function_ref< void(const Ref &)>) const override
Finds all occurrences (e.g.
llvm::StringRef CompletionSnippetSuffix
What to insert when completing this symbol, after the symbol name.
const_iterator end() const
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::StringRef Type
Raw representation of the OpaqueType of the symbol, used for scoring purposes.
SymbolOrigin Origin
Where this symbol came from. Usually an index provides a constant value.
Records an event whose duration is the lifetime of the Span object.
llvm::StringRef ReturnType
Type when this symbol is used in an expression.
#define SPAN_ATTACH(S, Name, Expr)
Attach a key-value pair to a Span event.
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...