diff options
Diffstat (limited to 'clang-tools-extra/clangd/index/FileIndex.h')
| -rw-r--r-- | clang-tools-extra/clangd/index/FileIndex.h | 17 |
1 files changed, 12 insertions, 5 deletions
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<SymbolSlab> 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<SymbolSlab> Slab, + std::unique_ptr<SymbolOccurrenceSlab> Occurrences); // The shared_ptr keeps the symbols alive std::shared_ptr<std::vector<const Symbol *>> allSymbols(); + /// Returns all symbol occurrences for all active files. + std::shared_ptr<MemIndex::OccurrenceMap> allOccurrences() const; + private: mutable std::mutex Mutex; /// \brief Stores the latest snapshots for all active files. llvm::StringMap<std::shared_ptr<SymbolSlab>> FileToSlabs; + /// Stores the latest occurrence slabs for all active files. + llvm::StringMap<std::shared_ptr<SymbolOccurrenceSlab>> FileToOccurrenceSlabs; }; /// \brief This manages symbls from files and an in-memory index on all symbols. @@ -90,12 +97,12 @@ private: std::vector<std::string> 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<SymbolSlab, SymbolOccurrenceSlab> indexAST(ASTContext &AST, std::shared_ptr<Preprocessor> PP, llvm::Optional<llvm::ArrayRef<Decl *>> TopLevelDecls = llvm::None, llvm::ArrayRef<std::string> URISchemes = {}); |

