qmlengine.h 5.41 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 QmlAdapter;
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

Kai Koehne's avatar
Kai Koehne committed
65
private slots:
66
    void disconnected();
67
    void documentUpdated(QmlJS::Document::Ptr doc);
68
    void expressionEvaluated(quint32 queryId, const QVariant &result);
69

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

Kai Koehne's avatar
Kai Koehne committed
73 74 75 76 77 78 79
    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);

80
private:
hjk's avatar
hjk committed
81 82 83 84 85 86 87 88
    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
89
    bool isSynchronous() const { return false; }
hjk's avatar
hjk committed
90 91
    bool canDisplayTooltip() const { return false; }

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

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

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

    void continueInferior();
    void interruptInferior();

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

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

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

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

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

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

138
    bool hasCapability(unsigned) const;
139
    void quitDebugger();
140

141 142 143 144
    void closeConnection();
    void startApplicationLauncher();
    void stopApplicationLauncher();

hjk's avatar
hjk committed
145 146 147 148 149 150
    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
151

hjk's avatar
hjk committed
152
private:
153
    friend class QmlCppEngine;
hjk's avatar
hjk committed
154 155
    friend class QmlEnginePrivate;
    QmlEnginePrivate *d;
156 157
};

158
} // namespace Internal
159 160
} // namespace Debugger

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