From e8064b6f6dabe873d3afa80c026ad5dece2b18cd Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Fri, 31 Aug 2018 19:53:37 +0000 Subject: [clangd] Implement findOccurrences interface in dynamic index. Summary: Implement the interface in - FileIndex - MemIndex - MergeIndex Depends on https://reviews.llvm.org/D50385. Reviewers: sammccall, ilya-biryukov Reviewed By: sammccall Subscribers: mgrang, ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D51279 llvm-svn: 341242 --- clang-tools-extra/clangd/index/FileIndex.h | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'clang-tools-extra/clangd/index/FileIndex.h') diff --git a/clang-tools-extra/clangd/index/FileIndex.h b/clang-tools-extra/clangd/index/FileIndex.h index 58fad2f62e2..0794472885c 100644 --- a/clang-tools-extra/clangd/index/FileIndex.h +++ b/clang-tools-extra/clangd/index/FileIndex.h @@ -39,18 +39,25 @@ namespace clangd { /// locking when we swap or obtain refereces to snapshots. class FileSymbols { public: - /// \brief Updates all symbols in a file. If \p Slab is nullptr, symbols for - /// \p Path will be removed. - void update(PathRef Path, std::unique_ptr Slab); + /// \brief Updates all symbols and occurrences in a file. + /// If \p Slab (Occurrence) is nullptr, symbols (occurrences) for \p Path + /// will be removed. + void update(PathRef Path, std::unique_ptr Slab, + std::unique_ptr Occurrences); // The shared_ptr keeps the symbols alive std::shared_ptr> allSymbols(); + /// Returns all symbol occurrences for all active files. + std::shared_ptr allOccurrences() const; + private: mutable std::mutex Mutex; /// \brief Stores the latest snapshots for all active files. llvm::StringMap> FileToSlabs; + /// Stores the latest occurrence slabs for all active files. + llvm::StringMap> FileToOccurrenceSlabs; }; /// \brief This manages symbls from files and an in-memory index on all symbols. @@ -90,12 +97,12 @@ private: std::vector URISchemes; }; -/// Retrieves namespace and class level symbols in \p AST. +/// Retrieves symbols and symbol occurrences in \p AST. /// Exposed to assist in unit tests. /// If URISchemes is empty, the default schemes in SymbolCollector will be used. /// If \p TopLevelDecls is set, only these decls are indexed. Otherwise, all top /// level decls obtained from \p AST are indexed. -SymbolSlab +std::pair indexAST(ASTContext &AST, std::shared_ptr PP, llvm::Optional> TopLevelDecls = llvm::None, llvm::ArrayRef URISchemes = {}); -- cgit v1.2.3