summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/index/FileIndex.h
diff options
context:
space:
mode:
authorHaojian Wu <hokein@google.com>2018-08-31 19:53:37 +0000
committerHaojian Wu <hokein@google.com>2018-08-31 19:53:37 +0000
commite8064b6f6dabe873d3afa80c026ad5dece2b18cd (patch)
treef556fd6947a4fa74dc111952b046a2b33881032d /clang-tools-extra/clangd/index/FileIndex.h
parent4cae04873bcdb5eb629e4e71b36a0a87fe79083c (diff)
downloadbcm5719-llvm-e8064b6f6dabe873d3afa80c026ad5dece2b18cd.tar.gz
bcm5719-llvm-e8064b6f6dabe873d3afa80c026ad5dece2b18cd.zip
[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
Diffstat (limited to 'clang-tools-extra/clangd/index/FileIndex.h')
-rw-r--r--clang-tools-extra/clangd/index/FileIndex.h17
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 = {});
OpenPOWER on IntegriCloud