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 {
"qmlcppengine.cpp", "qmlcppengine.h",
"qmlengine.cpp", "qmlengine.h",
"qmlengineutils.cpp", "qmlengineutils.h",
"qmlinspectoradapter.cpp", "qmlinspectoradapter.h",
"qmlinspectoragent.cpp", "qmlinspectoragent.h",
"qmlv8debuggerclientconstants.h"
]
......
......@@ -4,13 +4,11 @@ HEADERS += \
$$PWD/qmlcppengine.h \
$$PWD/interactiveinterpreter.h \
$$PWD/qmlv8debuggerclientconstants.h \
$$PWD/qmlinspectoragent.h \
$$PWD/qmlinspectoradapter.h
$$PWD/qmlinspectoragent.h
SOURCES += \
$$PWD/qmlengine.cpp \
$$PWD/qmlengineutils.cpp \
$$PWD/qmlcppengine.cpp \
$$PWD/interactiveinterpreter.cpp \
$$PWD/qmlinspectoragent.cpp \
$$PWD/qmlinspectoradapter.cpp
$$PWD/qmlinspectoragent.cpp
......@@ -31,7 +31,6 @@
#include "qmlengine.h"
#include "interactiveinterpreter.h"
#include "qmlinspectoradapter.h"
#include "qmlinspectoragent.h"
#include "qmlv8debuggerclientconstants.h"
#include "qmlengineutils.h"
......@@ -136,7 +135,7 @@ public:
QmlEnginePrivate(QmlEngine *engine_, QmlDebugConnection *connection_)
: QmlDebugClient(QLatin1String("V8Debugger"), connection_),
engine(engine_),
inspectorAdapter(engine, connection_),
inspectorAgent(engine, connection_),
connection(connection_)
{}
......@@ -206,7 +205,7 @@ public:
QHash<QString, QWeakPointer<BaseTextEditor> > sourceEditors;
InteractiveInterpreter interpreter;
ApplicationLauncher applicationLauncher;
QmlInspectorAdapter inspectorAdapter;
QmlInspectorAgent inspectorAgent;
QmlOutputParser outputParser;
QTimer noDebugOutputTimer;
......@@ -254,8 +253,6 @@ QmlEngine::QmlEngine(const DebuggerRunParameters &startParameters, DebuggerEngin
this, &QmlEngine::updateCurrentContext);
connect(inspectorView(), SIGNAL(currentIndexChanged(QModelIndex)),
SLOT(updateCurrentContext()));
connect(d->inspectorAdapter.agent(), &QmlInspectorAgent::expressionResult,
this, &QmlEngine::expressionEvaluated);
connect(&d->applicationLauncher, &ApplicationLauncher::processExited,
this, &QmlEngine::disconnected);
......@@ -965,8 +962,8 @@ void QmlEngine::assignValueInDebugger(WatchItem *item,
const QString &expression, const QVariant &value)
{
if (!expression.isEmpty()) {
if (item->isInspect() && d->inspectorAdapter.agent()) {
d->inspectorAdapter.agent()->assignValue(item, expression, value);
if (item->isInspect()) {
d->inspectorAgent.assignValue(item, expression, value);
} else {
StackHandler *handler = stackHandler();
QString exp = QString(_("%1 = %2;")).arg(expression).arg(value.toString());
......@@ -986,7 +983,7 @@ void QmlEngine::expandItem(const QByteArray &iname)
QTC_ASSERT(item, return);
if (item->isInspect()) {
d->inspectorAdapter.agent()->updateWatchData(*item);
d->inspectorAgent.updateWatchData(*item);
} else {
LookupItems items;
items.insert(int(item->id), {item->iname, item->name});
......@@ -1013,7 +1010,7 @@ void QmlEngine::selectWatchData(const QByteArray &iname)
{
const WatchItem *item = watchHandler()->findItem(iname);
if (item && item->isInspect())
d->inspectorAdapter.agent()->watchDataSelected(item->id);
d->inspectorAgent.watchDataSelected(item->id);
}
bool compareConsoleItems(const ConsoleItem *a, const ConsoleItem *b)
......@@ -1186,9 +1183,8 @@ bool QmlEngine::evaluateScript(const QString &expression)
// When engine->state() == InferiorStopOk, the expression is sent to debuggerClient.
if (state() != InferiorStopOk) {
QModelIndex currentIndex = inspectorView()->currentIndex();
QmlInspectorAgent *agent = d->inspectorAdapter.agent();
quint32 queryId = agent->queryExpressionResult(watchHandler()->watchItem(currentIndex)->id,
expression);
quint32 queryId = d->inspectorAgent.queryExpressionResult
(watchHandler()->watchItem(currentIndex)->id, expression);
if (queryId) {
d->queryIds.append(queryId);
} else {
......
......@@ -45,7 +45,7 @@ namespace Internal {
class WatchData;
class WatchItem;
class QmlEnginePrivate;
class QmlAdapter;
class QmlInspectorAgent;
class QmlEngine : public DebuggerEngine, QmlJS::IScriptEvaluator
{
......@@ -62,10 +62,11 @@ public:
QmlDebug::QmlDebugClient::State newState);
void logServiceActivity(const QString &service, const QString &logMessage);
void expressionEvaluated(quint32 queryId, const QVariant &result);
private slots:
void disconnected();
void documentUpdated(QmlJS::Document::Ptr doc);
void expressionEvaluated(quint32 queryId, const QVariant &result);
void errorMessageBoxFinished(int result);
void updateCurrentContext();
......@@ -153,6 +154,7 @@ private:
private:
friend class QmlCppEngine;
friend class QmlEnginePrivate;
friend class QmlInspectorAgent;
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 @@
#include <QStack>
#include <QTimer>
#include <coreplugin/icontext.h>
#include <debugger/debuggerconstants.h>
#include <qmldebug/baseenginedebugclient.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 WatchData;
//map <filename, editorRevision> -> <lineNumber, columnNumber> -> debugId
......@@ -50,7 +62,7 @@ class QmlInspectorAgent : public QObject
{
Q_OBJECT
public:
explicit QmlInspectorAgent(DebuggerEngine *engine, QObject *parent = 0);
QmlInspectorAgent(QmlEngine *engine, QmlDebug::QmlDebugConnection *connection);
void fetchObject(int debugId);
quint32 queryExpressionResult(int debugId, const QString &expression);
......@@ -59,55 +71,21 @@ public:
void updateWatchData(const WatchData &data);
void watchDataSelected(quint64 id);
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;
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;
int parentIdForObject(int objectDebugId);
void reloadEngines();
public slots:
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);
QmlDebug::BaseToolsClient *toolsClient() const;
private slots:
private:
void updateState();
void onResult(quint32 queryId, const QVariant &value, const QByteArray &type);
void newObject(int engineId, int objectId, int parentId);
void onValueChanged(int debugId, const QByteArray &propertyName, const QVariant &value);
private:
void queryEngineContext();
void updateObjectTree(const QmlDebug::ContextReference &context);
void verifyAndInsertObjectInTree(const QmlDebug::ObjectReference &object);
void insertObjectInTree(const QmlDebug::ObjectReference &result);
......@@ -125,8 +103,31 @@ private:
bool isConnected() const;
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:
DebuggerEngine *m_debuggerEngine;
QmlEngine *m_qmlEngine;
QmlDebug::BaseEngineDebugClient *m_engineClient;
quint32 m_engineQueryId;
......@@ -142,6 +143,25 @@ private:
QList<int> m_objectWatches;
QList<int> m_fetchDataIds;
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
......
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