summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/ClangdUnit.cpp
diff options
context:
space:
mode:
authorEric Liu <ioeric@google.com>2017-12-19 18:00:37 +0000
committerEric Liu <ioeric@google.com>2017-12-19 18:00:37 +0000
commitbfac8f782c92415a3f19f57a63c1a43fc3c336ae (patch)
tree63a7b325ae5dbb975a484b85f058bf053d093e94 /clang-tools-extra/clangd/ClangdUnit.cpp
parentb6ddbef673052424c8d748ae930469ab73d70ab4 (diff)
downloadbcm5719-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/ClangdUnit.cpp')
-rw-r--r--clang-tools-extra/clangd/ClangdUnit.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/clang-tools-extra/clangd/ClangdUnit.cpp b/clang-tools-extra/clangd/ClangdUnit.cpp
index f735e09ff1f..b6bf3f75eaa 100644
--- a/clang-tools-extra/clangd/ClangdUnit.cpp
+++ b/clang-tools-extra/clangd/ClangdUnit.cpp
@@ -357,17 +357,21 @@ ParsedASTWrapper::ParsedASTWrapper(llvm::Optional<ParsedAST> AST)
std::shared_ptr<CppFile>
CppFile::Create(PathRef FileName, tooling::CompileCommand Command,
bool StorePreamblesInMemory,
- std::shared_ptr<PCHContainerOperations> PCHs) {
- return std::shared_ptr<CppFile>(new CppFile(
- FileName, std::move(Command), StorePreamblesInMemory, std::move(PCHs)));
+ std::shared_ptr<PCHContainerOperations> PCHs,
+ ASTParsedCallback ASTCallback) {
+ return std::shared_ptr<CppFile>(
+ new CppFile(FileName, std::move(Command), StorePreamblesInMemory,
+ std::move(PCHs), std::move(ASTCallback)));
}
CppFile::CppFile(PathRef FileName, tooling::CompileCommand Command,
bool StorePreamblesInMemory,
- std::shared_ptr<PCHContainerOperations> PCHs)
+ std::shared_ptr<PCHContainerOperations> PCHs,
+ ASTParsedCallback ASTCallback)
: FileName(FileName), Command(std::move(Command)),
StorePreamblesInMemory(StorePreamblesInMemory), RebuildCounter(0),
- RebuildInProgress(false), PCHs(std::move(PCHs)) {
+ RebuildInProgress(false), PCHs(std::move(PCHs)),
+ ASTCallback(std::move(ASTCallback)) {
// FIXME(ibiryukov): we should pass a proper Context here.
log(Context::empty(), "Opened file " + FileName + " with command [" +
this->Command.Directory + "] " +
@@ -570,6 +574,8 @@ CppFile::deferRebuild(StringRef NewContents,
if (NewAST) {
Diagnostics.insert(Diagnostics.end(), NewAST->getDiagnostics().begin(),
NewAST->getDiagnostics().end());
+ if (That->ASTCallback)
+ That->ASTCallback(Ctx, That->FileName, NewAST.getPointer());
} else {
// Don't report even Preamble diagnostics if we coulnd't build AST.
Diagnostics.clear();
OpenPOWER on IntegriCloud