10 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_INDEX_H 11 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_INDEX_H 13 #include "clang/Index/IndexSymbol.h" 14 #include "clang/Lex/Lexer.h" 15 #include "llvm/ADT/DenseMap.h" 16 #include "llvm/ADT/DenseSet.h" 17 #include "llvm/ADT/Hashing.h" 18 #include "llvm/ADT/Optional.h" 19 #include "llvm/ADT/StringExtras.h" 45 explicit operator bool()
const {
return !FileURI.empty(); }
47 return std::tie(FileURI, Start, End) ==
64 explicit SymbolID(llvm::StringRef USR);
67 return HashValue == Sym.HashValue;
70 return HashValue < Sym.HashValue;
74 std::string str()
const;
77 static constexpr
unsigned HashByteLength = 20;
81 static_assert(
sizeof(
size_t) <= HashByteLength,
"size_t longer than SHA1!");
83 memcpy(&Result, ID.HashValue.data(),
sizeof(size_t));
84 return llvm::hash_code(Result);
86 friend llvm::raw_ostream &
operator<<(llvm::raw_ostream &OS,
90 std::array<uint8_t, HashByteLength> HashValue;
116 return hash_value(Sym);
139 return static_cast<SymbolOrigin>(
static_cast<uint8_t
>(A) |
140 static_cast<uint8_t>(B));
146 return static_cast<SymbolOrigin>(
static_cast<uint8_t
>(A) &
147 static_cast<uint8_t>(B));
187 unsigned References = 0;
190 bool IsIndexedForCodeCompletion =
false;
249 size_t size()
const {
return Symbols.size(); }
252 return sizeof(*this) + Arena.getTotalMemory() +
253 Symbols.capacity() *
sizeof(
Symbol);
262 void insert(
const Symbol &S);
267 return I ==
SymbolIndex.end() ? nullptr : &Symbols[I->second];
274 llvm::BumpPtrAllocator Arena;
276 llvm::DenseSet<llvm::StringRef> Strings;
277 std::vector<Symbol> Symbols;
283 SymbolSlab(llvm::BumpPtrAllocator Arena, std::vector<Symbol> Symbols)
284 : Arena(std::move(Arena)), Symbols(std::move(Symbols)) {}
286 llvm::BumpPtrAllocator Arena;
287 std::vector<Symbol> Symbols;
303 size_t MaxCandidateCount = UINT_MAX;
305 bool RestrictForCodeCompletion =
false;
312 llvm::DenseSet<SymbolID>
IDs;
343 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_INDEX_H SourceLocation Loc
'#' location in the include directive
llvm::StringRef Documentation
Documentation including comment for the symbol declaration.
Optional symbol details that are not required to be set.
Some operations such as code completion produce a set of candidates.
const Symbol * find(const SymbolID &ID)
llvm::StringRef IncludeHeader
This can be either a URI of the header to be #include'd for this symbol, or a literal header quoted w...
friend llvm::hash_code hash_value(const SymbolID &ID)
std::vector< Symbol >::const_iterator const_iterator
Interface for symbol indexes that can be used for searching or matching symbols among a set of symbol...
llvm::DenseSet< SymbolID > IDs
SymbolOrigin operator|(SymbolOrigin A, SymbolOrigin B)
static clang::clangd::SymbolID getEmptyKey()
llvm::unique_function< void(llvm::Expected< T >)> Callback
A Callback<T> is a void function that accepts Expected<T>.
llvm::StringRef ReturnType
Type when this symbol is used in an expression.
std::vector< std::string > Scopes
If this is non-empty, symbols must be in at least one of the scopes (e.g.
index::SymbolInfo SymInfo
SymbolOrigin operator &(SymbolOrigin A, SymbolOrigin B)
SymbolLocation Definition
clang::find_all_symbols::SymbolInfo SymbolInfo
llvm::StringRef Signature
A brief description of the symbol that can be appended in the completion candidate list...
std::string Query
A query string for the fuzzy find.
SymbolLocation CanonicalDeclaration
bool operator==(const SymbolLocation &Loc) const
static bool isEqual(const clang::clangd::SymbolID &LHS, const clang::clangd::SymbolID &RHS)
Position Start
The symbol range, using half-open range [Start, End).
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
std::vector< std::string > ProximityPaths
Contextually relevant files (e.g.
const_iterator begin() const
SymbolOrigin & operator|=(SymbolOrigin &A, SymbolOrigin B)
static clang::clangd::SymbolID getTombstoneKey()
void operator>>(StringRef Str, SymbolID &ID)
bool operator<(const SymbolID &Sym) const
static unsigned getHashValue(const clang::clangd::SymbolID &Sym)
double quality(const Symbol &S)
llvm::StringRef CompletionSnippetSuffix
What to insert when completing this symbol, after the symbol name.
const_iterator end() const
std::array< uint8_t, 20 > SymbolID
raw_ostream & operator<<(raw_ostream &OS, const CodeCompletion &C)
bool operator==(const Position &P) const
bool operator==(const SymbolID &Sym) const