forked from qt-creator/qt-creator
AutoTest: Fix initial parse when loading session
Avoid displaying tests from other projects of the same session which have been indexed but do not belong to the current startup project. Change-Id: I6e0fb62cc97898ef3853ec61580dd2deb5ac64e5 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -202,30 +202,14 @@ static void performParse(QFutureInterface<TestParseResultPtr> &futureInterface,
|
|||||||
|
|
||||||
/****** threaded parsing stuff *******/
|
/****** threaded parsing stuff *******/
|
||||||
|
|
||||||
void TestCodeParser::onCppDocumentUpdated(const CPlusPlus::Document::Ptr &document)
|
void TestCodeParser::onDocumentUpdated(const QString &fileName)
|
||||||
{
|
{
|
||||||
if (m_codeModelParsing) {
|
|
||||||
if (!m_fullUpdatePostponed) {
|
|
||||||
m_partialUpdatePostponed = true;
|
|
||||||
m_postponedFiles.insert(document->fileName());
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ProjectExplorer::Project *project = ProjectExplorer::SessionManager::startupProject();
|
ProjectExplorer::Project *project = ProjectExplorer::SessionManager::startupProject();
|
||||||
if (!project)
|
if (!project)
|
||||||
return;
|
return;
|
||||||
const QString fileName = document->fileName();
|
if (!project->files(ProjectExplorer::Project::SourceFiles).contains(fileName))
|
||||||
if (!project->files(ProjectExplorer::Project::AllFiles).contains(fileName))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
qCDebug(LOG) << "calling scanForTests (onCppDocumentUpdated)";
|
|
||||||
scanForTests(QStringList(fileName));
|
|
||||||
}
|
|
||||||
|
|
||||||
void TestCodeParser::onQmlDocumentUpdated(const QmlJS::Document::Ptr &document)
|
|
||||||
{
|
|
||||||
const QString &fileName = document->fileName();
|
|
||||||
if (m_codeModelParsing) {
|
if (m_codeModelParsing) {
|
||||||
if (!m_fullUpdatePostponed) {
|
if (!m_fullUpdatePostponed) {
|
||||||
m_partialUpdatePostponed = true;
|
m_partialUpdatePostponed = true;
|
||||||
@@ -234,22 +218,26 @@ void TestCodeParser::onQmlDocumentUpdated(const QmlJS::Document::Ptr &document)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProjectExplorer::Project *project = ProjectExplorer::SessionManager::startupProject();
|
|
||||||
if (!project)
|
|
||||||
return;
|
|
||||||
if (!project->files(ProjectExplorer::Project::AllFiles).contains(fileName)) {
|
|
||||||
// what if the file is not listed inside the pro file, but will be used anyway?
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
scanForTests(QStringList(fileName));
|
scanForTests(QStringList(fileName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TestCodeParser::onCppDocumentUpdated(const CPlusPlus::Document::Ptr &document)
|
||||||
|
{
|
||||||
|
onDocumentUpdated(document->fileName());
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestCodeParser::onQmlDocumentUpdated(const QmlJS::Document::Ptr &document)
|
||||||
|
{
|
||||||
|
onDocumentUpdated(document->fileName());
|
||||||
|
}
|
||||||
|
|
||||||
void TestCodeParser::onStartupProjectChanged(ProjectExplorer::Project *project)
|
void TestCodeParser::onStartupProjectChanged(ProjectExplorer::Project *project)
|
||||||
{
|
{
|
||||||
if (m_parserState == FullParse || m_parserState == PartialParse)
|
if (m_parserState == FullParse || m_parserState == PartialParse) {
|
||||||
|
qCDebug(LOG) << "Canceling scanForTest (startup project changed)";
|
||||||
Core::ProgressManager::instance()->cancelTasks(Constants::TASK_PARSE);
|
Core::ProgressManager::instance()->cancelTasks(Constants::TASK_PARSE);
|
||||||
else if (project)
|
}
|
||||||
|
if (project)
|
||||||
emitUpdateTestTree();
|
emitUpdateTestTree();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -275,6 +263,7 @@ bool TestCodeParser::postponed(const QStringList &fileList)
|
|||||||
m_partialUpdatePostponed = false;
|
m_partialUpdatePostponed = false;
|
||||||
m_postponedFiles.clear();
|
m_postponedFiles.clear();
|
||||||
m_fullUpdatePostponed = true;
|
m_fullUpdatePostponed = true;
|
||||||
|
qCDebug(LOG) << "Canceling scanForTest (full parse triggered while running a scan)";
|
||||||
Core::ProgressManager::instance()->cancelTasks(Constants::TASK_PARSE);
|
Core::ProgressManager::instance()->cancelTasks(Constants::TASK_PARSE);
|
||||||
} else {
|
} else {
|
||||||
// partial parse triggered, but full parse is postponed already, ignoring this
|
// partial parse triggered, but full parse is postponed already, ignoring this
|
||||||
@@ -352,8 +341,15 @@ void TestCodeParser::scanForTests(const QStringList &fileList)
|
|||||||
|
|
||||||
void TestCodeParser::onTaskStarted(Core::Id type)
|
void TestCodeParser::onTaskStarted(Core::Id type)
|
||||||
{
|
{
|
||||||
if (type == CppTools::Constants::TASK_INDEX)
|
if (type == CppTools::Constants::TASK_INDEX) {
|
||||||
m_codeModelParsing = true;
|
m_codeModelParsing = true;
|
||||||
|
if (m_parserState == FullParse || m_parserState == PartialParse) {
|
||||||
|
m_fullUpdatePostponed = m_parserState == FullParse;
|
||||||
|
m_partialUpdatePostponed = !m_fullUpdatePostponed;
|
||||||
|
qCDebug(LOG) << "Canceling scan for test (CppModelParsing started)";
|
||||||
|
Core::ProgressManager::instance()->cancelTasks(Constants::TASK_PARSE);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestCodeParser::onAllTasksFinished(Core::Id type)
|
void TestCodeParser::onAllTasksFinished(Core::Id type)
|
||||||
|
@@ -82,6 +82,7 @@ private:
|
|||||||
bool postponed(const QStringList &fileList);
|
bool postponed(const QStringList &fileList);
|
||||||
void scanForTests(const QStringList &fileList = QStringList());
|
void scanForTests(const QStringList &fileList = QStringList());
|
||||||
|
|
||||||
|
void onDocumentUpdated(const QString &fileName);
|
||||||
void onTaskStarted(Core::Id type);
|
void onTaskStarted(Core::Id type);
|
||||||
void onAllTasksFinished(Core::Id type);
|
void onAllTasksFinished(Core::Id type);
|
||||||
void onFinished();
|
void onFinished();
|
||||||
|
Reference in New Issue
Block a user