clang-tools 20.0.0git
|
Collect declarations (symbols) from an AST. More...
#include <SymbolCollector.h>
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 |
void | setPreprocessor (Preprocessor &PP) |
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 . | |
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. | |
static const Decl * | getRefContainer (const Decl *Enclosing, const SymbolCollector::Options &Opts) |
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 58 of file SymbolCollector.h.
clang::clangd::SymbolCollector::SymbolCollector | ( | Options | Opts | ) |
Definition at line 494 of file SymbolCollector.cpp.
|
default |
|
override |
Definition at line 913 of file SymbolCollector.cpp.
References clang::clangd::SymbolCollector::Options::CollectMacro, Directives, clang::clangd::SymbolSlab::Builder::erase(), clang::clangd::SymbolSlab::Builder::find(), clang::clangd::getStdHeader(), ID, clang::clangd::Symbol::Import, clang::clangd::Symbol::Include, clang::clangd::SymbolSlab::Builder::insert(), clang::clangd::Symbol::Invalid, and clang::clangd::References.
|
static |
Definition at line 567 of file SymbolCollector.cpp.
References shouldCollectSymbol().
Referenced by handleDeclOccurrence().
|
override |
Definition at line 580 of file SymbolCollector.cpp.
References clang::clangd::SymbolCollector::Options::CollectMainFileRefs, clang::clangd::SymbolCollector::Options::CountReferences, clang::clangd::SymbolSlab::Builder::find(), getRefContainer(), ID, clang::clangd::isHeaderFile(), Loc, clang::clangd::SymbolCollector::Options::RefFilter, clang::clangd::SymbolCollector::Options::RefsInHeaders, and shouldCollectSymbol().
|
override |
Definition at line 750 of file SymbolCollector.cpp.
References clang::clangd::SymbolCollector::Options::CollectMacro, clang::clangd::SymbolCollector::Options::CollectMainFileSymbols, clang::clangd::SymbolCollector::Options::CountReferences, clang::clangd::SymbolSlab::Builder::find(), clang::clangd::getSignature(), ID, clang::clangd::Symbol::IndexedForCodeCompletion, clang::clangd::SymbolSlab::Builder::insert(), clang::clangd::isHeaderFile(), Loc, Name, clang::clangd::SymbolCollector::Options::Origin, clang::clangd::SymbolCollector::Options::RefFilter, clang::clangd::SymbolCollector::Options::RefsInHeaders, shouldIndexFile(), Signature, SnippetSuffix, and clang::clangd::Symbol::VisibleOutsideFile.
void clang::clangd::SymbolCollector::handleMacros | ( | const MainFileMacros & | MacroRefsToIndex | ) |
Definition at line 706 of file SymbolCollector.cpp.
References clang::clangd::Position::character, clang::clangd::Definition, clang::clangd::SymbolLocation::End, clang::clangd::Range::end, clang::clangd::SymbolLocation::FileURI, clang::clangd::Symbol::IndexedForCodeCompletion, clang::clangd::SymbolSlab::Builder::insert(), clang::clangd::RefSlab::Builder::insert(), clang::clangd::Ref::Kind, clang::clangd::Position::line, clang::clangd::Ref::Location, clang::clangd::MainFileMacros::MacroRefs, clang::clangd::SymbolCollector::Options::Origin, clang::clangd::Reference, clang::clangd::SymbolLocation::Position::setColumn(), clang::clangd::SymbolLocation::Position::setLine(), clang::clangd::sourceLocationInMainFile(), clang::clangd::SymbolLocation::Start, clang::clangd::Range::start, clang::clangd::toSourceCode(), and clang::clangd::Symbol::VisibleOutsideFile.
|
override |
Definition at line 497 of file SymbolCollector.cpp.
|
inline |
Definition at line 136 of file SymbolCollector.h.
|
inlineoverride |
Definition at line 133 of file SymbolCollector.h.
|
static |
Returns true is ND
should be collected.
Definition at line 506 of file SymbolCollector.cpp.
References clang::clangd::hasReservedName(), and clang::clangd::hasReservedScope().
Referenced by clang::clangd::getIndexableLocalDecls(), getRefContainer(), and handleDeclOccurrence().
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 1168 of file SymbolCollector.cpp.
References clang::clangd::SymbolCollector::Options::FileFilter.
Referenced by handleMacroOccurrence().
|
inline |
Definition at line 151 of file SymbolCollector.h.
|
inline |
Definition at line 152 of file SymbolCollector.h.
|
inline |
Definition at line 150 of file SymbolCollector.h.