2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
2022-12-21 10:12:09 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2014-10-07 12:30:54 +02:00
|
|
|
|
2016-03-18 07:55:01 +01:00
|
|
|
#pragma once
|
2014-10-07 12:30:54 +02:00
|
|
|
|
2016-05-11 13:02:42 +02:00
|
|
|
#include "itestparser.h"
|
2014-11-06 16:01:06 +01:00
|
|
|
|
2016-06-20 07:03:55 +02:00
|
|
|
#include <qmljs/qmljsdocument.h>
|
2023-01-27 01:56:55 +01:00
|
|
|
|
|
|
|
|
#include <utils/futuresynchronizer.h>
|
2020-10-09 13:07:55 +02:00
|
|
|
#include <utils/id.h>
|
2016-06-20 07:03:55 +02:00
|
|
|
|
2020-10-09 13:07:55 +02:00
|
|
|
#include <QObject>
|
2016-10-24 12:51:03 +02:00
|
|
|
#include <QTimer>
|
2014-10-07 12:30:54 +02:00
|
|
|
|
2017-05-16 11:15:57 +02:00
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
class QThreadPool;
|
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
|
2020-10-09 13:07:55 +02:00
|
|
|
namespace ProjectExplorer { class Project; }
|
2023-05-10 19:54:52 +02:00
|
|
|
namespace Tasking { class TaskTree; }
|
2020-10-09 13:07:55 +02:00
|
|
|
|
2014-10-07 12:30:54 +02:00
|
|
|
namespace Autotest {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
class TestCodeParser : public QObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
2015-02-10 14:20:43 +01:00
|
|
|
enum State {
|
|
|
|
|
Idle,
|
|
|
|
|
PartialParse,
|
2015-02-12 15:48:24 +01:00
|
|
|
FullParse,
|
2023-08-25 14:10:10 +02:00
|
|
|
Shutdown,
|
|
|
|
|
DisabledTemporarily
|
2015-02-10 14:20:43 +01:00
|
|
|
};
|
|
|
|
|
|
2020-03-16 12:59:23 +01:00
|
|
|
TestCodeParser();
|
2023-01-27 01:56:55 +01:00
|
|
|
~TestCodeParser();
|
2020-03-16 12:59:23 +01:00
|
|
|
|
2015-02-12 15:48:24 +01:00
|
|
|
void setState(State state);
|
2015-04-10 15:09:45 +02:00
|
|
|
State state() const { return m_parserState; }
|
2016-03-14 15:36:03 +01:00
|
|
|
bool isParsing() const { return m_parserState == PartialParse || m_parserState == FullParse; }
|
2015-07-27 13:54:27 +02:00
|
|
|
void setDirty() { m_dirty = true; }
|
2021-01-01 19:19:33 +01:00
|
|
|
void syncTestFrameworks(const QList<ITestParser *> &parsers);
|
2016-02-10 10:43:31 +01:00
|
|
|
#ifdef WITH_TESTS
|
|
|
|
|
bool furtherParsingExpected() const
|
2021-07-02 08:11:03 +02:00
|
|
|
{ return m_singleShotScheduled || m_postponedUpdateType != UpdateType::NoUpdate; }
|
2016-02-10 10:43:31 +01:00
|
|
|
#endif
|
2014-10-07 12:30:54 +02:00
|
|
|
|
|
|
|
|
signals:
|
2016-01-25 13:05:12 +01:00
|
|
|
void aboutToPerformFullParse();
|
2023-01-27 01:56:55 +01:00
|
|
|
void testParseResultReady(const TestParseResultPtr result); // TODO: pass list of results?
|
2015-02-17 14:45:26 +01:00
|
|
|
void parsingStarted();
|
2015-02-10 14:20:43 +01:00
|
|
|
void parsingFinished();
|
2015-07-27 13:54:27 +02:00
|
|
|
void parsingFailed();
|
2023-04-23 15:29:11 +02:00
|
|
|
void requestRemoval(const QSet<Utils::FilePath> &filePaths);
|
2020-10-19 13:56:19 +02:00
|
|
|
void requestRemoveAllFrameworkItems();
|
2014-10-07 12:30:54 +02:00
|
|
|
|
2016-06-28 22:38:54 +03:00
|
|
|
public:
|
2017-03-06 15:24:16 +01:00
|
|
|
void emitUpdateTestTree(ITestParser *parser = nullptr);
|
2021-01-01 19:19:33 +01:00
|
|
|
void updateTestTree(const QSet<ITestParser *> &parsers = {});
|
2015-01-27 15:22:17 +01:00
|
|
|
void onCppDocumentUpdated(const CPlusPlus::Document::Ptr &document);
|
|
|
|
|
void onQmlDocumentUpdated(const QmlJS::Document::Ptr &document);
|
2016-02-10 15:48:00 +01:00
|
|
|
void onStartupProjectChanged(ProjectExplorer::Project *project);
|
2015-04-02 12:16:55 +02:00
|
|
|
void onProjectPartsUpdated(ProjectExplorer::Project *project);
|
2023-08-25 14:10:10 +02:00
|
|
|
void aboutToShutdown(bool isFinal);
|
2014-10-07 12:30:54 +02:00
|
|
|
|
|
|
|
|
private:
|
2023-04-23 17:25:46 +02:00
|
|
|
bool postponed(const QSet<Utils::FilePath> &fileList);
|
|
|
|
|
void scanForTests(const QSet<Utils::FilePath> &filePaths = {},
|
2021-01-01 19:19:33 +01:00
|
|
|
const QList<ITestParser *> &parsers = {});
|
2015-02-05 16:07:45 +01:00
|
|
|
|
2017-08-08 15:42:03 +02:00
|
|
|
// qml files must be handled slightly different
|
2021-05-26 15:50:03 +02:00
|
|
|
void onDocumentUpdated(const Utils::FilePath &fileName, bool isQmlFile = false);
|
2020-06-26 13:59:38 +02:00
|
|
|
void onTaskStarted(Utils::Id type);
|
|
|
|
|
void onAllTasksFinished(Utils::Id type);
|
2023-01-27 01:56:55 +01:00
|
|
|
void onFinished(bool success);
|
2015-02-10 14:20:43 +01:00
|
|
|
void onPartialParsingFinished();
|
2016-10-24 12:51:03 +02:00
|
|
|
void parsePostponedFiles();
|
2016-06-20 07:03:55 +02:00
|
|
|
void releaseParserInternals();
|
2014-10-07 12:30:54 +02:00
|
|
|
|
2021-01-01 19:18:40 +01:00
|
|
|
// used internally to indicate a parse that failed due to having triggered a parse for a file that
|
|
|
|
|
// is not (yet) part of the CppModelManager's snapshot
|
|
|
|
|
bool m_parsingHasFailed = false;
|
|
|
|
|
|
2016-10-24 12:51:03 +02:00
|
|
|
bool m_codeModelParsing = false;
|
2023-01-27 01:56:55 +01:00
|
|
|
enum class UpdateType { NoUpdate, PartialUpdate, FullUpdate };
|
|
|
|
|
UpdateType m_postponedUpdateType = UpdateType::NoUpdate;
|
2016-10-24 12:51:03 +02:00
|
|
|
bool m_dirty = false;
|
|
|
|
|
bool m_singleShotScheduled = false;
|
|
|
|
|
bool m_reparseTimerTimedOut = false;
|
2021-05-26 15:50:03 +02:00
|
|
|
QSet<Utils::FilePath> m_postponedFiles;
|
2016-11-08 16:00:21 +01:00
|
|
|
State m_parserState = Idle;
|
2019-09-06 12:16:46 +02:00
|
|
|
QList<ITestParser *> m_testCodeParsers; // ptrs are still owned by TestFrameworkManager
|
2016-10-24 12:51:03 +02:00
|
|
|
QTimer m_reparseTimer;
|
2021-01-01 19:19:33 +01:00
|
|
|
QSet<ITestParser *> m_updateParsers;
|
2023-01-27 01:56:55 +01:00
|
|
|
Utils::FutureSynchronizer m_futureSynchronizer;
|
2023-05-10 19:54:52 +02:00
|
|
|
std::unique_ptr<Tasking::TaskTree> m_taskTree;
|
2023-04-24 16:00:18 +02:00
|
|
|
QHash<Utils::FilePath, int> m_qmlEditorRev;
|
2023-05-12 11:13:03 +02:00
|
|
|
|
|
|
|
|
QElapsedTimer m_parsingTimer;
|
2014-10-07 12:30:54 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
2016-05-11 13:02:42 +02:00
|
|
|
} // namespace Autotest
|