qmlengine.h 6.69 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).
**
Eike Ziller's avatar
Eike Ziller committed
7
** Contact: http://www.qt-project.org/
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.
**
28 29 30
**
**************************************************************************/

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

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

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

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

namespace Core {
class IEditor;
}

52
namespace Debugger {
53
namespace Internal {
54

55
class QmlAdapter;
Kai Koehne's avatar
Kai Koehne committed
56
class QtMessageLogItem;
57

58
class QmlEngine : public DebuggerEngine
59 60 61 62
{
    Q_OBJECT

public:
63
    explicit QmlEngine(const DebuggerStartParameters &startParameters);
64
    ~QmlEngine();
65

66 67
    void notifyEngineRemoteSetupDone(int gdbServerPort, int qmlPort);
    void notifyEngineRemoteSetupFailed(const QString &message);
68

69
    bool canDisplayTooltip() const;
70

71 72
    void showMessage(const QString &msg, int channel = LogDebug,
                     int timeout = -1) const;
73 74
    void gotoLocation(const Internal::Location &location);

75
    void filterApplicationMessage(const QString &msg, int channel);
76 77
    void inferiorSpontaneousStop();

Kai Koehne's avatar
Kai Koehne committed
78 79 80 81 82 83 84
    enum LogDirection {
        LogSend,
        LogReceive
    };

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

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

90 91
    void insertBreakpoint(BreakpointModelId id);

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

private slots:
97
    void disconnected();
98
    void documentUpdated(QmlJS::Document::Ptr doc);
99
    void expressionEvaluated(quint32 queryId, const QVariant &result);
100

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

Kai Koehne's avatar
Kai Koehne committed
106 107 108 109 110 111 112 113 114 115 116
    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();

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

hjk's avatar
hjk committed
126
    void setupEngine();
hjk's avatar
hjk committed
127 128 129 130 131
    void setupInferior();
    void runEngine();
    void shutdownInferior();
    void shutdownEngine();

132
    bool setToolTipExpression(const QPoint &mousePos,
133
        TextEditor::ITextEditor *editor, const DebuggerToolTipContext &);
134 135 136 137

    void continueInferior();
    void interruptInferior();

138
    void executeRunToLine(const ContextData &data);
139
    void executeRunToFunction(const QString &functionName);
140
    void executeJumpToLine(const ContextData &data);
141 142 143 144 145

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

    void attemptBreakpointSynchronization();
146 147
    void removeBreakpoint(BreakpointModelId id);
    void changeBreakpoint(BreakpointModelId id);
148
    bool acceptsBreakpoint(BreakpointModelId id) const;
149

150
    void assignValueInDebugger(const WatchData *data,
hjk's avatar
hjk committed
151
        const QString &expr, const QVariant &value);
152 153


154 155 156 157 158
    void loadSymbols(const QString &moduleName);
    void loadAllSymbols();
    void requestModuleSymbols(const QString &moduleName);
    void reloadModules();
    void reloadRegisters() {}
159
    void reloadSourceFiles();
160 161
    void reloadFullStack() {}

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

168
    bool hasCapability(unsigned) const;
169
    void quitDebugger();
170

171
private:
172 173 174 175
    void closeConnection();
    void startApplicationLauncher();
    void stopApplicationLauncher();

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

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

Kai Koehne's avatar
Kai Koehne committed
190 191 192 193
    QmlAdapter m_adapter;
    QmlInspectorAdapter m_inspectorAdapter;
    ProjectExplorer::ApplicationLauncher m_applicationLauncher;
    QTimer m_noDebugOutputTimer;
Kai Koehne's avatar
Kai Koehne committed
194
    QmlDebug::QmlOutputParser m_outputParser;
Kai Koehne's avatar
Kai Koehne committed
195 196 197 198 199 200 201 202
    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;

203
    friend class QmlCppEngine;
204 205
};

206
} // namespace Internal
207 208
} // namespace Debugger

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