1 | // SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. |
---|---|
2 | // |
3 | // SPDX-License-Identifier: GPL-3.0-or-later |
4 | |
5 | #ifndef JSDebugger_H |
6 | #define JSDebugger_H |
7 | |
8 | #include "base/abstractdebugger.h" |
9 | |
10 | #include <QObject> |
11 | #include <QtScript/QScriptEngine> |
12 | #include <QScriptEngineDebugger> |
13 | |
14 | class AbstractWidget; |
15 | class AbstractCentral; |
16 | class JSDebugger : public AbstractDebugger |
17 | { |
18 | Q_OBJECT |
19 | public: |
20 | explicit JSDebugger(QObject *parent = nullptr); |
21 | ~JSDebugger() override; |
22 | |
23 | QWidget *getOutputPane() const override; |
24 | QWidget *getStackPane() const override; |
25 | QWidget *getLocalsPane() const override; |
26 | QWidget *getBreakpointPane() const override; |
27 | |
28 | void startDebug() override; |
29 | void detachDebug() override; |
30 | |
31 | void interruptDebug() override; |
32 | void continueDebug() override; |
33 | void abortDebug() override; |
34 | void restartDebug() override; |
35 | |
36 | void stepOver() override; |
37 | void stepIn() override; |
38 | void stepOut() override; |
39 | |
40 | RunState getRunState() const override; |
41 | bool runCoredump(const QString &target, const QString &core, const QString &kit) override; |
42 | |
43 | signals: |
44 | void execCommand(QScriptEngineDebugger::DebuggerAction debuggerAction); |
45 | |
46 | public slots: |
47 | void slotEvaluationSuspended(); |
48 | void slotEvaluationResumed(); |
49 | void setupDebugEnv(); |
50 | |
51 | private: |
52 | void runCommand(QScriptEngineDebugger::DebuggerAction command); |
53 | QWidget *debuggerWidget(QScriptEngineDebugger::DebuggerWidget widget) const; |
54 | QScriptValue evaluateFile(QScriptEngine &engine, const QString &filePath); |
55 | void addPagesToContext(const QScriptEngineDebugger &debugger); |
56 | void removePagesFromContext(); |
57 | |
58 | RunState runState = kNoRun; |
59 | |
60 | QWidget *oldWidgetEdit = nullptr; |
61 | QWidget *oldWidgetWatch = nullptr; |
62 | |
63 | AbstractWidget *stackPane = nullptr; |
64 | AbstractWidget *breakpointsPane = nullptr; |
65 | AbstractWidget *scriptPane = nullptr; |
66 | AbstractWidget *errorPane = nullptr; |
67 | AbstractWidget *localsPane = nullptr; |
68 | AbstractCentral *codeEditor = nullptr; |
69 | }; |
70 | |
71 | #endif // JSDebugger_H |
72 |