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);
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::EnumConstant,
"@\\0");
77 return sym(
Name, index::SymbolKind::Variable,
"@\\0");
81 return sym(
Name, index::SymbolKind::Namespace,
"@N@\\0");
85 return sym(
Name, index::SymbolKind::Concept,
"@CT@\\0");
89 llvm::StringRef USRPrefix) {
91 std::string
USR = USRPrefix.str() +
Name.str();
96 Sym.
SymInfo.Lang = index::SymbolLanguage::ObjC;
103 return objcSym(
Name, index::SymbolKind::Class,
"objc(cs)");
107 std::string USRPrefix = (
"objc(cy)" +
Name +
"@").str();
108 return objcSym(CategoryName, index::SymbolKind::Extension, USRPrefix);
112 return objcSym(
Name, index::SymbolKind::Protocol,
"objc(pl)");
117 for (llvm::StringRef QName : QualifiedNames)
119 return std::move(Slab).build();
123 std::vector<std::string> Names;
124 for (
int I = Begin; I <= End; I++)
125 Names.push_back(std::to_string(I));
135 std::vector<std::string> Matches;
140 *Incomplete = IsIncomplete;
146 llvm::ArrayRef<SymbolID> IDs) {
148 Req.
IDs.insert(IDs.begin(), IDs.end());
149 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.
Symbol objcCategory(llvm::StringRef Name, llvm::StringRef CategoryName)
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...
Symbol objcProtocol(llvm::StringRef Name)
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 objcClass(llvm::StringRef Name)
Symbol symbol(llvm::StringRef QName)
SymbolSlab::Builder is a mutable container that can 'freeze' to SymbolSlab.
Symbol enmConstant(llvm::StringRef Name)
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.
Symbol objcSym(llvm::StringRef Name, index::SymbolKind Kind, llvm::StringRef USRPrefix)