forked from qt-creator/qt-creator
Clang: Use timer in ClangIpcServer in the file watcher to send diagnostics
One mechanism for all diagnostic updates is better to maintain. Change-Id: I774577bfa343162ded362977a0727a12379d1eab Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
This commit is contained in:
@@ -59,14 +59,6 @@ ClangFileSystemWatcher::ClangFileSystemWatcher(TranslationUnits &translationUnit
|
|||||||
&QFileSystemWatcher::fileChanged,
|
&QFileSystemWatcher::fileChanged,
|
||||||
this,
|
this,
|
||||||
&ClangFileSystemWatcher::updateTranslationUnitsWithChangedDependencies);
|
&ClangFileSystemWatcher::updateTranslationUnitsWithChangedDependencies);
|
||||||
|
|
||||||
connect(&changedDiagnosticsTimer,
|
|
||||||
&QTimer::timeout,
|
|
||||||
this,
|
|
||||||
&ClangFileSystemWatcher::sendChangedDiagnostics);
|
|
||||||
|
|
||||||
changedDiagnosticsTimer.setSingleShot(true);
|
|
||||||
changedDiagnosticsTimer.setInterval(100);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClangFileSystemWatcher::addFiles(const QSet<Utf8String> &filePaths)
|
void ClangFileSystemWatcher::addFiles(const QSet<Utf8String> &filePaths)
|
||||||
@@ -77,13 +69,9 @@ void ClangFileSystemWatcher::addFiles(const QSet<Utf8String> &filePaths)
|
|||||||
void ClangFileSystemWatcher::updateTranslationUnitsWithChangedDependencies(const QString &filePath)
|
void ClangFileSystemWatcher::updateTranslationUnitsWithChangedDependencies(const QString &filePath)
|
||||||
{
|
{
|
||||||
translationUnits.updateTranslationUnitsWithChangedDependencies(filePath);
|
translationUnits.updateTranslationUnitsWithChangedDependencies(filePath);
|
||||||
changedDiagnosticsTimer.start();
|
|
||||||
watcher.addPath(filePath);
|
watcher.addPath(filePath);
|
||||||
}
|
|
||||||
|
|
||||||
void ClangFileSystemWatcher::sendChangedDiagnostics()
|
emit fileChanged();
|
||||||
{
|
|
||||||
translationUnits.sendChangedDiagnostics();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace ClangBackEnd
|
} // namespace ClangBackEnd
|
||||||
|
|||||||
@@ -33,7 +33,6 @@
|
|||||||
|
|
||||||
#include <QFileSystemWatcher>
|
#include <QFileSystemWatcher>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
#include <QTimer>
|
|
||||||
|
|
||||||
class Utf8String;
|
class Utf8String;
|
||||||
|
|
||||||
@@ -50,13 +49,14 @@ public:
|
|||||||
|
|
||||||
void addFiles(const QSet<Utf8String> &filePaths);
|
void addFiles(const QSet<Utf8String> &filePaths);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void fileChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateTranslationUnitsWithChangedDependencies(const QString &filePath);
|
void updateTranslationUnitsWithChangedDependencies(const QString &filePath);
|
||||||
void sendChangedDiagnostics();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QFileSystemWatcher watcher;
|
QFileSystemWatcher watcher;
|
||||||
QTimer changedDiagnosticsTimer;
|
|
||||||
TranslationUnits &translationUnits;
|
TranslationUnits &translationUnits;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -69,6 +69,10 @@ ClangIpcServer::ClangIpcServer()
|
|||||||
QObject::connect(&sendDiagnosticsTimer,
|
QObject::connect(&sendDiagnosticsTimer,
|
||||||
&QTimer::timeout,
|
&QTimer::timeout,
|
||||||
[this] () { translationUnits.sendChangedDiagnostics(); });
|
[this] () { translationUnits.sendChangedDiagnostics(); });
|
||||||
|
|
||||||
|
QObject::connect(translationUnits.clangFileSystemWatcher(),
|
||||||
|
&ClangFileSystemWatcher::fileChanged,
|
||||||
|
[this] () { sendDiagnosticsTimer.start(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClangIpcServer::end()
|
void ClangIpcServer::end()
|
||||||
|
|||||||
@@ -42,6 +42,7 @@
|
|||||||
#include <utf8string.h>
|
#include <utf8string.h>
|
||||||
|
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
namespace ClangBackEnd {
|
namespace ClangBackEnd {
|
||||||
|
|
||||||
|
|||||||
@@ -166,6 +166,11 @@ QVector<FileContainer> TranslationUnits::newerFileContainers(const QVector<FileC
|
|||||||
return newerContainers;
|
return newerContainers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const ClangFileSystemWatcher *TranslationUnits::clangFileSystemWatcher() const
|
||||||
|
{
|
||||||
|
return &fileSystemWatcher;
|
||||||
|
}
|
||||||
|
|
||||||
void TranslationUnits::createOrUpdateTranslationUnit(const FileContainer &fileContainer)
|
void TranslationUnits::createOrUpdateTranslationUnit(const FileContainer &fileContainer)
|
||||||
{
|
{
|
||||||
TranslationUnit::FileExistsCheck checkIfFileExists = fileContainer.hasUnsavedFileContent() ? TranslationUnit::DoNotCheckIfFileExists : TranslationUnit::CheckIfFileExists;
|
TranslationUnit::FileExistsCheck checkIfFileExists = fileContainer.hasUnsavedFileContent() ? TranslationUnit::DoNotCheckIfFileExists : TranslationUnit::CheckIfFileExists;
|
||||||
|
|||||||
@@ -71,6 +71,8 @@ public:
|
|||||||
|
|
||||||
QVector<FileContainer> newerFileContainers(const QVector<FileContainer> &fileContainers) const;
|
QVector<FileContainer> newerFileContainers(const QVector<FileContainer> &fileContainers) const;
|
||||||
|
|
||||||
|
const ClangFileSystemWatcher *clangFileSystemWatcher() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void createOrUpdateTranslationUnit(const FileContainer &fileContainer);
|
void createOrUpdateTranslationUnit(const FileContainer &fileContainer);
|
||||||
std::vector<TranslationUnit>::iterator findTranslationUnit(const FileContainer &fileContainer);
|
std::vector<TranslationUnit>::iterator findTranslationUnit(const FileContainer &fileContainer);
|
||||||
|
|||||||
Reference in New Issue
Block a user