Go to the documentation of this file.
10 #include "clang/Index/IndexSymbol.h"
11 #include "llvm/Support/Regex.h"
19 size_t Pos = QName.rfind(
"::");
20 if (
Pos == llvm::StringRef::npos) {
24 Sym.
Name = QName.substr(
Pos + 2);
25 Sym.
Scope = QName.substr(0,
Pos + 2);
30 static std::string
replace(llvm::StringRef Haystack, llvm::StringRef Needle,
31 llvm::StringRef Repl) {
32 llvm::SmallVector<llvm::StringRef> Parts;
33 Haystack.split(Parts, Needle);
40 llvm::StringRef USRFormat) {
42 std::string USR =
"c:";
43 size_t Pos = QName.rfind(
"::");
44 if (
Pos == llvm::StringRef::npos) {
48 Sym.
Name = QName.substr(
Pos + 2);
49 Sym.
Scope = QName.substr(0,
Pos + 2);
50 USR +=
"@N@" +
replace(QName.substr(0,
Pos),
"::",
"@N@");
52 USR += llvm::Regex(
"^.*$").sub(USRFormat, Sym.
Name);
61 return sym(
Name, index::SymbolKind::Function,
"@F@\\0#");
65 return sym(
Name, index::SymbolKind::Class,
"@S@\\0");
69 return sym(
Name, index::SymbolKind::Enum,
"@E@\\0");
73 return sym(
Name, index::SymbolKind::Variable,
"@\\0");
77 return sym(
Name, index::SymbolKind::Namespace,
"@N@\\0");
81 return sym(
Name, index::SymbolKind::Concept,
"@CT@\\0");
86 for (llvm::StringRef QName : QualifiedNames)
88 return std::move(Slab).build();
92 std::vector<std::string> Names;
93 for (
int I = Begin; I <= End; I++)
94 Names.push_back(std::to_string(I));
104 std::vector<std::string> Matches;
109 *Incomplete = IsIncomplete;
115 llvm::ArrayRef<SymbolID> IDs) {
117 Req.
IDs.insert(IDs.begin(), IDs.end());
118 std::vector<std::string>
Results;
@ IndexedForCodeCompletion
Whether or not this symbol is meant to be used for the code completion.
SymbolID ID
The ID of the symbol.
Symbol var(llvm::StringRef Name)
Symbol cls(llvm::StringRef Name)
static std::string join(ArrayRef< SpecialMemberFunctionsCheck::SpecialMemberFunctionKind > SMFS, llvm::StringRef AndOr)
Symbol func(llvm::StringRef Name)
Symbol ns(llvm::StringRef Name)
SymbolSlab generateNumSymbols(int Begin, int End)
std::vector< std::string > match(const SymbolIndex &I, const FuzzyFindRequest &Req, bool *Incomplete)
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.
SymbolSlab generateSymbols(std::vector< std::string > QualifiedNames)
SymbolOrigin Origin
Where this symbol came from. Usually an index provides a constant value.
The class presents a C++ symbol, e.g.
index::SymbolInfo SymInfo
The symbol information, like symbol kind.
static std::string replace(llvm::StringRef Haystack, llvm::StringRef Needle, llvm::StringRef Repl)
std::vector< CodeCompletionResult > Results
llvm::StringRef Name
The unqualified name of the symbol, e.g. "bar" (for ns::bar).
std::array< uint8_t, 20 > SymbolID
Symbol enm(llvm::StringRef Name)
Symbol conceptSym(llvm::StringRef Name)
std::string getQualifiedName(const Symbol &Sym)
std::vector< std::string > lookup(const SymbolIndex &I, llvm::ArrayRef< SymbolID > IDs)
clang::find_all_symbols::SymbolInfo::SymbolKind SymbolKind
Symbol sym(llvm::StringRef QName, index::SymbolKind Kind, llvm::StringRef USRFormat)
llvm::DenseSet< SymbolID > IDs
Interface for symbol indexes that can be used for searching or matching symbols among a set of symbol...
llvm::StringRef TemplateSpecializationArgs
Argument list in human-readable format, will be displayed to help disambiguate between different spec...
llvm::StringRef Scope
The containing namespace. e.g. "" (global), "ns::" (top-level namespace).
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Symbol symbol(llvm::StringRef QName)
SymbolSlab::Builder is a mutable container that can 'freeze' to SymbolSlab.
An immutable symbol container that stores a set of symbols.
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.