Commit 156320ff authored by hjk's avatar hjk

Debugger: Merge QmlInspectorAdapter into QmlInspectorAgent

There's a 1:1 relation, and the abstraction is not needed anymore.

Also remove some unused code.

Change-Id: I09a2522deb5d522f46ec7518d19978a038032fbb
Reviewed-by: default avatarUlf Hermann <ulf.hermann@theqtcompany.com>
parent 5c815dea
...@@ -149,7 +149,6 @@ QtcPlugin { ...@@ -149,7 +149,6 @@ QtcPlugin {
"qmlcppengine.cpp", "qmlcppengine.h", "qmlcppengine.cpp", "qmlcppengine.h",
"qmlengine.cpp", "qmlengine.h", "qmlengine.cpp", "qmlengine.h",
"qmlengineutils.cpp", "qmlengineutils.h", "qmlengineutils.cpp", "qmlengineutils.h",
"qmlinspectoradapter.cpp", "qmlinspectoradapter.h",
"qmlinspectoragent.cpp", "qmlinspectoragent.h", "qmlinspectoragent.cpp", "qmlinspectoragent.h",
"qmlv8debuggerclientconstants.h" "qmlv8debuggerclientconstants.h"
] ]
......
...@@ -4,13 +4,11 @@ HEADERS += \ ...@@ -4,13 +4,11 @@ HEADERS += \
$$PWD/qmlcppengine.h \ $$PWD/qmlcppengine.h \
$$PWD/interactiveinterpreter.h \ $$PWD/interactiveinterpreter.h \
$$PWD/qmlv8debuggerclientconstants.h \ $$PWD/qmlv8debuggerclientconstants.h \
$$PWD/qmlinspectoragent.h \ $$PWD/qmlinspectoragent.h
$$PWD/qmlinspectoradapter.h
SOURCES += \ SOURCES += \
$$PWD/qmlengine.cpp \ $$PWD/qmlengine.cpp \
$$PWD/qmlengineutils.cpp \ $$PWD/qmlengineutils.cpp \
$$PWD/qmlcppengine.cpp \ $$PWD/qmlcppengine.cpp \
$$PWD/interactiveinterpreter.cpp \ $$PWD/interactiveinterpreter.cpp \
$$PWD/qmlinspectoragent.cpp \ $$PWD/qmlinspectoragent.cpp
$$PWD/qmlinspectoradapter.cpp
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
#include "qmlengine.h" #include "qmlengine.h"
#include "interactiveinterpreter.h" #include "interactiveinterpreter.h"
#include "qmlinspectoradapter.h"
#include "qmlinspectoragent.h" #include "qmlinspectoragent.h"
#include "qmlv8debuggerclientconstants.h" #include "qmlv8debuggerclientconstants.h"
#include "qmlengineutils.h" #include "qmlengineutils.h"
...@@ -136,7 +135,7 @@ public: ...@@ -136,7 +135,7 @@ public:
QmlEnginePrivate(QmlEngine *engine_, QmlDebugConnection *connection_) QmlEnginePrivate(QmlEngine *engine_, QmlDebugConnection *connection_)
: QmlDebugClient(QLatin1String("V8Debugger"), connection_), : QmlDebugClient(QLatin1String("V8Debugger"), connection_),
engine(engine_), engine(engine_),
inspectorAdapter(engine, connection_), inspectorAgent(engine, connection_),
connection(connection_) connection(connection_)
{} {}
...@@ -206,7 +205,7 @@ public: ...@@ -206,7 +205,7 @@ public:
QHash<QString, QWeakPointer<BaseTextEditor> > sourceEditors; QHash<QString, QWeakPointer<BaseTextEditor> > sourceEditors;
InteractiveInterpreter interpreter; InteractiveInterpreter interpreter;
ApplicationLauncher applicationLauncher; ApplicationLauncher applicationLauncher;
QmlInspectorAdapter inspectorAdapter; QmlInspectorAgent inspectorAgent;
QmlOutputParser outputParser; QmlOutputParser outputParser;
QTimer noDebugOutputTimer; QTimer noDebugOutputTimer;
...@@ -254,8 +253,6 @@ QmlEngine::QmlEngine(const DebuggerRunParameters &startParameters, DebuggerEngin ...@@ -254,8 +253,6 @@ QmlEngine::QmlEngine(const DebuggerRunParameters &startParameters, DebuggerEngin
this, &QmlEngine::updateCurrentContext); this, &QmlEngine::updateCurrentContext);
connect(inspectorView(), SIGNAL(currentIndexChanged(QModelIndex)), connect(inspectorView(), SIGNAL(currentIndexChanged(QModelIndex)),
SLOT(updateCurrentContext())); SLOT(updateCurrentContext()));
connect(d->inspectorAdapter.agent(), &QmlInspectorAgent::expressionResult,
this, &QmlEngine::expressionEvaluated);
connect(&d->applicationLauncher, &ApplicationLauncher::processExited, connect(&d->applicationLauncher, &ApplicationLauncher::processExited,
this, &QmlEngine::disconnected); this, &QmlEngine::disconnected);
...@@ -965,8 +962,8 @@ void QmlEngine::assignValueInDebugger(WatchItem *item, ...@@ -965,8 +962,8 @@ void QmlEngine::assignValueInDebugger(WatchItem *item,
const QString &expression, const QVariant &value) const QString &expression, const QVariant &value)
{ {
if (!expression.isEmpty()) { if (!expression.isEmpty()) {
if (item->isInspect() && d->inspectorAdapter.agent()) { if (item->isInspect()) {
d->inspectorAdapter.agent()->assignValue(item, expression, value); d->inspectorAgent.assignValue(item, expression, value);
} else { } else {
StackHandler *handler = stackHandler(); StackHandler *handler = stackHandler();
QString exp = QString(_("%1 = %2;")).arg(expression).arg(value.toString()); QString exp = QString(_("%1 = %2;")).arg(expression).arg(value.toString());
...@@ -986,7 +983,7 @@ void QmlEngine::expandItem(const QByteArray &iname) ...@@ -986,7 +983,7 @@ void QmlEngine::expandItem(const QByteArray &iname)
QTC_ASSERT(item, return); QTC_ASSERT(item, return);
if (item->isInspect()) { if (item->isInspect()) {
d->inspectorAdapter.agent()->updateWatchData(*item); d->inspectorAgent.updateWatchData(*item);
} else { } else {
LookupItems items; LookupItems items;
items.insert(int(item->id), {item->iname, item->name}); items.insert(int(item->id), {item->iname, item->name});
...@@ -1013,7 +1010,7 @@ void QmlEngine::selectWatchData(const QByteArray &iname) ...@@ -1013,7 +1010,7 @@ void QmlEngine::selectWatchData(const QByteArray &iname)
{ {
const WatchItem *item = watchHandler()->findItem(iname); const WatchItem *item = watchHandler()->findItem(iname);
if (item && item->isInspect()) if (item && item->isInspect())
d->inspectorAdapter.agent()->watchDataSelected(item->id); d->inspectorAgent.watchDataSelected(item->id);
} }
bool compareConsoleItems(const ConsoleItem *a, const ConsoleItem *b) bool compareConsoleItems(const ConsoleItem *a, const ConsoleItem *b)
...@@ -1186,9 +1183,8 @@ bool QmlEngine::evaluateScript(const QString &expression) ...@@ -1186,9 +1183,8 @@ bool QmlEngine::evaluateScript(const QString &expression)
// When engine->state() == InferiorStopOk, the expression is sent to debuggerClient. // When engine->state() == InferiorStopOk, the expression is sent to debuggerClient.
if (state() != InferiorStopOk) { if (state() != InferiorStopOk) {
QModelIndex currentIndex = inspectorView()->currentIndex(); QModelIndex currentIndex = inspectorView()->currentIndex();
QmlInspectorAgent *agent = d->inspectorAdapter.agent(); quint32 queryId = d->inspectorAgent.queryExpressionResult
quint32 queryId = agent->queryExpressionResult(watchHandler()->watchItem(currentIndex)->id, (watchHandler()->watchItem(currentIndex)->id, expression);
expression);
if (queryId) { if (queryId) {
d->queryIds.append(queryId); d->queryIds.append(queryId);
} else { } else {
......
...@@ -45,7 +45,7 @@ namespace Internal { ...@@ -45,7 +45,7 @@ namespace Internal {
class WatchData; class WatchData;
class WatchItem; class WatchItem;
class QmlEnginePrivate; class QmlEnginePrivate;
class QmlAdapter; class QmlInspectorAgent;
class QmlEngine : public DebuggerEngine, QmlJS::IScriptEvaluator class QmlEngine : public DebuggerEngine, QmlJS::IScriptEvaluator
{ {
...@@ -62,10 +62,11 @@ public: ...@@ -62,10 +62,11 @@ public:
QmlDebug::QmlDebugClient::State newState); QmlDebug::QmlDebugClient::State newState);
void logServiceActivity(const QString &service, const QString &logMessage); void logServiceActivity(const QString &service, const QString &logMessage);
void expressionEvaluated(quint32 queryId, const QVariant &result);
private slots: private slots:
void disconnected(); void disconnected();
void documentUpdated(QmlJS::Document::Ptr doc); void documentUpdated(QmlJS::Document::Ptr doc);
void expressionEvaluated(quint32 queryId, const QVariant &result);
void errorMessageBoxFinished(int result); void errorMessageBoxFinished(int result);
void updateCurrentContext(); void updateCurrentContext();
...@@ -153,6 +154,7 @@ private: ...@@ -153,6 +154,7 @@ private:
private: private:
friend class QmlCppEngine; friend class QmlCppEngine;
friend class QmlEnginePrivate; friend class QmlEnginePrivate;
friend class QmlInspectorAgent;
QmlEnginePrivate *d; QmlEnginePrivate *d;
}; };
......
This diff is collapsed.
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** 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
** a written agreement between you and The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** 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.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef QMLINSPECTORADAPTER_H
#define QMLINSPECTORADAPTER_H
#include <debugger/debuggerconstants.h>
#include <coreplugin/icontext.h>
#include <qmldebug/qmldebugclient.h>
namespace QmlDebug {
class BaseEngineDebugClient;
class BaseToolsClient;
class ObjectReference;
class FileReference;
class QmlDebugConnection;
}
namespace Debugger {
namespace Internal {
class DebuggerEngine;
class QmlEngine;
class QmlInspectorAgent;
class QmlInspectorAdapter : public QObject
{
Q_OBJECT
public:
QmlInspectorAdapter(QmlEngine *engine, QmlDebug::QmlDebugConnection *connection);
~QmlInspectorAdapter();
QmlDebug::BaseEngineDebugClient *engineClient() const;
QmlDebug::BaseToolsClient *toolsClient() const;
QmlInspectorAgent *agent() const;
int currentSelectedDebugId() const;
QString currentSelectedDisplayName() const;
signals:
void expressionResult();
private:
void onEngineStateChanged(const Debugger::DebuggerState);
void clientStateChanged(QmlDebug::QmlDebugClient::State state);
void toolsClientStateChanged(QmlDebug::QmlDebugClient::State state);
void engineClientStateChanged(QmlDebug::QmlDebugClient::State state);
void selectObjectsFromToolsClient(const QList<int> &debugIds);
void onObjectFetched(const QmlDebug::ObjectReference &ref);
void onSelectActionTriggered(bool checked);
void onZoomActionTriggered(bool checked);
void onShowAppOnTopChanged(bool checked);
void onReloaded();
void jumpToObjectDefinitionInEditor(const QmlDebug::FileReference &objSource, int debugId = -1);
void setActiveEngineClient(QmlDebug::BaseEngineDebugClient *client);
void showConnectionStateMessage(const QString &message);
enum SelectionTarget { NoTarget, ToolTarget, EditorTarget };
void selectObject(
const QmlDebug::ObjectReference &objectReference,
SelectionTarget target);
void enableTools(const bool enable);
QmlEngine *m_qmlEngine;
DebuggerEngine *m_masterEngine;
QmlDebug::BaseEngineDebugClient *m_engineClient;
QHash<QString, QmlDebug::BaseEngineDebugClient*> m_engineClients;
QmlDebug::BaseToolsClient *m_toolsClient;
QmlInspectorAgent *m_agent;
SelectionTarget m_targetToSync;
int m_debugIdToSelect;
int m_currentSelectedDebugId;
QString m_currentSelectedDebugName;
// toolbar
bool m_toolsClientConnected;
Core::Context m_inspectorToolsContext;
QAction *m_selectAction;
QAction *m_zoomAction;
QAction *m_showAppOnTopAction;
bool m_engineClientConnected;
};
} // namespace Internal
} // namespace Debugger
#endif // QMLINSPECTORADAPTER_H
...@@ -34,12 +34,24 @@ ...@@ -34,12 +34,24 @@
#include <QStack> #include <QStack>
#include <QTimer> #include <QTimer>
#include <coreplugin/icontext.h>
#include <debugger/debuggerconstants.h>
#include <qmldebug/baseenginedebugclient.h> #include <qmldebug/baseenginedebugclient.h>
#include <qmldebug/qmldebugclient.h>
namespace QmlDebug {
class BaseEngineDebugClient;
class BaseToolsClient;
class ObjectReference;
class FileReference;
class QmlDebugConnection;
}
namespace Debugger { namespace Debugger {
namespace Internal { namespace Internal {
class DebuggerEngine; class DebuggerEngine;
class QmlEngine;
class WatchData; class WatchData;
//map <filename, editorRevision> -> <lineNumber, columnNumber> -> debugId //map <filename, editorRevision> -> <lineNumber, columnNumber> -> debugId
...@@ -50,7 +62,7 @@ class QmlInspectorAgent : public QObject ...@@ -50,7 +62,7 @@ class QmlInspectorAgent : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit QmlInspectorAgent(DebuggerEngine *engine, QObject *parent = 0); QmlInspectorAgent(QmlEngine *engine, QmlDebug::QmlDebugConnection *connection);
void fetchObject(int debugId); void fetchObject(int debugId);
quint32 queryExpressionResult(int debugId, const QString &expression); quint32 queryExpressionResult(int debugId, const QString &expression);
...@@ -59,55 +71,21 @@ public: ...@@ -59,55 +71,21 @@ public:
void updateWatchData(const WatchData &data); void updateWatchData(const WatchData &data);
void watchDataSelected(quint64 id); void watchDataSelected(quint64 id);
bool selectObjectInTree(int debugId); bool selectObjectInTree(int debugId);
void addObjectWatch(int objectDebugId);
quint32 setBindingForObject(int objectDebugId,
const QString &propertyName,
const QVariant &value,
bool isLiteralValue,
QString source,
int line);
quint32 setMethodBodyForObject(int objectDebugId, const QString &methodName,
const QString &methodBody);
quint32 resetBindingForObject(int objectDebugId,
const QString &propertyName);
QmlDebug::ObjectReference objectForName(const QString &objectId) const;
QmlDebug::ObjectReference objectForId(int objectDebugId) const; QmlDebug::ObjectReference objectForId(int objectDebugId) const;
int objectIdForLocation(int line, int column) const;
QHash<int, QString> rootObjectIds() const;
DebugIdHash debugIdHash() const { return m_debugIdHash; }
bool addObjectWatch(int objectDebugId);
bool isObjectBeingWatched(int objectDebugId);
bool removeObjectWatch(int objectDebugId);
void removeAllObjectWatches();
void setEngineClient(QmlDebug::BaseEngineDebugClient *client);
QString displayName(int objectDebugId) const; QString displayName(int objectDebugId) const;
int parentIdForObject(int objectDebugId);
void reloadEngines(); void reloadEngines();
public slots: QmlDebug::BaseToolsClient *toolsClient() const;
void fetchContextObjectsForLocation(const QString &file,
int lineNumber, int columnNumber);
void queryEngineContext();
signals:
void objectTreeUpdated();
void objectFetched(const QmlDebug::ObjectReference &ref);
void expressionResult(quint32 queryId, const QVariant &value);
void propertyChanged(int debugId, const QByteArray &propertyName,
const QVariant &propertyValue);
void automaticUpdateFailed();
void jumpToObjectDefinition(const QmlDebug::FileReference &objSource, int debugId);
private slots: private:
void updateState(); void updateState();
void onResult(quint32 queryId, const QVariant &value, const QByteArray &type); void onResult(quint32 queryId, const QVariant &value, const QByteArray &type);
void newObject(int engineId, int objectId, int parentId); void newObject(int engineId, int objectId, int parentId);
void onValueChanged(int debugId, const QByteArray &propertyName, const QVariant &value); void onValueChanged(int debugId, const QByteArray &propertyName, const QVariant &value);
private: void queryEngineContext();
void updateObjectTree(const QmlDebug::ContextReference &context); void updateObjectTree(const QmlDebug::ContextReference &context);
void verifyAndInsertObjectInTree(const QmlDebug::ObjectReference &object); void verifyAndInsertObjectInTree(const QmlDebug::ObjectReference &object);
void insertObjectInTree(const QmlDebug::ObjectReference &result); void insertObjectInTree(const QmlDebug::ObjectReference &result);
...@@ -125,8 +103,31 @@ private: ...@@ -125,8 +103,31 @@ private:
bool isConnected() const; bool isConnected() const;
void clearObjectTree(); void clearObjectTree();
void onEngineStateChanged(const Debugger::DebuggerState);
void clientStateChanged(QmlDebug::QmlDebugClient::State state);
void toolsClientStateChanged(QmlDebug::QmlDebugClient::State state);
void engineClientStateChanged(QmlDebug::QmlDebugClient::State state);
void selectObjectsFromToolsClient(const QList<int> &debugIds);
void onSelectActionTriggered(bool checked);
void onZoomActionTriggered(bool checked);
void onShowAppOnTopChanged(bool checked);
void onReloaded();
void jumpToObjectDefinitionInEditor(const QmlDebug::FileReference &objSource, int debugId = -1);
void setActiveEngineClient(QmlDebug::BaseEngineDebugClient *client);
enum SelectionTarget { NoTarget, ToolTarget, EditorTarget };
void selectObject(
const QmlDebug::ObjectReference &objectReference,
SelectionTarget target);
void enableTools(const bool enable);
private: private:
DebuggerEngine *m_debuggerEngine; QmlEngine *m_qmlEngine;
QmlDebug::BaseEngineDebugClient *m_engineClient; QmlDebug::BaseEngineDebugClient *m_engineClient;
quint32 m_engineQueryId; quint32 m_engineQueryId;
...@@ -142,6 +143,25 @@ private: ...@@ -142,6 +143,25 @@ private:
QList<int> m_objectWatches; QList<int> m_objectWatches;
QList<int> m_fetchDataIds; QList<int> m_fetchDataIds;
QTimer m_delayQueryTimer; QTimer m_delayQueryTimer;
DebuggerEngine *m_masterEngine;
QHash<QString, QmlDebug::BaseEngineDebugClient*> m_engineClients;
QmlDebug::BaseToolsClient *m_toolsClient;
SelectionTarget m_targetToSync;
int m_debugIdToSelect;
int m_currentSelectedDebugId;
QString m_currentSelectedDebugName;
// toolbar
bool m_toolsClientConnected;
Core::Context m_inspectorToolsContext;
QAction *m_selectAction;
QAction *m_zoomAction;
QAction *m_showAppOnTopAction;
bool m_engineClientConnected;
}; };
} // Internal } // Internal
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment