9#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_SYMBOL_H
10#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_SYMBOL_H
15#include "clang/Index/IndexSymbol.h"
16#include "llvm/ADT/BitmaskEnum.h"
17#include "llvm/ADT/StringRef.h"
18#include "llvm/Support/StringSaver.h"
43 index::SymbolInfo
SymInfo = index::SymbolInfo();
97 LLVM_MARK_AS_BITMASK_ENUM(
Import)
157 static_cast<uint8_t
>(B));
164llvm::raw_ostream &
operator<<(llvm::raw_ostream &
OS,
const Symbol &S);
172 CB(S.TemplateSpecializationArgs);
174 CB(S.CompletionSnippetSuffix);
178 auto RawCharPointerCB = [&CB](
const char *&P) {
179 llvm::StringRef S(P);
181 assert(!S.data()[S.size()] &&
"Visited StringRef must be null-terminated");
184 RawCharPointerCB(S.CanonicalDeclaration.FileURI);
185 RawCharPointerCB(S.Definition.FileURI);
187 for (
auto &Include : S.IncludeHeaders)
188 CB(Include.IncludeHeader);
213 bool empty()
const {
return Symbols.empty(); }
216 return sizeof(*this) + Arena.getTotalMemory() +
217 Symbols.capacity() *
sizeof(
Symbol);
235 auto I = Symbols.find(
ID);
236 return I == Symbols.end() ? nullptr : &I->second;
243 llvm::BumpPtrAllocator Arena;
245 llvm::UniqueStringSaver UniqueStrings;
247 llvm::DenseMap<SymbolID, Symbol> Symbols;
251 SymbolSlab(llvm::BumpPtrAllocator Arena, std::vector<Symbol> Symbols)
252 :
Arena(std::move(
Arena)), Symbols(std::move(Symbols)) {}
254 llvm::BumpPtrAllocator Arena;
255 std::vector<Symbol> Symbols;
258llvm::raw_ostream &
operator<<(llvm::raw_ostream &
OS,
const SymbolSlab &Slab);
llvm::BumpPtrAllocator Arena
llvm::raw_string_ostream OS
SymbolSlab::Builder is a mutable container that can 'freeze' to SymbolSlab.
const Symbol * find(const SymbolID &ID)
Returns the symbol with an ID, if it exists. Valid until insert/remove.
void erase(const SymbolID &ID)
Removes the symbol with an ID, if it exists.
void insert(const Symbol &S)
Adds a symbol, overwriting any existing one with the same ID.
SymbolSlab build() &&
Consumes the builder to finalize the slab.
An immutable symbol container that stores a set of symbols.
const_iterator begin() const
const_iterator end() const
const_iterator find(const SymbolID &SymID) const
std::vector< Symbol >::const_iterator const_iterator
void visitStrings(Symbol &S, const Callback &CB)
Invokes Callback with each StringRef& contained in the Symbol.
LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE()
llvm::raw_ostream & operator<<(llvm::raw_ostream &OS, const CodeCompletion &C)
DeclRelationSet operator|(DeclRelation L, DeclRelation R)
llvm::unique_function< void(llvm::Expected< T >)> Callback
A Callback<T> is a void function that accepts Expected<T>.
float quality(const Symbol &S)
Computes query-independent quality score for a Symbol.
IncludeGraphNode::SourceFlag & operator|=(IncludeGraphNode::SourceFlag &A, IncludeGraphNode::SourceFlag B)
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
The class presents a C++ symbol, e.g.
@ IndexedForCodeCompletion
Whether or not this symbol is meant to be used for the code completion.
@ Deprecated
Indicates if the symbol is deprecated.
@ ImplementationDetail
Symbol is an implementation detail.
@ VisibleOutsideFile
Symbol is visible to other files (not e.g. a static helper function).
@ Include
#include "header.h"
@ Import
#import "header.h"
SymbolLocation Definition
The location of the symbol's definition, if one was found.
llvm::StringRef Type
Raw representation of the OpaqueType of the symbol, used for scoring purposes.
llvm::StringRef Documentation
Documentation including comment for the symbol declaration.
index::SymbolInfo SymInfo
The symbol information, like symbol kind.
llvm::SmallVector< IncludeHeaderWithReferences, 1 > IncludeHeaders
One Symbol can potentially be included via different headers.
llvm::StringRef Name
The unqualified name of the symbol, e.g. "bar" (for ns::bar).
llvm::StringRef Scope
The containing namespace. e.g. "" (global), "ns::" (top-level namespace).
llvm::StringRef Signature
A brief description of the symbol that can be appended in the completion candidate list.
unsigned References
The number of translation units that reference this symbol from their main file.
llvm::StringRef ReturnType
Type when this symbol is used in an expression.
llvm::StringRef TemplateSpecializationArgs
Argument list in human-readable format, will be displayed to help disambiguate between different spec...
SymbolLocation CanonicalDeclaration
The location of the preferred declaration of the symbol.
llvm::StringRef CompletionSnippetSuffix
What to insert when completing this symbol, after the symbol name.
SymbolID ID
The ID of the symbol.
SymbolOrigin Origin
Where this symbol came from. Usually an index provides a constant value.