AutoTest: Only handle document updates if necessary

Do not send qml document updated unnecessarily in case we know
that nothing had changed at all.

Change-Id: I1d6b94dcd68753e0f451a2812a752ff92f4860af
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
Christian Stenger
2023-04-24 16:00:18 +02:00
parent 57d982e5ca
commit ca3d889831
2 changed files with 14 additions and 2 deletions

View File

@@ -7,6 +7,7 @@
#include "autotesttr.h"
#include "testtreemodel.h"
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/progressmanager/progressmanager.h>
#include <coreplugin/progressmanager/taskprogress.h>
#include <cppeditor/cppeditorconstants.h>
@@ -47,6 +48,11 @@ TestCodeParser::TestCodeParser()
connect(progressManager, &ProgressManager::allTasksFinished,
this, &TestCodeParser::onAllTasksFinished);
connect(this, &TestCodeParser::parsingFinished, this, &TestCodeParser::releaseParserInternals);
connect(EditorManager::instance(), &EditorManager::documentClosed, this, [this](IDocument *doc){
QTC_ASSERT(doc, return);
if (FilePath filePath = doc->filePath(); filePath.endsWith(".qml"))
m_qmlEditorRev.remove(filePath);
});
m_reparseTimer.setSingleShot(true);
connect(&m_reparseTimer, &QTimer::timeout, this, &TestCodeParser::parsePostponedFiles);
m_threadPool->setMaxThreadCount(std::max(QThread::idealThreadCount()/4, 1));
@@ -169,12 +175,17 @@ void TestCodeParser::onQmlDocumentUpdated(const QmlJS::Document::Ptr &document)
{
static const QStringList ignoredSuffixes{ "qbs", "ui.qml" };
const FilePath fileName = document->fileName();
if (!ignoredSuffixes.contains(fileName.suffix()))
onDocumentUpdated(fileName, true);
int editorRevision = document->editorRevision();
if (editorRevision != m_qmlEditorRev.value(fileName, 0)) {
m_qmlEditorRev.insert(fileName, editorRevision);
if (!ignoredSuffixes.contains(fileName.suffix()))
onDocumentUpdated(fileName, true);
}
}
void TestCodeParser::onStartupProjectChanged(Project *project)
{
m_qmlEditorRev.clear();
if (m_parserState == FullParse || m_parserState == PartialParse) {
qCDebug(LOG) << "Canceling scanForTest (startup project changed)";
ProgressManager::cancelTasks(Constants::TASK_PARSE);