diff options
| author | Eric Liu <ioeric@google.com> | 2017-12-19 18:00:37 +0000 |
|---|---|---|
| committer | Eric Liu <ioeric@google.com> | 2017-12-19 18:00:37 +0000 |
| commit | bfac8f782c92415a3f19f57a63c1a43fc3c336ae (patch) | |
| tree | 63a7b325ae5dbb975a484b85f058bf053d093e94 /clang-tools-extra/clangd/ClangdServer.cpp | |
| parent | b6ddbef673052424c8d748ae930469ab73d70ab4 (diff) | |
| download | bcm5719-llvm-bfac8f782c92415a3f19f57a63c1a43fc3c336ae.tar.gz bcm5719-llvm-bfac8f782c92415a3f19f57a63c1a43fc3c336ae.zip | |
[clangd] Build dynamic index and use it for code completion.
Reviewers: sammccall
Reviewed By: sammccall
Subscribers: klimek, ilya-biryukov, cfe-commits
Differential Revision: https://reviews.llvm.org/D41289
llvm-svn: 321092
Diffstat (limited to 'clang-tools-extra/clangd/ClangdServer.cpp')
| -rw-r--r-- | clang-tools-extra/clangd/ClangdServer.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/clang-tools-extra/clangd/ClangdServer.cpp b/clang-tools-extra/clangd/ClangdServer.cpp index 129fc074e44..e7c9c7a5148 100644 --- a/clang-tools-extra/clangd/ClangdServer.cpp +++ b/clang-tools-extra/clangd/ClangdServer.cpp @@ -134,8 +134,19 @@ ClangdServer::ClangdServer(GlobalCompilationDatabase &CDB, FileSystemProvider &FSProvider, unsigned AsyncThreadsCount, bool StorePreamblesInMemory, + bool BuildDynamicSymbolIndex, llvm::Optional<StringRef> ResourceDir) : CDB(CDB), DiagConsumer(DiagConsumer), FSProvider(FSProvider), + FileIdx(BuildDynamicSymbolIndex ? new FileIndex() : nullptr), + // Pass a callback into `Units` to extract symbols from a newly parsed + // file and rebuild the file index synchronously each time an AST is + // parsed. + // FIXME(ioeric): this can be slow and we may be able to index on less + // critical paths. + Units(FileIdx + ? [this](const Context &Ctx, PathRef Path, + ParsedAST *AST) { FileIdx->update(Ctx, Path, AST); } + : ASTParsedCallback()), ResourceDir(ResourceDir ? ResourceDir->str() : getStandardResourceDir()), PCHs(std::make_shared<PCHContainerOperations>()), StorePreamblesInMemory(StorePreamblesInMemory), @@ -238,6 +249,8 @@ void ClangdServer::codeComplete( Resources->getPossiblyStalePreamble(); // Copy completion options for passing them to async task handler. auto CodeCompleteOpts = Opts; + if (FileIdx) + CodeCompleteOpts.Index = FileIdx.get(); // A task that will be run asynchronously. auto Task = // 'mutable' to reassign Preamble variable. |

