diff --git a/src/tools/clangbackend/ipcsource/clangfilesystemwatcher.cpp b/src/tools/clangbackend/ipcsource/clangfilesystemwatcher.cpp index 0da656e9a51..aa084c7a03b 100644 --- a/src/tools/clangbackend/ipcsource/clangfilesystemwatcher.cpp +++ b/src/tools/clangbackend/ipcsource/clangfilesystemwatcher.cpp @@ -59,14 +59,6 @@ ClangFileSystemWatcher::ClangFileSystemWatcher(TranslationUnits &translationUnit &QFileSystemWatcher::fileChanged, this, &ClangFileSystemWatcher::updateTranslationUnitsWithChangedDependencies); - - connect(&changedDiagnosticsTimer, - &QTimer::timeout, - this, - &ClangFileSystemWatcher::sendChangedDiagnostics); - - changedDiagnosticsTimer.setSingleShot(true); - changedDiagnosticsTimer.setInterval(100); } void ClangFileSystemWatcher::addFiles(const QSet &filePaths) @@ -77,13 +69,9 @@ void ClangFileSystemWatcher::addFiles(const QSet &filePaths) void ClangFileSystemWatcher::updateTranslationUnitsWithChangedDependencies(const QString &filePath) { translationUnits.updateTranslationUnitsWithChangedDependencies(filePath); - changedDiagnosticsTimer.start(); watcher.addPath(filePath); -} -void ClangFileSystemWatcher::sendChangedDiagnostics() -{ - translationUnits.sendChangedDiagnostics(); + emit fileChanged(); } } // namespace ClangBackEnd diff --git a/src/tools/clangbackend/ipcsource/clangfilesystemwatcher.h b/src/tools/clangbackend/ipcsource/clangfilesystemwatcher.h index d22234e8aeb..2b5314d2d83 100644 --- a/src/tools/clangbackend/ipcsource/clangfilesystemwatcher.h +++ b/src/tools/clangbackend/ipcsource/clangfilesystemwatcher.h @@ -33,7 +33,6 @@ #include #include -#include class Utf8String; @@ -50,13 +49,14 @@ public: void addFiles(const QSet &filePaths); +signals: + void fileChanged(); + private: void updateTranslationUnitsWithChangedDependencies(const QString &filePath); - void sendChangedDiagnostics(); private: QFileSystemWatcher watcher; - QTimer changedDiagnosticsTimer; TranslationUnits &translationUnits; }; diff --git a/src/tools/clangbackend/ipcsource/clangipcserver.cpp b/src/tools/clangbackend/ipcsource/clangipcserver.cpp index 4438ba023b9..e26bfca1904 100644 --- a/src/tools/clangbackend/ipcsource/clangipcserver.cpp +++ b/src/tools/clangbackend/ipcsource/clangipcserver.cpp @@ -69,6 +69,10 @@ ClangIpcServer::ClangIpcServer() QObject::connect(&sendDiagnosticsTimer, &QTimer::timeout, [this] () { translationUnits.sendChangedDiagnostics(); }); + + QObject::connect(translationUnits.clangFileSystemWatcher(), + &ClangFileSystemWatcher::fileChanged, + [this] () { sendDiagnosticsTimer.start(); }); } void ClangIpcServer::end() diff --git a/src/tools/clangbackend/ipcsource/clangipcserver.h b/src/tools/clangbackend/ipcsource/clangipcserver.h index 5e4b6ef172a..9535fe16240 100644 --- a/src/tools/clangbackend/ipcsource/clangipcserver.h +++ b/src/tools/clangbackend/ipcsource/clangipcserver.h @@ -42,6 +42,7 @@ #include #include +#include namespace ClangBackEnd { diff --git a/src/tools/clangbackend/ipcsource/translationunits.cpp b/src/tools/clangbackend/ipcsource/translationunits.cpp index c0ec3a67e6c..b6c94e08c84 100644 --- a/src/tools/clangbackend/ipcsource/translationunits.cpp +++ b/src/tools/clangbackend/ipcsource/translationunits.cpp @@ -166,6 +166,11 @@ QVector TranslationUnits::newerFileContainers(const QVector newerFileContainers(const QVector &fileContainers) const; + const ClangFileSystemWatcher *clangFileSystemWatcher() const; + private: void createOrUpdateTranslationUnit(const FileContainer &fileContainer); std::vector::iterator findTranslationUnit(const FileContainer &fileContainer);