qmlengine.h 6.23 KB
Newer Older
1
2
3
4
5
6
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
7
** Contact: Nokia Corporation (qt-info@nokia.com)
8
9
10
11
**
**
** GNU Lesser General Public License Usage
**
hjk's avatar
hjk committed
12
13
14
15
16
17
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18
**
con's avatar
con committed
19
** In addition, as a special exception, Nokia gives you certain additional
hjk's avatar
hjk committed
20
** rights. These rights are described in the Nokia Qt LGPL Exception
con's avatar
con committed
21
22
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
23
24
25
26
27
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
con's avatar
con committed
28
** If you have questions regarding the use of this file, please contact
29
** Nokia at qt-info@nokia.com.
30
31
32
33
34
35
**
**************************************************************************/

#ifndef DEBUGGER_QMLENGINE_H
#define DEBUGGER_QMLENGINE_H

36
#include "debuggerengine.h"
37
#include <qmljsdebugclient/qmlenginedebugclient.h>
38
#include <qmljsdebugclient/qdebugmessageclient.h>
con's avatar
con committed
39
#include <utils/outputformat.h>
40
#include <qmljs/qmljsdocument.h>
hjk's avatar
hjk committed
41

42
#include <QAbstractSocket>
43

hjk's avatar
hjk committed
44
QT_BEGIN_NAMESPACE
45
class QTextDocument;
hjk's avatar
hjk committed
46
QT_END_NAMESPACE
47
48
49
50
51

namespace Core {
class IEditor;
}

52
namespace Debugger {
53
54
55

class QmlAdapter;

56
namespace Internal {
57

58
class QtMessageLogItem;
Tobias Hunger's avatar
Tobias Hunger committed
59
class QmlEnginePrivate;
60

61
class QmlEngine : public DebuggerEngine
62
63
64
65
{
    Q_OBJECT

public:
66
67
68
69
70
    enum LogDirection {
        LogSend,
        LogReceive
    };

71
72
    QmlEngine(const DebuggerStartParameters &startParameters,
        DebuggerEngine *masterEngine);
73
    ~QmlEngine();
74

Christian Kandeler's avatar
Christian Kandeler committed
75
    void handleRemoteSetupDone(int gdbServerPort, int qmlPort);
76
77
    void handleRemoteSetupFailed(const QString &message);

78
    bool canDisplayTooltip() const;
79

80
81
    void showMessage(const QString &msg, int channel = LogDebug,
                     int timeout = -1) const;
82
83
    void gotoLocation(const Internal::Location &location);

84
    void filterApplicationMessage(const QString &msg, int channel);
85
86
    void inferiorSpontaneousStop();

87
    void logMessage(const QString &service, LogDirection direction, const QString &str);
88

89
90
91
    void setSourceFiles(const QStringList &fileNames);
    void updateScriptSource(const QString &fileName, int lineOffset, int columnOffset, const QString &source);

92
93
    QmlAdapter *adapter() const;

94
95
    void insertBreakpoint(BreakpointModelId id);

96
97
public slots:
    void disconnected();
98
    void documentUpdated(QmlJS::Document::Ptr doc);
99

100
private slots:
101
    void errorMessageBoxFinished(int result);
102
    void updateCurrentContext();
103
104
    void appendDebugOutput(QtMsgType type, const QString &message,
                           const QmlJsDebugClient::QDebugContextInfo &info);
105

106
private:
107
    // DebuggerEngine implementation.
hjk's avatar
hjk committed
108
    bool isSynchronous() const { return false; }
109
110
111
112
113
114
    void executeStep();
    void executeStepOut();
    void executeNext();
    void executeStepI();
    void executeNextI();

hjk's avatar
hjk committed
115
    void setupEngine();
hjk's avatar
hjk committed
116
117
118
119
120
    void setupInferior();
    void runEngine();
    void shutdownInferior();
    void shutdownEngine();

121
    bool setToolTipExpression(const QPoint &mousePos,
122
        TextEditor::ITextEditor *editor, const DebuggerToolTipContext &);
123
124
125
126

    void continueInferior();
    void interruptInferior();

127
    void executeRunToLine(const ContextData &data);
128
    void executeRunToFunction(const QString &functionName);
129
    void executeJumpToLine(const ContextData &data);
130
131
132
133
134

    void activateFrame(int index);
    void selectThread(int index);

    void attemptBreakpointSynchronization();
135
136
    void removeBreakpoint(BreakpointModelId id);
    void changeBreakpoint(BreakpointModelId id);
137
    bool acceptsBreakpoint(BreakpointModelId id) const;
138

139
    void assignValueInDebugger(const WatchData *data,
hjk's avatar
hjk committed
140
        const QString &expr, const QVariant &value);
141
142


143
144
145
146
147
    void loadSymbols(const QString &moduleName);
    void loadAllSymbols();
    void requestModuleSymbols(const QString &moduleName);
    void reloadModules();
    void reloadRegisters() {}
148
    void reloadSourceFiles();
149
150
    void reloadFullStack() {}

Olivier Goffart's avatar
Olivier Goffart committed
151
    bool supportsThreads() const { return false; }
152
153
    void updateWatchData(const WatchData &data,
        const WatchUpdateFlags &flags);
hjk's avatar
hjk committed
154
    void executeDebuggerCommand(const QString &command);
155
    bool evaluateScriptExpression(const QString &expression);
156

157
    bool hasCapability(unsigned) const;
158

159
signals:
hjk's avatar
hjk committed
160
161
    void tooltipRequested(const QPoint &mousePos,
        TextEditor::ITextEditor *editor, int cursorPos);
162

Lasse Holmstedt's avatar
Lasse Holmstedt committed
163
private slots:
164
    void tryToConnect(quint16 port = 0);
165
    void beginConnection(quint16 port = 0);
Lasse Holmstedt's avatar
Lasse Holmstedt committed
166
    void connectionEstablished();
167
168
    void connectionStartupFailed();
    void appStartupFailed(const QString &errorMessage);
169
    void connectionError(QAbstractSocket::SocketError error);
170
    void serviceConnectionError(const QString &service);
con's avatar
con committed
171
    void appendMessage(const QString &msg, Utils::OutputFormat);
Lasse Holmstedt's avatar
Lasse Holmstedt committed
172

173
    void synchronizeWatchers();
174
175
    void onDebugQueryStateChanged(
            QmlJsDebugClient::QDeclarativeDebugQuery::State state);
176

177
private:
178
179
180
181
    void closeConnection();
    void startApplicationLauncher();
    void stopApplicationLauncher();

182
183
    bool isShadowBuildProject() const;
    QString fromShadowBuildFilename(const QString &filename) const;
hjk's avatar
hjk committed
184
185
    QString mangleFilenamePaths(const QString &filename,
        const QString &oldBasePath, const QString &newBasePath) const;
186
187
    QString qmlImportPath() const;

188
    void updateEditor(Core::IEditor *editor, const QTextDocument *document);
189
    bool canEvaluateScript(const QString &script);
190
191
    QtMessageLogItem *constructLogItemTree(const QVariant &result,
                                           const QString &key = QString());
192
193
    bool adjustBreakpointLineAndColumn(const QString &filePath, quint32 *line,
                                       quint32 *column, bool *valid);
194

Lasse Holmstedt's avatar
Lasse Holmstedt committed
195
private:
196
    friend class QmlCppEngine;
hjk's avatar
hjk committed
197
    QmlEnginePrivate *d;
198
199
};

200
} // namespace Internal
201
202
203
} // namespace Debugger

#endif // DEBUGGER_QMLENGINE_H