From a88a635e3d13c6731eca7d22e5d0aed2568d179a Mon Sep 17 00:00:00 2001
From: Roberto Raggi <roberto.raggi@nokia.com>
Date: Mon, 28 Jun 2010 17:46:42 +0200
Subject: [PATCH] Let's start from scratch with a new debugger for QmlJS.

---
 src/plugins/plugins.pro                       |  14 ++--
 .../QmlJSInspector.pluginspec}                |   2 +-
 .../images/logo.png                           | Bin
 .../qmljsinspector/qmljsdebuggerclient.cpp    |  53 +++++++++++++++
 .../qmljsinspector/qmljsdebuggerclient.h      |  63 ++++++++++++++++++
 .../qmljsinspector.pro}                       |  26 +++++---
 .../qmljsinspector.qrc}                       |   0
 .../qmljsinspector_global.h}                  |   2 +-
 .../qmljsinspectorconstants.h}                |   6 +-
 .../qmljsinspectorcontext.cpp}                |   8 +--
 .../qmljsinspectorcontext.h}                  |   9 +--
 .../qmljsinspectorplugin.cpp}                 |   8 +--
 .../qmljsinspectorplugin.h}                   |   8 +--
 .../qmlprojectruncontrol.cpp                  |   4 +-
 14 files changed, 161 insertions(+), 42 deletions(-)
 rename src/plugins/{qmlinspector/QmlInspector.pluginspec => qmljsinspector/QmlJSInspector.pluginspec} (94%)
 rename src/plugins/{qmlinspector => qmljsinspector}/images/logo.png (100%)
 create mode 100644 src/plugins/qmljsinspector/qmljsdebuggerclient.cpp
 create mode 100644 src/plugins/qmljsinspector/qmljsdebuggerclient.h
 rename src/plugins/{qmlinspector/qmlinspector.pro => qmljsinspector/qmljsinspector.pro} (50%)
 rename src/plugins/{qmlinspector/qmlinspector.qrc => qmljsinspector/qmljsinspector.qrc} (100%)
 rename src/plugins/{qmlinspector/qmlinspector_global.h => qmljsinspector/qmljsinspector_global.h} (97%)
 rename src/plugins/{qmlinspector/qmlinspectorconstants.h => qmljsinspector/qmljsinspectorconstants.h} (95%)
 rename src/plugins/{qmlinspector/inspectorcontext.cpp => qmljsinspector/qmljsinspectorcontext.cpp} (93%)
 rename src/plugins/{qmlinspector/inspectorcontext.h => qmljsinspector/qmljsinspectorcontext.h} (95%)
 rename src/plugins/{qmlinspector/qmlinspectorplugin.cpp => qmljsinspector/qmljsinspectorplugin.cpp} (97%)
 rename src/plugins/{qmlinspector/qmlinspectorplugin.h => qmljsinspector/qmljsinspectorplugin.h} (94%)

diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro
index a7810d191d2..3f2dd7b7d1c 100644
--- a/src/plugins/plugins.pro
+++ b/src/plugins/plugins.pro
@@ -43,10 +43,10 @@ contains(QT_CONFIG, declarative) {
     include(../private_headers.pri)
     exists($${QT_PRIVATE_HEADERS}/QtDeclarative/private/qdeclarativecontext_p.h) {
         SUBDIRS += plugin_qmldesigner \
-                   plugin_qmlinspector
+                   plugin_qmljsinspector
     } else {
         warning()
-        warning("QmlDesigner and QmlInspector plugins have been disabled")
+        warning("QmlDesigner and QmlJSInspector plugins have been disabled")
         warning("The plugins depend on on private headers from QtDeclarative module.")
         warning("To enable them, pass 'QT_PRIVATE_HEADERS=$QTDIR/include' to qmake, where $QTDIR is the source directory of qt.")
         warning()
@@ -200,12 +200,10 @@ plugin_qmldesigner.depends = plugin_coreplugin
 plugin_qmldesigner.depends += plugin_texteditor
 plugin_qmldesigner.depends += plugin_qmljseditor
 
-plugin_qmlinspector.subdir = qmlinspector
-plugin_qmlinspector.depends += plugin_projectexplorer
-plugin_qmlinspector.depends += plugin_cppeditor
-plugin_qmlinspector.depends += plugin_qmlprojectmanager
-plugin_qmlinspector.depends += plugin_debugger
-plugin_qmlinspector.depends += plugin_cpptools
+plugin_qmljsinspector.subdir = qmljsinspector
+plugin_qmljsinspector.depends += plugin_projectexplorer
+plugin_qmljsinspector.depends += plugin_qmlprojectmanager
+plugin_qmljsinspector.depends += plugin_debugger
 
 plugin_mercurial.subdir = mercurial
 plugin_mercurial.depends = plugin_vcsbase
diff --git a/src/plugins/qmlinspector/QmlInspector.pluginspec b/src/plugins/qmljsinspector/QmlJSInspector.pluginspec
similarity index 94%
rename from src/plugins/qmlinspector/QmlInspector.pluginspec
rename to src/plugins/qmljsinspector/QmlJSInspector.pluginspec
index 5f217f9ed11..788e28f6364 100644
--- a/src/plugins/qmlinspector/QmlInspector.pluginspec
+++ b/src/plugins/qmljsinspector/QmlJSInspector.pluginspec
@@ -1,4 +1,4 @@
-<plugin name="QmlInspector" version="2.1.80" compatVersion="2.1.80">
+<plugin name="QmlJSInspector" version="2.1.80" compatVersion="2.1.80">
     <vendor>Nokia Corporation</vendor>
     <copyright>(C) 2010 Nokia Corporation</copyright>
     <license>
diff --git a/src/plugins/qmlinspector/images/logo.png b/src/plugins/qmljsinspector/images/logo.png
similarity index 100%
rename from src/plugins/qmlinspector/images/logo.png
rename to src/plugins/qmljsinspector/images/logo.png
diff --git a/src/plugins/qmljsinspector/qmljsdebuggerclient.cpp b/src/plugins/qmljsinspector/qmljsdebuggerclient.cpp
new file mode 100644
index 00000000000..7458c23ab7d
--- /dev/null
+++ b/src/plugins/qmljsinspector/qmljsdebuggerclient.cpp
@@ -0,0 +1,53 @@
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** Commercial Usage
+**
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://qt.nokia.com/contact.
+**
+**************************************************************************/
+#include "qmljsdebuggerclient.h"
+
+using namespace QmlJSInspector::Internal;
+
+DebuggerClient::DebuggerClient(QDeclarativeDebugConnection *client, Debugger::Internal::QmlEngine *engine)
+    : QDeclarativeDebugClient(QLatin1String("Debugger"), client)
+    , connection(client), engine(engine)
+{
+    connect(engine, SIGNAL(sendMessage(QByteArray)), this, SLOT(slotSendMessage(QByteArray)));
+    setEnabled(true);
+}
+
+DebuggerClient::~DebuggerClient()
+{
+}
+
+void DebuggerClient::messageReceived(const QByteArray &data)
+{
+    engine->messageReceived(data);
+}
+
+void DebuggerClient::slotSendMessage(const QByteArray &message)
+{
+    QDeclarativeDebugClient::sendMessage(message);
+}
diff --git a/src/plugins/qmljsinspector/qmljsdebuggerclient.h b/src/plugins/qmljsinspector/qmljsdebuggerclient.h
new file mode 100644
index 00000000000..b77aa9f4263
--- /dev/null
+++ b/src/plugins/qmljsinspector/qmljsdebuggerclient.h
@@ -0,0 +1,63 @@
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** Commercial Usage
+**
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://qt.nokia.com/contact.
+**
+**************************************************************************/
+#ifndef QMLJSDEBUGGERCLIENT_H
+#define QMLJSDEBUGGERCLIENT_H
+
+#include <debugger/qml/qmlengine.h>
+#include <debugger/stackframe.h>
+#include <debugger/stackhandler.h>
+#include <debugger/debuggerrunner.h>
+#include <private/qdeclarativedebugclient_p.h> // QML private API
+
+namespace QmlJSInspector {
+namespace Internal {
+
+class DebuggerClient : public QDeclarativeDebugClient
+{
+    Q_OBJECT
+
+public:
+    DebuggerClient(QDeclarativeDebugConnection *client, Debugger::Internal::QmlEngine *engine);
+    virtual ~DebuggerClient();
+
+public: // attributes
+    QDeclarativeDebugConnection *connection;
+    Debugger::Internal::QmlEngine *engine;
+
+private Q_SLOTS:
+    void slotSendMessage(const QByteArray &message);
+
+protected:
+    virtual void messageReceived(const QByteArray &data);
+};
+
+} // Internal
+} // QmlJSInspector
+
+#endif // QMLJSDEBUGGERCLIENT_H
diff --git a/src/plugins/qmlinspector/qmlinspector.pro b/src/plugins/qmljsinspector/qmljsinspector.pro
similarity index 50%
rename from src/plugins/qmlinspector/qmlinspector.pro
rename to src/plugins/qmljsinspector/qmljsinspector.pro
index db07adbcb54..0f8b6abb015 100644
--- a/src/plugins/qmlinspector/qmlinspector.pro
+++ b/src/plugins/qmljsinspector/qmljsinspector.pro
@@ -1,23 +1,27 @@
 TEMPLATE = lib
-TARGET = QmlInspector
-
+TARGET = QmlJSInspector
 INCLUDEPATH += .
 DEPENDPATH += .
+QT += declarative
 
 include(../../private_headers.pri)
 
-DEFINES += QMLINSPECTOR_LIBRARY
+DEFINES += QMLJSINSPECTOR_LIBRARY
 
-HEADERS += qmlinspectorplugin.h \
-           qmlinspectorconstants.h \
-           qmlinspector_global.h \
-           inspectorcontext.h \
+HEADERS += \
+qmljsdebuggerclient.h \
+qmljsinspector_global.h \
+qmljsinspectorconstants.h \
+qmljsinspectorcontext.h \
+qmljsinspectorplugin.h
 
-SOURCES += qmlinspectorplugin.cpp \
-           inspectorcontext.cpp
+SOURCES += \
+qmljsdebuggerclient.cpp \
+qmljsinspectorcontext.cpp \
+qmljsinspectorplugin.cpp
 
-OTHER_FILES += QmlInspector.pluginspec
-RESOURCES += qmlinspector.qrc
+OTHER_FILES += QmlJSInspector.pluginspec
+RESOURCES += qmljsinspector.qrc
 
 include(../../qtcreatorplugin.pri)
 include(../../plugins/projectexplorer/projectexplorer.pri)
diff --git a/src/plugins/qmlinspector/qmlinspector.qrc b/src/plugins/qmljsinspector/qmljsinspector.qrc
similarity index 100%
rename from src/plugins/qmlinspector/qmlinspector.qrc
rename to src/plugins/qmljsinspector/qmljsinspector.qrc
diff --git a/src/plugins/qmlinspector/qmlinspector_global.h b/src/plugins/qmljsinspector/qmljsinspector_global.h
similarity index 97%
rename from src/plugins/qmlinspector/qmlinspector_global.h
rename to src/plugins/qmljsinspector/qmljsinspector_global.h
index bf82eb5303f..44dbc83f20e 100644
--- a/src/plugins/qmlinspector/qmlinspector_global.h
+++ b/src/plugins/qmljsinspector/qmljsinspector_global.h
@@ -31,7 +31,7 @@
 
 #include <QtCore/QtGlobal>
 
-#if defined(QMLINSPECTOR_LIBRARY)
+#if defined(QMLJSINSPECTOR_LIBRARY)
 #  define QMLINSPECTOR_EXPORT Q_DECL_EXPORT
 #else
 #  define QMLINSPECTOR_EXPORT Q_DECL_IMPORT
diff --git a/src/plugins/qmlinspector/qmlinspectorconstants.h b/src/plugins/qmljsinspector/qmljsinspectorconstants.h
similarity index 95%
rename from src/plugins/qmlinspector/qmlinspectorconstants.h
rename to src/plugins/qmljsinspector/qmljsinspectorconstants.h
index 9e91549552d..ee04ce02afc 100644
--- a/src/plugins/qmlinspector/qmlinspectorconstants.h
+++ b/src/plugins/qmljsinspector/qmljsinspectorconstants.h
@@ -26,10 +26,10 @@
 ** contact the sales department at http://qt.nokia.com/contact.
 **
 **************************************************************************/
-#ifndef QMLINSPECTORCONSTANTS_H
-#define QMLINSPECTORCONSTANTS_H
+#ifndef QMLJSINSPECTORCONSTANTS_H
+#define QMLJSINSPECTORCONSTANTS_H
 
-namespace QmlInspector {
+namespace QmlJSInspector {
     namespace Constants {
         const char * const RUN = "QmlInspector.Run";
         const char * const STOP = "QmlInspector.Stop";
diff --git a/src/plugins/qmlinspector/inspectorcontext.cpp b/src/plugins/qmljsinspector/qmljsinspectorcontext.cpp
similarity index 93%
rename from src/plugins/qmlinspector/inspectorcontext.cpp
rename to src/plugins/qmljsinspector/qmljsinspectorcontext.cpp
index dee945e253c..3a687adf5c9 100644
--- a/src/plugins/qmlinspector/inspectorcontext.cpp
+++ b/src/plugins/qmljsinspector/qmljsinspectorcontext.cpp
@@ -27,15 +27,15 @@
 **
 **************************************************************************/
 
-#include "inspectorcontext.h"
-#include "qmlinspectorconstants.h"
+#include "qmljsinspectorcontext.h"
+#include "qmljsinspectorconstants.h"
 
 #include <coreplugin/icore.h>
 #include <QtGui/QWidget>
 #include <QtCore/QDebug>
 
-using namespace QmlInspector::Internal;
-using namespace QmlInspector::Constants;
+using namespace QmlJSInspector::Internal;
+using namespace QmlJSInspector::Constants;
 
 InspectorContext::InspectorContext(QWidget *widget)
   : IContext(widget),
diff --git a/src/plugins/qmlinspector/inspectorcontext.h b/src/plugins/qmljsinspector/qmljsinspectorcontext.h
similarity index 95%
rename from src/plugins/qmlinspector/inspectorcontext.h
rename to src/plugins/qmljsinspector/qmljsinspectorcontext.h
index 5b7066efa66..7a4e1dd2443 100644
--- a/src/plugins/qmlinspector/inspectorcontext.h
+++ b/src/plugins/qmljsinspector/qmljsinspectorcontext.h
@@ -27,8 +27,8 @@
 **
 **************************************************************************/
 
-#ifndef INSPECTORCONTEXT_H
-#define INSPECTORCONTEXT_H
+#ifndef QMLJSINSPECTORCONTEXT_H
+#define QMLJSINSPECTORCONTEXT_H
 
 #include <coreplugin/icontext.h>
 #include <QList>
@@ -37,7 +37,7 @@ QT_BEGIN_NAMESPACE
 class QWidget;
 QT_END_NAMESPACE
 
-namespace QmlInspector {
+namespace QmlJSInspector {
 namespace Internal {
 
 class ObjectPropertiesView;
@@ -72,4 +72,5 @@ private:
 } // Internal
 } // QmlInspector
 
-#endif // DESIGNMODECONTEXT_H
+#endif
+
diff --git a/src/plugins/qmlinspector/qmlinspectorplugin.cpp b/src/plugins/qmljsinspector/qmljsinspectorplugin.cpp
similarity index 97%
rename from src/plugins/qmlinspector/qmlinspectorplugin.cpp
rename to src/plugins/qmljsinspector/qmljsinspectorplugin.cpp
index b86f696d427..82c7c5f7695 100644
--- a/src/plugins/qmlinspector/qmlinspectorplugin.cpp
+++ b/src/plugins/qmljsinspector/qmljsinspectorplugin.cpp
@@ -27,8 +27,8 @@
 **
 **************************************************************************/
 
-#include "qmlinspectorconstants.h"
-#include "qmlinspectorplugin.h"
+#include "qmljsinspectorconstants.h"
+#include "qmljsinspectorplugin.h"
 
 #include <debugger/debuggeruiswitcher.h>
 #include <debugger/debuggerconstants.h>
@@ -59,8 +59,8 @@
 
 #include <QtCore/QDebug>
 
-using namespace QmlInspector::Internal;
-using namespace QmlInspector::Constants;
+using namespace QmlJSInspector::Internal;
+using namespace QmlJSInspector::Constants;
 
 namespace {
 QToolButton *createToolButton(QAction *action)
diff --git a/src/plugins/qmlinspector/qmlinspectorplugin.h b/src/plugins/qmljsinspector/qmljsinspectorplugin.h
similarity index 94%
rename from src/plugins/qmlinspector/qmlinspectorplugin.h
rename to src/plugins/qmljsinspector/qmljsinspectorplugin.h
index e1dbf12911b..ddd55e09493 100644
--- a/src/plugins/qmlinspector/qmlinspectorplugin.h
+++ b/src/plugins/qmljsinspector/qmljsinspectorplugin.h
@@ -26,8 +26,8 @@
 ** contact the sales department at http://qt.nokia.com/contact.
 **
 **************************************************************************/
-#ifndef QMLINSPECTORPLUGIN_H
-#define QMLINSPECTORPLUGIN_H
+#ifndef QMLJSINSPECTORPLUGIN_H
+#define QMLJSINSPECTORPLUGIN_H
 
 #include <extensionsystem/iplugin.h>
 
@@ -45,7 +45,7 @@ namespace ProjectExplorer {
     class Project;
 }
 
-namespace QmlInspector {
+namespace QmlJSInspector {
 namespace Internal {
 
 class QmlInspectorPlugin : public ExtensionSystem::IPlugin
@@ -69,6 +69,6 @@ private slots:
 };
 
 } // end of namespace Internal
-} // end of namespace QmlInspector
+} // end of QmlJSInspector
 
 #endif // QMLINSPECTORPLUGIN_H
diff --git a/src/plugins/qmlprojectmanager/qmlprojectruncontrol.cpp b/src/plugins/qmlprojectmanager/qmlprojectruncontrol.cpp
index 16c5c49aa9f..7461ef73f47 100644
--- a/src/plugins/qmlprojectmanager/qmlprojectruncontrol.cpp
+++ b/src/plugins/qmlprojectmanager/qmlprojectruncontrol.cpp
@@ -41,7 +41,7 @@
 
 #include <debugger/debuggerconstants.h>
 #include <debugger/debuggeruiswitcher.h>
-#include <qmlinspector/qmlinspectorconstants.h>
+#include <qmljsinspector/qmljsinspectorconstants.h>
 
 #include <QDir>
 #include <QLabel>
@@ -86,7 +86,7 @@ void QmlRunControl::start()
 
     // FIXME this line should be refactored out in order to remove the dependency between
     // debugger and qmlprojectmanager, because debugger also relies on cpptools.
-    Debugger::DebuggerUISwitcher::instance()->setActiveLanguage(QmlInspector::Constants::LANG_QML);
+    Debugger::DebuggerUISwitcher::instance()->setActiveLanguage(QmlJSInspector::Constants::LANG_QML);
 
     emit started();
     emit appendMessage(this, tr("Starting %1 %2").arg(QDir::toNativeSeparators(m_executable),
-- 
GitLab