9 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_SYMBOL_COLLECTOR_H 10 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_SYMBOL_COLLECTOR_H 14 #include "clang/AST/ASTContext.h" 15 #include "clang/AST/Decl.h" 16 #include "clang/Basic/SourceLocation.h" 17 #include "clang/Basic/SourceManager.h" 18 #include "clang/Index/IndexDataConsumer.h" 19 #include "clang/Index/IndexSymbol.h" 20 #include "clang/Sema/CodeCompleteConsumer.h" 21 #include "llvm/ADT/DenseMap.h" 81 std::function<bool(const SourceManager &, FileID)>
FileFilter =
nullptr;
88 const Options &Opts,
bool IsMainFileSymbol);
93 this->PP = std::move(PP);
98 ArrayRef<index::SymbolRelation> Relations,
100 index::IndexDataConsumer::ASTNodeInfo ASTNode)
override;
103 index::SymbolRoleSet Roles,
104 SourceLocation Loc)
override;
112 const Symbol *addDeclaration(
const NamedDecl &,
SymbolID,
bool IsMainFileSymbol);
113 void addDefinition(
const NamedDecl &,
const Symbol &DeclSymbol);
122 std::shared_ptr<Preprocessor> PP;
123 std::shared_ptr<GlobalCodeCompletionAllocator> CompletionAllocator;
124 std::unique_ptr<CodeCompletionTUInfo> CompletionTUInfo;
126 using DeclRef = std::pair<SourceLocation, index::SymbolRoleSet>;
128 llvm::DenseSet<const NamedDecl *> ReferencedDecls;
129 llvm::DenseSet<const IdentifierInfo *> ReferencedMacros;
130 llvm::DenseMap<const NamedDecl *, std::vector<DeclRef>> DeclRefs;
136 llvm::DenseMap<const Decl *, const Decl *> CanonicalDecls;
138 llvm::DenseMap<FileID, bool> FilesToIndexCache;
SourceLocation Loc
'#' location in the include directive
bool handleMacroOccurence(const IdentifierInfo *Name, const MacroInfo *MI, index::SymbolRoleSet Roles, SourceLocation Loc) override
bool CollectMacro
Collect macros.
Collect declarations (symbols) from an AST.
void initialize(ASTContext &Ctx) override
Maps a definition location onto an #include file, based on a set of filename rules.
std::string FallbackDir
When symbol paths cannot be resolved to absolute paths (e.g.
bool handleDeclOccurence(const Decl *D, index::SymbolRoleSet Roles, ArrayRef< index::SymbolRelation > Relations, SourceLocation Loc, index::IndexDataConsumer::ASTNodeInfo ASTNode) override
static constexpr llvm::StringLiteral Name
SymbolCollector(Options Opts)
bool CollectMainFileSymbols
Collect symbols local to main-files, such as static functions and symbols inside an anonymous namespa...
std::function< bool(const SourceManager &, FileID)> FileFilter
If this is set, only collect symbols/references from a file if FileFilter(SM, FID) is true...
static bool shouldCollectSymbol(const NamedDecl &ND, const ASTContext &ASTCtx, const Options &Opts, bool IsMainFileSymbol)
Returns true is ND should be collected.
bool RefsInHeaders
If set to true, SymbolCollector will collect all refs (from main file and included headers); otherwis...
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
void setPreprocessor(std::shared_ptr< Preprocessor > PP) override
const CanonicalIncludes * Includes
If set, this is used to map symbol #include path to a potentially different #include path...
RefKind RefFilter
The symbol ref kinds that will be collected.