Changeset View
Changeset View
Standalone View
Standalone View
clangd/index/SymbolCollector.h
Show All 39 Lines | struct Options { | ||||
/// Specifies URI schemes that can be used to generate URIs for file paths | /// Specifies URI schemes that can be used to generate URIs for file paths | ||||
/// in symbols. The list of schemes will be tried in order until a working | /// in symbols. The list of schemes will be tried in order until a working | ||||
/// scheme is found. If no scheme works, symbol location will be dropped. | /// scheme is found. If no scheme works, symbol location will be dropped. | ||||
std::vector<std::string> URISchemes = {"file"}; | std::vector<std::string> URISchemes = {"file"}; | ||||
bool CollectIncludePath = false; | bool CollectIncludePath = false; | ||||
/// If set, this is used to map symbol #include path to a potentially | /// If set, this is used to map symbol #include path to a potentially | ||||
/// different #include path. | /// different #include path. | ||||
const CanonicalIncludes *Includes = nullptr; | const CanonicalIncludes *Includes = nullptr; | ||||
// Populate the Symbol.References field. | |||||
bool CountReferences = false; | |||||
}; | }; | ||||
SymbolCollector(Options Opts); | SymbolCollector(Options Opts); | ||||
void initialize(ASTContext &Ctx) override; | void initialize(ASTContext &Ctx) override; | ||||
void setPreprocessor(std::shared_ptr<Preprocessor> PP) override { | void setPreprocessor(std::shared_ptr<Preprocessor> PP) override { | ||||
this->PP = std::move(PP); | this->PP = std::move(PP); | ||||
} | } | ||||
bool | bool | ||||
handleDeclOccurence(const Decl *D, index::SymbolRoleSet Roles, | handleDeclOccurence(const Decl *D, index::SymbolRoleSet Roles, | ||||
ArrayRef<index::SymbolRelation> Relations, FileID FID, | ArrayRef<index::SymbolRelation> Relations, FileID FID, | ||||
unsigned Offset, | unsigned Offset, | ||||
index::IndexDataConsumer::ASTNodeInfo ASTNode) override; | index::IndexDataConsumer::ASTNodeInfo ASTNode) override; | ||||
SymbolSlab takeSymbols() { return std::move(Symbols).build(); } | SymbolSlab takeSymbols() { return std::move(Symbols).build(); } | ||||
void finish() override; | |||||
private: | private: | ||||
const Symbol *addDeclaration(const NamedDecl &, SymbolID); | const Symbol *addDeclaration(const NamedDecl &, SymbolID); | ||||
void addDefinition(const NamedDecl &, const Symbol &DeclSymbol); | void addDefinition(const NamedDecl &, const Symbol &DeclSymbol); | ||||
// All Symbols collected from the AST. | // All Symbols collected from the AST. | ||||
SymbolSlab::Builder Symbols; | SymbolSlab::Builder Symbols; | ||||
ASTContext *ASTCtx; | ASTContext *ASTCtx; | ||||
std::shared_ptr<Preprocessor> PP; | std::shared_ptr<Preprocessor> PP; | ||||
std::shared_ptr<GlobalCodeCompletionAllocator> CompletionAllocator; | std::shared_ptr<GlobalCodeCompletionAllocator> CompletionAllocator; | ||||
std::unique_ptr<CodeCompletionTUInfo> CompletionTUInfo; | std::unique_ptr<CodeCompletionTUInfo> CompletionTUInfo; | ||||
Options Opts; | Options Opts; | ||||
// Decls referenced from the current TU, flushed on finish(). | |||||
llvm::DenseSet<const NamedDecl *> ReferencedDecls; | |||||
}; | }; | ||||
} // namespace clangd | } // namespace clangd | ||||
} // namespace clang | } // namespace clang |