qmlengine.h 5.47 KB
Newer Older
hjk's avatar
hjk committed
1
/****************************************************************************
2
**
Eike Ziller's avatar
Eike Ziller committed
3 4
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
5
**
hjk's avatar
hjk committed
6
** This file is part of Qt Creator.
7
**
hjk's avatar
hjk committed
8 9 10 11
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
Eike Ziller's avatar
Eike Ziller committed
12 13
** a written agreement between you and The Qt Company.  For licensing terms and
** conditions see http://www.qt.io/terms-conditions.  For further information
Eike Ziller's avatar
Eike Ziller committed
14
** use the contact form at http://www.qt.io/contact-us.
15 16
**
** GNU Lesser General Public License Usage
hjk's avatar
hjk committed
17
** Alternatively, this file may be used under the terms of the GNU Lesser
Eike Ziller's avatar
Eike Ziller committed
18 19 20 21 22 23
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file.  Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
hjk's avatar
hjk committed
24
**
Eike Ziller's avatar
Eike Ziller committed
25 26
** In addition, as a special exception, The Qt Company gives you certain additional
** rights.  These rights are described in The Qt Company LGPL Exception
con's avatar
con committed
27 28
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
29
****************************************************************************/
30

Kai Koehne's avatar
Kai Koehne committed
31 32
#ifndef QMLENGINE_H
#define QMLENGINE_H
33

34
#include <debugger/debuggerengine.h>
Kai Koehne's avatar
Kai Koehne committed
35

36
#include <qmldebug/qdebugmessageclient.h>
hjk's avatar
hjk committed
37
#include <qmldebug/qmldebugclient.h>
Kai Koehne's avatar
Kai Koehne committed
38
#include <qmldebug/qmloutputparser.h>
39
#include <qmljs/iscriptevaluator.h>
40
#include <qmljs/qmljsdocument.h>
hjk's avatar
hjk committed
41

42
namespace Debugger {
43
namespace Internal {
44

hjk's avatar
hjk committed
45 46 47
class WatchData;
class WatchItem;
class QmlEnginePrivate;
48
class QmlInspectorAgent;
49

50
class QmlEngine : public DebuggerEngine, QmlJS::IScriptEvaluator
51 52 53 54
{
    Q_OBJECT

public:
55
    explicit QmlEngine(const DebuggerRunParameters &runParameters,
Aurindam Jana's avatar
Aurindam Jana committed
56
                       DebuggerEngine *masterEngine = 0);
57
    ~QmlEngine();
58

hjk's avatar
hjk committed
59
    void filterApplicationMessage(const QString &msg, int channel) const;
60

hjk's avatar
hjk committed
61 62 63
    void logServiceStateChange(const QString &service, float version,
                               QmlDebug::QmlDebugClient::State newState);
    void logServiceActivity(const QString &service, const QString &logMessage);
64

65 66
    void expressionEvaluated(quint32 queryId, const QVariant &result);

Kai Koehne's avatar
Kai Koehne committed
67
private slots:
68
    void disconnected();
69
    void documentUpdated(QmlJS::Document::Ptr doc);
70

71
    void errorMessageBoxFinished(int result);
72
    void updateCurrentContext();
73

Kai Koehne's avatar
Kai Koehne committed
74 75 76 77 78 79 80
    void tryToConnect(quint16 port = 0);
    void beginConnection(quint16 port = 0);
    void connectionEstablished();
    void connectionStartupFailed();
    void appStartupFailed(const QString &errorMessage);
    void appendMessage(const QString &msg, Utils::OutputFormat);

81
private:
hjk's avatar
hjk committed
82 83 84 85 86 87 88 89
    void notifyEngineRemoteServerRunning(const QByteArray &, int pid);
    void notifyEngineRemoteSetupFinished(const RemoteSetupResult &result);

    void showMessage(const QString &msg, int channel = LogDebug,
                     int timeout = -1) const;
    void gotoLocation(const Internal::Location &location);
    void insertBreakpoint(Breakpoint bp);

hjk's avatar
hjk committed
90
    bool isSynchronous() const { return false; }
hjk's avatar
hjk committed
91 92
    bool canDisplayTooltip() const { return false; }

93 94 95 96 97 98
    void executeStep();
    void executeStepOut();
    void executeNext();
    void executeStepI();
    void executeNextI();

hjk's avatar
hjk committed
99
    void setupEngine();
hjk's avatar
hjk committed
100 101 102 103 104
    void setupInferior();
    void runEngine();
    void shutdownInferior();
    void shutdownEngine();

105
    bool canHandleToolTip(const DebuggerToolTipContext &) const;
106 107 108 109

    void continueInferior();
    void interruptInferior();

110
    void executeRunToLine(const ContextData &data);
111
    void executeRunToFunction(const QString &functionName);
112
    void executeJumpToLine(const ContextData &data);
113 114

    void activateFrame(int index);
hjk's avatar
hjk committed
115
    void selectThread(ThreadId threadId);
116 117

    void attemptBreakpointSynchronization();
118 119 120
    void removeBreakpoint(Breakpoint bp);
    void changeBreakpoint(Breakpoint bp);
    bool acceptsBreakpoint(Breakpoint bp) const;
121

122
    void assignValueInDebugger(WatchItem *item,
hjk's avatar
hjk committed
123
        const QString &expr, const QVariant &value);
124

125 126 127 128 129
    void loadSymbols(const QString &moduleName);
    void loadAllSymbols();
    void requestModuleSymbols(const QString &moduleName);
    void reloadModules();
    void reloadRegisters() {}
130
    void reloadSourceFiles();
131 132
    void reloadFullStack() {}

133
    void updateAll();
hjk's avatar
hjk committed
134 135
    void updateItem(const QByteArray &iname);
    void expandItem(const QByteArray &iname);
136
    void selectWatchData(const QByteArray &iname);
137
    void executeDebuggerCommand(const QString &command, DebuggerLanguages languages);
138
    bool evaluateScript(const QString &expression);
139

140
    bool hasCapability(unsigned) const;
141
    void quitDebugger();
142

143 144 145 146
    void closeConnection();
    void startApplicationLauncher();
    void stopApplicationLauncher();

hjk's avatar
hjk committed
147 148 149 150 151 152
    void connectionErrorOccurred(QDebugSupport::Error socketError);
    void clientStateChanged(QmlDebug::QmlDebugClient::State state);
    void checkConnectionState();
    void showConnectionStateMessage(const QString &message);
    void showConnectionErrorMessage(const QString &message);
    bool isConnected() const;
Kai Koehne's avatar
Kai Koehne committed
153

hjk's avatar
hjk committed
154
private:
155
    friend class QmlCppEngine;
hjk's avatar
hjk committed
156
    friend class QmlEnginePrivate;
157
    friend class QmlInspectorAgent;
hjk's avatar
hjk committed
158
    QmlEnginePrivate *d;
159 160
};

161
} // namespace Internal
162 163
} // namespace Debugger

Kai Koehne's avatar
Kai Koehne committed
164
#endif // QMLENGINE_H