clang-tools  14.0.0git
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:
Inheritance graph
[legend]
Collaboration diagram for clang::clangd::SymbolCollector:
Collaboration graph
[legend]

Classes

class  HeaderFileURICache
 
struct  Options
 

Public Member Functions

 SymbolCollector (Options Opts)
 
 ~SymbolCollector ()
 
void initialize (ASTContext &Ctx) override
 
void setPreprocessor (std::shared_ptr< Preprocessor > PP) override
 
bool handleDeclOccurrence (const Decl *D, index::SymbolRoleSet Roles, ArrayRef< index::SymbolRelation > Relations, SourceLocation Loc, index::IndexDataConsumer::ASTNodeInfo ASTNode) override
 
bool handleMacroOccurrence (const IdentifierInfo *Name, const MacroInfo *MI, index::SymbolRoleSet Roles, SourceLocation Loc) override
 
void handleMacros (const MainFileMacros &MacroRefsToIndex)
 
SymbolSlab takeSymbols ()
 
RefSlab takeRefs ()
 
RelationSlab takeRelations ()
 
bool shouldIndexFile (FileID FID)
 Returns true if we are interested in references and declarations from FID. More...
 
void finish () override
 

Static Public Member Functions

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

Detailed Description

Collect declarations (symbols) from an AST.

It collects most declarations except:

References to main-file symbols are not collected.

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 46 of file SymbolCollector.h.

Constructor & Destructor Documentation

◆ SymbolCollector()

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

Definition at line 348 of file SymbolCollector.cpp.

◆ ~SymbolCollector()

clang::clangd::SymbolCollector::~SymbolCollector ( )
default

Member Function Documentation

◆ finish()

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

◆ handleDeclOccurrence()

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

Definition at line 411 of file SymbolCollector.cpp.

References ns1::ns2::D.

◆ handleMacroOccurrence()

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

Definition at line 573 of file SymbolCollector.cpp.

◆ handleMacros()

void clang::clangd::SymbolCollector::handleMacros ( const MainFileMacros MacroRefsToIndex)

Definition at line 535 of file SymbolCollector.cpp.

◆ initialize()

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

Definition at line 351 of file SymbolCollector.cpp.

References Ctx.

◆ setPreprocessor()

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

Definition at line 102 of file SymbolCollector.h.

◆ shouldCollectSymbol()

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

Returns true is ND should be collected.

Definition at line 360 of file SymbolCollector.cpp.

Referenced by clang::clangd::getIndexableLocalDecls().

◆ shouldIndexFile()

bool clang::clangd::SymbolCollector::shouldIndexFile ( FileID  FID)

Returns true if we are interested in references and declarations from FID.

If this function return false, bodies of functions inside those files will be skipped to decrease indexing time.

Definition at line 903 of file SymbolCollector.cpp.

◆ takeRefs()

RefSlab clang::clangd::SymbolCollector::takeRefs ( )
inline

Definition at line 119 of file SymbolCollector.h.

◆ takeRelations()

RelationSlab clang::clangd::SymbolCollector::takeRelations ( )
inline

Definition at line 120 of file SymbolCollector.h.

◆ takeSymbols()

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

Definition at line 118 of file SymbolCollector.h.


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