CompilationDatabase: Refresh the tree on the JSON file update

Reparse the compile_commands.json file when it has changed.

Fixes: QTCREATORBUG-21733
Change-Id: I8e5a99efd136b1d46a417817bde5b5b989109eea
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This commit is contained in:
Ivan Donchevskii
2019-03-14 11:09:36 +01:00
parent 429eb73ace
commit ed43e6d99f
2 changed files with 26 additions and 8 deletions

View File

@@ -419,14 +419,29 @@ CompilationDatabaseProject::CompilationDatabaseProject(const Utils::FileName &pr
m_kit.reset(KitManager::defaultKit()->clone());
connect(this, &CompilationDatabaseProject::parsingFinished,
this, [this]() { addTarget(createTarget(m_kit.get())); });
emitParsingStarted();
const QFuture<void> future = ::Utils::runAsync([this, projectFile](){
buildTreeAndProjectParts(projectFile);
connect(this, &CompilationDatabaseProject::parsingFinished, this, [this]() {
if (!m_hasTarget) {
addTarget(createTarget(m_kit.get()));
m_hasTarget = true;
}
});
reparseProject(projectFile);
m_fileSystemWatcher.addFile(projectFile.toString(), Utils::FileSystemWatcher::WatchModifiedDate);
connect(&m_fileSystemWatcher,
&Utils::FileSystemWatcher::fileChanged,
this,
[this](const QString &projectFile) {
reparseProject(Utils::FileName::fromString(projectFile));
});
}
void CompilationDatabaseProject::reparseProject(const Utils::FileName &projectFile)
{
emitParsingStarted();
const QFuture<void> future = ::Utils::runAsync(
[this, projectFile]() { buildTreeAndProjectParts(projectFile); });
m_parserWatcher.setFuture(future);
}