Commit 1a0c618e authored by Marco Bubke's avatar Marco Bubke

Clang: Don't add non existing files to the file system watcher

Change-Id: I210bb19576cc1b7a6639487f868bcf20065c73b5
Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@theqtcompany.com>
parent 514efee6
......@@ -34,6 +34,7 @@
#include <utf8stringvector.h>
#include <QFileInfo>
#include <QStringList>
#include <algorithm>
......@@ -45,11 +46,27 @@ namespace {
QStringList toStringList(const QSet<Utf8String> &files)
{
QStringList resultList;
resultList.reserve(files.size());
std::copy(files.cbegin(), files.cend(), std::back_inserter(resultList));
return resultList;
}
QStringList filterExistingFiles(QStringList &&filePaths)
{
auto fileExists = [] (const QString &filePath) {
return QFileInfo::exists(filePath);
};
auto startOfNonExistingFilePaths = std::partition(filePaths.begin(),
filePaths.end(),
fileExists);
filePaths.erase(startOfNonExistingFilePaths, filePaths.end());
return filePaths;
}
}
ClangFileSystemWatcher::ClangFileSystemWatcher(TranslationUnits &translationUnits)
......@@ -63,7 +80,10 @@ ClangFileSystemWatcher::ClangFileSystemWatcher(TranslationUnits &translationUnit
void ClangFileSystemWatcher::addFiles(const QSet<Utf8String> &filePaths)
{
watcher.addPaths(toStringList(filePaths));
const auto existingFiles = filterExistingFiles(toStringList(filePaths));
if (!existingFiles.isEmpty())
watcher.addPaths(existingFiles);
}
void ClangFileSystemWatcher::updateTranslationUnitsWithChangedDependencies(const QString &filePath)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment