clang-tools  7.0.0
Classes | Public Member Functions | Static Public Member Functions | List of all members
clang::clangd::SymbolCollector Class Reference

Collect declarations (symbols) from an AST. More...

#include <SymbolCollector.h>

Inheritance diagram for clang::clangd::SymbolCollector:
[legend]
Collaboration diagram for clang::clangd::SymbolCollector:
[legend]

Classes

struct  Options
 

Public Member Functions

 SymbolCollector (Options Opts)
 
void initialize (ASTContext &Ctx) override
 
void setPreprocessor (std::shared_ptr< Preprocessor > PP) override
 
bool handleDeclOccurence (const Decl *D, index::SymbolRoleSet Roles, ArrayRef< index::SymbolRelation > Relations, SourceLocation Loc, index::IndexDataConsumer::ASTNodeInfo ASTNode) override
 
bool handleMacroOccurence (const IdentifierInfo *Name, const MacroInfo *MI, index::SymbolRoleSet Roles, SourceLocation Loc) override
 
SymbolSlab takeSymbols ()
 
void finish () override
 

Static Public Member Functions

static bool shouldCollectSymbol (const NamedDecl &ND, ASTContext &ASTCtx, const Options &Opts)
 Returns true is ND should be collected. More...
 

Detailed Description

Collect declarations (symbols) from an AST.

It collects most declarations except:

See also shouldCollectSymbol(...).

Clients (e.g. clangd) can use SymbolCollector together with index::indexTopLevelDecls to retrieve all symbols when the source file is changed.

Definition at line 37 of file SymbolCollector.h.

Constructor & Destructor Documentation

◆ SymbolCollector()

clang::clangd::SymbolCollector::SymbolCollector ( Options  Opts)

Definition at line 229 of file SymbolCollector.cpp.

Member Function Documentation

◆ finish()

void clang::clangd::SymbolCollector::finish ( )
override

◆ handleDeclOccurence()

bool clang::clangd::SymbolCollector::handleDeclOccurence ( const Decl *  D,
index::SymbolRoleSet  Roles,
ArrayRef< index::SymbolRelation >  Relations,
SourceLocation  Loc,
index::IndexDataConsumer::ASTNodeInfo  ASTNode 
)
override

Definition at line 285 of file SymbolCollector.cpp.

References shouldCollectSymbol().

Referenced by setPreprocessor().

◆ handleMacroOccurence()

bool clang::clangd::SymbolCollector::handleMacroOccurence ( const IdentifierInfo *  Name,
const MacroInfo *  MI,
index::SymbolRoleSet  Roles,
SourceLocation  Loc 
)
override

Definition at line 344 of file SymbolCollector.cpp.

Referenced by setPreprocessor().

◆ initialize()

void clang::clangd::SymbolCollector::initialize ( ASTContext &  Ctx)
override

Definition at line 231 of file SymbolCollector.cpp.

References Ctx.

◆ setPreprocessor()

void clang::clangd::SymbolCollector::setPreprocessor ( std::shared_ptr< Preprocessor >  PP)
inlineoverride

Definition at line 73 of file SymbolCollector.h.

References handleDeclOccurence(), handleMacroOccurence(), Loc, and Name.

◆ shouldCollectSymbol()

bool clang::clangd::SymbolCollector::shouldCollectSymbol ( const NamedDecl &  ND,
ASTContext &  ASTCtx,
const Options Opts 
)
static

Returns true is ND should be collected.

AST matchers require non-const ASTContext.

Definition at line 238 of file SymbolCollector.cpp.

Referenced by handleDeclOccurence().

◆ takeSymbols()

SymbolSlab clang::clangd::SymbolCollector::takeSymbols ( )
inline

Definition at line 87 of file SymbolCollector.h.

References finish().


The documentation for this class was generated from the following files: