qmlengine.h 6.8 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
**
**************************************************************************/

Kai Koehne's avatar
Kai Koehne committed
33 34
#ifndef QMLENGINE_H
#define QMLENGINE_H
35

36
#include "debuggerengine.h"
Kai Koehne's avatar
Kai Koehne committed
37 38 39 40 41
#include "interactiveinterpreter.h"
#include "qmladapter.h"
#include "qmlinspectoradapter.h"

#include <projectexplorer/applicationlauncher.h>
42
#include <qmldebug/qdebugmessageclient.h>
Kai Koehne's avatar
Kai Koehne committed
43
#include <qmldebug/qmloutputparser.h>
44
#include <qmljs/qmljsdocument.h>
Kai Koehne's avatar
Kai Koehne committed
45
#include <utils/outputformat.h>
hjk's avatar
hjk committed
46

47
#include <QAbstractSocket>
Kai Koehne's avatar
Kai Koehne committed
48
#include <QTextDocument>
49 50 51 52 53

namespace Core {
class IEditor;
}

54
namespace Debugger {
55
namespace Internal {
56

57
class QmlAdapter;
Kai Koehne's avatar
Kai Koehne committed
58
class QtMessageLogItem;
59

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

public:
65 66
    QmlEngine(const DebuggerStartParameters &startParameters,
        DebuggerEngine *masterEngine);
67
    ~QmlEngine();
68

Christian Kandeler's avatar
Christian Kandeler committed
69
    void handleRemoteSetupDone(int gdbServerPort, int qmlPort);
70 71
    void handleRemoteSetupFailed(const QString &message);

72
    bool canDisplayTooltip() const;
73

74 75
    void showMessage(const QString &msg, int channel = LogDebug,
                     int timeout = -1) const;
76 77
    void gotoLocation(const Internal::Location &location);

78
    void filterApplicationMessage(const QString &msg, int channel);
79 80
    void inferiorSpontaneousStop();

Kai Koehne's avatar
Kai Koehne committed
81 82 83 84 85 86 87
    enum LogDirection {
        LogSend,
        LogReceive
    };

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

89
    void setSourceFiles(const QStringList &fileNames);
Kai Koehne's avatar
Kai Koehne committed
90 91
    void updateScriptSource(const QString &fileName, int lineOffset,
                            int columnOffset, const QString &source);
92

93 94
    void insertBreakpoint(BreakpointModelId id);

Kai Koehne's avatar
Kai Koehne committed
95 96 97 98 99
signals:
    void tooltipRequested(const QPoint &mousePos,
        TextEditor::ITextEditor *editor, int cursorPos);

private slots:
100
    void disconnected();
101
    void documentUpdated(QmlJS::Document::Ptr doc);
102
    void expressionEvaluated(quint32 queryId, const QVariant &result);
103

104
    void errorMessageBoxFinished(int result);
105
    void updateCurrentContext();
106
    void appendDebugOutput(QtMsgType type, const QString &message,
107
                           const QmlDebug::QDebugContextInfo &info);
108

Kai Koehne's avatar
Kai Koehne committed
109 110 111 112 113 114 115 116 117 118 119
    void tryToConnect(quint16 port = 0);
    void beginConnection(quint16 port = 0);
    void connectionEstablished();
    void connectionStartupFailed();
    void appStartupFailed(const QString &errorMessage);
    void connectionError(QAbstractSocket::SocketError error);
    void serviceConnectionError(const QString &service);
    void appendMessage(const QString &msg, Utils::OutputFormat);

    void synchronizeWatchers();

120
private:
121
    // DebuggerEngine implementation.
hjk's avatar
hjk committed
122
    bool isSynchronous() const { return false; }
123 124 125 126 127 128
    void executeStep();
    void executeStepOut();
    void executeNext();
    void executeStepI();
    void executeNextI();

hjk's avatar
hjk committed
129
    void setupEngine();
hjk's avatar
hjk committed
130 131 132 133 134
    void setupInferior();
    void runEngine();
    void shutdownInferior();
    void shutdownEngine();

135
    bool setToolTipExpression(const QPoint &mousePos,
136
        TextEditor::ITextEditor *editor, const DebuggerToolTipContext &);
137 138 139 140

    void continueInferior();
    void interruptInferior();

141
    void executeRunToLine(const ContextData &data);
142
    void executeRunToFunction(const QString &functionName);
143
    void executeJumpToLine(const ContextData &data);
144 145 146 147 148

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

    void attemptBreakpointSynchronization();
149 150
    void removeBreakpoint(BreakpointModelId id);
    void changeBreakpoint(BreakpointModelId id);
151
    bool acceptsBreakpoint(BreakpointModelId id) const;
152

153
    void assignValueInDebugger(const WatchData *data,
hjk's avatar
hjk committed
154
        const QString &expr, const QVariant &value);
155 156


157 158 159 160 161
    void loadSymbols(const QString &moduleName);
    void loadAllSymbols();
    void requestModuleSymbols(const QString &moduleName);
    void reloadModules();
    void reloadRegisters() {}
162
    void reloadSourceFiles();
163 164
    void reloadFullStack() {}

Olivier Goffart's avatar
Olivier Goffart committed
165
    bool supportsThreads() const { return false; }
166 167
    void updateWatchData(const WatchData &data,
        const WatchUpdateFlags &flags);
168
    void executeDebuggerCommand(const QString &command, DebuggerLanguages languages);
169
    bool evaluateScriptExpression(const QString &expression);
170

171
    bool hasCapability(unsigned) const;
172

173
private:
174 175 176 177
    void closeConnection();
    void startApplicationLauncher();
    void stopApplicationLauncher();

178 179
    bool isShadowBuildProject() const;
    QString fromShadowBuildFilename(const QString &filename) const;
hjk's avatar
hjk committed
180 181
    QString mangleFilenamePaths(const QString &filename,
        const QString &oldBasePath, const QString &newBasePath) const;
182 183
    QString qmlImportPath() const;

184
    void updateEditor(Core::IEditor *editor, const QTextDocument *document);
185
    bool canEvaluateScript(const QString &script);
Aurindam Jana's avatar
Aurindam Jana committed
186 187
    QtMessageLogItem *constructLogItemTree(QtMessageLogItem *parent,
                                           const QVariant &result,
188
                                           const QString &key = QString());
189 190
    bool adjustBreakpointLineAndColumn(const QString &filePath, quint32 *line,
                                       quint32 *column, bool *valid);
191

Kai Koehne's avatar
Kai Koehne committed
192 193 194 195
    QmlAdapter m_adapter;
    QmlInspectorAdapter m_inspectorAdapter;
    ProjectExplorer::ApplicationLauncher m_applicationLauncher;
    QTimer m_noDebugOutputTimer;
Kai Koehne's avatar
Kai Koehne committed
196
    QmlDebug::QmlOutputParser m_outputParser;
Kai Koehne's avatar
Kai Koehne committed
197 198 199 200 201 202 203 204
    QHash<QString, QTextDocument*> m_sourceDocuments;
    QHash<QString, QWeakPointer<TextEditor::ITextEditor> > m_sourceEditors;
    InteractiveInterpreter m_interpreter;
    QHash<QString,BreakpointModelId> pendingBreakpoints;
    QList<quint32> queryIds;
    bool m_retryOnConnectFail;
    bool m_automaticConnect;

205
    friend class QmlCppEngine;
206 207
};

208
} // namespace Internal
209 210
} // namespace Debugger

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