forked from qt-creator/qt-creator
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:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user