9#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_SYMBOL_H
10#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_SYMBOL_H
16#include "clang/Index/IndexSymbol.h"
17#include "llvm/ADT/BitmaskEnum.h"
18#include "llvm/ADT/StringRef.h"
19#include "llvm/Support/StringSaver.h"
32 "Too many SymbolTags to fit in uint32_t. Change to uint64_t if "
33 "we ever have more than 32 tags.");
53 index::SymbolInfo
SymInfo = index::SymbolInfo();
111 LLVM_MARK_AS_BITMASK_ENUM(
Import)
173 static_cast<uint8_t
>(B));
180llvm::raw_ostream &
operator<<(llvm::raw_ostream &OS,
const Symbol &S);
194 auto RawCharPointerCB = [&CB](
const char *&P) {
195 llvm::StringRef S(P);
197 assert(!S.data()[S.size()] &&
"Visited StringRef must be null-terminated");
204 CB(Include.IncludeHeader);
229 bool empty()
const {
return Symbols.empty(); }
232 return sizeof(*this) + Arena.getTotalMemory() +
233 Symbols.capacity() *
sizeof(
Symbol);
251 auto I = Symbols.find(ID);
252 return I == Symbols.end() ? nullptr : &I->second;
259 llvm::BumpPtrAllocator Arena;
261 llvm::UniqueStringSaver UniqueStrings;
263 llvm::DenseMap<SymbolID, Symbol> Symbols;
270 llvm::BumpPtrAllocator Arena;
274llvm::raw_ostream &
operator<<(llvm::raw_ostream &OS,
const SymbolSlab &Slab);
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.
const_iterator begin() const
const_iterator end() const
const_iterator find(const SymbolID &SymID) const
std::vector< Symbol >::const_iterator const_iterator
FIXME: Skip testing on windows temporarily due to the different escaping code mode.
void visitStrings(Symbol &S, const Callback &CB)
Invokes Callback with each StringRef& contained in the Symbol.
uint32_t SymbolTags
A bitmask type representing symbol tags supported by LSP.
llvm::unique_function< void(llvm::Expected< T >)> Callback
A Callback<T> is a void function that accepts Expected<T>.
LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE()
llvm::raw_ostream & operator<<(llvm::raw_ostream &OS, const CodeCompletion &C)
DeclRelationSet operator|(DeclRelation L, DeclRelation R)
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++ -*-===//
Ensure we have enough bits to represent all SymbolTag values.
@ 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.
@ HasDocComment
Symbol has an attached documentation comment.
@ 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.
SymbolTags Tags
Symbol tags for LSP protocol (Deprecated, Static, Virtual, Abstract, Final, ReadOnly,...
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.