diff options
author | Aurindam Jana <aurindam.jana@digia.com> | 2012-10-08 13:17:10 +0200 |
---|---|---|
committer | Aurindam Jana <aurindam.jana@digia.com> | 2012-10-09 18:22:00 +0200 |
commit | 1d04c4c3df701726c6e4c806e9d3f9e97832babd (patch) | |
tree | b4a0e9d374ea3ce6b07b365b957218909e2efc45 /src/libs/qmljs | |
parent | 3ebbba2e0793d7da419353f26ff2f319c07f4f84 (diff) | |
download | qt-creator-1d04c4c3df701726c6e4c806e9d3f9e97832babd.tar.gz |
Debugger: Remove the dependence on QmlJSTools
Change-Id: I26765134c19b9a6cf1e7ad26f313e2d4f8faf258
Reviewed-by: Christiaan Janssen <christiaan.janssen@digia.com>
Diffstat (limited to 'src/libs/qmljs')
-rw-r--r-- | src/libs/qmljs/consoleitem.cpp | 152 | ||||
-rw-r--r-- | src/libs/qmljs/consoleitem.h | 84 | ||||
-rw-r--r-- | src/libs/qmljs/consolemanagerinterface.cpp | 54 | ||||
-rw-r--r-- | src/libs/qmljs/consolemanagerinterface.h | 64 | ||||
-rw-r--r-- | src/libs/qmljs/iscriptevaluator.h | 48 | ||||
-rw-r--r-- | src/libs/qmljs/qmljs-lib.pri | 9 | ||||
-rw-r--r-- | src/libs/qmljs/qmljs.qbs | 5 |
7 files changed, 414 insertions, 2 deletions
diff --git a/src/libs/qmljs/consoleitem.cpp b/src/libs/qmljs/consoleitem.cpp new file mode 100644 index 0000000000..9e9150d145 --- /dev/null +++ b/src/libs/qmljs/consoleitem.cpp @@ -0,0 +1,152 @@ +/**************************************************************************** +** +** 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 "consoleitem.h" + +namespace QmlJS { + +/////////////////////////////////////////////////////////////////////// +// +// ConsoleItem +// +/////////////////////////////////////////////////////////////////////// + +ConsoleItem::ConsoleItem(ConsoleItem *parent, ConsoleItem::ItemType itemType, + const QString &text) + : m_parentItem(parent), + itemType(itemType), + line(-1) + +{ + setText(text); +} + +ConsoleItem::~ConsoleItem() +{ + qDeleteAll(m_childItems); +} + +ConsoleItem *ConsoleItem::child(int number) +{ + return m_childItems.value(number); +} + +int ConsoleItem::childCount() const +{ + return m_childItems.size(); +} + +int ConsoleItem::childNumber() const +{ + if (m_parentItem) + return m_parentItem->m_childItems.indexOf(const_cast<ConsoleItem *>(this)); + + return 0; +} + +bool ConsoleItem::insertChildren(int position, int count) +{ + if (position < 0 || position > m_childItems.size()) + return false; + + for (int row = 0; row < count; ++row) { + ConsoleItem *item = new ConsoleItem(this, ConsoleItem::UndefinedType, + QString()); + m_childItems.insert(position, item); + } + + return true; +} + +void ConsoleItem::insertChild(ConsoleItem *item, bool sorted) +{ + if (!sorted) { + m_childItems.insert(m_childItems.count(), item); + return; + } + + int i = 0; + for (; i < m_childItems.count(); i++) { + if (item->m_text < m_childItems[i]->m_text) + break; + } + m_childItems.insert(i, item); +} + +bool ConsoleItem::insertChild(int position, ConsoleItem *item) +{ + if (position < 0 || position > m_childItems.size()) + return false; + + m_childItems.insert(position, item); + + return true; +} + +ConsoleItem *ConsoleItem::parent() +{ + return m_parentItem; +} + +bool ConsoleItem::removeChildren(int position, int count) +{ + if (position < 0 || position + count > m_childItems.size()) + return false; + + for (int row = 0; row < count; ++row) + delete m_childItems.takeAt(position); + + return true; +} + +bool ConsoleItem::detachChild(int position) +{ + if (position < 0 || position > m_childItems.size()) + return false; + + m_childItems.removeAt(position); + + return true; +} + +void ConsoleItem::setText(const QString &text) +{ + m_text = text; + for (int i = 0; i < m_text.length(); ++i) { + if (m_text.at(i).isPunct()) + m_text.insert(++i, QChar(0x200b)); // ZERO WIDTH SPACE + } +} + +const QString &ConsoleItem::text() const +{ + return m_text; +} + +} // QmlJS diff --git a/src/libs/qmljs/consoleitem.h b/src/libs/qmljs/consoleitem.h new file mode 100644 index 0000000000..15db44387c --- /dev/null +++ b/src/libs/qmljs/consoleitem.h @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** 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 CONSOLEITEM_H +#define CONSOLEITEM_H + +#include "qmljs_global.h" + +#include <QList> +#include <QString> + +namespace QmlJS { + +class QMLJS_EXPORT ConsoleItem +{ +public: + enum ItemType + { + UndefinedType = 0x01, // Can be used for unknown and for Return values + DebugType = 0x02, + WarningType = 0x04, + ErrorType = 0x08, + InputType = 0x10, + DefaultTypes = InputType | UndefinedType + }; + Q_DECLARE_FLAGS(ItemTypes, ItemType) + + ConsoleItem(ConsoleItem *parent, + ConsoleItem::ItemType type = ConsoleItem::UndefinedType, + const QString &data = QString()); + ~ConsoleItem(); + + ConsoleItem *child(int number); + int childCount() const; + bool insertChildren(int position, int count); + 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; + void setText(const QString &text); + const QString &text() const; + +private: + ConsoleItem *m_parentItem; + QList<ConsoleItem *> m_childItems; + QString m_text; + +public: + ConsoleItem::ItemType itemType; + QString file; + int line; +}; + +} // QmlJS + +#endif // CONSOLEITEM_H diff --git a/src/libs/qmljs/consolemanagerinterface.cpp b/src/libs/qmljs/consolemanagerinterface.cpp new file mode 100644 index 0000000000..c78e3a6633 --- /dev/null +++ b/src/libs/qmljs/consolemanagerinterface.cpp @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** 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 diff --git a/src/libs/qmljs/consolemanagerinterface.h b/src/libs/qmljs/consolemanagerinterface.h new file mode 100644 index 0000000000..4ee6067f29 --- /dev/null +++ b/src/libs/qmljs/consolemanagerinterface.h @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** 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 diff --git a/src/libs/qmljs/iscriptevaluator.h b/src/libs/qmljs/iscriptevaluator.h new file mode 100644 index 0000000000..dfa780fbe4 --- /dev/null +++ b/src/libs/qmljs/iscriptevaluator.h @@ -0,0 +1,48 @@ +/**************************************************************************** +** +** 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 diff --git a/src/libs/qmljs/qmljs-lib.pri b/src/libs/qmljs/qmljs-lib.pri index bbc1d06bda..6f4f72db85 100644 --- a/src/libs/qmljs/qmljs-lib.pri +++ b/src/libs/qmljs/qmljs-lib.pri @@ -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 diff --git a/src/libs/qmljs/qmljs.qbs b/src/libs/qmljs/qmljs.qbs index 6a4e8b0c21..7a981b7d2a 100644 --- a/src/libs/qmljs/qmljs.qbs +++ b/src/libs/qmljs/qmljs.qbs @@ -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 { |