summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Stenger <christian.stenger@theqtcompany.com>2015-02-19 11:19:59 +0100
committerChristian Stenger <christian.stenger@theqtcompany.com>2015-02-27 15:03:52 +0200
commit9eb616718903e9f3b64f96d3fe72b3ec5d525263 (patch)
treed55e326c85a4ec3b2e9d01daa6b4419e0bc2deb9
parent01eb2ad24fc90ba5cf21e703d7bebe7538bd14ba (diff)
downloadqt-creator-9eb616718903e9f3b64f96d3fe72b3ec5d525263.tar.gz
Improve handling of disabled parser and re-enabling parser
Instead of always parsing again when re-enabling parser do it only if there are changes of the current project. If the current project has not changed since last parsing just rely on the cached information. Change-Id: I7681318132f37172730648604ddbecf1cd37d177 Reviewed-by: Oliver Wolff <oliver.wolff@theqtcompany.com> Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
-rw-r--r--plugins/autotest/testcodeparser.cpp44
-rw-r--r--plugins/autotest/testcodeparser.h1
-rw-r--r--plugins/autotest/testtreemodel.cpp32
-rw-r--r--plugins/autotest/testtreemodel.h2
4 files changed, 36 insertions, 43 deletions
diff --git a/plugins/autotest/testcodeparser.cpp b/plugins/autotest/testcodeparser.cpp
index ed8e1facf4..004168ab6a 100644
--- a/plugins/autotest/testcodeparser.cpp
+++ b/plugins/autotest/testcodeparser.cpp
@@ -59,7 +59,8 @@ TestCodeParser::TestCodeParser(TestTreeModel *parent)
m_pendingUpdate(false),
m_fullUpdatePostPoned(false),
m_partialUpdatePostPoned(false),
- m_parserState(Idle)
+ m_dirty(true),
+ m_parserState(Disabled)
{
// connect to ProgressManager to post-pone test parsing when CppModelManager is parsing
auto progressManager = qobject_cast<Core::ProgressManager *>(Core::ProgressManager::instance());
@@ -76,12 +77,22 @@ TestCodeParser::~TestCodeParser()
clearCache();
}
+ProjectExplorer::Project *currentProject()
+{
+ const ProjectExplorer::SessionManager *session = ProjectExplorer::SessionManager::instance();
+ if (!session || !session->hasProjects())
+ return 0;
+ return session->startupProject();
+}
+
void TestCodeParser::setState(State state)
{
m_parserState = state;
if (m_parserState == Disabled) {
m_pendingUpdate = m_fullUpdatePostPoned = m_partialUpdatePostPoned = false;
m_postPonedFiles.clear();
+ } else if (m_parserState == Idle && m_dirty && currentProject()) {
+ scanForTests(m_postPonedFiles.toList());
}
}
@@ -90,14 +101,6 @@ void TestCodeParser::emitUpdateTestTree()
QTimer::singleShot(1000, this, SLOT(updateTestTree()));
}
-ProjectExplorer::Project *currentProject()
-{
- const ProjectExplorer::SessionManager *session = ProjectExplorer::SessionManager::instance();
- if (!session || !session->hasProjects())
- return 0;
- return session->startupProject();
-}
-
void TestCodeParser::updateTestTree()
{
if (!m_parserEnabled) {
@@ -578,14 +581,29 @@ bool TestCodeParser::postponed(const QStringList &fileList)
}
return true;
case Disabled:
- qWarning("Checking for postponing but being disabled...");
- return false;
+ break;
}
QTC_ASSERT(false, return false); // should not happen at all
}
void TestCodeParser::scanForTests(const QStringList &fileList)
{
+ if (m_parserState == Disabled) {
+ m_dirty = true;
+ if (fileList.isEmpty()) {
+ m_fullUpdatePostPoned = true;
+ m_partialUpdatePostPoned = false;
+ m_postPonedFiles.clear();
+ } else {
+ if (!m_fullUpdatePostPoned) {
+ m_partialUpdatePostPoned = true;
+ foreach (const QString &file, fileList)
+ m_postPonedFiles.insert(file);
+ }
+ }
+ return;
+ }
+
if (postponed(fileList))
return;
@@ -730,6 +748,7 @@ void TestCodeParser::onFinished()
case FullParse:
m_parserState = Idle;
emit parsingFinished();
+ m_dirty = false;
break;
default:
qWarning("I should not be here...");
@@ -752,6 +771,9 @@ void TestCodeParser::onPartialParsingFinished()
tmp << file;
m_postPonedFiles.clear();
scanForTests(tmp);
+ } else {
+ m_dirty = false;
+ emit parsingFinished();
}
}
diff --git a/plugins/autotest/testcodeparser.h b/plugins/autotest/testcodeparser.h
index c4ca773f38..85582d1d5d 100644
--- a/plugins/autotest/testcodeparser.h
+++ b/plugins/autotest/testcodeparser.h
@@ -113,6 +113,7 @@ private:
bool m_pendingUpdate;
bool m_fullUpdatePostPoned;
bool m_partialUpdatePostPoned;
+ bool m_dirty;
QSet<QString> m_postPonedFiles;
State m_parserState;
};
diff --git a/plugins/autotest/testtreemodel.cpp b/plugins/autotest/testtreemodel.cpp
index 0b21ec3cea..e707aaa052 100644
--- a/plugins/autotest/testtreemodel.cpp
+++ b/plugins/autotest/testtreemodel.cpp
@@ -51,8 +51,7 @@ TestTreeModel::TestTreeModel(QObject *parent) :
m_autoTestRootItem(new TestTreeItem(tr("Auto Tests"), QString(), TestTreeItem::ROOT, m_rootItem)),
m_quickTestRootItem(new TestTreeItem(tr("Qt Quick Tests"), QString(), TestTreeItem::ROOT, m_rootItem)),
m_parser(new TestCodeParser(this)),
- m_connectionsInitialized(false),
- m_initializationCounter(0)
+ m_connectionsInitialized(false)
{
m_rootItem->appendChild(m_autoTestRootItem);
m_rootItem->appendChild(m_quickTestRootItem);
@@ -103,13 +102,10 @@ TestTreeModel::~TestTreeModel()
void TestTreeModel::enableParsing()
{
- ++m_initializationCounter;
-
+ m_parser->setState(TestCodeParser::Idle);
if (m_connectionsInitialized)
return;
- m_parser->setState(TestCodeParser::Idle);
-
ProjectExplorer::SessionManager *sm = ProjectExplorer::SessionManager::instance();
connect(sm, &ProjectExplorer::SessionManager::startupProjectChanged,
m_parser, &TestCodeParser::emitUpdateTestTree);
@@ -126,35 +122,11 @@ void TestTreeModel::enableParsing()
connect(qmlJsMM, &QmlJS::ModelManagerInterface::aboutToRemoveFiles,
m_parser, &TestCodeParser::removeFiles, Qt::QueuedConnection);
m_connectionsInitialized = true;
- m_parser->updateTestTree();
}
void TestTreeModel::disableParsing()
{
- if (!m_connectionsInitialized)
- return;
- if (--m_initializationCounter != 0)
- return;
-
- ProjectExplorer::SessionManager *sm = ProjectExplorer::SessionManager::instance();
- disconnect(sm, &ProjectExplorer::SessionManager::startupProjectChanged,
- m_parser, &TestCodeParser::emitUpdateTestTree);
-
- CppTools::CppModelManager *cppMM = CppTools::CppModelManager::instance();
- disconnect(cppMM, &CppTools::CppModelManager::documentUpdated,
- m_parser, &TestCodeParser::onCppDocumentUpdated);
- disconnect(cppMM, &CppTools::CppModelManager::aboutToRemoveFiles,
- m_parser, &TestCodeParser::removeFiles);
-
- QmlJS::ModelManagerInterface *qmlJsMM = QmlJS::ModelManagerInterface::instance();
- disconnect(qmlJsMM, &QmlJS::ModelManagerInterface::documentUpdated,
- m_parser, &TestCodeParser::onQmlDocumentUpdated);
- disconnect(qmlJsMM, &QmlJS::ModelManagerInterface::aboutToRemoveFiles,
- m_parser, &TestCodeParser::removeFiles);
-
m_parser->setState(TestCodeParser::Disabled);
-
- m_connectionsInitialized = false;
}
QModelIndex TestTreeModel::index(int row, int column, const QModelIndex &parent) const
diff --git a/plugins/autotest/testtreemodel.h b/plugins/autotest/testtreemodel.h
index f1229cedf5..437aa787be 100644
--- a/plugins/autotest/testtreemodel.h
+++ b/plugins/autotest/testtreemodel.h
@@ -113,8 +113,6 @@ private:
TestTreeItem *m_quickTestRootItem;
TestCodeParser *m_parser;
bool m_connectionsInitialized;
- int m_initializationCounter;
-
};
class TestTreeSortFilterModel : public QSortFilterProxyModel