Commit 1d04c4c3 authored by Aurindam Jana's avatar Aurindam Jana

Debugger: Remove the dependence on QmlJSTools

Change-Id: I26765134c19b9a6cf1e7ad26f313e2d4f8faf258
Reviewed-by: default avatarChristiaan Janssen <christiaan.janssen@digia.com>
parent 3ebbba2e
/**************************************************************************
/****************************************************************************
**
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
......@@ -27,17 +27,17 @@
**
****************************************************************************/
#include "qmlconsoleitem.h"
#include "consoleitem.h"
namespace QmlJSTools {
namespace QmlJS {
///////////////////////////////////////////////////////////////////////
//
// QmlConsoleItem
// ConsoleItem
//
///////////////////////////////////////////////////////////////////////
QmlConsoleItem::QmlConsoleItem(QmlConsoleItem *parent, QmlConsoleItem::ItemType itemType,
ConsoleItem::ConsoleItem(ConsoleItem *parent, ConsoleItem::ItemType itemType,
const QString &text)
: m_parentItem(parent),
itemType(itemType),
......@@ -47,36 +47,36 @@ QmlConsoleItem::QmlConsoleItem(QmlConsoleItem *parent, QmlConsoleItem::ItemType
setText(text);
}
QmlConsoleItem::~QmlConsoleItem()
ConsoleItem::~ConsoleItem()
{
qDeleteAll(m_childItems);
}
QmlConsoleItem *QmlConsoleItem::child(int number)
ConsoleItem *ConsoleItem::child(int number)
{
return m_childItems.value(number);
}
int QmlConsoleItem::childCount() const
int ConsoleItem::childCount() const
{
return m_childItems.size();
}
int QmlConsoleItem::childNumber() const
int ConsoleItem::childNumber() const
{
if (m_parentItem)
return m_parentItem->m_childItems.indexOf(const_cast<QmlConsoleItem *>(this));
return m_parentItem->m_childItems.indexOf(const_cast<ConsoleItem *>(this));
return 0;
}
bool QmlConsoleItem::insertChildren(int position, int count)
bool ConsoleItem::insertChildren(int position, int count)
{
if (position < 0 || position > m_childItems.size())
return false;
for (int row = 0; row < count; ++row) {
QmlConsoleItem *item = new QmlConsoleItem(this, QmlConsoleItem::UndefinedType,
ConsoleItem *item = new ConsoleItem(this, ConsoleItem::UndefinedType,
QString());
m_childItems.insert(position, item);
}
......@@ -84,7 +84,7 @@ bool QmlConsoleItem::insertChildren(int position, int count)
return true;
}
void QmlConsoleItem::insertChild(QmlConsoleItem *item, bool sorted)
void ConsoleItem::insertChild(ConsoleItem *item, bool sorted)
{
if (!sorted) {
m_childItems.insert(m_childItems.count(), item);
......@@ -99,7 +99,7 @@ void QmlConsoleItem::insertChild(QmlConsoleItem *item, bool sorted)
m_childItems.insert(i, item);
}
bool QmlConsoleItem::insertChild(int position, QmlConsoleItem *item)
bool ConsoleItem::insertChild(int position, ConsoleItem *item)
{
if (position < 0 || position > m_childItems.size())
return false;
......@@ -109,12 +109,12 @@ bool QmlConsoleItem::insertChild(int position, QmlConsoleItem *item)
return true;
}
QmlConsoleItem *QmlConsoleItem::parent()
ConsoleItem *ConsoleItem::parent()
{
return m_parentItem;
}
bool QmlConsoleItem::removeChildren(int position, int count)
bool ConsoleItem::removeChildren(int position, int count)
{
if (position < 0 || position + count > m_childItems.size())
return false;
......@@ -125,7 +125,7 @@ bool QmlConsoleItem::removeChildren(int position, int count)
return true;
}
bool QmlConsoleItem::detachChild(int position)
bool ConsoleItem::detachChild(int position)
{
if (position < 0 || position > m_childItems.size())
return false;
......@@ -135,7 +135,7 @@ bool QmlConsoleItem::detachChild(int position)
return true;
}
void QmlConsoleItem::setText(const QString &text)
void ConsoleItem::setText(const QString &text)
{
m_text = text;
for (int i = 0; i < m_text.length(); ++i) {
......@@ -144,9 +144,9 @@ void QmlConsoleItem::setText(const QString &text)
}
}
const QString &QmlConsoleItem::text() const
const QString &ConsoleItem::text() const
{
return m_text;
}
} // QmlJSTools
} // QmlJS
/**************************************************************************
/****************************************************************************
**
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
......@@ -27,17 +27,17 @@
**
****************************************************************************/
#ifndef QMLCONSOLEITEM_H
#define QMLCONSOLEITEM_H
#ifndef CONSOLEITEM_H
#define CONSOLEITEM_H
#include "qmljstools_global.h"
#include "qmljs_global.h"
#include <QList>
#include <QString>
namespace QmlJSTools {
namespace QmlJS {
class QMLJSTOOLS_EXPORT QmlConsoleItem
class QMLJS_EXPORT ConsoleItem
{
public:
enum ItemType
......@@ -51,17 +51,17 @@ public:
};
Q_DECLARE_FLAGS(ItemTypes, ItemType)
QmlConsoleItem(QmlConsoleItem *parent,
QmlConsoleItem::ItemType type = QmlConsoleItem::UndefinedType,
ConsoleItem(ConsoleItem *parent,
ConsoleItem::ItemType type = ConsoleItem::UndefinedType,
const QString &data = QString());
~QmlConsoleItem();
~ConsoleItem();
QmlConsoleItem *child(int number);
ConsoleItem *child(int number);
int childCount() const;
bool insertChildren(int position, int count);
void insertChild(QmlConsoleItem *item, bool sorted);
bool insertChild(int position, QmlConsoleItem *item);
QmlConsoleItem *parent();
void insertChild(ConsoleItem *item, bool sorted);
bool insertChild(int position, ConsoleItem *item);
ConsoleItem *parent();
bool removeChildren(int position, int count);
bool detachChild(int position);
int childNumber() const;
......@@ -69,16 +69,16 @@ public:
const QString &text() const;
private:
QmlConsoleItem *m_parentItem;
QList<QmlConsoleItem *> m_childItems;
ConsoleItem *m_parentItem;
QList<ConsoleItem *> m_childItems;
QString m_text;
public:
QmlConsoleItem::ItemType itemType;
ConsoleItem::ItemType itemType;
QString file;
int line;
};
} // QmlJSTools
} // QmlJS
#endif // QMLCONSOLEITEM_H
#endif // CONSOLEITEM_H
/****************************************************************************
**
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** 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 Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/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 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.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "consolemanagerinterface.h"
namespace QmlJS {
static ConsoleManagerInterface *g_instance = 0;
ConsoleManagerInterface::ConsoleManagerInterface(QObject *parent)
: QObject(parent)
{
Q_ASSERT(!g_instance);
g_instance = this;
}
ConsoleManagerInterface::~ConsoleManagerInterface()
{
Q_ASSERT(g_instance == this);
g_instance = 0;
}
ConsoleManagerInterface *ConsoleManagerInterface::instance()
{
return g_instance;
}
} // QmlJS
/****************************************************************************
**
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** 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 Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/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 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.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef CONSOLEMANAGERINTERFACE_H
#define CONSOLEMANAGERINTERFACE_H
#include "qmljs_global.h"
#include "consoleitem.h"
#include <QObject>
namespace QmlJS {
class IScriptEvaluator;
class QMLJS_EXPORT ConsoleManagerInterface : public QObject
{
Q_OBJECT
public:
ConsoleManagerInterface(QObject *parent = 0);
~ConsoleManagerInterface();
static ConsoleManagerInterface *instance();
virtual void showConsolePane() = 0;
virtual ConsoleItem *rootItem() const = 0;
virtual void setScriptEvaluator(IScriptEvaluator *scriptEvaluator) = 0;
virtual void setContext(const QString &context) = 0;
virtual void printToConsolePane(ConsoleItem::ItemType itemType, const QString &text,
bool bringToForeground = false) = 0;
virtual void printToConsolePane(ConsoleItem *item, bool bringToForeground = false) = 0;
};
} // QmlJS
#endif // CONSOLEMANAGERINTERFACE_H
/****************************************************************************
**
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** 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 Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/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 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.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef ISCRIPTEVALUATOR_H
#define ISCRIPTEVALUATOR_H
#include "qmljs_global.h"
#include <QString>
namespace QmlJS {
class QMLJS_EXPORT IScriptEvaluator
{
public:
IScriptEvaluator() {}
virtual bool evaluateScript(const QString &script) = 0;
};
} // QmlJS
#endif // ISCRIPTEVALUATOR_H
......@@ -33,7 +33,10 @@ HEADERS += \
$$PWD/qmljsscopechain.h \
$$PWD/qmljsutils.h \
$$PWD/qmljsstaticanalysismessage.h \
$$PWD/jsoncheck.h
$$PWD/jsoncheck.h \
$$PWD/consolemanagerinterface.h \
$$PWD/consoleitem.h \
$$PWD/iscriptevaluator.h
SOURCES += \
$$PWD/qmljsbind.cpp \
......@@ -58,7 +61,9 @@ SOURCES += \
$$PWD/qmljsscopechain.cpp \
$$PWD/qmljsutils.cpp \
$$PWD/qmljsstaticanalysismessage.cpp \
$$PWD/jsoncheck.cpp
$$PWD/jsoncheck.cpp \
$$PWD/consolemanagerinterface.cpp \
$$PWD/consoleitem.cpp
RESOURCES += \
$$PWD/qmljs.qrc
......
......@@ -96,6 +96,11 @@ QtcLibrary {
"parser/qmljsmemorypool_p.h",
"parser/qmljsparser.cpp",
"parser/qmljsparser_p.h",
"consolemanagerinterface.cpp",
"consolemanagerinterface.h",
"consoleitem.cpp",
"consoleitem.h",
"iscriptevaluator.h"
]
ProductModule {
......
......@@ -18,7 +18,6 @@ Alternatively, this plugin may be used under the terms of the GNU Lesser General
<dependency name=\"Core\" version=\"$$QTCREATOR_VERSION\"/>
<dependency name=\"Find\" version=\"$$QTCREATOR_VERSION\"/>
<dependency name=\"CppTools\" version=\"$$QTCREATOR_VERSION\"/>
<dependency name=\"QmlJsTools\" version=\"$$QTCREATOR_VERSION\"/>
<!-- Debugger plugin adds items to the editor\'s context menu -->
<dependency name=\"CppEditor\" version=\"$$QTCREATOR_VERSION\" type=\"optional\"/>
</dependencyList>
......
......@@ -3,7 +3,6 @@ include(../../plugins/cpptools/cpptools.pri)
include(../../plugins/find/find.pri)
include(../../plugins/projectexplorer/projectexplorer.pri)
include(../../plugins/texteditor/texteditor.pri)
include(../../plugins/qmljstools/qmljstools.pri)
include(../../libs/cplusplus/cplusplus.pri)
include(../../libs/utils/utils.pri)
include(../../libs/qmljs/qmljs.pri)
......
......@@ -116,7 +116,6 @@ public:
virtual void openMemoryEditor() = 0;
virtual void languagesChanged() = 0;
virtual void executeDebuggerCommand(const QString &command, DebuggerLanguages languages) = 0;
virtual bool evaluateScriptExpression(const QString &expression) = 0;
virtual Utils::SavedAction *action(int code) const = 0;
virtual bool boolSetting(int code) const = 0;
......
......@@ -64,7 +64,7 @@
#include <utils/qtcassert.h>
#include <utils/fileinprojectfinder.h>
#include <qmljstools/qmlconsolemanager.h>
#include <qmljs/consolemanagerinterface.h>
#include <QDebug>
#include <QTimer>
......@@ -532,9 +532,9 @@ void DebuggerEngine::showMessage(const QString &msg, int channel, int timeout) c
}
//if (msg.size() && msg.at(0).isUpper() && msg.at(1).isUpper())
// qDebug() << qPrintable(msg) << "IN STATE" << state();
QmlJSTools::QmlConsoleManager *consoleManager = QmlJSTools::QmlConsoleManager::instance();
QmlJS::ConsoleManagerInterface *consoleManager = QmlJS::ConsoleManagerInterface::instance();
if (channel == ConsoleOutput && consoleManager)
consoleManager->printToConsolePane(QmlJSTools::QmlConsoleItem::UndefinedType, msg);
consoleManager->printToConsolePane(QmlJS::ConsoleItem::UndefinedType, msg);
debuggerCore()->showMessage(msg, channel, timeout);
if (d->m_runControl) {
......@@ -1655,12 +1655,6 @@ void DebuggerEngine::executeDebuggerCommand(const QString &, DebuggerLanguages)
showStatusMessage(tr("This debugger cannot handle user input."));
}
bool DebuggerEngine::evaluateScriptExpression(const QString &)
{
showStatusMessage(tr("This debugger cannot handle user input."));
return false;
}
BreakHandler *DebuggerEngine::breakHandler() const
{
return debuggerCore()->breakHandler();
......
......@@ -269,8 +269,6 @@ public:
QString toFileInProject(const QUrl &fileUrl);
virtual bool evaluateScriptExpression(const QString &expression);
signals:
void stateChanged(Debugger::DebuggerState state);
// A new stack frame is on display including locals.
......
......@@ -124,8 +124,6 @@
# include <utils/winutils.h>
#endif
#include <qmljstools/qmlconsolemanager.h>
#include <QComboBox>
#include <QDockWidget>
#include <QFileDialog>
......@@ -964,7 +962,6 @@ public slots:
void aboutToSaveSession();
void executeDebuggerCommand(const QString &command, DebuggerLanguages languages);
bool evaluateScriptExpression(const QString &expression);
void coreShutdown();
#ifdef WITH_TESTS
......@@ -2069,13 +2066,6 @@ void DebuggerPluginPrivate::connectEngine(DebuggerEngine *engine)
mainWindow()->setEngineDebugLanguages(engine->startParameters().languages);
mainWindow()->setCurrentEngine(engine);
QmlJSTools::QmlConsoleManager *consoleManager = QmlJSTools::QmlConsoleManager::instance();
if (consoleManager) {
if (engine->startParameters().languages & QmlLanguage)
consoleManager->setDebuggerEngine(engine);
else
consoleManager->setDebuggerEngine(0);
}
}
static void changeFontSize(QWidget *widget, qreal size)
......@@ -2490,11 +2480,6 @@ void DebuggerPluginPrivate::showStatusMessage(const QString &msg0, int timeout)
m_statusLabel->showStatusMessage(msg, timeout);
}
bool DebuggerPluginPrivate::evaluateScriptExpression(const QString &expression)
{
return currentEngine()->evaluateScriptExpression(expression);
}
void DebuggerPluginPrivate::openMemoryEditor()
{
AddressDialog dialog;
......
......@@ -40,6 +40,7 @@
#include <texteditor/itexteditor.h>
#include <qmljseditor/qmljseditorconstants.h>
#include <cppeditor/cppeditorconstants.h>
#include <qmljs/consolemanagerinterface.h>
#include <QTimer>
......@@ -400,11 +401,6 @@ void QmlCppEngine::executeDebuggerCommand(const QString &command, DebuggerLangua
d->m_cppEngine->executeDebuggerCommand(command, languages);
}
bool QmlCppEngine::evaluateScriptExpression(const QString &expression)
{
return d->m_qmlEngine->evaluateScriptExpression(expression);
}
/////////////////////////////////////////////////////////
void QmlCppEngine::setupEngine()
......@@ -466,6 +462,9 @@ void QmlCppEngine::shutdownEngine()
{
EDEBUG("\nMASTER SHUTDOWN ENGINE");
d->m_cppEngine->shutdownSlaveEngine();
QmlJS::ConsoleManagerInterface *consoleManager = QmlJS::ConsoleManagerInterface::instance();
if (consoleManager)
consoleManager->setScriptEvaluator(0);
}
void QmlCppEngine::quitDebugger()
......
......@@ -110,7 +110,6 @@ protected:
void executeRunToFunction(const QString &functionName);
void executeJumpToLine(const ContextData &data);
void executeDebuggerCommand(const QString &command, DebuggerLanguages languages);
bool evaluateScriptExpression(const QString &expression);
void setupEngine();
void setupInferior();
......
......@@ -50,11 +50,12 @@
#include "sourcefileshandler.h"
#include "watchutils.h"
#include <extensionsystem/pluginmanager.h>
#include <qmldebug/baseenginedebugclient.h>
#include <qmljseditor/qmljseditorconstants.h>
#include <qmljs/parser/qmljsast_p.h>
#include <qmljs/qmljsmodelmanagerinterface.h>
#include <qmljs/consolemanagerinterface.h>
#include <qmljs/consoleitem.h>
#include <utils/environment.h>
#include <utils/qtcassert.h>
......@@ -66,9 +67,6 @@
#include <texteditor/itexteditor.h>
#include <qmljstools/qmlconsolemanager.h>
#include <qmljstools/qmlconsoleitem.h>
#include <QDateTime>
#include <QDebug>
#include <QDir>
......@@ -261,6 +259,11 @@ public:
quint32 *column;
};
QmlJS::ConsoleManagerInterface *qmlConsoleManager()
{
return QmlJS::ConsoleManagerInterface::instance();
}
///////////////////////////////////////////////////////////////////////
//
// QmlEngine
......@@ -276,8 +279,6 @@ QmlEngine::QmlEngine(const DebuggerStartParameters &startParameters)
{
setObjectName(QLatin1String("QmlEngine"));
ExtensionSystem::PluginManager::addObject(this);
connect(&m_adapter, SIGNAL(connectionError(QAbstractSocket::SocketError)),
SLOT(connectionError(QAbstractSocket::SocketError)));
connect(&m_adapter, SIGNAL(serviceConnectionError(QString)),
......@@ -331,25 +332,23 @@ QmlEngine::QmlEngine(const DebuggerStartParameters &startParameters)
m_noDebugOutputTimer.setInterval(8000);
connect(&m_noDebugOutputTimer, SIGNAL(timeout()), this, SLOT(tryToConnect()));
connect(ModelManagerInterface::instance(),
SIGNAL(documentUpdated(QmlJS::Document::Ptr)),
this,
SLOT(documentUpdated(QmlJS::Document::Ptr)));
ModelManagerInterface *mmIface = ModelManagerInterface::instance();
if (mmIface) {
connect(ModelManagerInterface::instance(), SIGNAL(documentUpdated(QmlJS::Document::Ptr)),
this, SLOT(documentUpdated(QmlJS::Document::Ptr)));
}
// we won't get any debug output
if (startParameters.useTerminal) {
m_noDebugOutputTimer.setInterval(0);
m_retryOnConnectFail = true;
m_automaticConnect = true;
}
if (qmlConsoleManager())
qmlConsoleManager()->setScriptEvaluator(this);
}
QmlEngine::~QmlEngine()
{
if (ExtensionSystem::PluginManager::allObjects().contains(this)) {
ExtensionSystem::PluginManager::removeObject(this);
}
QList<Core::IEditor *> editorsToClose;
QHash<QString, QWeakPointer<TextEditor::ITextEditor> >::iterator iter;
......@@ -649,6 +648,8 @@ void QmlEngine::shutdownInferior()
void QmlEngine::shutdownEngine()
{
if (qmlConsoleManager())
qmlConsoleManager()->setScriptEvaluator(0);
m_noDebugOutputTimer.stop();
// double check (ill engine?):
......@@ -1030,16 +1031,16 @@ void QmlEngine::synchronizeWatchers()
}
}
QmlJSTools::QmlConsoleItem *constructLogItemTree(QmlJSTools::QmlConsoleItem *parent,
QmlJS::ConsoleItem *constructLogItemTree(QmlJS::ConsoleItem *parent,
const QVariant &result,
const QString &key = QString())
{
using namespace QmlJSTools;
using namespace QmlJS;
bool sorted = debuggerCore()->boolSetting(SortStructMembers);
if (!result.isValid())
return 0;
QmlConsoleItem *item = new QmlConsoleItem(parent);
ConsoleItem *item = new ConsoleItem(parent);
if (result.type() == QVariant::Map) {
if (key.isEmpty())
item->setText(_("Object"));
......@@ -1049,7 +1050,7 @@ QmlJSTools::QmlConsoleItem *constructLogItemTree(QmlJSTools::QmlConsoleItem *par
QMapIterator<QString, QVariant> i(result.toMap());
while (i.hasNext()) {
i.next();
QmlConsoleItem *child = constructLogItemTree(item, i.value(), i.key());
ConsoleItem *child = constructLogItemTree(item, i.value(), i.key());
if (child)
item->insertChild(child, sorted);
}
......@@ -1060,7 +1061,7 @@ QmlJSTools::QmlConsoleItem *constructLogItemTree(QmlJSTools::QmlConsoleItem *par
item->setText(QString(_("[%1] : List")).arg(key));
QVariantList resultList = result.toList();
for