|
clang-tools 22.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 912 of file SymbolCollector.cpp.
References clang::clangd::getStdHeader(), clang::clangd::Symbol::Import, clang::clangd::Symbol::Include, clang::clangd::Symbol::IncludeHeaders, clang::clangd::Symbol::Invalid, clang::clangd::References, and clang::clangd::Symbol::SymInfo.
|
static |
Definition at line 567 of file SymbolCollector.cpp.
References shouldCollectSymbol().
Referenced by handleDeclOccurrence().
|
override |
Definition at line 580 of file SymbolCollector.cpp.
References getRefContainer(), clang::clangd::isHeaderFile(), and shouldCollectSymbol().
|
override |
Definition at line 749 of file SymbolCollector.cpp.
References clang::clangd::Symbol::CanonicalDeclaration, clang::clangd::Symbol::CompletionSnippetSuffix, clang::clangd::Symbol::Flags, clang::clangd::getSignature(), clang::clangd::Symbol::ID, clang::clangd::Symbol::IndexedForCodeCompletion, clang::clangd::isHeaderFile(), clang::clangd::Symbol::Name, clang::clangd::Symbol::Origin, shouldIndexFile(), clang::clangd::Symbol::Signature, clang::clangd::Symbol::SymInfo, and clang::clangd::Symbol::VisibleOutsideFile.
| void clang::clangd::SymbolCollector::handleMacros | ( | const MainFileMacros & | MacroRefsToIndex | ) |
Definition at line 706 of file SymbolCollector.cpp.
References clang::clangd::Symbol::CanonicalDeclaration, clang::clangd::Position::character, clang::clangd::Definition, clang::clangd::SymbolLocation::End, clang::clangd::Range::end, clang::clangd::SymbolLocation::FileURI, clang::clangd::Symbol::Flags, clang::clangd::halfOpenToRange(), clang::clangd::Symbol::ID, clang::clangd::Symbol::IndexedForCodeCompletion, clang::clangd::Ref::Kind, clang::clangd::Position::line, clang::clangd::Ref::Location, clang::clangd::MainFileMacros::MacroRefs, clang::clangd::Symbol::Name, clang::clangd::Symbol::Origin, clang::clangd::Reference, clang::clangd::SymbolLocation::Position::setColumn(), clang::clangd::SymbolLocation::Position::setLine(), clang::clangd::SymbolLocation::Start, clang::clangd::Range::start, clang::clangd::Symbol::SymInfo, 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 1167 of file SymbolCollector.cpp.
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.