clang-tools  10.0.0svn
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
Collaboration diagram for clang::clangd::SymbolCollector:
Collaboration graph


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 ()
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 45 of file SymbolCollector.h.

Constructor & Destructor Documentation

◆ SymbolCollector()

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

Definition at line 192 of file SymbolCollector.cpp.

Member Function Documentation

◆ finish()

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

Definition at line 461 of file SymbolCollector.cpp.

Referenced by takeRelations().

◆ handleDeclOccurence()

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

Definition at line 247 of file SymbolCollector.cpp.

References D.

Referenced by setPreprocessor().

◆ handleMacroOccurence()

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

Definition at line 347 of file SymbolCollector.cpp.

Referenced by setPreprocessor().

◆ initialize()

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

Definition at line 194 of file SymbolCollector.cpp.

References Ctx.

◆ setPreprocessor()

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

Definition at line 97 of file SymbolCollector.h.

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

◆ shouldCollectSymbol()

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

◆ 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 733 of file SymbolCollector.cpp.

Referenced by takeRelations().

◆ takeRefs()

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

Definition at line 112 of file SymbolCollector.h.

◆ takeRelations()

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

Definition at line 113 of file SymbolCollector.h.

References finish(), and shouldIndexFile().

◆ takeSymbols()

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

Definition at line 111 of file SymbolCollector.h.

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