From 8e11f81d96b5aac2c1df87b13a59dd86a85461e1 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen <erik.verbruggen@nokia.com> Date: Fri, 15 Jan 2010 13:39:54 +0100 Subject: [PATCH] Gotten rid of dulplicate files, and fixed includes. --- src/libs/libs.pro | 2 +- src/libs/qml/qml.pri | 5 - .../{qml/qml-lib.pri => qmljs/qmljs-lib.pri} | 2 +- src/libs/qmljs/qmljs.pri | 5 + src/libs/{qml/qml.pro => qmljs/qmljs.pro} | 4 +- .../filemanager/addarraymembervisitor.cpp | 6 +- .../core/filemanager/addobjectvisitor.cpp | 6 +- .../core/filemanager/addpropertyvisitor.cpp | 6 +- .../filemanager/astobjecttextextractor.cpp | 4 +- .../core/filemanager/astobjecttextextractor.h | 8 +- .../filemanager/changeobjecttypevisitor.cpp | 4 +- .../filemanager/changepropertyvisitor.cpp | 6 +- .../core/filemanager/changeset.cpp | 359 --------- .../qmldesigner/core/filemanager/changeset.h | 120 --- .../core/filemanager/filemanager.pri | 13 +- .../filemanager/firstdefinitionfinder.cpp | 4 +- .../core/filemanager/firstdefinitionfinder.h | 7 +- .../core/filemanager/idcollector.cpp | 93 --- .../core/filemanager/idcollector.h | 69 -- .../qmldesigner/core/filemanager/indenter.cpp | 90 --- .../qmldesigner/core/filemanager/indenter.h | 43 -- .../moveobjectbeforeobjectvisitor.cpp | 10 +- .../core/filemanager/moveobjectvisitor.cpp | 10 +- .../filemanager/objectlengthcalculator.cpp | 4 +- .../core/filemanager/objectlengthcalculator.h | 7 +- .../core/filemanager/qmldocument.cpp | 165 ----- .../core/filemanager/qmldocument.h | 109 --- .../core/filemanager/qmlrefactoring.cpp | 5 +- .../core/filemanager/qmlrefactoring.h | 8 +- .../core/filemanager/qmlrewriter.cpp | 10 +- .../core/filemanager/qmlrewriter.h | 8 +- .../core/filemanager/qmlsymbol.cpp | 116 --- .../qmldesigner/core/filemanager/qmlsymbol.h | 121 --- .../filemanager/removepropertyvisitor.cpp | 6 +- .../removeuiobjectmembervisitor.cpp | 9 +- .../core/filemanager/utils_global.h | 37 - .../core/model/modeltotextmerger.cpp | 7 +- .../core/model/plaintexteditmodifier.cpp | 2 +- .../qmldesigner/qmldesigner_dependencies.pri | 2 +- src/plugins/qmleditor/qmlcodecompletion.cpp | 2 +- src/plugins/qmleditor/qmlcodecompletion.h | 2 +- src/plugins/qmleditor/qmleditor.cpp | 12 +- src/plugins/qmleditor/qmleditor.h | 2 +- .../qmleditor/qmleditor_dependencies.pri | 2 +- .../qmleditor/qmlexpressionundercursor.cpp | 12 +- .../qmleditor/qmlexpressionundercursor.h | 6 +- src/plugins/qmleditor/qmlhoverhandler.cpp | 2 +- src/plugins/qmleditor/qmllookupcontext.cpp | 6 +- src/plugins/qmleditor/qmllookupcontext.h | 8 +- src/plugins/qmleditor/qmlmodelmanager.h | 2 +- .../qmleditor/qmlmodelmanagerinterface.h | 4 +- .../qmleditor/qmlresolveexpression.cpp | 4 +- src/plugins/qmleditor/qmlresolveexpression.h | 4 +- .../qmlprojectmanager/qmltaskmanager.h | 2 +- src/shared/qml/metatype/exception.cpp | 191 ----- src/shared/qml/metatype/exception.h | 70 -- .../qml/metatype/invalidmetainfoexception.cpp | 62 -- .../qml/metatype/invalidmetainfoexception.h | 50 -- src/shared/qml/metatype/metainfo.cpp | 489 ------------ src/shared/qml/metatype/metainfo.h | 112 --- src/shared/qml/metatype/nodemetainfo.cpp | 699 ------------------ src/shared/qml/metatype/nodemetainfo.h | 132 ---- src/shared/qml/metatype/propertymetainfo.cpp | 405 ---------- src/shared/qml/metatype/propertymetainfo.h | 113 --- src/shared/qml/qml.pri | 43 -- .../metatype => qmljs}/QmlMetaTypeBackend.cpp | 0 .../metatype => qmljs}/QmlMetaTypeBackend.h | 6 +- .../QtDeclarativeMetaTypeBackend.cpp | 96 +-- .../QtDeclarativeMetaTypeBackend.h | 14 +- src/shared/{qml => qmljs}/parser/parser.pri | 2 +- src/shared/{qml => qmljs}/parser/qmljs.g | 0 src/shared/{qml => qmljs}/parser/qmljsast.cpp | 0 src/shared/{qml => qmljs}/parser/qmljsast_p.h | 0 .../{qml => qmljs}/parser/qmljsastfwd_p.h | 0 .../{qml => qmljs}/parser/qmljsastvisitor.cpp | 0 .../{qml => qmljs}/parser/qmljsastvisitor_p.h | 0 .../{qml => qmljs}/parser/qmljsengine_p.cpp | 0 .../{qml => qmljs}/parser/qmljsengine_p.h | 0 .../{qml => qmljs}/parser/qmljsglobal_p.h | 0 .../{qml => qmljs}/parser/qmljsgrammar.cpp | 0 .../{qml => qmljs}/parser/qmljsgrammar_p.h | 0 .../{qml => qmljs}/parser/qmljslexer.cpp | 0 .../{qml => qmljs}/parser/qmljslexer_p.h | 0 .../{qml => qmljs}/parser/qmljsmemorypool_p.h | 0 .../{qml => qmljs}/parser/qmljsnodepool_p.h | 0 .../{qml => qmljs}/parser/qmljsparser.cpp | 0 .../{qml => qmljs}/parser/qmljsparser_p.h | 0 src/shared/{qml => qmljs}/qml_global.h | 0 src/shared/{qml => qmljs}/qmldocument.cpp | 10 +- src/shared/{qml => qmljs}/qmldocument.h | 0 src/shared/{qml => qmljs}/qmlidcollector.cpp | 3 +- src/shared/{qml => qmljs}/qmlidcollector.h | 8 +- src/shared/qmljs/qmljs.pri | 33 + src/shared/{qml => qmljs}/qmlpackageinfo.cpp | 0 src/shared/{qml => qmljs}/qmlpackageinfo.h | 2 +- src/shared/{qml => qmljs}/qmlsymbol.cpp | 5 +- src/shared/{qml => qmljs}/qmlsymbol.h | 4 +- .../{qml/metatype => qmljs}/qmltypesystem.cpp | 0 .../{qml/metatype => qmljs}/qmltypesystem.h | 6 +- .../qmldesigner/standalone/standalone.pro | 6 + .../qmldesigner/bauhaustests/bauhaustests.pro | 5 + .../qml/qmldesigner/coretests/coretests.pro | 7 +- .../propertyeditortests.pro | 5 + tests/auto/qml/qmleditor/lookup/lookup.pro | 3 +- .../auto/qml/qmleditor/lookup/tst_lookup.cpp | 4 +- 105 files changed, 212 insertions(+), 3935 deletions(-) delete mode 100644 src/libs/qml/qml.pri rename src/libs/{qml/qml-lib.pri => qmljs/qmljs-lib.pri} (87%) create mode 100644 src/libs/qmljs/qmljs.pri rename src/libs/{qml/qml.pro => qmljs/qmljs.pro} (78%) delete mode 100644 src/plugins/qmldesigner/core/filemanager/changeset.cpp delete mode 100644 src/plugins/qmldesigner/core/filemanager/changeset.h delete mode 100644 src/plugins/qmldesigner/core/filemanager/idcollector.cpp delete mode 100644 src/plugins/qmldesigner/core/filemanager/idcollector.h delete mode 100644 src/plugins/qmldesigner/core/filemanager/indenter.cpp delete mode 100644 src/plugins/qmldesigner/core/filemanager/indenter.h delete mode 100644 src/plugins/qmldesigner/core/filemanager/qmldocument.cpp delete mode 100644 src/plugins/qmldesigner/core/filemanager/qmldocument.h delete mode 100644 src/plugins/qmldesigner/core/filemanager/qmlsymbol.cpp delete mode 100644 src/plugins/qmldesigner/core/filemanager/qmlsymbol.h delete mode 100644 src/plugins/qmldesigner/core/filemanager/utils_global.h delete mode 100644 src/shared/qml/metatype/exception.cpp delete mode 100644 src/shared/qml/metatype/exception.h delete mode 100644 src/shared/qml/metatype/invalidmetainfoexception.cpp delete mode 100644 src/shared/qml/metatype/invalidmetainfoexception.h delete mode 100644 src/shared/qml/metatype/metainfo.cpp delete mode 100644 src/shared/qml/metatype/metainfo.h delete mode 100644 src/shared/qml/metatype/nodemetainfo.cpp delete mode 100644 src/shared/qml/metatype/nodemetainfo.h delete mode 100644 src/shared/qml/metatype/propertymetainfo.cpp delete mode 100644 src/shared/qml/metatype/propertymetainfo.h delete mode 100644 src/shared/qml/qml.pri rename src/shared/{qml/metatype => qmljs}/QmlMetaTypeBackend.cpp (100%) rename src/shared/{qml/metatype => qmljs}/QmlMetaTypeBackend.h (95%) rename src/shared/{qml/metatype => qmljs}/QtDeclarativeMetaTypeBackend.cpp (58%) rename src/shared/{qml/metatype => qmljs}/QtDeclarativeMetaTypeBackend.h (81%) rename src/shared/{qml => qmljs}/parser/parser.pri (96%) rename src/shared/{qml => qmljs}/parser/qmljs.g (100%) rename src/shared/{qml => qmljs}/parser/qmljsast.cpp (100%) rename src/shared/{qml => qmljs}/parser/qmljsast_p.h (100%) rename src/shared/{qml => qmljs}/parser/qmljsastfwd_p.h (100%) rename src/shared/{qml => qmljs}/parser/qmljsastvisitor.cpp (100%) rename src/shared/{qml => qmljs}/parser/qmljsastvisitor_p.h (100%) rename src/shared/{qml => qmljs}/parser/qmljsengine_p.cpp (100%) rename src/shared/{qml => qmljs}/parser/qmljsengine_p.h (100%) rename src/shared/{qml => qmljs}/parser/qmljsglobal_p.h (100%) rename src/shared/{qml => qmljs}/parser/qmljsgrammar.cpp (100%) rename src/shared/{qml => qmljs}/parser/qmljsgrammar_p.h (100%) rename src/shared/{qml => qmljs}/parser/qmljslexer.cpp (100%) rename src/shared/{qml => qmljs}/parser/qmljslexer_p.h (100%) rename src/shared/{qml => qmljs}/parser/qmljsmemorypool_p.h (100%) rename src/shared/{qml => qmljs}/parser/qmljsnodepool_p.h (100%) rename src/shared/{qml => qmljs}/parser/qmljsparser.cpp (100%) rename src/shared/{qml => qmljs}/parser/qmljsparser_p.h (100%) rename src/shared/{qml => qmljs}/qml_global.h (100%) rename src/shared/{qml => qmljs}/qmldocument.cpp (95%) rename src/shared/{qml => qmljs}/qmldocument.h (100%) rename src/shared/{qml => qmljs}/qmlidcollector.cpp (98%) rename src/shared/{qml => qmljs}/qmlidcollector.h (94%) create mode 100644 src/shared/qmljs/qmljs.pri rename src/shared/{qml => qmljs}/qmlpackageinfo.cpp (100%) rename src/shared/{qml => qmljs}/qmlpackageinfo.h (98%) rename src/shared/{qml => qmljs}/qmlsymbol.cpp (99%) rename src/shared/{qml => qmljs}/qmlsymbol.h (98%) rename src/shared/{qml/metatype => qmljs}/qmltypesystem.cpp (100%) rename src/shared/{qml/metatype => qmljs}/qmltypesystem.h (95%) diff --git a/src/libs/libs.pro b/src/libs/libs.pro index d0abdb4d790..15d97c0c4e8 100644 --- a/src/libs/libs.pro +++ b/src/libs/libs.pro @@ -8,7 +8,7 @@ SUBDIRS = \ utils \ utils/process_stub.pro \ cplusplus \ - qml + qmljs SUPPORT_QT_MAEMO = $$(QTCREATOR_WITH_MAEMO) !isEmpty(SUPPORT_QT_MAEMO) { diff --git a/src/libs/qml/qml.pri b/src/libs/qml/qml.pri deleted file mode 100644 index 18fb0f76557..00000000000 --- a/src/libs/qml/qml.pri +++ /dev/null @@ -1,5 +0,0 @@ -INCLUDEPATH += $$PWD/../../shared -INCLUDEPATH += $$PWD/../../shared/qml $$PWD/../../shared/qml/parser - -DEPENDPATH += $$PWD/../../shared -LIBS *= -l$$qtLibraryTarget(Qml) diff --git a/src/libs/qml/qml-lib.pri b/src/libs/qmljs/qmljs-lib.pri similarity index 87% rename from src/libs/qml/qml-lib.pri rename to src/libs/qmljs/qmljs-lib.pri index 0a43a59b570..65b7ddeef5c 100644 --- a/src/libs/qml/qml-lib.pri +++ b/src/libs/qmljs/qmljs-lib.pri @@ -6,7 +6,7 @@ contains(CONFIG, dll) { INCLUDEPATH += $$PWD -include($$PWD/../../shared/qml/qml.pri) +include($$PWD/../../shared/qmljs/qmljs.pri) ##contains(QT, gui) { ##HEADERS += \ diff --git a/src/libs/qmljs/qmljs.pri b/src/libs/qmljs/qmljs.pri new file mode 100644 index 00000000000..4d2285d2d0a --- /dev/null +++ b/src/libs/qmljs/qmljs.pri @@ -0,0 +1,5 @@ +INCLUDEPATH += $$PWD/../../shared +INCLUDEPATH += $$PWD/../../shared/qmljs $$PWD/../../shared/qmljs/parser + +DEPENDPATH += $$PWD/../../shared/qmljs +LIBS *= -l$$qtLibraryTarget(QmlJS) diff --git a/src/libs/qml/qml.pro b/src/libs/qmljs/qmljs.pro similarity index 78% rename from src/libs/qml/qml.pro rename to src/libs/qmljs/qmljs.pro index 6d865048843..31a8c7fb847 100644 --- a/src/libs/qml/qml.pro +++ b/src/libs/qmljs/qmljs.pro @@ -1,9 +1,9 @@ TEMPLATE = lib CONFIG += dll -TARGET = Qml +TARGET = QmlJS DEFINES += QML_BUILD_LIB QT_CREATOR unix:QMAKE_CXXFLAGS_DEBUG += -O3 include(../../qtcreatorlibrary.pri) -include(qml-lib.pri) +include(qmljs-lib.pri) diff --git a/src/plugins/qmldesigner/core/filemanager/addarraymembervisitor.cpp b/src/plugins/qmldesigner/core/filemanager/addarraymembervisitor.cpp index 321377b457d..f8ab6cb7bda 100644 --- a/src/plugins/qmldesigner/core/filemanager/addarraymembervisitor.cpp +++ b/src/plugins/qmldesigner/core/filemanager/addarraymembervisitor.cpp @@ -27,11 +27,11 @@ ** **************************************************************************/ -#include <qmljsast_p.h> -#include <qmljsengine_p.h> - #include "addarraymembervisitor.h" +#include <qmljs/parser/qmljsast_p.h> +#include <qmljs/parser/qmljsengine_p.h> + using namespace QmlDesigner; using namespace QmlDesigner::Internal; using namespace QmlJS; diff --git a/src/plugins/qmldesigner/core/filemanager/addobjectvisitor.cpp b/src/plugins/qmldesigner/core/filemanager/addobjectvisitor.cpp index 66cff0b7323..731b15808ab 100644 --- a/src/plugins/qmldesigner/core/filemanager/addobjectvisitor.cpp +++ b/src/plugins/qmldesigner/core/filemanager/addobjectvisitor.cpp @@ -27,11 +27,11 @@ ** **************************************************************************/ -#include <qmljsast_p.h> -#include <qmljsengine_p.h> - #include "addobjectvisitor.h" +#include <qmljs/parser/qmljsast_p.h> +#include <qmljs/parser/qmljsengine_p.h> + using namespace QmlDesigner; using namespace QmlDesigner::Internal; using namespace QmlJS; diff --git a/src/plugins/qmldesigner/core/filemanager/addpropertyvisitor.cpp b/src/plugins/qmldesigner/core/filemanager/addpropertyvisitor.cpp index 89850272335..ecbf0cf2794 100644 --- a/src/plugins/qmldesigner/core/filemanager/addpropertyvisitor.cpp +++ b/src/plugins/qmldesigner/core/filemanager/addpropertyvisitor.cpp @@ -27,11 +27,11 @@ ** **************************************************************************/ -#include <qmljsast_p.h> -#include <qmljsengine_p.h> - #include "addpropertyvisitor.h" +#include <qmljs/parser/qmljsast_p.h> +#include <qmljs/parser/qmljsengine_p.h> + using namespace QmlDesigner; using namespace QmlDesigner::Internal; using namespace QmlJS; diff --git a/src/plugins/qmldesigner/core/filemanager/astobjecttextextractor.cpp b/src/plugins/qmldesigner/core/filemanager/astobjecttextextractor.cpp index 8d315256713..8b5d4ad9649 100644 --- a/src/plugins/qmldesigner/core/filemanager/astobjecttextextractor.cpp +++ b/src/plugins/qmldesigner/core/filemanager/astobjecttextextractor.cpp @@ -28,8 +28,10 @@ **************************************************************************/ #include "astobjecttextextractor.h" -#include "qmljsast_p.h" +#include <qmljs/parser/qmljsast_p.h> + +using namespace Qml; using namespace QmlDesigner; using namespace QmlJS::AST; diff --git a/src/plugins/qmldesigner/core/filemanager/astobjecttextextractor.h b/src/plugins/qmldesigner/core/filemanager/astobjecttextextractor.h index a22a585bf69..47c48a3ec84 100644 --- a/src/plugins/qmldesigner/core/filemanager/astobjecttextextractor.h +++ b/src/plugins/qmldesigner/core/filemanager/astobjecttextextractor.h @@ -30,10 +30,10 @@ #ifndef ASTOBJECTTEXTEXTRACTOR_H #define ASTOBJECTTEXTEXTRACTOR_H -#include <QtCore/QString> +#include <qmljs/parser/qmljsastvisitor_p.h> +#include <qmljs/qmldocument.h> -#include "qmldocument.h" -#include "qmljsastvisitor_p.h" +#include <QtCore/QString> namespace QmlDesigner { @@ -49,7 +49,7 @@ protected: virtual bool visit(QmlJS::AST::UiObjectDefinition *ast); private: - QmlDocument::Ptr m_document; + Qml::QmlDocument::Ptr m_document; quint32 m_location; QString m_text; }; diff --git a/src/plugins/qmldesigner/core/filemanager/changeobjecttypevisitor.cpp b/src/plugins/qmldesigner/core/filemanager/changeobjecttypevisitor.cpp index bbb01c08936..a7059f82b88 100644 --- a/src/plugins/qmldesigner/core/filemanager/changeobjecttypevisitor.cpp +++ b/src/plugins/qmldesigner/core/filemanager/changeobjecttypevisitor.cpp @@ -28,8 +28,8 @@ **************************************************************************/ #include "changeobjecttypevisitor.h" -#include <qmljsast_p.h> -#include <qmljsengine_p.h> +#include <qmljs/parser/qmljsast_p.h> +#include <qmljs/parser/qmljsengine_p.h> using namespace QmlJS; using namespace QmlJS::AST; diff --git a/src/plugins/qmldesigner/core/filemanager/changepropertyvisitor.cpp b/src/plugins/qmldesigner/core/filemanager/changepropertyvisitor.cpp index f0ea5155ba1..ee3598461a8 100644 --- a/src/plugins/qmldesigner/core/filemanager/changepropertyvisitor.cpp +++ b/src/plugins/qmldesigner/core/filemanager/changepropertyvisitor.cpp @@ -27,11 +27,11 @@ ** **************************************************************************/ -#include <qmljsast_p.h> -#include <qmljsengine_p.h> - #include "changepropertyvisitor.h" +#include <qmljs/parser/qmljsast_p.h> +#include <qmljs/parser/qmljsengine_p.h> + using namespace QmlJS; using namespace QmlJS::AST; using namespace QmlDesigner; diff --git a/src/plugins/qmldesigner/core/filemanager/changeset.cpp b/src/plugins/qmldesigner/core/filemanager/changeset.cpp deleted file mode 100644 index b006106a16b..00000000000 --- a/src/plugins/qmldesigner/core/filemanager/changeset.cpp +++ /dev/null @@ -1,359 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** 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, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "changeset.h" - -namespace Utils { - -ChangeSet::ChangeSet() - : m_string(0), m_cursor(0), m_error(false) -{ -} - -static bool overlaps(int posA, int lengthA, int posB, int lengthB) { - if (lengthB > 0) { - return - // right edge of B contained in A - (posA < posB + lengthB && posA + lengthA >= posB + lengthB) - // left edge of B contained in A - || (posA <= posB && posA + lengthA > posB) - // A contained in B - || (posB < posA && posB + lengthB > posA + lengthA); - } else { - return (posB > posA && posB < posA + lengthA); - } -} - -bool ChangeSet::hasOverlap(int pos, int length) -{ - QListIterator<EditOp> i(m_operationList); - while (i.hasNext()) { - const EditOp &cmd = i.next(); - - switch (cmd.type) { - case EditOp::Replace: - if (overlaps(pos, length, cmd.pos1, cmd.length1)) - return true; - break; - - case EditOp::Move: - if (overlaps(pos, length, cmd.pos1, cmd.length1)) - return true; - if (cmd.pos2 > pos && cmd.pos2 < pos + length) - return true; - break; - - case EditOp::Insert: - if (cmd.pos1 > pos && cmd.pos1 < pos + length) - return true; - break; - - case EditOp::Remove: - if (overlaps(pos, length, cmd.pos1, cmd.length1)) - return true; - break; - - case EditOp::Flip: - if (overlaps(pos, length, cmd.pos1, cmd.length1)) - return true; - if (overlaps(pos, length, cmd.pos2, cmd.length2)) - return true; - break; - - case EditOp::Copy: - if (overlaps(pos, length, cmd.pos1, cmd.length1)) - return true; - if (cmd.pos2 > pos && cmd.pos2 < pos + length) - return true; - break; - - case EditOp::Unset: - break; - } - } - - return false; -} - -bool ChangeSet::isEmpty() const -{ - return m_operationList.isEmpty(); -} - -QList<ChangeSet::EditOp> ChangeSet::operationList() const -{ - return m_operationList; -} - -void ChangeSet::clear() -{ - m_string = 0; - m_cursor = 0; - m_operationList.clear(); - m_error = false; -} - -bool ChangeSet::replace(int pos, int length, const QString &replacement) -{ - if (hasOverlap(pos, length)) - m_error = true; - - EditOp cmd(EditOp::Replace); - cmd.pos1 = pos; - cmd.length1 = length; - cmd.text = replacement; - m_operationList += cmd; - - return !m_error; -} - -bool ChangeSet::move(int pos, int length, int to) -{ - if (hasOverlap(pos, length) - || hasOverlap(to, 0) - || overlaps(pos, length, to, 0)) - m_error = true; - - EditOp cmd(EditOp::Move); - cmd.pos1 = pos; - cmd.length1 = length; - cmd.pos2 = to; - m_operationList += cmd; - - return !m_error; -} - -bool ChangeSet::insert(int pos, const QString &text) -{ - if (hasOverlap(pos, 0)) - m_error = true; - - EditOp cmd(EditOp::Insert); - cmd.pos1 = pos; - cmd.text = text; - m_operationList += cmd; - - return !m_error; -} - -bool ChangeSet::remove(int pos, int length) -{ - if (hasOverlap(pos, length)) - m_error = true; - - EditOp cmd(EditOp::Remove); - cmd.pos1 = pos; - cmd.length1 = length; - m_operationList += cmd; - - return !m_error; -} - -bool ChangeSet::flip(int pos1, int length1, int pos2, int length2) -{ - if (hasOverlap(pos1, length1) - || hasOverlap(pos2, length2) - || overlaps(pos1, length1, pos2, length2)) - m_error = true; - - EditOp cmd(EditOp::Flip); - cmd.pos1 = pos1; - cmd.length1 = length1; - cmd.pos2 = pos2; - cmd.length2 = length2; - m_operationList += cmd; - - return !m_error; -} - -bool ChangeSet::copy(int pos, int length, int to) -{ - if (hasOverlap(pos, length) - || hasOverlap(to, 0) - || overlaps(pos, length, to, 0)) - m_error = true; - - EditOp cmd(EditOp::Copy); - cmd.pos1 = pos; - cmd.length1 = length; - cmd.pos2 = to; - m_operationList += cmd; - - return !m_error; -} - -void ChangeSet::doReplace(const EditOp &replace, QList<EditOp> *replaceList) -{ - Q_ASSERT(replace.type == EditOp::Replace); - - { - QMutableListIterator<EditOp> i(*replaceList); - while (i.hasNext()) { - EditOp &c = i.next(); - if (replace.pos1 <= c.pos1) - c.pos1 += replace.text.size(); - if (replace.pos1 < c.pos1) - c.pos1 -= replace.length1; - } - } - - if (m_string) { - m_string->replace(replace.pos1, replace.length1, replace.text); - } else if (m_cursor) { - m_cursor->setPosition(replace.pos1); - m_cursor->setPosition(replace.pos1 + replace.length1, QTextCursor::KeepAnchor); - m_cursor->insertText(replace.text); - } -} - -void ChangeSet::convertToReplace(const EditOp &op, QList<EditOp> *replaceList) -{ - EditOp replace1(EditOp::Replace); - EditOp replace2(EditOp::Replace); - - switch (op.type) { - case EditOp::Replace: - replaceList->append(op); - break; - - case EditOp::Move: - replace1.pos1 = op.pos1; - replace1.length1 = op.length1; - replaceList->append(replace1); - - replace2.pos1 = op.pos2; - replace2.text = textAt(op.pos1, op.length1); - replaceList->append(replace2); - break; - - case EditOp::Insert: - replace1.pos1 = op.pos1; - replace1.text = op.text; - replaceList->append(replace1); - break; - - case EditOp::Remove: - replace1.pos1 = op.pos1; - replace1.length1 = op.length1; - replaceList->append(replace1); - break; - - case EditOp::Flip: - replace1.pos1 = op.pos1; - replace1.length1 = op.length1; - replace1.text = textAt(op.pos2, op.length2); - replaceList->append(replace1); - - replace2.pos1 = op.pos2; - replace2.length1 = op.length2; - replace2.text = textAt(op.pos1, op.length1); - replaceList->append(replace2); - break; - - case EditOp::Copy: - replace1.pos1 = op.pos2; - replace1.text = textAt(op.pos1, op.length1); - replaceList->append(replace1); - break; - - case EditOp::Unset: - break; - } -} - -bool ChangeSet::hadErrors() -{ - return m_error; -} - -void ChangeSet::apply(QString *s) -{ - m_string = s; - apply_helper(); - m_string = 0; -} - -void ChangeSet::apply(QTextCursor *textCursor) -{ - m_cursor = textCursor; - apply_helper(); - m_cursor = 0; -} - -QString ChangeSet::textAt(int pos, int length) -{ - if (m_string) { - return m_string->mid(pos, length); - } else if (m_cursor) { - m_cursor->setPosition(pos); - m_cursor->setPosition(pos + length, QTextCursor::KeepAnchor); - return m_cursor->selectedText(); - } - return QString(); -} - -void ChangeSet::apply_helper() -{ - // convert all ops to replace - QList<EditOp> replaceList; - { - while (!m_operationList.isEmpty()) { - const EditOp cmd(m_operationList.first()); - m_operationList.removeFirst(); - convertToReplace(cmd, &replaceList); - } - } - - // execute replaces - if (m_cursor) - m_cursor->beginEditBlock(); - - while (!replaceList.isEmpty()) { - const EditOp cmd(replaceList.first()); - replaceList.removeFirst(); - doReplace(cmd, &replaceList); - } - - if (m_cursor) - m_cursor->endEditBlock(); -} - -} // end namespace Utils diff --git a/src/plugins/qmldesigner/core/filemanager/changeset.h b/src/plugins/qmldesigner/core/filemanager/changeset.h deleted file mode 100644 index 2f46bd835d3..00000000000 --- a/src/plugins/qmldesigner/core/filemanager/changeset.h +++ /dev/null @@ -1,120 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** 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, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef CHANGESET_H -#define CHANGESET_H - -#include "utils_global.h" - -#include <QtCore/QString> -#include <QtCore/QList> -#include <QtCore/QSharedPointer> -#include <QtGui/QTextCursor> - -namespace Utils { - -class QTCREATOR_UTILS_EXPORT ChangeSet -{ -public: - struct EditOp { - enum Type - { - Unset, - Replace, - Move, - Insert, - Remove, - Flip, - Copy - }; - - EditOp(): type(Unset), pos1(0), pos2(0), length1(0), length2(0) {} - EditOp(Type t): type(t), pos1(0), pos2(0), length1(0), length2(0) {} - - Type type; - int pos1; - int pos2; - int length1; - int length2; - QString text; - }; - -public: - ChangeSet(); - - bool isEmpty() const; - - QList<EditOp> operationList() const; - - void clear(); - - bool replace(int pos, int length, const QString &replacement); - bool move(int pos, int length, int to); - bool insert(int pos, const QString &text); - bool remove(int pos, int length); - bool flip(int pos1, int length1, int pos2, int length2); - bool copy(int pos, int length, int to); - - bool hadErrors(); - - void apply(QString *s); - void apply(QTextCursor *textCursor); - -private: - bool hasOverlap(int pos, int length); - QString textAt(int pos, int length); - - void doReplace(const EditOp &replace, QList<EditOp> *replaceList); - void convertToReplace(const EditOp &op, QList<EditOp> *replaceList); - - void apply_helper(); - -private: - QString *m_string; - QTextCursor *m_cursor; - - QList<EditOp> m_operationList; - bool m_error; -}; - -} // namespace Utils - -#endif // CHANGESET_H diff --git a/src/plugins/qmldesigner/core/filemanager/filemanager.pri b/src/plugins/qmldesigner/core/filemanager/filemanager.pri index 0a8cad635cb..03ca7da00f5 100644 --- a/src/plugins/qmldesigner/core/filemanager/filemanager.pri +++ b/src/plugins/qmldesigner/core/filemanager/filemanager.pri @@ -1,6 +1,4 @@ -SOURCES += $$PWD/qmldocument.cpp \ - $$PWD/idcollector.cpp \ - $$PWD/qmlsymbol.cpp \ +SOURCES += \ $$PWD/qmlrewriter.cpp \ $$PWD/qmlrefactoring.cpp \ $$PWD/changeobjecttypevisitor.cpp \ @@ -12,15 +10,11 @@ SOURCES += $$PWD/qmldocument.cpp \ $$PWD/addobjectvisitor.cpp \ $$PWD/addarraymembervisitor.cpp \ $$PWD/astobjecttextextractor.cpp \ - $$PWD/indenter.cpp \ - $$PWD/changeset.cpp \ $$PWD/objectlengthcalculator.cpp \ $$PWD/firstdefinitionfinder.cpp \ $$PWD/moveobjectbeforeobjectvisitor.cpp -HEADERS += $$PWD/qmldocument.h \ - $$PWD/idcollector.h \ +HEADERS += \ $$PWD/qmleditor_global.h \ - $$PWD/qmlsymbol.h \ $$PWD/qmlrewriter.h \ $$PWD/qmlrefactoring.h \ $$PWD/changeobjecttypevisitor.h \ @@ -32,9 +26,6 @@ HEADERS += $$PWD/qmldocument.h \ $$PWD/addobjectvisitor.h \ $$PWD/addarraymembervisitor.h \ $$PWD/astobjecttextextractor.h \ - $$PWD/indenter.h \ - $$PWD/changeset.h \ - $$PWD/utils_global.h \ $$PWD/objectlengthcalculator.h \ $$PWD/firstdefinitionfinder.h \ $$PWD/moveobjectbeforeobjectvisitor.h diff --git a/src/plugins/qmldesigner/core/filemanager/firstdefinitionfinder.cpp b/src/plugins/qmldesigner/core/filemanager/firstdefinitionfinder.cpp index de3b5fb1bed..3063d821cf5 100644 --- a/src/plugins/qmldesigner/core/filemanager/firstdefinitionfinder.cpp +++ b/src/plugins/qmldesigner/core/filemanager/firstdefinitionfinder.cpp @@ -29,9 +29,9 @@ #include "firstdefinitionfinder.h" -#include <qmljsast_p.h> +#include <qmljs/parser/qmljsast_p.h> -using namespace QmlDesigner; +using namespace Qml; using namespace QmlDesigner; using namespace QmlJS::AST; diff --git a/src/plugins/qmldesigner/core/filemanager/firstdefinitionfinder.h b/src/plugins/qmldesigner/core/filemanager/firstdefinitionfinder.h index 84bd859fe3a..869b9e173fd 100644 --- a/src/plugins/qmldesigner/core/filemanager/firstdefinitionfinder.h +++ b/src/plugins/qmldesigner/core/filemanager/firstdefinitionfinder.h @@ -30,9 +30,8 @@ #ifndef FIRSTDEFINITIONFINDER_H #define FIRSTDEFINITIONFINDER_H -#include "qmldocument.h" - -#include <qmljsastvisitor_p.h> +#include <qmljs/parser/qmljsastvisitor_p.h> +#include <qmljs/qmldocument.h> namespace QmlDesigner { @@ -52,7 +51,7 @@ protected: void extractFirstObjectDefinition(QmlJS::AST::UiObjectInitializer* ast); private: - QmlDesigner::QmlDocument::Ptr m_doc; + Qml::QmlDocument::Ptr m_doc; quint32 m_offset; QmlJS::AST::UiObjectDefinition *m_firstObjectDefinition; diff --git a/src/plugins/qmldesigner/core/filemanager/idcollector.cpp b/src/plugins/qmldesigner/core/filemanager/idcollector.cpp deleted file mode 100644 index 26ccfc18574..00000000000 --- a/src/plugins/qmldesigner/core/filemanager/idcollector.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2009 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 "idcollector.h" -#include "qmljsast_p.h" -#include "qmljsengine_p.h" - -using namespace QmlJS; -using namespace QmlJS::AST; -using namespace QmlDesigner; -using namespace QmlDesigner::Internal; - -QMap<QString, QmlIdSymbol*> IdCollector::operator()(const QString &fileName, QmlJS::AST::UiProgram *ast) -{ - _fileName = fileName; - _ids.clear(); - - Node::accept(ast, this); - - return _ids; -} - -bool IdCollector::visit(QmlJS::AST::UiObjectBinding *ast) -{ - _scopes.push(ast); - return true; -} - -bool IdCollector::visit(QmlJS::AST::UiObjectDefinition *ast) -{ - _scopes.push(ast); - return true; -} - -void IdCollector::endVisit(QmlJS::AST::UiObjectBinding *) -{ - _scopes.pop(); -} - -void IdCollector::endVisit(QmlJS::AST::UiObjectDefinition *) -{ - _scopes.pop(); -} - -bool IdCollector::visit(QmlJS::AST::UiScriptBinding *ast) -{ - if (!(ast->qualifiedId->next) && ast->qualifiedId->name->asString() == "id") - if (ExpressionStatement *e = cast<ExpressionStatement*>(ast->statement)) - if (IdentifierExpression *i = cast<IdentifierExpression*>(e->expression)) - addId(i->name->asString(), ast); - - return false; -} - -void IdCollector::addId(const QString &id, QmlJS::AST::UiScriptBinding *ast) -{ - if (!_ids.contains(id)) { - Node *parent = _scopes.top(); - - if (UiObjectBinding *binding = cast<UiObjectBinding*>(parent)) - _ids[id] = new QmlIdSymbol(_fileName, ast, QmlSymbolFromFile(_fileName, binding)); - else if (UiObjectDefinition *definition = cast<UiObjectDefinition*>(parent)) - _ids[id] = new QmlIdSymbol(_fileName, ast, QmlSymbolFromFile(_fileName, definition)); - else - Q_ASSERT(!"Unknown parent for id"); - } -} diff --git a/src/plugins/qmldesigner/core/filemanager/idcollector.h b/src/plugins/qmldesigner/core/filemanager/idcollector.h deleted file mode 100644 index edd47cff089..00000000000 --- a/src/plugins/qmldesigner/core/filemanager/idcollector.h +++ /dev/null @@ -1,69 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2009 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 IDCOLLECTOR_H -#define IDCOLLECTOR_H - -#include <QMap> -#include <QPair> -#include <QStack> -#include <QString> - -#include "qmljsastvisitor_p.h" -#include "qmlsymbol.h" - -namespace QmlDesigner { -namespace Internal { - -class IdCollector: protected QmlJS::AST::Visitor -{ -public: - QMap<QString, QmlIdSymbol*> operator()(const QString &fileName, QmlJS::AST::UiProgram *ast); - -protected: - virtual bool visit(QmlJS::AST::UiObjectBinding *ast); - virtual bool visit(QmlJS::AST::UiObjectDefinition *ast); - virtual bool visit(QmlJS::AST::UiScriptBinding *ast); - - virtual void endVisit(QmlJS::AST::UiObjectBinding *); - virtual void endVisit(QmlJS::AST::UiObjectDefinition *); - -private: - void addId(const QString &id, QmlJS::AST::UiScriptBinding *ast); - -private: - QString _fileName; - QMap<QString, QmlIdSymbol*> _ids; - QStack<QmlJS::AST::Node *> _scopes; -}; - -} // namespace Internal -} // namespace QmlDesigner - -#endif // IDCOLLECTOR_H diff --git a/src/plugins/qmldesigner/core/filemanager/indenter.cpp b/src/plugins/qmldesigner/core/filemanager/indenter.cpp deleted file mode 100644 index 86fa4511609..00000000000 --- a/src/plugins/qmldesigner/core/filemanager/indenter.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2009 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 "indenter.h" - -using namespace QmlDesigner; - -Indenter::Indenter() -{ -} - -//static int blockStartState(const QTextBlock &block) -//{ -// int state = block.userState(); -// -// if (state == -1) -// return 0; -// else -// return state & 0xff; -//} -// -//void ScriptEditor::indentBlock(QTextDocument *, QTextBlock block, QChar typedChar) -//{ -// TextEditor::TabSettings ts = tabSettings(); -// -// QTextCursor tc(block); -// -// const QString blockText = block.text(); -// int startState = blockStartState(block.previous()); -// -// QScriptIncrementalScanner scanner; -// const QList<QScriptIncrementalScanner::Token> tokens = scanner(blockText, startState); -// -// if (! tokens.isEmpty()) { -// const QScriptIncrementalScanner::Token tk = tokens.first(); -// -// if (tk.is(QScriptIncrementalScanner::Token::RightBrace) -// || tk.is(QScriptIncrementalScanner::Token::RightBracket)) { -// if (TextEditor::TextBlockUserData::findPreviousBlockOpenParenthesis(&tc)) { -// const QString text = tc.block().text(); -// int indent = ts.columnAt(text, ts.firstNonSpace(text)); -// ts.indentLine(block, indent); -// return; -// } -// } -// } -// -// int initialIndent = 0; -// for (QTextBlock it = block.previous(); it.isValid(); it = it.previous()) { -// const QString text = it.text(); -// -// if (! text.isEmpty()) { -// initialIndent = ts.columnAt(text, ts.firstNonSpace(text)); -// break; -// } -// } -// -// const int braceDepth = blockBraceDepth(block.previous()); -// const int previousBraceDepth = blockBraceDepth(block.previous().previous()); -// const int delta = qMax(0, braceDepth - previousBraceDepth); -// int indent = initialIndent + (delta * ts.m_indentSize); -// ts.indentLine(block, indent); -//} -// diff --git a/src/plugins/qmldesigner/core/filemanager/indenter.h b/src/plugins/qmldesigner/core/filemanager/indenter.h deleted file mode 100644 index 7918ad01f17..00000000000 --- a/src/plugins/qmldesigner/core/filemanager/indenter.h +++ /dev/null @@ -1,43 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2009 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 INDENTER_H -#define INDENTER_H - -namespace QmlDesigner { - -class Indenter -{ -public: - Indenter(); -}; - -} // namespace QmlDesigner - -#endif // INDENTER_H diff --git a/src/plugins/qmldesigner/core/filemanager/moveobjectbeforeobjectvisitor.cpp b/src/plugins/qmldesigner/core/filemanager/moveobjectbeforeobjectvisitor.cpp index 1aa67095712..37b987492c5 100644 --- a/src/plugins/qmldesigner/core/filemanager/moveobjectbeforeobjectvisitor.cpp +++ b/src/plugins/qmldesigner/core/filemanager/moveobjectbeforeobjectvisitor.cpp @@ -27,14 +27,14 @@ ** **************************************************************************/ -#include <QtCore/QDebug> - -#include <qmljsast_p.h> -#include <qmljsengine_p.h> - #include "moveobjectbeforeobjectvisitor.h" #include "textmodifier.h" +#include <qmljs/parser/qmljsast_p.h> +#include <qmljs/parser/qmljsengine_p.h> + +#include <QtCore/QDebug> + using namespace QmlJS; using namespace QmlJS::AST; using namespace QmlDesigner::Internal; diff --git a/src/plugins/qmldesigner/core/filemanager/moveobjectvisitor.cpp b/src/plugins/qmldesigner/core/filemanager/moveobjectvisitor.cpp index b3932fcfe27..e902d2a348d 100644 --- a/src/plugins/qmldesigner/core/filemanager/moveobjectvisitor.cpp +++ b/src/plugins/qmldesigner/core/filemanager/moveobjectvisitor.cpp @@ -27,14 +27,14 @@ ** **************************************************************************/ -#include <QtCore/QDebug> - -#include <qmljsast_p.h> -#include <qmljsengine_p.h> - #include "moveobjectvisitor.h" #include "textmodifier.h" +#include <qmljs/parser/qmljsast_p.h> +#include <qmljs/parser/qmljsengine_p.h> + +#include <QtCore/QDebug> + using namespace QmlJS; using namespace QmlJS::AST; using namespace QmlDesigner::Internal; diff --git a/src/plugins/qmldesigner/core/filemanager/objectlengthcalculator.cpp b/src/plugins/qmldesigner/core/filemanager/objectlengthcalculator.cpp index c416bbc8150..88dbe6d1db4 100644 --- a/src/plugins/qmldesigner/core/filemanager/objectlengthcalculator.cpp +++ b/src/plugins/qmldesigner/core/filemanager/objectlengthcalculator.cpp @@ -29,9 +29,9 @@ #include "objectlengthcalculator.h" -#include <qmljsast_p.h> +#include <qmljs/parser/qmljsast_p.h> -using namespace QmlDesigner; +using namespace Qml; using namespace QmlDesigner; using namespace QmlJS::AST; diff --git a/src/plugins/qmldesigner/core/filemanager/objectlengthcalculator.h b/src/plugins/qmldesigner/core/filemanager/objectlengthcalculator.h index 970d086078e..c796dfee095 100644 --- a/src/plugins/qmldesigner/core/filemanager/objectlengthcalculator.h +++ b/src/plugins/qmldesigner/core/filemanager/objectlengthcalculator.h @@ -30,9 +30,8 @@ #ifndef OBJECTLENGTHCALCULATOR_H #define OBJECTLENGTHCALCULATOR_H -#include "qmldocument.h" - -#include <qmljsastvisitor_p.h> +#include <qmljs/parser/qmljsastvisitor_p.h> +#include <qmljs/qmldocument.h> namespace QmlDesigner { @@ -50,7 +49,7 @@ protected: virtual bool visit(QmlJS::AST::UiObjectDefinition *ast); private: - QmlDocument::Ptr m_doc; + Qml::QmlDocument::Ptr m_doc; quint32 m_offset; quint32 m_length; }; diff --git a/src/plugins/qmldesigner/core/filemanager/qmldocument.cpp b/src/plugins/qmldesigner/core/filemanager/qmldocument.cpp deleted file mode 100644 index bf05f48c675..00000000000 --- a/src/plugins/qmldesigner/core/filemanager/qmldocument.cpp +++ /dev/null @@ -1,165 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2009 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 "idcollector.h" -#include "qmldocument.h" -#include "qmljsast_p.h" -#include "qmljslexer_p.h" -#include "qmljsparser_p.h" -#include "qmljsengine_p.h" -#include "qmljsnodepool_p.h" - -using namespace QmlDesigner; -using namespace QmlJS; - -QmlDocument::QmlDocument(const QString &fileName) - : _engine(0) - , _pool(0) - , _program(0) - , _fileName(fileName) - , _parsedCorrectly(false) -{ - const int slashIdx = fileName.lastIndexOf('/'); - if (slashIdx != -1) - _path = fileName.left(slashIdx); - - if (fileName.toLower().endsWith(".qml")) - _componentName = fileName.mid(slashIdx + 1, fileName.size() - (slashIdx + 1) - 4); -} - -QmlDocument::~QmlDocument() -{ - if (_engine) - delete _engine; - - if (_pool) - delete _pool; - - qDeleteAll(_ids.values()); -} - -QmlDocument::Ptr QmlDocument::create(const QString &fileName) -{ - QmlDocument::Ptr doc(new QmlDocument(fileName)); - return doc; -} - -AST::UiProgram *QmlDocument::program() const -{ - return _program; -} - -QList<DiagnosticMessage> QmlDocument::diagnosticMessages() const -{ - return _diagnosticMessages; -} - -QString QmlDocument::source() const -{ - return _source; -} - -void QmlDocument::setSource(const QString &source) -{ - _source = source; -} - -bool QmlDocument::parse() -{ - Q_ASSERT(! _engine); - Q_ASSERT(! _pool); - Q_ASSERT(! _program); - - _engine = new Engine(); - _pool = new NodePool(_fileName, _engine); - _ids.clear(); - - Lexer lexer(_engine); - Parser parser(_engine); - - lexer.setCode(_source, /*line = */ 1); - - _parsedCorrectly = parser.parse(); - _program = parser.ast(); - _diagnosticMessages = parser.diagnosticMessages(); - - if (_parsedCorrectly && _program) { - Internal::IdCollector collect; - _ids = collect(_fileName, _program); - } - - return _parsedCorrectly; -} - -Snapshot::Snapshot() -{ -} - -Snapshot::~Snapshot() -{ -} - -void Snapshot::insert(const QmlDocument::Ptr &document) -{ - QMap<QString, QmlDocument::Ptr>::insert(document->fileName(), document); -} - -QmlDocument::PtrList Snapshot::importedDocuments(const QmlDocument::Ptr &doc, const QString &importPath) const -{ - QmlDocument::PtrList result; - - const QString docPath = doc->path() + '/' + importPath; - - foreach (QmlDocument::Ptr candidate, *this) { - if (candidate == doc) - continue; - - if (candidate->path() == doc->path() || candidate->path() == docPath) - result.append(candidate); - } - - return result; -} - -QMap<QString, QmlDocument::Ptr> Snapshot::componentsDefinedByImportedDocuments(const QmlDocument::Ptr &doc, const QString &importPath) const -{ - QMap<QString, QmlDocument::Ptr> result; - - const QString docPath = doc->path() + '/' + importPath; - - foreach (QmlDocument::Ptr candidate, *this) { - if (candidate == doc) - continue; - - if (candidate->path() == doc->path() || candidate->path() == docPath) - result.insert(candidate->componentName(), candidate); - } - - return result; -} diff --git a/src/plugins/qmldesigner/core/filemanager/qmldocument.h b/src/plugins/qmldesigner/core/filemanager/qmldocument.h deleted file mode 100644 index c9cfaa6adfb..00000000000 --- a/src/plugins/qmldesigner/core/filemanager/qmldocument.h +++ /dev/null @@ -1,109 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2009 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 QMLDOCUMENT_H -#define QMLDOCUMENT_H - -#include <corelib_global.h> - -#include <QtCore/QList> -#include <QtCore/QMap> -#include <QtCore/QPair> -#include <QtCore/QSharedPointer> -#include <QtCore/QString> - -#include "qmleditor_global.h" -#include "qmljsengine_p.h" -#include "qmljsastfwd_p.h" -#include "qmlsymbol.h" - -namespace QmlDesigner { - -class CORESHARED_EXPORT QmlDocument -{ -public: - typedef QSharedPointer<QmlDocument> Ptr; - typedef QList<QmlDocument::Ptr> PtrList; - typedef QMap<QString, QmlIdSymbol*> IdTable; - -protected: - QmlDocument(const QString &fileName); - -public: - ~QmlDocument(); - - static QmlDocument::Ptr create(const QString &fileName); - - QmlJS::AST::UiProgram *program() const; - QList<QmlJS::DiagnosticMessage> diagnosticMessages() const; - - QString source() const; - void setSource(const QString &source); - - bool parse(); - - bool isParsedCorrectly() const - { return _parsedCorrectly; } - - IdTable ids() const { return _ids; } - - QString fileName() const { return _fileName; } - QString path() const { return _path; } - QString componentName() const { return _componentName; } - -private: - QmlJS::Engine *_engine; - QmlJS::NodePool *_pool; - QmlJS::AST::UiProgram *_program; - QList<QmlJS::DiagnosticMessage> _diagnosticMessages; - QString _fileName; - QString _path; - QString _componentName; - QString _source; - bool _parsedCorrectly; - IdTable _ids; -}; - -class CORESHARED_EXPORT Snapshot: public QMap<QString, QmlDocument::Ptr> -{ -public: - Snapshot(); - ~Snapshot(); - - void insert(const QmlDocument::Ptr &document); - - QmlDocument::Ptr document(const QString &fileName) const - { return value(fileName); } - - QmlDocument::PtrList importedDocuments(const QmlDocument::Ptr &doc, const QString &importPath) const; - QMap<QString, QmlDocument::Ptr> componentsDefinedByImportedDocuments(const QmlDocument::Ptr &doc, const QString &importPath) const; -}; - -} // emd of namespace QmlDesigner - -#endif // QMLDOCUMENT_H diff --git a/src/plugins/qmldesigner/core/filemanager/qmlrefactoring.cpp b/src/plugins/qmldesigner/core/filemanager/qmlrefactoring.cpp index 86165c6d8fe..9a97350cdf1 100644 --- a/src/plugins/qmldesigner/core/filemanager/qmlrefactoring.cpp +++ b/src/plugins/qmldesigner/core/filemanager/qmlrefactoring.cpp @@ -40,10 +40,11 @@ #include "removepropertyvisitor.h" #include "removeuiobjectmembervisitor.h" +using namespace Qml; using namespace QmlDesigner; using namespace QmlDesigner::Internal; -QmlRefactoring::QmlRefactoring(const QmlDocument::Ptr &doc, QmlDesigner::TextModifier &modifier, const QStringList &propertyOrder): +QmlRefactoring::QmlRefactoring(const QmlDocument::Ptr &doc, TextModifier &modifier, const QStringList &propertyOrder): qmlDocument(doc), textModifier(&modifier), m_propertyOrder(propertyOrder) @@ -56,7 +57,7 @@ bool QmlRefactoring::reparseDocument() // qDebug() << "QmlRefactoring::reparseDocument() new QML source:" << newSource; - QmlDesigner::QmlDocument::Ptr tmpDocument(QmlDesigner::QmlDocument::create("<ModelToTextMerger>")); + QmlDocument::Ptr tmpDocument(QmlDocument::create("<ModelToTextMerger>")); tmpDocument->setSource(newSource); if (tmpDocument->parse()) { diff --git a/src/plugins/qmldesigner/core/filemanager/qmlrefactoring.h b/src/plugins/qmldesigner/core/filemanager/qmlrefactoring.h index eff1d4318c1..c149ef0b404 100644 --- a/src/plugins/qmldesigner/core/filemanager/qmlrefactoring.h +++ b/src/plugins/qmldesigner/core/filemanager/qmlrefactoring.h @@ -32,7 +32,7 @@ #include <import.h> #include <textmodifier.h> -#include <filemanager/qmldocument.h> +#include <qmljs/qmldocument.h> #include <QSet> #include <QString> @@ -51,7 +51,7 @@ public: }; public: - QmlRefactoring(const QmlDocument::Ptr &doc, QmlDesigner::TextModifier &modifier, const QStringList &propertyOrder); + QmlRefactoring(const Qml::QmlDocument::Ptr &doc, QmlDesigner::TextModifier &modifier, const QStringList &propertyOrder); bool reparseDocument(); @@ -70,8 +70,8 @@ public: bool removeProperty(int parentLocation, const QString &name); private: - QmlDocument::Ptr qmlDocument; - QmlDesigner::TextModifier *textModifier; + Qml::QmlDocument::Ptr qmlDocument; + TextModifier *textModifier; QStringList m_propertyOrder; }; diff --git a/src/plugins/qmldesigner/core/filemanager/qmlrewriter.cpp b/src/plugins/qmldesigner/core/filemanager/qmlrewriter.cpp index e9542212e5b..95d5aa579d6 100644 --- a/src/plugins/qmldesigner/core/filemanager/qmlrewriter.cpp +++ b/src/plugins/qmldesigner/core/filemanager/qmlrewriter.cpp @@ -27,13 +27,13 @@ ** **************************************************************************/ -#include <QDebug> -#include <QTextBlock> +#include "qmlrewriter.h" -#include <qmljsast_p.h> -#include <qmljsengine_p.h> +#include <qmljs/parser/qmljsast_p.h> +#include <qmljs/parser/qmljsengine_p.h> -#include "qmlrewriter.h" +#include <QDebug> +#include <QTextBlock> #include <typeinfo> diff --git a/src/plugins/qmldesigner/core/filemanager/qmlrewriter.h b/src/plugins/qmldesigner/core/filemanager/qmlrewriter.h index 335bc701696..8635d3bebce 100644 --- a/src/plugins/qmldesigner/core/filemanager/qmlrewriter.h +++ b/src/plugins/qmldesigner/core/filemanager/qmlrewriter.h @@ -30,12 +30,12 @@ #ifndef QMLREWRITER_H #define QMLREWRITER_H -#include <QtCore/QStack> -#include <QtCore/QString> +#include "textmodifier.h" -#include <qmljsastvisitor_p.h> +#include <qmljs/parser/qmljsastvisitor_p.h> -#include "textmodifier.h" +#include <QtCore/QStack> +#include <QtCore/QString> namespace QmlDesigner { namespace Internal { diff --git a/src/plugins/qmldesigner/core/filemanager/qmlsymbol.cpp b/src/plugins/qmldesigner/core/filemanager/qmlsymbol.cpp deleted file mode 100644 index 4d561e764f4..00000000000 --- a/src/plugins/qmldesigner/core/filemanager/qmlsymbol.cpp +++ /dev/null @@ -1,116 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2009 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 "qmljsast_p.h" -#include "qmlsymbol.h" - -using namespace QmlDesigner; -using namespace QmlJS; -using namespace QmlJS::AST; - -QmlSymbol::~QmlSymbol() -{ -} - -bool QmlSymbol::isBuildInSymbol() const -{ return asBuildInSymbol() != 0; } - -bool QmlSymbol::isSymbolFromFile() const -{ return asSymbolFromFile() != 0; } - -bool QmlSymbol::isIdSymbol() const -{ return asIdSymbol() != 0; } - -QmlBuildInSymbol const *QmlSymbol::asBuildInSymbol() const -{ return 0; } - -QmlSymbolFromFile const *QmlSymbol::asSymbolFromFile() const -{ return 0; } - -QmlIdSymbol const *QmlSymbol::asIdSymbol() const -{ return 0; } - -QmlBuildInSymbol::~QmlBuildInSymbol() -{} - -QmlBuildInSymbol const* QmlBuildInSymbol::asBuildInSymbol() const -{ return this; } - -QmlSymbolFromFile::QmlSymbolFromFile(const QString &fileName, QmlJS::AST::UiObjectMember *node): - _fileName(fileName), - _node(node) -{} - -QmlSymbolFromFile::~QmlSymbolFromFile() -{} - -const QmlSymbolFromFile *QmlSymbolFromFile::asSymbolFromFile() const -{ return this; } - -int QmlSymbolFromFile::line() const -{ return _node->firstSourceLocation().startLine; } - -int QmlSymbolFromFile::column() const -{ return _node->firstSourceLocation().startColumn; } - -QmlIdSymbol::QmlIdSymbol(const QString &fileName, QmlJS::AST::UiScriptBinding *idNode, const QmlSymbolFromFile &parentNode): - QmlSymbolFromFile(fileName, idNode), - _parentNode(parentNode) -{} - -QmlIdSymbol::~QmlIdSymbol() -{} - -QmlIdSymbol const *QmlIdSymbol::asIdSymbol() const -{ return this; } - -int QmlIdSymbol::line() const -{ return idNode()->statement->firstSourceLocation().startLine; } - -int QmlIdSymbol::column() const -{ return idNode()->statement->firstSourceLocation().startColumn; } - -QmlJS::AST::UiScriptBinding *QmlIdSymbol::idNode() const -{ return cast<UiScriptBinding*>(node()); } - -QmlPropertyDefinitionSymbol::QmlPropertyDefinitionSymbol(const QString &fileName, QmlJS::AST::UiPublicMember *propertyNode): - QmlSymbolFromFile(fileName, propertyNode) -{} - -QmlPropertyDefinitionSymbol::~QmlPropertyDefinitionSymbol() -{} - -int QmlPropertyDefinitionSymbol::line() const -{ return propertyNode()->identifierToken.startLine; } - -int QmlPropertyDefinitionSymbol::column() const -{ return propertyNode()->identifierToken.startColumn; } - -QmlJS::AST::UiPublicMember *QmlPropertyDefinitionSymbol::propertyNode() const -{ return cast<UiPublicMember*>(node()); } diff --git a/src/plugins/qmldesigner/core/filemanager/qmlsymbol.h b/src/plugins/qmldesigner/core/filemanager/qmlsymbol.h deleted file mode 100644 index 197cfb9fa5f..00000000000 --- a/src/plugins/qmldesigner/core/filemanager/qmlsymbol.h +++ /dev/null @@ -1,121 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2009 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 QMLSYMBOL_H -#define QMLSYMBOL_H - -#include <QString> - -#include "qmljsastfwd_p.h" - -namespace QmlDesigner { - -class QmlSymbol -{ -public: - virtual ~QmlSymbol() = 0; - - bool isBuildInSymbol() const; - bool isSymbolFromFile() const; - bool isIdSymbol() const; - - virtual class QmlBuildInSymbol const *asBuildInSymbol() const; - virtual class QmlSymbolFromFile const *asSymbolFromFile() const; - virtual class QmlIdSymbol const *asIdSymbol() const; -}; - -class QmlBuildInSymbol: public QmlSymbol -{ -public: - virtual ~QmlBuildInSymbol(); - - virtual QmlBuildInSymbol const *asBuildInSymbol() const; - -private: -}; - -class QmlSymbolFromFile: public QmlSymbol -{ -public: - QmlSymbolFromFile(const QString &fileName, QmlJS::AST::UiObjectMember *node); - virtual ~QmlSymbolFromFile(); - - virtual QmlSymbolFromFile const *asSymbolFromFile() const; - - QString fileName() const - { return _fileName; } - - virtual int line() const; - virtual int column() const; - - QmlJS::AST::UiObjectMember *node() const - { return _node; } - -private: - QString _fileName; - QmlJS::AST::UiObjectMember *_node; -}; - -class QmlIdSymbol: public QmlSymbolFromFile -{ -public: - QmlIdSymbol(const QString &fileName, QmlJS::AST::UiScriptBinding *idNode, const QmlSymbolFromFile &parentNode); - virtual ~QmlIdSymbol(); - - QmlIdSymbol const *asIdSymbol() const; - - virtual int line() const; - virtual int column() const; - - QmlSymbolFromFile const *parentNode() const - { return &_parentNode; } - -private: - QmlJS::AST::UiScriptBinding *idNode() const; - -private: - QmlSymbolFromFile _parentNode; -}; - -class QmlPropertyDefinitionSymbol: public QmlSymbolFromFile -{ -public: - QmlPropertyDefinitionSymbol(const QString &fileName, QmlJS::AST::UiPublicMember *propertyNode); - virtual ~QmlPropertyDefinitionSymbol(); - - virtual int line() const; - virtual int column() const; - -private: - QmlJS::AST::UiPublicMember *propertyNode() const; -}; - -} // namespace QmlDesigner - -#endif // QMLSYMBOL_H diff --git a/src/plugins/qmldesigner/core/filemanager/removepropertyvisitor.cpp b/src/plugins/qmldesigner/core/filemanager/removepropertyvisitor.cpp index e59a0cab6d9..0698e34cc06 100644 --- a/src/plugins/qmldesigner/core/filemanager/removepropertyvisitor.cpp +++ b/src/plugins/qmldesigner/core/filemanager/removepropertyvisitor.cpp @@ -27,11 +27,11 @@ ** **************************************************************************/ -#include <qmljsast_p.h> -#include <qmljsengine_p.h> - #include "removepropertyvisitor.h" +#include <qmljs/parser/qmljsast_p.h> +#include <qmljs/parser/qmljsengine_p.h> + using namespace QmlDesigner::Internal; using namespace QmlJS; using namespace QmlJS::AST; diff --git a/src/plugins/qmldesigner/core/filemanager/removeuiobjectmembervisitor.cpp b/src/plugins/qmldesigner/core/filemanager/removeuiobjectmembervisitor.cpp index ec5ff404b76..812bcbc0efe 100644 --- a/src/plugins/qmldesigner/core/filemanager/removeuiobjectmembervisitor.cpp +++ b/src/plugins/qmldesigner/core/filemanager/removeuiobjectmembervisitor.cpp @@ -27,12 +27,13 @@ ** **************************************************************************/ -#include <QDebug> -#include <qmljsast_p.h> -#include <qmljsengine_p.h> - #include "removeuiobjectmembervisitor.h" +#include <qmljs/parser/qmljsast_p.h> +#include <qmljs/parser/qmljsengine_p.h> + +#include <QDebug> + using namespace QmlDesigner; using namespace QmlDesigner::Internal; using namespace QmlJS; diff --git a/src/plugins/qmldesigner/core/filemanager/utils_global.h b/src/plugins/qmldesigner/core/filemanager/utils_global.h deleted file mode 100644 index a97322e5c9e..00000000000 --- a/src/plugins/qmldesigner/core/filemanager/utils_global.h +++ /dev/null @@ -1,37 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2009 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 UTILS_GLOBAL_H -#define UTILS_GLOBAL_H - -#include <QtCore/qglobal.h> - -#define QTCREATOR_UTILS_EXPORT - -#endif // UTILS_GLOBAL_H diff --git a/src/plugins/qmldesigner/core/model/modeltotextmerger.cpp b/src/plugins/qmldesigner/core/model/modeltotextmerger.cpp index 362573a7735..16947a495ac 100644 --- a/src/plugins/qmldesigner/core/model/modeltotextmerger.cpp +++ b/src/plugins/qmldesigner/core/model/modeltotextmerger.cpp @@ -32,16 +32,19 @@ #include "qmltextgenerator.h" #include "rewriteactioncompressor.h" #include "rewriterview.h" -#include <filemanager/qmldocument.h> -#include <QDebug> + +#include <qmljs/qmldocument.h> #include <variantproperty.h> #include <nodelistproperty.h> #include <nodeproperty.h> #include <textmodifier.h> +#include <QDebug> + #define INDENT_DEPTH 4 #undef DUMP_REWRITE_ACTIONS +using namespace Qml; using namespace QmlDesigner; using namespace QmlDesigner::Internal; diff --git a/src/plugins/qmldesigner/core/model/plaintexteditmodifier.cpp b/src/plugins/qmldesigner/core/model/plaintexteditmodifier.cpp index d6ff674cdd9..76ff4e510c4 100644 --- a/src/plugins/qmldesigner/core/model/plaintexteditmodifier.cpp +++ b/src/plugins/qmldesigner/core/model/plaintexteditmodifier.cpp @@ -32,7 +32,7 @@ #include <QtGui/QPlainTextEdit> #include <QtGui/QUndoStack> -#include <filemanager/changeset.h> +#include <utils/changeset.h> #include "plaintexteditmodifier.h" diff --git a/src/plugins/qmldesigner/qmldesigner_dependencies.pri b/src/plugins/qmldesigner/qmldesigner_dependencies.pri index 384afa46750..a8477ab6267 100644 --- a/src/plugins/qmldesigner/qmldesigner_dependencies.pri +++ b/src/plugins/qmldesigner/qmldesigner_dependencies.pri @@ -1,4 +1,4 @@ include(../../libs/utils/utils.pri) -include(../../libs/qml/qml.pri) +include(../../libs/qmljs/qmljs.pri) include(../coreplugin/coreplugin.pri) include(../texteditor/texteditor.pri) diff --git a/src/plugins/qmleditor/qmlcodecompletion.cpp b/src/plugins/qmleditor/qmlcodecompletion.cpp index 48fa5512a1a..725748bd0b6 100644 --- a/src/plugins/qmleditor/qmlcodecompletion.cpp +++ b/src/plugins/qmleditor/qmlcodecompletion.cpp @@ -34,7 +34,7 @@ #include "qmllookupcontext.h" #include "qmlresolveexpression.h" -#include <qml/qmlsymbol.h> +#include <qmljs/qmlsymbol.h> #include <texteditor/basetexteditor.h> #include <QtDebug> diff --git a/src/plugins/qmleditor/qmlcodecompletion.h b/src/plugins/qmleditor/qmlcodecompletion.h index a8b864dcdec..86305607a30 100644 --- a/src/plugins/qmleditor/qmlcodecompletion.h +++ b/src/plugins/qmleditor/qmlcodecompletion.h @@ -30,7 +30,7 @@ #ifndef QMLCODECOMPLETION_H #define QMLCODECOMPLETION_H -#include <qml/metatype/qmltypesystem.h> +#include <qmljs/qmltypesystem.h> #include <texteditor/icompletioncollector.h> namespace TextEditor { diff --git a/src/plugins/qmleditor/qmleditor.cpp b/src/plugins/qmleditor/qmleditor.cpp index 4513984d4a6..b3bb4aed635 100644 --- a/src/plugins/qmleditor/qmleditor.cpp +++ b/src/plugins/qmleditor/qmleditor.cpp @@ -39,12 +39,12 @@ #include <qscripthighlighter/qscriptindenter.h> -#include <qml/metatype/qmltypesystem.h> -#include <qml/parser/qmljsastvisitor_p.h> -#include <qml/parser/qmljsast_p.h> -#include <qml/parser/qmljsengine_p.h> -#include <qml/qmldocument.h> -#include <qml/qmlidcollector.h> +#include <qmljs/qmltypesystem.h> +#include <qmljs/parser/qmljsastvisitor_p.h> +#include <qmljs/parser/qmljsast_p.h> +#include <qmljs/parser/qmljsengine_p.h> +#include <qmljs/qmldocument.h> +#include <qmljs/qmlidcollector.h> #include <coreplugin/icore.h> #include <coreplugin/actionmanager/actionmanager.h> diff --git a/src/plugins/qmleditor/qmleditor.h b/src/plugins/qmleditor/qmleditor.h index 8e220bf022c..4d5f9101da7 100644 --- a/src/plugins/qmleditor/qmleditor.h +++ b/src/plugins/qmleditor/qmleditor.h @@ -30,7 +30,7 @@ #ifndef QMLEDITORW_H #define QMLEDITORW_H -#include <qml/qmldocument.h> +#include <qmljs/qmldocument.h> #include <qscripthighlighter/qscriptincrementalscanner.h> #include <texteditor/basetexteditor.h> diff --git a/src/plugins/qmleditor/qmleditor_dependencies.pri b/src/plugins/qmleditor/qmleditor_dependencies.pri index 0075f51fe88..0e3c0a210bd 100644 --- a/src/plugins/qmleditor/qmleditor_dependencies.pri +++ b/src/plugins/qmleditor/qmleditor_dependencies.pri @@ -2,5 +2,5 @@ include(../../plugins/coreplugin/coreplugin.pri) include(../../plugins/texteditor/texteditor.pri) include(../../plugins/help/help.pri) include(../../shared/indenter/indenter.pri) -include(../../libs/qml/qml.pri) +include(../../libs/qmljs/qmljs.pri) include(../../libs/utils/utils.pri) diff --git a/src/plugins/qmleditor/qmlexpressionundercursor.cpp b/src/plugins/qmleditor/qmlexpressionundercursor.cpp index 47e852e13da..feda2b13dce 100644 --- a/src/plugins/qmleditor/qmlexpressionundercursor.cpp +++ b/src/plugins/qmleditor/qmlexpressionundercursor.cpp @@ -29,12 +29,12 @@ #include "qmlexpressionundercursor.h" -#include <qml/parser/qmljsast_p.h> -#include <qml/parser/qmljsastvisitor_p.h> -#include <qml/parser/qmljsengine_p.h> -#include <qml/parser/qmljslexer_p.h> -#include <qml/parser/qmljsnodepool_p.h> -#include <qml/parser/qmljsparser_p.h> +#include <qmljs/parser/qmljsast_p.h> +#include <qmljs/parser/qmljsastvisitor_p.h> +#include <qmljs/parser/qmljsengine_p.h> +#include <qmljs/parser/qmljslexer_p.h> +#include <qmljs/parser/qmljsnodepool_p.h> +#include <qmljs/parser/qmljsparser_p.h> #include <QDebug> diff --git a/src/plugins/qmleditor/qmlexpressionundercursor.h b/src/plugins/qmleditor/qmlexpressionundercursor.h index 11b46a60ead..e054d913054 100644 --- a/src/plugins/qmleditor/qmlexpressionundercursor.h +++ b/src/plugins/qmleditor/qmlexpressionundercursor.h @@ -31,9 +31,9 @@ #define QMLEXPRESSIONUNDERCURSOR_H -#include <qml/parser/qmljsastfwd_p.h> -#include <qml/qmldocument.h> -#include <qml/qmlsymbol.h> +#include <qmljs/parser/qmljsastfwd_p.h> +#include <qmljs/qmldocument.h> +#include <qmljs/qmlsymbol.h> #include <QStack> #include <QTextBlock> diff --git a/src/plugins/qmleditor/qmlhoverhandler.cpp b/src/plugins/qmleditor/qmlhoverhandler.cpp index 799a669b709..d508489e815 100644 --- a/src/plugins/qmleditor/qmlhoverhandler.cpp +++ b/src/plugins/qmleditor/qmlhoverhandler.cpp @@ -38,7 +38,7 @@ #include <coreplugin/editormanager/editormanager.h> #include <debugger/debuggerconstants.h> #include <extensionsystem/pluginmanager.h> -#include <qml/qmlsymbol.h> +#include <qmljs/qmlsymbol.h> #include <texteditor/itexteditor.h> #include <texteditor/basetexteditor.h> diff --git a/src/plugins/qmleditor/qmllookupcontext.cpp b/src/plugins/qmleditor/qmllookupcontext.cpp index 77369e61424..f3103118164 100644 --- a/src/plugins/qmleditor/qmllookupcontext.cpp +++ b/src/plugins/qmleditor/qmllookupcontext.cpp @@ -31,9 +31,9 @@ #include "qmllookupcontext.h" #include "qmlresolveexpression.h" -#include <qml/metatype/qmltypesystem.h> -#include <qml/parser/qmljsast_p.h> -#include <qml/parser/qmljsengine_p.h> +#include <qmljs/parser/qmljsast_p.h> +#include <qmljs/parser/qmljsengine_p.h> +#include <qmljs/qmltypesystem.h> #include <QDebug> diff --git a/src/plugins/qmleditor/qmllookupcontext.h b/src/plugins/qmleditor/qmllookupcontext.h index 7f2f300ee2c..b406d087cad 100644 --- a/src/plugins/qmleditor/qmllookupcontext.h +++ b/src/plugins/qmleditor/qmllookupcontext.h @@ -30,10 +30,10 @@ #ifndef QMLLOOKUPCONTEXT_H #define QMLLOOKUPCONTEXT_H -#include <qml/metatype/qmltypesystem.h> -#include <qml/parser/qmljsastvisitor_p.h> -#include <qml/qmldocument.h> -#include <qml/qmlsymbol.h> +#include <qmljs/qmltypesystem.h> +#include <qmljs/parser/qmljsastvisitor_p.h> +#include <qmljs/qmldocument.h> +#include <qmljs/qmlsymbol.h> #include <QStack> diff --git a/src/plugins/qmleditor/qmlmodelmanager.h b/src/plugins/qmleditor/qmlmodelmanager.h index 25ed28ac9b2..dbc6d490cfa 100644 --- a/src/plugins/qmleditor/qmlmodelmanager.h +++ b/src/plugins/qmleditor/qmlmodelmanager.h @@ -32,7 +32,7 @@ #include "qmlmodelmanagerinterface.h" -#include <qml/qmldocument.h> +#include <qmljs/qmldocument.h> #include <QFuture> #include <QFutureSynchronizer> diff --git a/src/plugins/qmleditor/qmlmodelmanagerinterface.h b/src/plugins/qmleditor/qmlmodelmanagerinterface.h index a221e6d13c7..9de2e97dcb0 100644 --- a/src/plugins/qmleditor/qmlmodelmanagerinterface.h +++ b/src/plugins/qmleditor/qmlmodelmanagerinterface.h @@ -36,8 +36,8 @@ #include <QStringList> #include <QSharedPointer> -#include <qml/qmldocument.h> -#include <qml/metatype/qmltypesystem.h> +#include <qmljs/qmldocument.h> +#include <qmljs/qmltypesystem.h> namespace Qml { diff --git a/src/plugins/qmleditor/qmlresolveexpression.cpp b/src/plugins/qmleditor/qmlresolveexpression.cpp index 72eeebdcb5b..2a626851b30 100644 --- a/src/plugins/qmleditor/qmlresolveexpression.cpp +++ b/src/plugins/qmleditor/qmlresolveexpression.cpp @@ -29,8 +29,8 @@ #include "qmlresolveexpression.h" -#include <qml/parser/qmljsast_p.h> -#include <qml/parser/qmljsengine_p.h> +#include <qmljs/parser/qmljsast_p.h> +#include <qmljs/parser/qmljsengine_p.h> using namespace Qml; using namespace QmlEditor; diff --git a/src/plugins/qmleditor/qmlresolveexpression.h b/src/plugins/qmleditor/qmlresolveexpression.h index 64b603f6ae6..0e01f21cc38 100644 --- a/src/plugins/qmleditor/qmlresolveexpression.h +++ b/src/plugins/qmleditor/qmlresolveexpression.h @@ -32,8 +32,8 @@ #include "qmllookupcontext.h" -#include <qml/parser/qmljsastvisitor_p.h> -#include <qml/qmlsymbol.h> +#include <qmljs/parser/qmljsastvisitor_p.h> +#include <qmljs/qmlsymbol.h> namespace QmlEditor { namespace Internal { diff --git a/src/plugins/qmlprojectmanager/qmltaskmanager.h b/src/plugins/qmlprojectmanager/qmltaskmanager.h index 460f09005dd..dd7561f2d88 100644 --- a/src/plugins/qmlprojectmanager/qmltaskmanager.h +++ b/src/plugins/qmlprojectmanager/qmltaskmanager.h @@ -31,7 +31,7 @@ #define QMLTASKMANAGER_H #include <projectexplorer/taskwindow.h> -#include <qml/qmldocument.h> +#include <qmljs/qmldocument.h> #include <QtCore/QObject> diff --git a/src/shared/qml/metatype/exception.cpp b/src/shared/qml/metatype/exception.cpp deleted file mode 100644 index 7c7c228c4c1..00000000000 --- a/src/shared/qml/metatype/exception.cpp +++ /dev/null @@ -1,191 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2009 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 "exception.h" - -#ifdef Q_OS_LINUX -#include <execinfo.h> -#include <cxxabi.h> -#endif - -#include <QDebug> -#include <QRegExp> - -/*! -\defgroup CoreExceptions -*/ -/*! -\class Qml::Exception -\ingroup CoreExceptions -\brief This is the abstract base class for all excetions. - Exceptions should be used in cases there is no other way to say something goes wrong. For example - the result would be a inconsistent model or a crash. -*/ - -using namespace Qml; - -#ifdef Q_OS_LINUX -const char* demangle(const char* name) -{ - char buf[1024]; - size_t size = 1024; - int status; - char* res; - res = abi::__cxa_demangle(name, - buf, - &size, - &status); - return res; -} -#else -const char* demangle(const char* name) -{ - return name; -} -#endif - - -bool Exception::s_shouldAssert = false; - -void Exception::setShouldAssert(bool assert) -{ - s_shouldAssert = assert; -} - -bool Exception::shouldAssert() -{ - return s_shouldAssert; -} - -/*! -\brief Constructor - -\param line use the __LINE__ macro -\param function use the __FUNCTION__ or the Q_FUNC_INFO macro -\param file use the __FILE__ macro -*/ -Exception::Exception(int line, - const QString &function, - const QString &file) - : m_line(line), - m_function(function), - m_file(file) -{ -#ifdef Q_OS_LINUX - void * array[50]; - int nSize = backtrace(array, 50); - char ** symbols = backtrace_symbols(array, nSize); - - for (int i = 0; i < nSize; i++) - { - m_backTrace.append(QString("%1\n").arg(symbols[i])); - } - - free(symbols); -#endif - -if (s_shouldAssert) - Q_ASSERT_X(false, function.toLatin1(), QString("%1:%2 - %3").arg(file).arg(line).arg(function).toLatin1()); -} - -Exception::~Exception() -{ -} - -/*! -\brief Returns the unmangled backtrace of this exception - -\returns the backtrace as a string -*/ -QString Exception::backTrace() const -{ - return m_backTrace; -} - -/*! -\brief Returns the optional description of this exception - -\returns the description as string -*/ -QString Exception::description() const -{ - return QString(); -} - -/*! -\brief Returns the line number where this exception was thrown - -\returns the line number as integer -*/ -int Exception::line() const -{ - return m_line; -} - -/*! -\brief Returns the function name where this exception was thrown - -\returns the function name as string -*/ -QString Exception::function() const -{ - return m_function; -} - -/*! -\brief Returns the file name where this exception was thrown - -\returns the file name as string -*/ -QString Exception::file() const -{ - return m_file; -} - -QDebug operator<<(QDebug debug, const Exception &exception) -{ - debug.nospace() << "Exception: " << exception.type() << "\n" - "Function: " << exception.function() << "\n" - "File: " << exception.file() << "\n" - "Line: " << exception.line() << "\n"; - if (!exception.description().isEmpty()) - debug.nospace() << exception.description(); - - if (!exception.backTrace().isEmpty()) - debug.nospace() << exception.backTrace(); - - return debug.space(); -} - -/*! -\fn QString Exception::type() const -\brief Returns the type of this exception - -\returns the type as a string -*/ diff --git a/src/shared/qml/metatype/exception.h b/src/shared/qml/metatype/exception.h deleted file mode 100644 index 152a09c871e..00000000000 --- a/src/shared/qml/metatype/exception.h +++ /dev/null @@ -1,70 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2009 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 EXCEPTION_H -#define EXCEPTION_H - -#include <qml/qml_global.h> - -#include <QString> - -namespace Qml { - -class QML_EXPORT Exception -{ -public: - Exception(int line, - const QString &function, - const QString &file); - virtual ~Exception(); - - virtual QString type() const=0; - virtual QString description() const; - - int line() const; - QString function() const; - QString file() const; - QString backTrace() const; - - static void setShouldAssert(bool assert); - static bool shouldAssert(); - -private: - int m_line; - QString m_function; - QString m_file; - QString m_backTrace; - static bool s_shouldAssert; -}; - -QML_EXPORT QDebug operator<<(QDebug debug, const Exception &exception); - -} // namespace Qml - -#endif // EXCEPTION_H diff --git a/src/shared/qml/metatype/invalidmetainfoexception.cpp b/src/shared/qml/metatype/invalidmetainfoexception.cpp deleted file mode 100644 index fe2df242372..00000000000 --- a/src/shared/qml/metatype/invalidmetainfoexception.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2009 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 "invalidmetainfoexception.h" - -/*! -\class Qml::InvalidMetaInfoException -\ingroup CoreExceptions -\brief Exception for a invalid meta info - -\see NodeMetaInfo PropertyMetaInfo MetaInfo -*/ -using namespace Qml; -/*! -\brief Constructor - -\param line use the __LINE__ macro -\param function use the __FUNCTION__ or the Q_FUNC_INFO macro -\param file use the __FILE__ macro -*/ -InvalidMetaInfoException::InvalidMetaInfoException(int line, - const QString &function, - const QString &file) - : Exception(line, function, file) -{ -} - -/*! -\brief Returns the type of this exception - -\returns the type as a string -*/ -QString InvalidMetaInfoException::type() const -{ - return "InvalidMetaInfoException"; -} diff --git a/src/shared/qml/metatype/invalidmetainfoexception.h b/src/shared/qml/metatype/invalidmetainfoexception.h deleted file mode 100644 index 219833f7a0f..00000000000 --- a/src/shared/qml/metatype/invalidmetainfoexception.h +++ /dev/null @@ -1,50 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2009 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 INVALIDMETAINFOEXCEPTION_H -#define INVALIDMETAINFOEXCEPTION_H - -#include "exception.h" - -namespace Qml { - -class QML_EXPORT InvalidMetaInfoException : public Exception -{ -public: - InvalidMetaInfoException(int line, - const QString &function, - const QString &file); - - QString type() const; - -}; - -} - -#endif // INVALIDMETAINFOEXCEPTION_H diff --git a/src/shared/qml/metatype/metainfo.cpp b/src/shared/qml/metatype/metainfo.cpp deleted file mode 100644 index a95ea9e8339..00000000000 --- a/src/shared/qml/metatype/metainfo.cpp +++ /dev/null @@ -1,489 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2009 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 "invalidmetainfoexception.h" -#include "metainfo.h" -#include "propertymetainfo.h" - -#include <QDebug> -#include <QPair> -#include <QtAlgorithms> -#include <QMetaProperty> -#include <QmlMetaType> - -enum { - debug = false -}; - -namespace Qml { -namespace Internal { - -class MetaInfoPrivate -{ - Q_DISABLE_COPY(MetaInfoPrivate) -public: - typedef QSharedPointer<MetaInfoPrivate> Pointer; - typedef QWeakPointer<MetaInfoPrivate> WeakPointer; - - - MetaInfoPrivate(MetaInfo *q); - void clear(); - - void initialize(); - void parseQmlTypes(); - void parseNonQmlTypes(); - void parseValueTypes(); - void parseNonQmlClassRecursively(const QMetaObject *qMetaObject); - void parseProperties(NodeMetaInfo &nodeMetaInfo, const QMetaObject *qMetaObject) const; - void parseClassInfo(NodeMetaInfo &nodeMetaInfo, const QMetaObject *qMetaObject) const; - - QString typeName(const QMetaObject *qMetaObject) const; - - void parseXmlFiles(); - - QMultiHash<QString, QString> m_superClassHash; // the list of direct superclasses - QHash<QString, NodeMetaInfo> m_nodeMetaInfoHash; - QHash<QString, QString> m_QtTypesToQmlTypes; - - MetaInfo *m_q; - bool m_isInitialized; -}; - -MetaInfoPrivate::MetaInfoPrivate(MetaInfo *q) : - m_q(q), - m_isInitialized(false) -{ -} - -void MetaInfoPrivate::clear() -{ - m_superClassHash.clear(); - m_nodeMetaInfoHash.clear(); - m_isInitialized = false; -} - -void MetaInfoPrivate::initialize() -{ - parseQmlTypes(); - parseNonQmlTypes(); -// parseValueTypes(); -// parseXmlFiles(); - - m_isInitialized = true; -} - -void MetaInfoPrivate::parseProperties(NodeMetaInfo &nodeMetaInfo, const QMetaObject *qMetaObject) const -{ - Q_ASSERT_X(qMetaObject, Q_FUNC_INFO, "invalid QMetaObject"); - Q_ASSERT_X(nodeMetaInfo.isValid(), Q_FUNC_INFO, "invalid NodeMetaInfo"); - - for (int i = qMetaObject->propertyOffset(); i < qMetaObject->propertyCount(); ++i) { - QMetaProperty qProperty = qMetaObject->property(i); - - PropertyMetaInfo propertyInfo; - - propertyInfo.setName(QLatin1String(qProperty.name())); - - QString typeName(qProperty.typeName()); - QString noStar = typeName; - bool star = false; - while (noStar.contains('*')) {//strip star - noStar.chop(1); - star = true; - } - if (m_QtTypesToQmlTypes.contains(noStar)) { - typeName = star ? m_QtTypesToQmlTypes.value(noStar) + '*' : m_QtTypesToQmlTypes.value(noStar); - //### versions - } - int majorVersion = -1, minorVersion = -1; - if (QmlType *propertyType = QmlMetaType::qmlType(qMetaObject)) { - majorVersion = propertyType->majorVersion(); - minorVersion = propertyType->minorVersion(); - } - - propertyInfo.setType(typeName, majorVersion, minorVersion); - propertyInfo.setValid(true); - propertyInfo.setReadable(qProperty.isReadable()); - propertyInfo.setWritable(qProperty.isWritable()); - propertyInfo.setResettable(qProperty.isResettable()); - propertyInfo.setEnumType(qProperty.isEnumType()); - propertyInfo.setFlagType(qProperty.isFlagType()); - -// if (propertyInfo.isEnumType()) { -// EnumeratorMetaInfo enumerator; -// -// QMetaEnum qEnumerator = qProperty.enumerator(); -// enumerator.setValid(qEnumerator.isValid()); -// enumerator.setIsFlagType(qEnumerator.isFlag()); -// enumerator.setScope(qEnumerator.scope()); -// enumerator.setName(qEnumerator.name()); -// for (int i = 0 ;i < qEnumerator.keyCount(); i++) -// { -// enumerator.addElement(qEnumerator.valueToKey(i), i); -// } -// -// propertyInfo.setEnumerator(enumerator); -// } - - nodeMetaInfo.addProperty(propertyInfo); - } -} - -void MetaInfoPrivate::parseClassInfo(NodeMetaInfo &nodeMetaInfo, const QMetaObject *qMetaObject) const -{ - Q_ASSERT_X(qMetaObject, Q_FUNC_INFO, "invalid QMetaObject"); - Q_ASSERT_X(nodeMetaInfo.isValid(), Q_FUNC_INFO, "invalid NodeMetaInfo"); - for (int index = qMetaObject->classInfoCount() - 1 ; index >= 0 ; --index) { - QMetaClassInfo classInfo = qMetaObject->classInfo(index); - if (QLatin1String(classInfo.name()) == QLatin1String("DefaultProperty")) { - nodeMetaInfo.setDefaultProperty(classInfo.value()); - return; - } - } -} - -void MetaInfoPrivate::parseNonQmlClassRecursively(const QMetaObject *qMetaObject) -{ - Q_ASSERT_X(qMetaObject, Q_FUNC_INFO, "invalid QMetaObject"); - const QString className = qMetaObject->className(); - if ( !m_q->hasNodeMetaInfo(className) - && !QmlMetaType::qmlTypeNames().contains(typeName(qMetaObject).toAscii()) ) { - NodeMetaInfo nodeMetaInfo(*m_q); - nodeMetaInfo.setTypeName(typeName(qMetaObject)); - parseProperties(nodeMetaInfo, qMetaObject); - parseClassInfo(nodeMetaInfo, qMetaObject); - - if (debug) - qDebug() << "adding non qml type" << className << typeName(qMetaObject) << ", parent type" << typeName(qMetaObject->superClass()); - m_q->addNodeInfo(nodeMetaInfo, typeName(qMetaObject->superClass())); - } - - if (const QMetaObject *superClass = qMetaObject->superClass()) { - parseNonQmlClassRecursively(superClass); - } -} - - -QString MetaInfoPrivate::typeName(const QMetaObject *qMetaObject) const -{ - if (!qMetaObject) - return QString(); - QString className = qMetaObject->className(); - if (QmlType *qmlType = QmlMetaType::qmlType(qMetaObject)) { - QString qmlClassName(qmlType->qmlTypeName()); - if (!qmlClassName.isEmpty()) - className = qmlType->qmlTypeName(); // Ensure that we always use the qml name, - // if available. - } - return className; -} - -void MetaInfoPrivate::parseQmlTypes() -{ - foreach (QmlType *qmlType, QmlMetaType::qmlTypes()) { - const QString qtTypeName(qmlType->typeName()); - const QString qmlTypeName(qmlType->qmlTypeName()); - m_QtTypesToQmlTypes.insert(qtTypeName, qmlTypeName); - } - foreach (QmlType *qmlType, QmlMetaType::qmlTypes()) { - const QMetaObject *qMetaObject = qmlType->metaObject(); - - // parseQmlTypes is called iteratively e.g. when plugins are loaded - if (m_q->hasNodeMetaInfo(qmlType->qmlTypeName(), qmlType->majorVersion(), qmlType->minorVersion())) - continue; - - NodeMetaInfo nodeMetaInfo(*m_q); - nodeMetaInfo.setTypeName(qmlType->qmlTypeName()); - nodeMetaInfo.setMajorVersion(qmlType->majorVersion()); - nodeMetaInfo.setMinorVersion(qmlType->minorVersion()); - - parseProperties(nodeMetaInfo, qMetaObject); - parseClassInfo(nodeMetaInfo, qMetaObject); - - QString superTypeName = typeName(qMetaObject->superClass()); - if (qmlType->baseMetaObject() != qMetaObject) { - // type is declared with Q_DECLARE_EXTENDED_TYPE - // also parse properties of original type - parseProperties(nodeMetaInfo, qmlType->baseMetaObject()); - superTypeName = typeName(qmlType->baseMetaObject()->superClass()); - } - - m_q->addNodeInfo(nodeMetaInfo, superTypeName); - } -} - -void MetaInfoPrivate::parseNonQmlTypes() -{ - foreach (QmlType *qmlType, QmlMetaType::qmlTypes()) { - parseNonQmlClassRecursively(qmlType->metaObject()); - } -} - -} // namespace Internal - -using Qml::Internal::MetaInfoPrivate; - -MetaInfo MetaInfo::s_global; -QStringList MetaInfo::s_pluginDirs; - - -/*! -\class Qml::MetaInfo -\ingroup CoreModel -\brief The MetaInfo class provides meta information about qml types and properties. - -The MetaInfo, NodeMetaInfo, PropertyMetaInfo and EnumeratorMetaInfo -classes provide information about the (static and dynamic) qml types available in -a specific model. Just like their Model, ModelNode and AbstractProperty counterparts, -objects of these classes are handles - that means, they are implicitly shared, and -should be created on the stack. - -The MetaInfo object should always be accessed via the model (see Model::metaInfo()). -Otherwise types specific to a model (like sub components) might -be missed. - -\see Model::metaInfo(), Qml::NodeMetaInfo, Qml::PropertyMetaInfo, Qml::EnumeratorMetaInfo -*/ - -/*! - \brief Constructs a copy of the given meta info. - */ -MetaInfo::MetaInfo(const MetaInfo &metaInfo) : - m_p(metaInfo.m_p) -{ -} - -/*! - \brief Creates a meta information object with just the qml types registered statically. - You almost always want to use Model::metaInfo() instead! - - You almost certainly want to access the meta information for the model. - - \see Model::metaInfo() - */ -MetaInfo::MetaInfo() : - m_p(new MetaInfoPrivate(this)) -{ -} - -MetaInfo::~MetaInfo() -{ -} - -/*! - \brief Assigns other to this meta information and returns a reference to this meta information. - */ -MetaInfo& MetaInfo::operator=(const MetaInfo &other) -{ - m_p = other.m_p; - return *this; -} - -QList<NodeMetaInfo> MetaInfo::allTypes() const -{ - return m_p->m_nodeMetaInfoHash.values(); -} - -/*! - \brief Returns whether a type with the given name is registered in the meta system. - */ -bool MetaInfo::hasNodeMetaInfo(const QString &typeName, int /*majorVersion*/, int /*minorVersion*/) const -{ - if (m_p->m_nodeMetaInfoHash.contains(typeName)) - return true; - if (!isGlobal()) - return global().hasNodeMetaInfo(typeName); - return false; -} - -/*! - \brief Returns meta information for a qml type. An invalid NodeMetaInfo object if the type is unknown. - */ -NodeMetaInfo MetaInfo::nodeMetaInfo(const QString &typeName, int /*majorVersion*/, int /*minorVersion*/) const -{ - if (m_p->m_nodeMetaInfoHash.contains(typeName)) - return m_p->m_nodeMetaInfoHash.value(typeName, NodeMetaInfo()); - if (!isGlobal()) - return global().nodeMetaInfo(typeName); - - return NodeMetaInfo(); -} - -QStringList MetaInfo::superClasses(const QString &className) const -{ - QStringList ancestorList = m_p->m_superClassHash.values(className); - foreach (const QString &ancestor, ancestorList) { - QStringList superClassList = superClasses(ancestor); - if (!superClassList.isEmpty()) - ancestorList += superClassList; - } - if (!isGlobal()) - ancestorList += global().superClasses(className); - return ancestorList; -} - -QStringList MetaInfo::directSuperClasses(const QString &className) const -{ - QStringList directAncestorList = m_p->m_superClassHash.values(className); - if (!isGlobal()) - directAncestorList += global().directSuperClasses(className); - return directAncestorList; -} - -QList<NodeMetaInfo> MetaInfo::superClasses(const NodeMetaInfo &nodeInfo) const -{ - if (!nodeInfo.isValid()) { - Q_ASSERT_X(nodeInfo.isValid(), Q_FUNC_INFO, "Invalid nodeInfo argument"); - throw InvalidMetaInfoException(__LINE__, __FUNCTION__, __FILE__); - } - - QList<NodeMetaInfo> superClassList; - - foreach (const QString &typeName, superClasses(nodeInfo.typeName())) { - if (!hasNodeMetaInfo(typeName)) - continue; - const NodeMetaInfo superClass = nodeMetaInfo(typeName); - if (!superClassList.contains(superClass)) - superClassList.append(superClass); - } - return superClassList; -} - -QList<NodeMetaInfo> MetaInfo::directSuperClasses(const NodeMetaInfo &nodeInfo) const -{ - if (!nodeInfo.isValid()) { - Q_ASSERT_X(nodeInfo.isValid(), Q_FUNC_INFO, "Invalid nodeInfo argument"); - throw InvalidMetaInfoException(__LINE__, __FUNCTION__, __FILE__); - } - - QList<NodeMetaInfo> superClassList; - - foreach (const QString &typeName, directSuperClasses(nodeInfo.typeName())) { - if (!hasNodeMetaInfo(typeName)) - continue; - const NodeMetaInfo superClass = nodeMetaInfo(typeName); - if (!superClassList.contains(superClass)) - superClassList.append(superClass); - } - return superClassList; -} - -QStringList MetaInfo::itemLibraryItems() const -{ - QStringList completeList = m_p->m_nodeMetaInfoHash.keys(); - QStringList finalList; - foreach (const QString &name, completeList) { - if (nodeMetaInfo(name).isVisibleToItemLibrary()) - finalList.append(name); - } - - if (!isGlobal()) - finalList += global().itemLibraryItems(); - - return finalList; -} - -/*! - \brief Returns whether className is the same type or a type derived from superClassName. - */ -bool MetaInfo::isSubclassOf(const QString &className, const QString &superClassName) const -{ - return (className == superClassName) || superClasses(className).contains(superClassName); -} - -/*! - \brief Access to the global meta information object. - You almost always want to use Model::metaInfo() instead. - - Internally all meta information objects share this "global" object - where static qml type information is stored. - */ -MetaInfo MetaInfo::global() -{ - if (!s_global.m_p->m_isInitialized) { - s_global.m_p = QSharedPointer<MetaInfoPrivate>(new MetaInfoPrivate(&s_global)); - s_global.m_p->initialize(); - } - return s_global; -} - -/*! - \brief Clears the global meta information object. - - This method should be called once on application shutdown to free static data structures. - */ -void MetaInfo::clearGlobal() -{ - MetaInfo::global().m_p->clear(); -} - -void MetaInfo::setPluginPaths(const QStringList &paths) -{ - s_pluginDirs = paths; -} - -/*! - This bypasses the notifications to the model that the metatype has changed. - Use MetaInfo::addNodeInfo() instead - */ -void MetaInfo::addSuperClassRelationship(const QString &superClassName, const QString &className) -{ - m_p->m_superClassHash.insert(className, superClassName); -} - -void MetaInfo::addNodeInfo(NodeMetaInfo &nodeInfo, const QString &baseType) -{ - if (nodeInfo.typeName().isEmpty() || nodeInfo.metaInfo() != *this) - throw new InvalidMetaInfoException(__LINE__, __FUNCTION__, __FILE__); - - if (nodeInfo.typeName() == baseType) // prevent simple recursion - throw new InvalidMetaInfoException(__LINE__, __FUNCTION__, __FILE__); - - m_p->m_nodeMetaInfoHash.insert(nodeInfo.typeName(), nodeInfo); - - if (!baseType.isEmpty()) { - m_p->m_superClassHash.insert(nodeInfo.typeName(), baseType); - } -} - -bool MetaInfo::isGlobal() const -{ - return (this->m_p == s_global.m_p); -} - -bool operator==(const MetaInfo &first, const MetaInfo &second) -{ - return first.m_p == second.m_p; -} - -bool operator!=(const MetaInfo &first, const MetaInfo &second) -{ - return !(first == second); -} -} //namespace Qml diff --git a/src/shared/qml/metatype/metainfo.h b/src/shared/qml/metatype/metainfo.h deleted file mode 100644 index 52b6ce30537..00000000000 --- a/src/shared/qml/metatype/metainfo.h +++ /dev/null @@ -1,112 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2009 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 METAINFO_H -#define METAINFO_H - -#include <qml/qml_global.h> -#include <qml/metatype/nodemetainfo.h> -#include <qml/metatype/propertymetainfo.h> - -#include <QMultiHash> -#include <QString> -#include <QStringList> -#include <QtCore/QSharedPointer> - -namespace Qml { - -class ModelNode; -class AbstractProperty; - -namespace Internal { - class MetaInfoPrivate; - class ModelPrivate; - class SubComponentManagerPrivate; - typedef QSharedPointer<MetaInfoPrivate> MetaInfoPrivatePointer; -} - -QML_EXPORT bool operator==(const MetaInfo &first, const MetaInfo &second); -QML_EXPORT bool operator!=(const MetaInfo &first, const MetaInfo &second); - -class QML_EXPORT MetaInfo -{ - friend class Qml::Internal::MetaInfoPrivate; - friend class Qml::Internal::MetaInfoParser; - friend class Qml::NodeMetaInfo; - friend bool Qml::operator==(const MetaInfo &, const MetaInfo &); - -public: - MetaInfo(const MetaInfo &metaInfo); - ~MetaInfo(); - MetaInfo& operator=(const MetaInfo &other); - - QList<NodeMetaInfo> allTypes() const; - - bool hasNodeMetaInfo(const QString &typeName, int majorVersion = 4, int minorVersion = 6) const; - // ### makes no sense since ModelNode has minor/major version - NodeMetaInfo nodeMetaInfo(const ModelNode &node) const; - NodeMetaInfo nodeMetaInfo(const QString &typeName, int majorVersion = 4, int minorVersion = 6) const; - - // TODO: Move these to private - bool isSubclassOf(const QString &className, const QString &superClassName) const; - bool isSubclassOf(const ModelNode &modelNode, const QString &superClassName) const; - - bool hasEnumerator(const QString &enumeratorName) const; - - QStringList itemLibraryItems() const; - -public: - static MetaInfo global(); - static void clearGlobal(); - - static void setPluginPaths(const QStringList &paths); - -private: - QStringList superClasses(const QString &className) const; - QStringList directSuperClasses(const QString &className) const; - QList<NodeMetaInfo> superClasses(const NodeMetaInfo &nodeMetaInfo) const; - QList<NodeMetaInfo> directSuperClasses(const NodeMetaInfo &nodeMetaInfo) const; - - void addSuperClassRelationship(const QString &superClassName, const QString &className); - - void addNodeInfo(NodeMetaInfo &info, const QString &baseType); - - bool isGlobal() const; - -private: - MetaInfo(); - - Internal::MetaInfoPrivatePointer m_p; - static MetaInfo s_global; - static QStringList s_pluginDirs; -}; - -} // namespace Qml - -#endif // METAINFO_H diff --git a/src/shared/qml/metatype/nodemetainfo.cpp b/src/shared/qml/metatype/nodemetainfo.cpp deleted file mode 100644 index 9163e86c011..00000000000 --- a/src/shared/qml/metatype/nodemetainfo.cpp +++ /dev/null @@ -1,699 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2009 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 "invalidmetainfoexception.h" -#include "metainfo.h" -#include "nodemetainfo.h" -#include "propertymetainfo.h" - -#include <QtCore/QSharedData> -#include <QtCore/QtDebug> -#include <QtGui/QIcon> -#include <QtDeclarative/QmlMetaType> -#include <QtDeclarative/QmlContext> -#include <QtDeclarative/QmlEngine> -#include <QtDeclarative/QmlComponent> -#include <private/qmlvaluetype_p.h> - -namespace Qml { -namespace Internal { - -class NodeMetaInfoData : public QSharedData -{ -public: - typedef enum { - No = -1, - Unknown = 0, - Yes = 1, - } TristateBoolean; - -public: - NodeMetaInfoData(const MetaInfo &metaInfo) : - metaInfo(metaInfo), - isContainer(false), - isVisibleToItemLibrary(false), - isFXItem(Unknown), - icon(), - category("misc") - { } - - MetaInfo metaInfo; - QString typeName; - bool isContainer; - bool isVisibleToItemLibrary; - TristateBoolean isFXItem; - QHash<QString, PropertyMetaInfo> propertyMetaInfoHash; - QIcon icon; - QString category; - QString qmlFile; - QString defaultProperty; - int majorVersion; - int minorVersion; -}; - -} // namespace Internal - -/*! -\class Qml::NodeMetaInfo -\ingroup CoreModel -\brief The NodeMetaInfo class provides meta information about a qml type. - -A NodeMetaInfo object can be created via ModelNode::metaInfo, or MetaInfo::nodeMetaInfo. - -The object can be invalid - you can check this by calling isValid(). -The object is invalid if you ask for meta information for -an non-existing qml property. Also the node meta info can become invalid -if the enclosing type is deregistered from the meta type system (e.g. -a sub component qml file is deleted). Trying to call any accessor methods on an invalid -NodeMetaInfo object will result in an InvalidMetaInfoException being thrown. - -\see Qml::MetaInfo, Qml::PropertyMetaInfo, Qml::EnumeratorMetaInfo -*/ - -NodeMetaInfo::NodeMetaInfo() - : m_data(0) -{ - // create invalid node -} - -NodeMetaInfo::NodeMetaInfo(const MetaInfo &metaInfo) - : m_data(new Internal::NodeMetaInfoData(metaInfo)) -{ -} - -NodeMetaInfo::~NodeMetaInfo() -{ -} - -/*! - \brief Creates a copy of the handle. - */ -NodeMetaInfo::NodeMetaInfo(const NodeMetaInfo &other) - : m_data(other.m_data) -{ -} - -/*! - \brief Copies the handle. - */ -NodeMetaInfo &NodeMetaInfo::operator=(const NodeMetaInfo &other) -{ - if (this != &other) - this->m_data = other.m_data; - - return *this; -} - -/*! - \brief Returns whether the meta information system knows about this type. - */ -bool NodeMetaInfo::isValid() const -{ - return (m_data.data() != 0); -} - -MetaInfo NodeMetaInfo::metaInfo() const -{ - if (!isValid()) { - Q_ASSERT_X(0, Q_FUNC_INFO, "Invalid NodeMetaInfo object"); - throw InvalidMetaInfoException(__LINE__, __FUNCTION__, __FILE__); - } - - return m_data->metaInfo; -} - -/*! - \brief Creates an instance of the qml type in the given qml context. - - \throws InvalidArgumentException when the context argument is a null pointer - \throws InvalidMetaInfoException if the object is not valid - */ -QObject *NodeMetaInfo::createInstance(QmlContext *parentContext) const -{ - if (!parentContext) { - Q_ASSERT_X(0, Q_FUNC_INFO, "Context cannot be null"); - throw InvalidMetaInfoException(__LINE__, __FUNCTION__, __FILE__); - } - - if (!isValid()) { - Q_ASSERT_X(0, Q_FUNC_INFO, "Invalid NodeMetaInfo object"); - throw InvalidMetaInfoException(__LINE__, __FUNCTION__, __FILE__); - } - - QObject *object = 0; - if (isComponent()) { - // qml component - // TODO: This is maybe expensive ... - QmlComponent component(parentContext->engine(), QUrl::fromLocalFile(m_data->qmlFile)); - object = component.create(parentContext); - } else { - // primitive - object = QmlMetaType::qmlType(typeName().toAscii(), 4, 6)->create(); - if (object && parentContext) - QmlEngine::setContextForObject(object, new QmlContext(parentContext, object)); - } - return object; -} - -/*! - \brief Returns all (direct and indirect) ancestor types. - - \throws InvalidMetaInfoException if the object is not valid - */ -QList<NodeMetaInfo> NodeMetaInfo::superClasses() const -{ - if (!isValid()) { - Q_ASSERT_X(0, Q_FUNC_INFO, "Invalid NodeMetaInfo object"); - throw InvalidMetaInfoException(__LINE__, __FUNCTION__, __FILE__); - } - - return m_data->metaInfo.superClasses(*this); -} - -/*! - \brief Returns direct ancestor types. - - \throws InvalidMetaInfoException if the object is not valid - */ -QList<NodeMetaInfo> NodeMetaInfo::directSuperClasses() const -{ - if (!isValid()) { - Q_ASSERT_X(0, Q_FUNC_INFO, "Invalid NodeMetaInfo object"); - throw InvalidMetaInfoException(__LINE__, __FUNCTION__, __FILE__); - } - - return m_data->metaInfo.directSuperClasses(*this); -} - -/*! - \brief Returns meta information for all properties, including properties inherited from base types. - - Returns a Hash with the name of the property as key and property meta information as value. Node - In case there are multiple properties with the same name in the hierarchy the property defined - in the more concrete subclass is chosen. - - \throws InvalidMetaInfoException if the object is not valid - */ -QHash<QString,PropertyMetaInfo> NodeMetaInfo::properties(bool resolveDotSyntax ) const -{ - if (!isValid()) { - Q_ASSERT_X(0, Q_FUNC_INFO, "Invalid NodeMetaInfo object"); - throw InvalidMetaInfoException(__LINE__, __FUNCTION__, __FILE__); - } - - QHash<QString,PropertyMetaInfo> propertiesInfo; - propertiesInfo = m_data->propertyMetaInfoHash; - foreach (const NodeMetaInfo &nodeInfo, directSuperClasses()) { - QHash<QString,PropertyMetaInfo> superClassProperties = nodeInfo.properties(); - QHashIterator<QString,PropertyMetaInfo> iter(superClassProperties); - while (iter.hasNext()) { - iter.next(); - if (!propertiesInfo.contains(iter.key())) - propertiesInfo.insert(iter.key(), iter.value()); - } - } - if (resolveDotSyntax) { - QHashIterator<QString,PropertyMetaInfo> iter(dotProperties()); - while (iter.hasNext()) { - iter.next(); - if (!propertiesInfo.contains(iter.key())) - propertiesInfo.insert(iter.key(), iter.value()); - } - } - return propertiesInfo; -} - -/*! - \brief Returns meta information for all dot properties, including properties inherited from base types. - - */ -QHash<QString,PropertyMetaInfo> NodeMetaInfo::dotProperties() const -{ - if (!isValid()) { - Q_ASSERT_X(0, Q_FUNC_INFO, "Invalid NodeMetaInfo object"); - throw InvalidMetaInfoException(__LINE__, __FUNCTION__, __FILE__); - } - - QHash<QString,PropertyMetaInfo> propertiesInfo; - - foreach (const QString &propertyName, properties().keys()) { - if (property(propertyName).hasDotSubProperties()) { - QString propertyType = property(propertyName).type(); - if (propertyType.right(1) == "*") - propertyType = propertyType.left(propertyType.size() - 1).trimmed(); - NodeMetaInfo nodeInfo(m_data->metaInfo.nodeMetaInfo(propertyType, majorVersion(), minorVersion())); - if (nodeInfo.isValid()) { - QHashIterator<QString,PropertyMetaInfo> iter(nodeInfo.properties()); - while (iter.hasNext()) { - iter.next(); - if (!propertiesInfo.contains(iter.key()) && iter.key() != "objectName") - propertiesInfo.insert(propertyName + "." + iter.key(), iter.value()); - } - } - } - } - return propertiesInfo; -} - -/*! - \brief Returns meta information for a property. An invalid PropertyMetaInfo object if the given property name is unknown. - - \throws InvalidMetaInfoException if the object is not valid - */ -PropertyMetaInfo NodeMetaInfo::property(const QString &propertyName, bool resolveDotSyntax) const -{ - if (!isValid()) { - Q_ASSERT_X(0, Q_FUNC_INFO, "Invalid NodeMetaInfo object"); - throw InvalidMetaInfoException(__LINE__, __FUNCTION__, __FILE__); - } - - if (resolveDotSyntax && propertyName.contains('.')) { - const QStringList nameParts = propertyName.split('.'); - NodeMetaInfo nodeInfo = *this; - const int partCount = nameParts.size(); - for (int i = 0; i < partCount; ++i) { - const QString namePart(nameParts.at(i)); - const PropertyMetaInfo propInfo = nodeInfo.property(namePart, false); - - if (!propInfo.isValid()) - break; - - if (i + 1 == partCount) - return propInfo; - - QString propertyType = propInfo.type(); - if (propertyType.right(1) == "*") - propertyType = propertyType.left(propertyType.size() - 1).trimmed(); - nodeInfo = m_data->metaInfo.nodeMetaInfo(propertyType, majorVersion(), minorVersion()); - if (!nodeInfo.isValid()) { - qDebug() << "no type info available for" << propertyType; - break; - } - } - - return PropertyMetaInfo(); - } else { - PropertyMetaInfo propertyMetaInfo; - - if (hasLocalProperty(propertyName)) { - propertyMetaInfo = m_data->propertyMetaInfoHash.value(propertyName, PropertyMetaInfo()); - } else { - foreach (const NodeMetaInfo &superTypeMetaInfo, directSuperClasses()) { - Q_ASSERT(superTypeMetaInfo.isValid()); - propertyMetaInfo = superTypeMetaInfo.property(propertyName); - if (propertyMetaInfo.isValid()) - break; - } - } - - return propertyMetaInfo; - } -} - -/*! - \brief Returns whether the type has a (not inherited) property. - - \throws InvalidMetaInfoException if the object is not valid - */ -bool NodeMetaInfo::hasLocalProperty(const QString &propertyName, bool resolveDotSyntax) const -{ - if (!isValid()) { - Q_ASSERT_X(0, Q_FUNC_INFO, "Invalid NodeMetaInfo object"); - throw InvalidMetaInfoException(__LINE__, __FUNCTION__, __FILE__); - } - - if (resolveDotSyntax && propertyName.contains('.')) { - const QStringList nameParts = propertyName.split('.'); - NodeMetaInfo nodeInfo = *this; - const int partCount = nameParts.size(); - for (int i = 0; i < partCount; ++i) { - QString namePart(nameParts.at(i)); - const PropertyMetaInfo propInfo = nodeInfo.property(namePart, false); - - if (!propInfo.isValid()) - break; - - if (i + 1 == partCount) - return true; - - QString propertyType = propInfo.type(); - if (propertyType.right(1) == "*") - propertyType = propertyType.left(propertyType.size() - 1).trimmed(); - nodeInfo = m_data->metaInfo.nodeMetaInfo(propertyType, majorVersion(), minorVersion()); - if (!nodeInfo.isValid()) { - qDebug() << "no type info available for" << propertyType; - break; - } - } - - return false; - } else { - return m_data->propertyMetaInfoHash.contains(propertyName); - } -} - -/*! - \brief Returns whether the type has a (inherited or not inherited) property. - - \throws InvalidMetaInfoException if the object is not valid - */ -bool NodeMetaInfo::hasProperty(const QString &propertyName, bool resolveDotSyntax) const -{ - if (!isValid()) { - Q_ASSERT_X(0, Q_FUNC_INFO, "Invalid NodeMetaInfo object"); - throw InvalidMetaInfoException(__LINE__, __FUNCTION__, __FILE__); - } - - if (hasLocalProperty(propertyName, resolveDotSyntax)) - return true; - - foreach (const NodeMetaInfo &nodeMetaInfo, directSuperClasses()) { - if (nodeMetaInfo.hasProperty(propertyName, resolveDotSyntax)) - return true; - } - - return false; -} - -void NodeMetaInfo::addProperty(const PropertyMetaInfo &property) -{ - if (!isValid()) { - Q_ASSERT_X(0, Q_FUNC_INFO, "Invalid NodeMetaInfo object"); - throw InvalidMetaInfoException(__LINE__, __FUNCTION__, __FILE__); - } - m_data->propertyMetaInfoHash.insert(property.name(), property); -} - -/*! - \brief Returns the name of the qml type. - - This is not necessarily the class name: E.g. the class defining "Item" is QmlGraphicsItem. - - \throws InvalidMetaInfoException if the object is not valid - */ -QString NodeMetaInfo::typeName() const -{ - if (!isValid()) { - Q_ASSERT_X(0, Q_FUNC_INFO, "Invalid NodeMetaInfo object"); - throw InvalidMetaInfoException(__LINE__, __FUNCTION__, __FILE__); - } - return m_data->typeName; -} - -/*! - \brief Returns the name of the major number of the qml type. - - \throws InvalidMetaInfoException if the object is not valid -*/ -int NodeMetaInfo::majorVersion() const -{ - if (!isValid()) { - Q_ASSERT_X(0, Q_FUNC_INFO, "Invalid NodeMetaInfo object"); - throw InvalidMetaInfoException(__LINE__, __FUNCTION__, __FILE__); - } - - return 4; -} - - -/*! - \brief Returns the name of the minor number of the qml type to which the type is used. - - \throws InvalidMetaInfoException if the object is not valid -*/ -int NodeMetaInfo::minorVersion() const -{ - if (!isValid()) { - Q_ASSERT_X(0, Q_FUNC_INFO, "Invalid NodeMetaInfo object"); - throw InvalidMetaInfoException(__LINE__, __FUNCTION__, __FILE__); - } - - return m_data->minorVersion; -} - -bool NodeMetaInfo::hasDefaultProperty() const -{ - if (!isValid()) { - Q_ASSERT_X(0, Q_FUNC_INFO, "Invalid NodeMetaInfo object"); - throw InvalidMetaInfoException(__LINE__, __FUNCTION__, __FILE__); - } - - return m_data->defaultProperty.isNull(); -} - -QString NodeMetaInfo::defaultProperty() const -{ - if (!isValid()) { - Q_ASSERT_X(0, Q_FUNC_INFO, "Invalid NodeMetaInfo object"); - throw InvalidMetaInfoException(__LINE__, __FUNCTION__, __FILE__); - } - - return m_data->defaultProperty; -} - -void NodeMetaInfo::setDefaultProperty(const QString &defaultProperty) -{ - if (!isValid()) { - Q_ASSERT_X(0, Q_FUNC_INFO, "Invalid NodeMetaInfo object"); - throw InvalidMetaInfoException(__LINE__, __FUNCTION__, __FILE__); - } - - m_data->defaultProperty = defaultProperty; -} - -void NodeMetaInfo::setMajorVersion(int version) -{ - m_data->majorVersion = version; -} - -void NodeMetaInfo::setMinorVersion(int version) -{ - m_data->minorVersion = version; -} - -void NodeMetaInfo::setInvalid() -{ - if (!isValid()) - return; - - m_data = 0; -} - -void NodeMetaInfo::setTypeName(const QString &typeName) -{ - if (!isValid()) { - Q_ASSERT_X(0, Q_FUNC_INFO, "Invalid NodeMetaInfo object"); - throw InvalidMetaInfoException(__LINE__, __FUNCTION__, __FILE__); - } - m_data->typeName = typeName; -} - -uint qHash(const NodeMetaInfo &nodeMetaInfo) -{ - if (!nodeMetaInfo.isValid()) - return 0; - return qHash(nodeMetaInfo.m_data->typeName); -} - -bool operator==(const NodeMetaInfo &firstNodeInfo, - const NodeMetaInfo &secondNodeInfo) -{ - if (!firstNodeInfo.isValid() || !secondNodeInfo.isValid()) - return false; - return firstNodeInfo.m_data->typeName == secondNodeInfo.m_data->typeName; -} - -/*! - \brief Returns whether objects of these type can have children. - - \throws InvalidMetaInfoException if the object is not valid - */ -bool NodeMetaInfo::isContainer() const -{ - // TODO KAI: Is this too generic? - if (!isValid()) { - Q_ASSERT_X(0, Q_FUNC_INFO, "Invalid NodeMetaInfo object"); - throw InvalidMetaInfoException(__LINE__, __FUNCTION__, __FILE__); - } - return m_data->isContainer; -} - -bool NodeMetaInfo::isVisibleToItemLibrary() const -{ - if (!isValid()) { - Q_ASSERT_X(0, Q_FUNC_INFO, "Invalid NodeMetaInfo object"); - throw InvalidMetaInfoException(__LINE__, __FUNCTION__, __FILE__); - } - return m_data->isVisibleToItemLibrary; -} - -void NodeMetaInfo::setIsContainer(bool isContainer) -{ - if (!isValid()) { - Q_ASSERT_X(0, Q_FUNC_INFO, "Invalid NodeMetaInfo object"); - throw InvalidMetaInfoException(__LINE__, __FUNCTION__, __FILE__); - } - m_data->isContainer = isContainer; -} - -void NodeMetaInfo::setIsVisibleToItemLibrary(bool isVisibleToItemLibrary) -{ - if (!isValid()) { - Q_ASSERT_X(0, Q_FUNC_INFO, "Invalid NodeMetaInfo object"); - throw InvalidMetaInfoException(__LINE__, __FUNCTION__, __FILE__); - } - m_data->isVisibleToItemLibrary = isVisibleToItemLibrary; -} - -QIcon NodeMetaInfo::icon() const -{ - if (!isValid()) { - Q_ASSERT_X(0, Q_FUNC_INFO, "Invalid NodeMetaInfo object"); - throw InvalidMetaInfoException(__LINE__, __FUNCTION__, __FILE__); - } - return m_data->icon; -} - -QString NodeMetaInfo::category() const -{ - if (!isValid()) { - Q_ASSERT_X(0, Q_FUNC_INFO, "Invalid NodeMetaInfo object"); - throw InvalidMetaInfoException(__LINE__, __FUNCTION__, __FILE__); - } - return m_data->category; -} - -void NodeMetaInfo::setIcon(const QIcon &icon) -{ - if (!isValid()) { - Q_ASSERT_X(0, Q_FUNC_INFO, "Invalid NodeMetaInfo object"); - throw InvalidMetaInfoException(__LINE__, __FUNCTION__, __FILE__); - } - m_data->icon = icon; -} - -void NodeMetaInfo::setCategory(const QString &category) -{ - if (!isValid()) { - Q_ASSERT_X(0, Q_FUNC_INFO, "Invalid NodeMetaInfo object"); - throw InvalidMetaInfoException(__LINE__, __FUNCTION__, __FILE__); - } - m_data->category = category; -} - -/*! - \brief Returns whether the type inherits from "QWidget". - - \throws InvalidMetaInfoException if the object is not valid - */ -bool NodeMetaInfo::isWidget() const -{ - if (!isValid()) { - Q_ASSERT_X(0, Q_FUNC_INFO, "Invalid NodeMetaInfo object"); - throw InvalidMetaInfoException(__LINE__, __FUNCTION__, __FILE__); - } - return m_data->metaInfo.isSubclassOf(m_data->typeName, "Qt/QWidget"); -} - -/*! - \brief Returns whether the type inherits from "QGraphicsWidget". - - \throws InvalidMetaInfoException if the object is not valid - */ -bool NodeMetaInfo::isGraphicsWidget() const -{ - if (!isValid()) { - Q_ASSERT_X(0, Q_FUNC_INFO, "Invalid NodeMetaInfo object"); - throw InvalidMetaInfoException(__LINE__, __FUNCTION__, __FILE__); - } - return m_data->metaInfo.isSubclassOf(m_data->typeName, "Qt/QGraphicsWidget"); -} - -/*! - \brief Returns whether the type inherits from "QGraphicsObject". - - \throws InvalidMetaInfoException if the object is not valid - */ -bool NodeMetaInfo::isGraphicsObject() const -{ - if (!isValid()) { - Q_ASSERT_X(0, Q_FUNC_INFO, "Invalid NodeMetaInfo object"); - throw InvalidMetaInfoException(__LINE__, __FUNCTION__, __FILE__); - } - return m_data->metaInfo.isSubclassOf(m_data->typeName, "QGraphicsObject"); -} - -/*! - \brief Returns whether the type inherits from "Item/QmlGraphicsItem". - - \throws InvalidMetaInfoException if the object is not valid - */ -bool NodeMetaInfo::isQmlGraphicsItem() const -{ - if (!isValid()) { - Q_ASSERT_X(0, Q_FUNC_INFO, "Invalid NodeMetaInfo object"); - throw InvalidMetaInfoException(__LINE__, __FUNCTION__, __FILE__); - } - - if (m_data->isFXItem == Internal::NodeMetaInfoData::Unknown) { - m_data->isFXItem = m_data->metaInfo.isSubclassOf(m_data->typeName, "Qt/Item") ? Internal::NodeMetaInfoData::Yes : Internal::NodeMetaInfoData::No; - } - - return m_data->isFXItem == Internal::NodeMetaInfoData::Yes; -} - -bool NodeMetaInfo::isComponent() const -{ - return !m_data->qmlFile.isEmpty(); -} - -/*! - \brief Returns whether the type inherits from a type. - - \throws InvalidMetaInfoException if the object is not valid - */ -bool NodeMetaInfo::isSubclassOf(const QString &type, int /*majorVersion*/, int /*minorVersion*/) const -{ - if (!isValid()) { - Q_ASSERT_X(0, Q_FUNC_INFO, "Invalid NodeMetaInfo object"); - throw InvalidMetaInfoException(__LINE__, __FUNCTION__, __FILE__); - } - return m_data->metaInfo.isSubclassOf(m_data->typeName, type); -} - -void NodeMetaInfo::setQmlFile(const QString &filePath) -{ - if (!isValid()) { - Q_ASSERT_X(0, Q_FUNC_INFO, "Invalid NodeMetaInfo object"); - throw InvalidMetaInfoException(__LINE__, __FUNCTION__, __FILE__); - } - m_data->qmlFile = filePath; -} - -} // namespace Qml diff --git a/src/shared/qml/metatype/nodemetainfo.h b/src/shared/qml/metatype/nodemetainfo.h deleted file mode 100644 index d65894a8800..00000000000 --- a/src/shared/qml/metatype/nodemetainfo.h +++ /dev/null @@ -1,132 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2009 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 NODEMETAINFO_H -#define NODEMETAINFO_H - -#include <qml/qml_global.h> - -#include <QList> -#include <QString> -#include <QExplicitlySharedDataPointer> -#include <QIcon> - -class QmlContext; - -namespace Qml { - -class MetaInfo; - -namespace Internal { - class MetaInfoPrivate; - class MetaInfoParser; - class NodeMetaInfoData; - class SubComponentManagerPrivate; - class ItemLibraryInfoData; -} - -class PropertyMetaInfo; - -class QML_EXPORT NodeMetaInfo -{ - friend class Qml::MetaInfo; - friend class Qml::Internal::ItemLibraryInfoData; - friend class Qml::Internal::MetaInfoPrivate; - friend class Qml::Internal::MetaInfoParser; - friend QML_EXPORT uint qHash(const NodeMetaInfo &nodeMetaInfo); - friend QML_EXPORT bool operator ==(const NodeMetaInfo &firstNodeInfo, const NodeMetaInfo &secondNodeInfo); - -public: - ~NodeMetaInfo(); - - NodeMetaInfo(const NodeMetaInfo &other); - NodeMetaInfo &operator=(const NodeMetaInfo &other); - - bool isValid() const; - MetaInfo metaInfo() const; - - QObject *createInstance(QmlContext *parentContext) const; - - PropertyMetaInfo property(const QString &propertyName, bool resolveDotSyntax = false) const; - - QList<NodeMetaInfo> superClasses() const; - QList<NodeMetaInfo> directSuperClasses() const; - QHash<QString,PropertyMetaInfo> properties(bool resolveDotSyntax = false) const; - - - QString typeName() const; - int majorVersion() const; - int minorVersion() const; - - bool hasDefaultProperty() const; - QString defaultProperty() const; - - bool hasProperty(const QString &propertyName, bool resolveDotSyntax = false) const; - bool isContainer() const; - bool isVisibleToItemLibrary() const; - - bool isWidget() const; - bool isGraphicsWidget() const; - bool isGraphicsObject() const; - bool isQmlGraphicsItem() const; - bool isComponent() const; - bool isSubclassOf(const QString& type, int majorVersion = 4, int minorVersion = 6) const; - - QIcon icon() const; - QString category() const; - -private: - NodeMetaInfo(); - NodeMetaInfo(const MetaInfo &metaInfo); - - void setInvalid(); - void setTypeName(const QString &typeName); - void addProperty(const PropertyMetaInfo &property); - void setIsContainer(bool isContainer); - void setIsVisibleToItemLibrary(bool isVisibleToItemLibrary); - void setIcon(const QIcon &icon); - void setCategory(const QString &category); - void setQmlFile(const QString &filePath); - void setDefaultProperty(const QString &defaultProperty); - void setMajorVersion(int version); - void setMinorVersion(int version); - - bool hasLocalProperty(const QString &propertyName, bool resolveDotSyntax = false) const; - QHash<QString,PropertyMetaInfo> dotProperties() const; - -private: - QExplicitlySharedDataPointer<Internal::NodeMetaInfoData> m_data; -}; - -QML_EXPORT uint qHash(const NodeMetaInfo &nodeMetaInfo); -QML_EXPORT bool operator ==(const NodeMetaInfo &firstNodeInfo, - const NodeMetaInfo &secondNodeInfo); -} // namespace Qml - -#endif // NODEMETAINFO_H diff --git a/src/shared/qml/metatype/propertymetainfo.cpp b/src/shared/qml/metatype/propertymetainfo.cpp deleted file mode 100644 index 0d011210bad..00000000000 --- a/src/shared/qml/metatype/propertymetainfo.cpp +++ /dev/null @@ -1,405 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2009 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 "propertymetainfo.h" - -#include <QSharedData> - -#include "invalidmetainfoexception.h" -#include "metainfo.h" -#include <private/qmlvaluetype_p.h> - -namespace Qml { -namespace Internal { - -class PropertyMetaInfoData : public QSharedData -{ -public: - PropertyMetaInfoData() - : QSharedData(), - isValid(false), - readable(false), - writeable(false), - resettable(false), - enumType(false), - flagType(false), - isVisible(false) - {} - - QString name; - QString type; - int majorVersion; - int minorVersion; - bool isValid; - - bool readable; - bool writeable; - bool resettable; - - bool enumType; - bool flagType; - bool isVisible; - - QHash<QString, QVariant> defaultValueHash; -}; - -} // namespace Internal - -/*! -\class Qml::PropertyMetaInfo -\ingroup CoreModel -\brief The PropertyMetaInfo class provides meta information about a qml type property. - -A PropertyMetaInfo object can be NodeMetaInfo, or AbstractProperty::metaInfo. - -The object can be invalid - you can check this by calling isValid(). -The object is invalid if you ask for meta information for -an non-existing qml type. Also the node meta info can become invalid -if the type is deregistered from the meta type system (e.g. -a sub component qml file is deleted). Trying to call any accessor methods on an invalid -PropertyMetaInfo object will result in an InvalidMetaInfoException being thrown. - - -\see Qml::MetaInfo, Qml::NodeMetaInfo, Qml::EnumeratorMetaInfo -*/ - -PropertyMetaInfo::PropertyMetaInfo() - : m_data(new Internal::PropertyMetaInfoData) -{ -} - -PropertyMetaInfo::~PropertyMetaInfo() -{ -} - -/*! - \brief Creates a copy of the handle. - */ -PropertyMetaInfo::PropertyMetaInfo(const PropertyMetaInfo &other) - : m_data(other.m_data) -{ -} - -/*! - \brief Copies the handle. - */ -PropertyMetaInfo &PropertyMetaInfo::operator=(const PropertyMetaInfo &other) -{ - if (this != &other) - m_data = other.m_data; - - return *this; -} - -/*! - \brief Returns whether the meta information system knows about this property. - */ -bool PropertyMetaInfo::isValid() const -{ - return m_data->isValid; -} - -/*! - \brief Returns the name of the property. - */ -QString PropertyMetaInfo::name() const -{ - if (!isValid()) { - Q_ASSERT_X(isValid(), Q_FUNC_INFO, ""); - throw InvalidMetaInfoException(__LINE__, Q_FUNC_INFO, __FILE__); - } - return m_data->name; -} - -/*! - \brief Returns the type name of the property. - */ -QString PropertyMetaInfo::type() const -{ - if (!isValid()) { - Q_ASSERT_X(isValid(), Q_FUNC_INFO, ""); - throw InvalidMetaInfoException(__LINE__, Q_FUNC_INFO, __FILE__); - } - return m_data->type; -} - -int PropertyMetaInfo::typeMajorVersion() const -{ - if (!isValid()) { - Q_ASSERT_X(isValid(), Q_FUNC_INFO, ""); - throw InvalidMetaInfoException(__LINE__, Q_FUNC_INFO, __FILE__); - } - return m_data->majorVersion; -} - -int PropertyMetaInfo::typeMinorVersion() const -{ - if (!isValid()) { - Q_ASSERT_X(isValid(), Q_FUNC_INFO, ""); - throw InvalidMetaInfoException(__LINE__, Q_FUNC_INFO, __FILE__); - } - return m_data->minorVersion; -} - -bool PropertyMetaInfo::isVisibleToPropertyEditor() const -{ - if (!isValid()) { - Q_ASSERT_X(isValid(), Q_FUNC_INFO, ""); - throw InvalidMetaInfoException(__LINE__, Q_FUNC_INFO, __FILE__); - } - return m_data->isVisible; -} - -void PropertyMetaInfo::setIsVisibleToPropertyEditor(bool isVisible) -{ - m_data->isVisible = isVisible; -} - -/*! - \brief Returns the QVariant type of the property. - */ -QVariant::Type PropertyMetaInfo::variantTypeId() const -{ - if (!isValid()) { - Q_ASSERT_X(isValid(), Q_FUNC_INFO, ""); - throw InvalidMetaInfoException(__LINE__, Q_FUNC_INFO, __FILE__); - } - Q_ASSERT(!m_data->type.isEmpty()); - return QVariant::nameToType(m_data->type.toLatin1().data()); -} - -/*! - \brief Returns whether the propery is readable. - */ -bool PropertyMetaInfo::isReadable() const -{ - if (!isValid()) { - Q_ASSERT_X(isValid(), Q_FUNC_INFO, ""); - throw InvalidMetaInfoException(__LINE__, Q_FUNC_INFO, __FILE__); - } - return m_data->readable; -} - -/*! - \brief Returns whether the propery is writeable. - */ -bool PropertyMetaInfo::isWriteable() const -{ - if (!isValid()) { - Q_ASSERT_X(isValid(), Q_FUNC_INFO, ""); - throw InvalidMetaInfoException(__LINE__, Q_FUNC_INFO, __FILE__); - } - return m_data->writeable; -} - -/*! - \brief Returns whether the propery is resettable. - */ -bool PropertyMetaInfo::isResettable() const -{ - if (!isValid()) { - Q_ASSERT_X(isValid(), Q_FUNC_INFO, ""); - throw InvalidMetaInfoException(__LINE__, Q_FUNC_INFO, __FILE__); - } - return m_data->resettable; -} - -/*! - \brief Returns whether the propery is complex value type. - */ -bool PropertyMetaInfo::isValueType() const -{ - if (!isValid()) { - Q_ASSERT_X(isValid(), Q_FUNC_INFO, ""); - throw InvalidMetaInfoException(__LINE__, Q_FUNC_INFO, __FILE__); - } - - QmlValueType *valueType(QmlValueTypeFactory::valueType(variantTypeId())); - return valueType; -} - -/*! - \brief Returns whether the propery is a QmlList. - */ -bool PropertyMetaInfo::isListProperty() const -{ - if (!isValid()) { - Q_ASSERT_X(isValid(), Q_FUNC_INFO, ""); - throw InvalidMetaInfoException(__LINE__, Q_FUNC_INFO, __FILE__); - } - - return type().contains("QmlList"); -} - -/*! - \brief Returns whether the propery has sub properties with "." syntax e.g. font - */ -bool PropertyMetaInfo::hasDotSubProperties() const -{ - if (!isValid()) { - Q_ASSERT_X(isValid(), Q_FUNC_INFO, ""); - throw InvalidMetaInfoException(__LINE__, Q_FUNC_INFO, __FILE__); - } - - return isValueType() || !isWriteable(); -} - -/*! - \brief Returns whether the propery stores an enum value. - */ -bool PropertyMetaInfo::isEnumType() const -{ - if (!isValid()) { - Q_ASSERT_X(isValid(), Q_FUNC_INFO, ""); - throw InvalidMetaInfoException(__LINE__, Q_FUNC_INFO, __FILE__); - } - return m_data->enumType; -} - -/*! - \brief Returns whether the propery stores a flag value. - */ -bool PropertyMetaInfo::isFlagType() const -{ - if (!isValid()) { - Q_ASSERT_X(isValid(), Q_FUNC_INFO, ""); - throw InvalidMetaInfoException(__LINE__, Q_FUNC_INFO, __FILE__); - } - return m_data->flagType; -} - -/*! - \brief Returns a default value if there is one specified, an invalid QVariant otherwise. - */ -QVariant PropertyMetaInfo::defaultValue(const NodeMetaInfo &nodeMetaInfoArg) const -{ - if (!isValid()) { - Q_ASSERT_X(isValid(), Q_FUNC_INFO, ""); - throw InvalidMetaInfoException(__LINE__, Q_FUNC_INFO, __FILE__); - } - - QList<NodeMetaInfo> nodeMetaInfoList(nodeMetaInfoArg.superClasses()); - nodeMetaInfoList.prepend(nodeMetaInfoArg); - foreach (const NodeMetaInfo &nodeMetaInfo, nodeMetaInfoList) { - if (m_data->defaultValueHash.contains(nodeMetaInfo.typeName())) - return m_data->defaultValueHash.value(nodeMetaInfo.typeName()); - } - - return QVariant(); -} - -void PropertyMetaInfo::setName(const QString &name) -{ - m_data->name = name; -} - -void PropertyMetaInfo::setType(const QString &type, int majorVersion, int minorVersion) -{ - m_data->type = type; - m_data->majorVersion = majorVersion; - m_data->minorVersion = minorVersion; -} - -void PropertyMetaInfo::setValid(bool isValid) -{ - m_data->isValid = isValid; -} - -void PropertyMetaInfo::setReadable(bool isReadable) -{ - m_data->readable = isReadable; -} - -void PropertyMetaInfo::setWritable(bool isWritable) -{ - m_data->writeable = isWritable; -} - -void PropertyMetaInfo::setResettable(bool isRessetable) -{ - m_data->resettable = isRessetable; -} - -void PropertyMetaInfo::setEnumType(bool isEnumType) -{ - m_data->enumType = isEnumType; -} - -void PropertyMetaInfo::setFlagType(bool isFlagType) -{ - m_data->flagType = isFlagType; -} - -void PropertyMetaInfo::setDefaultValue(const NodeMetaInfo &nodeMetaInfo, const QVariant &value) -{ - m_data->defaultValueHash.insert(nodeMetaInfo.typeName(), value); -} - -/*! - \brief cast value type of QVariant parameter - - If the type of the passed variant does not correspond to type(), the method tries to convert - the value according to QVariant::convert(). Returns a new QVariant with casted value type - if successful, an invalid QVariant otherwise. - - \param variant the QVariant to take the value from - \returns QVariant with aligned value type, or invalid QVariant - */ -QVariant PropertyMetaInfo::castedValue(const QVariant &originalVariant) const -{ - if (!isValid()) { - Q_ASSERT_X(isValid(), Q_FUNC_INFO, ""); - throw InvalidMetaInfoException(__LINE__, Q_FUNC_INFO, __FILE__); - } - - QVariant variant = originalVariant; - if (m_data->enumType) { - return variant; - } - - QVariant::Type typeId = variantTypeId(); - - if (typeId == QVariant::UserType && m_data->type == QLatin1String("QVariant")) { - return variant; - } else if (variant.type() == QVariant::List && variant.type() == QVariant::List) { - // TODO: check the contents of the list - return variant; - } else if (type() == "var" || type() == "variant") { - return variant; - } else if (type() == "alias") { - // TODO: The Qml compiler resolves the alias type. We probably should do the same. - return variant; - } else if (variant.convert(typeId)) { - return variant; - } else { - return QVariant(); - } -} - -} // namespace Qml diff --git a/src/shared/qml/metatype/propertymetainfo.h b/src/shared/qml/metatype/propertymetainfo.h deleted file mode 100644 index 08fc37487b4..00000000000 --- a/src/shared/qml/metatype/propertymetainfo.h +++ /dev/null @@ -1,113 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2009 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 PROPERTYMETAINFO_H -#define PROPERTYMETAINFO_H - -#include <qml/qml_global.h> - -#include <QString> -#include <QExplicitlySharedDataPointer> -#include <QVariant> - -namespace Qml { - -class MetaInfo; -class NodeMetaInfo; - -namespace Internal { - -class MetaInfoPrivate; -class MetaInfoParser; -class PropertyMetaInfoData; - -} - -class QML_EXPORT PropertyMetaInfo -{ - friend class Qml::Internal::MetaInfoPrivate; - friend class Qml::Internal::MetaInfoParser; - friend class Qml::MetaInfo; - friend class Qml::NodeMetaInfo; -public: - PropertyMetaInfo(); - ~PropertyMetaInfo(); - - PropertyMetaInfo(const PropertyMetaInfo &other); - PropertyMetaInfo& operator=(const PropertyMetaInfo &other); - - bool isValid() const; - - QString name() const; - QString type() const; - int typeMajorVersion() const; - int typeMinorVersion() const; - - QVariant::Type variantTypeId() const; - - bool isReadable() const; - bool isWriteable() const; - bool isResettable() const; - bool isValueType() const; - bool isListProperty() const; - - bool isEnumType() const; - bool isFlagType() const; - - QVariant defaultValue(const NodeMetaInfo &nodeMetaInfo) const; - bool isVisibleToPropertyEditor() const; - - QVariant castedValue(const QVariant &variant) const; - -private: - void setName(const QString &name); - void setType(const QString &type, int majorVersion, int minorVersion); - void setValid(bool isValid); - - void setReadable(bool isReadable); - void setWritable(bool isWritable); - void setResettable(bool isRessetable); - - void setEnumType(bool isEnumType); - void setFlagType(bool isFlagType); - - void setDefaultValue(const NodeMetaInfo &nodeMetaInfo, const QVariant &value); - void setIsVisibleToPropertyEditor(bool isVisible); - - bool hasDotSubProperties() const; - - -private: - QExplicitlySharedDataPointer<Internal::PropertyMetaInfoData> m_data; -}; - -} // namespace Qml - - -#endif // PROPERTYMETAINFO_H diff --git a/src/shared/qml/qml.pri b/src/shared/qml/qml.pri deleted file mode 100644 index 9e9bbc0a77a..00000000000 --- a/src/shared/qml/qml.pri +++ /dev/null @@ -1,43 +0,0 @@ -include(parser/parser.pri) - -DEPENDPATH += $$PWD $$PWD/metatype -INCLUDEPATH *= $$PWD/.. - -HEADERS += \ - $$PWD/qml_global.h \ - $$PWD/qmlidcollector.h \ - $$PWD/qmldocument.h \ - $$PWD/qmlpackageinfo.h \ - $$PWD/qmlsymbol.h \ - $$PWD/metatype/exception.h \ - $$PWD/metatype/QmlMetaTypeBackend.h \ - $$PWD/metatype/qmltypesystem.h - -SOURCES += \ - $$PWD/qmlidcollector.cpp \ - $$PWD/qmldocument.cpp \ - $$PWD/qmlsymbol.cpp \ - $$PWD/qmlpackageinfo.cpp \ - $$PWD/metatype/exception.cpp \ - $$PWD/metatype/QmlMetaTypeBackend.cpp \ - $$PWD/metatype/qmltypesystem.cpp - -contains(QT_CONFIG, declarative) { - QT += declarative - - DEFINES += BUILD_DECLARATIVE_BACKEND - - HEADERS += \ - $$PWD/metatype/metainfo.h \ - $$PWD/metatype/nodemetainfo.h \ - $$PWD/metatype/propertymetainfo.h \ - $$PWD/metatype/QtDeclarativeMetaTypeBackend.h \ - $$PWD/metatype/invalidmetainfoexception.h - - SOURCES += \ - $$PWD/metatype/metainfo.cpp \ - $$PWD/metatype/nodemetainfo.cpp \ - $$PWD/metatype/propertymetainfo.cpp \ - $$PWD/metatype/QtDeclarativeMetaTypeBackend.cpp \ - $$PWD/metatype/invalidmetainfoexception.cpp -} diff --git a/src/shared/qml/metatype/QmlMetaTypeBackend.cpp b/src/shared/qmljs/QmlMetaTypeBackend.cpp similarity index 100% rename from src/shared/qml/metatype/QmlMetaTypeBackend.cpp rename to src/shared/qmljs/QmlMetaTypeBackend.cpp diff --git a/src/shared/qml/metatype/QmlMetaTypeBackend.h b/src/shared/qmljs/QmlMetaTypeBackend.h similarity index 95% rename from src/shared/qml/metatype/QmlMetaTypeBackend.h rename to src/shared/qmljs/QmlMetaTypeBackend.h index d9b9719dc1b..37f835449a0 100644 --- a/src/shared/qml/metatype/QmlMetaTypeBackend.h +++ b/src/shared/qmljs/QmlMetaTypeBackend.h @@ -30,9 +30,9 @@ #ifndef QMLMETATYPEBACKEND_H #define QMLMETATYPEBACKEND_H -#include <qml/qml_global.h> -#include <qml/qmlpackageinfo.h> -#include <qml/qmlsymbol.h> +#include <qmljs/qml_global.h> +#include <qmljs/qmlpackageinfo.h> +#include <qmljs/qmlsymbol.h> namespace Qml { diff --git a/src/shared/qml/metatype/QtDeclarativeMetaTypeBackend.cpp b/src/shared/qmljs/QtDeclarativeMetaTypeBackend.cpp similarity index 58% rename from src/shared/qml/metatype/QtDeclarativeMetaTypeBackend.cpp rename to src/shared/qmljs/QtDeclarativeMetaTypeBackend.cpp index 2533dcaff69..963423994be 100644 --- a/src/shared/qml/metatype/QtDeclarativeMetaTypeBackend.cpp +++ b/src/shared/qmljs/QtDeclarativeMetaTypeBackend.cpp @@ -27,7 +27,6 @@ ** **************************************************************************/ -#include "metainfo.h" #include "QtDeclarativeMetaTypeBackend.h" #include <QDebug> @@ -59,17 +58,9 @@ class QmlDeclarativeObjectSymbol: public QmlDeclarativeSymbol QmlDeclarativeObjectSymbol &operator=(const QmlDeclarativeObjectSymbol &); public: - QmlDeclarativeObjectSymbol(const NodeMetaInfo &metaInfo, QtDeclarativeMetaTypeBackend* backend): - QmlDeclarativeSymbol(backend), - m_metaInfo(metaInfo), - m_membersToBeDone(true) + QmlDeclarativeObjectSymbol(QtDeclarativeMetaTypeBackend* backend): + QmlDeclarativeSymbol(backend) { - Q_ASSERT(metaInfo.isValid()); - - m_name = m_metaInfo.typeName(); - const int slashIdx = m_name.indexOf('/'); - if (slashIdx != -1) - m_name = m_name.mid(slashIdx + 1); } virtual ~QmlDeclarativeObjectSymbol() @@ -83,19 +74,12 @@ public: virtual const List members() { - if (m_membersToBeDone) - initMembers(); - return m_members; } virtual List members(bool includeBaseClassMembers) { List result = members(); - - if (includeBaseClassMembers) - result.append(backend()->inheritedMembers(m_metaInfo)); - return result; } @@ -103,11 +87,6 @@ public: { return false; } public: - static QString key(const NodeMetaInfo &metaInfo) - { - return key(metaInfo.typeName(), metaInfo.majorVersion(), metaInfo.minorVersion()); - } - static QString key(const QString &typeNameWithPackage, int majorVersion, int minorVersion) { return QString(typeNameWithPackage) @@ -129,17 +108,6 @@ public: } private: - void initMembers() - { - if (!m_membersToBeDone) - return; - m_membersToBeDone = false; - - m_members = backend()->members(m_metaInfo); - } - -private: - NodeMetaInfo m_metaInfo; QString m_name; bool m_membersToBeDone; @@ -152,9 +120,8 @@ class QmlDeclarativePropertySymbol: public QmlDeclarativeSymbol QmlDeclarativePropertySymbol &operator=(const QmlDeclarativePropertySymbol &); public: - QmlDeclarativePropertySymbol(const PropertyMetaInfo &metaInfo, QtDeclarativeMetaTypeBackend* backend): - QmlDeclarativeSymbol(backend), - m_metaInfo(metaInfo) + QmlDeclarativePropertySymbol(QtDeclarativeMetaTypeBackend* backend): + QmlDeclarativeSymbol(backend) { } @@ -162,10 +129,10 @@ public: {} virtual const QString name() const - { return m_metaInfo.name(); } + { return QString(); } virtual QmlBuildInSymbol *type() const - { return backend()->typeOf(m_metaInfo); } + { return 0; } virtual const List members() { @@ -181,7 +148,6 @@ public: { return true; } private: - PropertyMetaInfo m_metaInfo; }; } // namespace Internal @@ -193,25 +159,15 @@ using namespace Qml::Internal; QtDeclarativeMetaTypeBackend::QtDeclarativeMetaTypeBackend(QmlTypeSystem *typeSystem): QmlMetaTypeBackend(typeSystem) { - foreach (const NodeMetaInfo &metaInfo, MetaInfo::global().allTypes()) { - m_symbols.insert(QmlDeclarativeObjectSymbol::key(metaInfo), new QmlDeclarativeObjectSymbol(metaInfo, this)); - } } QtDeclarativeMetaTypeBackend::~QtDeclarativeMetaTypeBackend() { - qDeleteAll(m_symbols.values()); } QList<QmlSymbol *> QtDeclarativeMetaTypeBackend::availableTypes(const QString &package, int majorVersion, int minorVersion) { QList<QmlSymbol *> result; - const QString prefix = package + QLatin1Char('/'); - - foreach (const NodeMetaInfo &metaInfo, MetaInfo::global().allTypes()) { - if (metaInfo.typeName().startsWith(prefix) && metaInfo.majorVersion() == majorVersion && metaInfo.minorVersion() == minorVersion) - result.append(getSymbol(metaInfo)); - } return result; } @@ -220,46 +176,6 @@ QmlSymbol *QtDeclarativeMetaTypeBackend::resolve(const QString &typeName, const { QList<QmlSymbol *> result; - foreach (const PackageInfo &package, packages) { - if (QmlSymbol *symbol = m_symbols.value(QmlDeclarativeObjectSymbol::key(package.name(), typeName, package.majorVersion(), package.minorVersion()), 0)) - return symbol; - } return 0; } - -QList<QmlSymbol *> QtDeclarativeMetaTypeBackend::members(const NodeMetaInfo &metaInfo) -{ - QList<QmlSymbol *> result; - - foreach (const PropertyMetaInfo &propertyInfo, metaInfo.properties(false).values()) { - result.append(new QmlDeclarativePropertySymbol(propertyInfo, this)); - } - - return result; -} - -QList<QmlSymbol *> QtDeclarativeMetaTypeBackend::inheritedMembers(const NodeMetaInfo &metaInfo) -{ - QList<QmlSymbol *> result; - - foreach (const NodeMetaInfo &superNode, metaInfo.directSuperClasses()) { - result.append(getSymbol(superNode)->members(true)); - } - - return result; -} - -QmlDeclarativeSymbol *QtDeclarativeMetaTypeBackend::typeOf(const PropertyMetaInfo &metaInfo) -{ - const QString key = QmlDeclarativeObjectSymbol::key(metaInfo.type(), metaInfo.typeMajorVersion(), metaInfo.typeMinorVersion()); - - return m_symbols.value(key, 0); -} - -QmlDeclarativeSymbol *QtDeclarativeMetaTypeBackend::getSymbol(const NodeMetaInfo &metaInfo) -{ - const QString key = QmlDeclarativeObjectSymbol::key(metaInfo); - - return m_symbols.value(key, 0); -} diff --git a/src/shared/qml/metatype/QtDeclarativeMetaTypeBackend.h b/src/shared/qmljs/QtDeclarativeMetaTypeBackend.h similarity index 81% rename from src/shared/qml/metatype/QtDeclarativeMetaTypeBackend.h rename to src/shared/qmljs/QtDeclarativeMetaTypeBackend.h index 2ef5eb3586d..dd565e5d570 100644 --- a/src/shared/qml/metatype/QtDeclarativeMetaTypeBackend.h +++ b/src/shared/qmljs/QtDeclarativeMetaTypeBackend.h @@ -30,9 +30,7 @@ #ifndef QTDECLARATIVEMETATYPEBACKEND_H #define QTDECLARATIVEMETATYPEBACKEND_H -#include <qml/metatype/QmlMetaTypeBackend.h> -#include <qml/metatype/nodemetainfo.h> -#include <qml/metatype/propertymetainfo.h> +#include <qmljs/QmlMetaTypeBackend.h> #include <QtCore/QList> @@ -57,15 +55,15 @@ public: virtual QmlSymbol *resolve(const QString &typeName, const QList<PackageInfo> &packages); protected: - QList<QmlSymbol *> members(const Qml::NodeMetaInfo &metaInfo); - QList<QmlSymbol *> inheritedMembers(const Qml::NodeMetaInfo &metaInfo); - QmlDeclarativeSymbol *typeOf(const Qml::PropertyMetaInfo &metaInfo); +// QList<QmlSymbol *> members(const Qml::NodeMetaInfo &metaInfo); +// QList<QmlSymbol *> inheritedMembers(const Qml::NodeMetaInfo &metaInfo); +// QmlDeclarativeSymbol *typeOf(const Qml::PropertyMetaInfo &metaInfo); private: - QmlDeclarativeSymbol *getSymbol(const Qml::NodeMetaInfo &metaInfo); +// QmlDeclarativeSymbol *getSymbol(const Qml::NodeMetaInfo &metaInfo); private: - QMap<QString, QmlDeclarativeSymbol*> m_symbols; +// QMap<QString, QmlDeclarativeSymbol*> m_symbols; }; } // namespace Internal diff --git a/src/shared/qml/parser/parser.pri b/src/shared/qmljs/parser/parser.pri similarity index 96% rename from src/shared/qml/parser/parser.pri rename to src/shared/qmljs/parser/parser.pri index 986b14673c8..ade452d5ff2 100644 --- a/src/shared/qml/parser/parser.pri +++ b/src/shared/qmljs/parser/parser.pri @@ -1,5 +1,5 @@ -INCLUDEPATH += $$PWD +##INCLUDEPATH += $$PWD DEPENDPATH += $$PWD HEADERS += $$PWD/qmljsast_p.h \ diff --git a/src/shared/qml/parser/qmljs.g b/src/shared/qmljs/parser/qmljs.g similarity index 100% rename from src/shared/qml/parser/qmljs.g rename to src/shared/qmljs/parser/qmljs.g diff --git a/src/shared/qml/parser/qmljsast.cpp b/src/shared/qmljs/parser/qmljsast.cpp similarity index 100% rename from src/shared/qml/parser/qmljsast.cpp rename to src/shared/qmljs/parser/qmljsast.cpp diff --git a/src/shared/qml/parser/qmljsast_p.h b/src/shared/qmljs/parser/qmljsast_p.h similarity index 100% rename from src/shared/qml/parser/qmljsast_p.h rename to src/shared/qmljs/parser/qmljsast_p.h diff --git a/src/shared/qml/parser/qmljsastfwd_p.h b/src/shared/qmljs/parser/qmljsastfwd_p.h similarity index 100% rename from src/shared/qml/parser/qmljsastfwd_p.h rename to src/shared/qmljs/parser/qmljsastfwd_p.h diff --git a/src/shared/qml/parser/qmljsastvisitor.cpp b/src/shared/qmljs/parser/qmljsastvisitor.cpp similarity index 100% rename from src/shared/qml/parser/qmljsastvisitor.cpp rename to src/shared/qmljs/parser/qmljsastvisitor.cpp diff --git a/src/shared/qml/parser/qmljsastvisitor_p.h b/src/shared/qmljs/parser/qmljsastvisitor_p.h similarity index 100% rename from src/shared/qml/parser/qmljsastvisitor_p.h rename to src/shared/qmljs/parser/qmljsastvisitor_p.h diff --git a/src/shared/qml/parser/qmljsengine_p.cpp b/src/shared/qmljs/parser/qmljsengine_p.cpp similarity index 100% rename from src/shared/qml/parser/qmljsengine_p.cpp rename to src/shared/qmljs/parser/qmljsengine_p.cpp diff --git a/src/shared/qml/parser/qmljsengine_p.h b/src/shared/qmljs/parser/qmljsengine_p.h similarity index 100% rename from src/shared/qml/parser/qmljsengine_p.h rename to src/shared/qmljs/parser/qmljsengine_p.h diff --git a/src/shared/qml/parser/qmljsglobal_p.h b/src/shared/qmljs/parser/qmljsglobal_p.h similarity index 100% rename from src/shared/qml/parser/qmljsglobal_p.h rename to src/shared/qmljs/parser/qmljsglobal_p.h diff --git a/src/shared/qml/parser/qmljsgrammar.cpp b/src/shared/qmljs/parser/qmljsgrammar.cpp similarity index 100% rename from src/shared/qml/parser/qmljsgrammar.cpp rename to src/shared/qmljs/parser/qmljsgrammar.cpp diff --git a/src/shared/qml/parser/qmljsgrammar_p.h b/src/shared/qmljs/parser/qmljsgrammar_p.h similarity index 100% rename from src/shared/qml/parser/qmljsgrammar_p.h rename to src/shared/qmljs/parser/qmljsgrammar_p.h diff --git a/src/shared/qml/parser/qmljslexer.cpp b/src/shared/qmljs/parser/qmljslexer.cpp similarity index 100% rename from src/shared/qml/parser/qmljslexer.cpp rename to src/shared/qmljs/parser/qmljslexer.cpp diff --git a/src/shared/qml/parser/qmljslexer_p.h b/src/shared/qmljs/parser/qmljslexer_p.h similarity index 100% rename from src/shared/qml/parser/qmljslexer_p.h rename to src/shared/qmljs/parser/qmljslexer_p.h diff --git a/src/shared/qml/parser/qmljsmemorypool_p.h b/src/shared/qmljs/parser/qmljsmemorypool_p.h similarity index 100% rename from src/shared/qml/parser/qmljsmemorypool_p.h rename to src/shared/qmljs/parser/qmljsmemorypool_p.h diff --git a/src/shared/qml/parser/qmljsnodepool_p.h b/src/shared/qmljs/parser/qmljsnodepool_p.h similarity index 100% rename from src/shared/qml/parser/qmljsnodepool_p.h rename to src/shared/qmljs/parser/qmljsnodepool_p.h diff --git a/src/shared/qml/parser/qmljsparser.cpp b/src/shared/qmljs/parser/qmljsparser.cpp similarity index 100% rename from src/shared/qml/parser/qmljsparser.cpp rename to src/shared/qmljs/parser/qmljsparser.cpp diff --git a/src/shared/qml/parser/qmljsparser_p.h b/src/shared/qmljs/parser/qmljsparser_p.h similarity index 100% rename from src/shared/qml/parser/qmljsparser_p.h rename to src/shared/qmljs/parser/qmljsparser_p.h diff --git a/src/shared/qml/qml_global.h b/src/shared/qmljs/qml_global.h similarity index 100% rename from src/shared/qml/qml_global.h rename to src/shared/qmljs/qml_global.h diff --git a/src/shared/qml/qmldocument.cpp b/src/shared/qmljs/qmldocument.cpp similarity index 95% rename from src/shared/qml/qmldocument.cpp rename to src/shared/qmljs/qmldocument.cpp index 473fb259d82..2cd13a58d5a 100644 --- a/src/shared/qml/qmldocument.cpp +++ b/src/shared/qmljs/qmldocument.cpp @@ -29,11 +29,11 @@ #include "qmlidcollector.h" #include "qmldocument.h" -#include "qmljsast_p.h" -#include "qmljslexer_p.h" -#include "qmljsparser_p.h" -#include "qmljsnodepool_p.h" -#include "qmljsastfwd_p.h" +#include <qmljs/parser/qmljsast_p.h> +#include <qmljs/parser/qmljslexer_p.h> +#include <qmljs/parser/qmljsparser_p.h> +#include <qmljs/parser/qmljsnodepool_p.h> +#include <qmljs/parser/qmljsastfwd_p.h> using namespace Qml; using namespace QmlJS; diff --git a/src/shared/qml/qmldocument.h b/src/shared/qmljs/qmldocument.h similarity index 100% rename from src/shared/qml/qmldocument.h rename to src/shared/qmljs/qmldocument.h diff --git a/src/shared/qml/qmlidcollector.cpp b/src/shared/qmljs/qmlidcollector.cpp similarity index 98% rename from src/shared/qml/qmlidcollector.cpp rename to src/shared/qmljs/qmlidcollector.cpp index 096728641a5..c45e9089ace 100644 --- a/src/shared/qml/qmlidcollector.cpp +++ b/src/shared/qmljs/qmlidcollector.cpp @@ -29,8 +29,9 @@ #include <QDebug> +#include <qmljs/parser/qmljsast_p.h> + #include "qmlidcollector.h" -#include "qmljsast_p.h" using namespace QmlJS; using namespace QmlJS::AST; diff --git a/src/shared/qml/qmlidcollector.h b/src/shared/qmljs/qmlidcollector.h similarity index 94% rename from src/shared/qml/qmlidcollector.h rename to src/shared/qmljs/qmlidcollector.h index 9fb93018dd8..310959c2404 100644 --- a/src/shared/qml/qmlidcollector.h +++ b/src/shared/qmljs/qmlidcollector.h @@ -30,10 +30,10 @@ #ifndef QMLIDCOLLECTOR_H #define QMLIDCOLLECTOR_H -#include <qml/parser/qmljsastvisitor_p.h> -#include <qml/parser/qmljsengine_p.h> -#include <qml/qmldocument.h> -#include <qml/qmlsymbol.h> +#include <qmljs/parser/qmljsastvisitor_p.h> +#include <qmljs/parser/qmljsengine_p.h> +#include <qmljs/qmldocument.h> +#include <qmljs/qmlsymbol.h> #include <QMap> #include <QPair> diff --git a/src/shared/qmljs/qmljs.pri b/src/shared/qmljs/qmljs.pri new file mode 100644 index 00000000000..c6128ec21ad --- /dev/null +++ b/src/shared/qmljs/qmljs.pri @@ -0,0 +1,33 @@ +include(parser/parser.pri) + +DEPENDPATH += $$PWD $$PWD/metatype +INCLUDEPATH += $$PWD/.. + +HEADERS += \ + $$PWD/qml_global.h \ + $$PWD/qmlidcollector.h \ + $$PWD/qmldocument.h \ + $$PWD/qmlpackageinfo.h \ + $$PWD/qmlsymbol.h \ + $$PWD/QmlMetaTypeBackend.h \ + $$PWD/qmltypesystem.h + +SOURCES += \ + $$PWD/qmlidcollector.cpp \ + $$PWD/qmldocument.cpp \ + $$PWD/qmlsymbol.cpp \ + $$PWD/qmlpackageinfo.cpp \ + $$PWD/QmlMetaTypeBackend.cpp \ + $$PWD/qmltypesystem.cpp + +contains(QT_CONFIG, declarative) { + QT += declarative + + DEFINES += BUILD_DECLARATIVE_BACKEND + + HEADERS += \ + $$PWD/QtDeclarativeMetaTypeBackend.h + + SOURCES += \ + $$PWD/QtDeclarativeMetaTypeBackend.cpp +} diff --git a/src/shared/qml/qmlpackageinfo.cpp b/src/shared/qmljs/qmlpackageinfo.cpp similarity index 100% rename from src/shared/qml/qmlpackageinfo.cpp rename to src/shared/qmljs/qmlpackageinfo.cpp diff --git a/src/shared/qml/qmlpackageinfo.h b/src/shared/qmljs/qmlpackageinfo.h similarity index 98% rename from src/shared/qml/qmlpackageinfo.h rename to src/shared/qmljs/qmlpackageinfo.h index 639588af208..bcb21172fe7 100644 --- a/src/shared/qml/qmlpackageinfo.h +++ b/src/shared/qmljs/qmlpackageinfo.h @@ -30,7 +30,7 @@ #ifndef PACKAGEINFO_H #define PACKAGEINFO_H -#include <qml/qml_global.h> +#include <qmljs/qml_global.h> #include <QtCore/QString> diff --git a/src/shared/qml/qmlsymbol.cpp b/src/shared/qmljs/qmlsymbol.cpp similarity index 99% rename from src/shared/qml/qmlsymbol.cpp rename to src/shared/qmljs/qmlsymbol.cpp index 4a8da962e45..96e946a7561 100644 --- a/src/shared/qml/qmlsymbol.cpp +++ b/src/shared/qmljs/qmlsymbol.cpp @@ -27,10 +27,11 @@ ** **************************************************************************/ -#include "qmljsast_p.h" -#include "qmljsengine_p.h" #include "qmlsymbol.h" +#include <qmljs/parser/qmljsast_p.h> +#include <qmljs/parser/qmljsengine_p.h> + using namespace Qml; using namespace QmlJS; using namespace QmlJS::AST; diff --git a/src/shared/qml/qmlsymbol.h b/src/shared/qmljs/qmlsymbol.h similarity index 98% rename from src/shared/qml/qmlsymbol.h rename to src/shared/qmljs/qmlsymbol.h index 6a42c8e3566..35ca2f3c8c8 100644 --- a/src/shared/qml/qmlsymbol.h +++ b/src/shared/qmljs/qmlsymbol.h @@ -30,8 +30,8 @@ #ifndef QMLSYMBOL_H #define QMLSYMBOL_H -#include <qml/parser/qmljsastfwd_p.h> -#include <qml/qml_global.h> +#include <qmljs/parser/qmljsastfwd_p.h> +#include <qmljs/qml_global.h> #include <QList> #include <QString> diff --git a/src/shared/qml/metatype/qmltypesystem.cpp b/src/shared/qmljs/qmltypesystem.cpp similarity index 100% rename from src/shared/qml/metatype/qmltypesystem.cpp rename to src/shared/qmljs/qmltypesystem.cpp diff --git a/src/shared/qml/metatype/qmltypesystem.h b/src/shared/qmljs/qmltypesystem.h similarity index 95% rename from src/shared/qml/metatype/qmltypesystem.h rename to src/shared/qmljs/qmltypesystem.h index cc553943bfc..3a0ff57577c 100644 --- a/src/shared/qml/metatype/qmltypesystem.h +++ b/src/shared/qmljs/qmltypesystem.h @@ -30,9 +30,9 @@ #ifndef QMLTYPESYSTEM_H #define QMLTYPESYSTEM_H -#include <qml/qml_global.h> -#include <qml/qmlpackageinfo.h> -#include <qml/qmlsymbol.h> +#include <qmljs/qml_global.h> +#include <qmljs/qmlpackageinfo.h> +#include <qmljs/qmlsymbol.h> #include <QtCore/QList> #include <QtCore/QObject> diff --git a/src/tools/qmldesigner/standalone/standalone.pro b/src/tools/qmldesigner/standalone/standalone.pro index f0e8fb093fc..9bc191991af 100644 --- a/src/tools/qmldesigner/standalone/standalone.pro +++ b/src/tools/qmldesigner/standalone/standalone.pro @@ -23,6 +23,12 @@ SOURCES += \ application.cpp \ welcomescreen.cpp +include(../../../shared/qmljs/qmljs.pri) +HEADERS+=../../../libs/utils/changeset.h +SOURCES+=../../../libs/utils/changeset.cpp +INCLUDEPATH+=../../../libs +DEFINES+=QTCREATOR_UTILS_STATIC_LIB QML_BUILD_STATIC_LIB + include(../../../plugins/qmldesigner/config.pri) include(../../../plugins/qmldesigner/components/integration/integration.pri) include(../../../plugins/qmldesigner/components/propertyeditor/propertyeditor.pri) diff --git a/tests/auto/qml/qmldesigner/bauhaustests/bauhaustests.pro b/tests/auto/qml/qmldesigner/bauhaustests/bauhaustests.pro index 19398348f93..e356d168a4b 100644 --- a/tests/auto/qml/qmldesigner/bauhaustests/bauhaustests.pro +++ b/tests/auto/qml/qmldesigner/bauhaustests/bauhaustests.pro @@ -3,6 +3,11 @@ QT += testlib DESTDIR = $$DESIGNER_BINARY_DIRECTORY include(../../../../../src/plugins/qmldesigner/core/core.pri) +include(../../../../../src/shared/qmljs/qmljs.pri) +HEADERS+=../../../../../src/libs/utils/changeset.h +SOURCES+=../../../../../src/libs/utils/changeset.cpp +INCLUDEPATH+=../../../../../src/libs +DEFINES+=QTCREATOR_UTILS_STATIC_LIB QML_BUILD_STATIC_LIB ##DEFINES += DONT_MESS_WITH_QDEBUG diff --git a/tests/auto/qml/qmldesigner/coretests/coretests.pro b/tests/auto/qml/qmldesigner/coretests/coretests.pro index 2466ac00943..803f2418869 100644 --- a/tests/auto/qml/qmldesigner/coretests/coretests.pro +++ b/tests/auto/qml/qmldesigner/coretests/coretests.pro @@ -4,8 +4,11 @@ QT += testlib \ declarative DESTDIR = $$DESIGNER_BINARY_DIRECTORY include(../../../../../src/plugins/qmldesigner/core/core.pri) -include(../../../../../src/shared/qml/qml.pri) -DEFINES+=QTCREATOR_UTILS_STATIC_LIB +include(../../../../../src/shared/qmljs/qmljs.pri) +HEADERS+=../../../../../src/libs/utils/changeset.h +SOURCES+=../../../../../src/libs/utils/changeset.cpp +INCLUDEPATH+=../../../../../src/libs +DEFINES+=QTCREATOR_UTILS_STATIC_LIB QML_BUILD_STATIC_LIB DEPENDPATH += .. DEPENDPATH += ../../../../../src/plugins/qmldesigner/core/include diff --git a/tests/auto/qml/qmldesigner/propertyeditortests/propertyeditortests.pro b/tests/auto/qml/qmldesigner/propertyeditortests/propertyeditortests.pro index 9daa18c38fb..9c86267b81b 100644 --- a/tests/auto/qml/qmldesigner/propertyeditortests/propertyeditortests.pro +++ b/tests/auto/qml/qmldesigner/propertyeditortests/propertyeditortests.pro @@ -6,6 +6,11 @@ QT += testlib \ declarative DESTDIR = $$DESIGNER_BINARY_DIRECTORY include(../../../../../src/plugins/qmldesigner/core/core.pri) +include(../../../../../src/shared/qmljs/qmljs.pri) +HEADERS+=../../../../../src/libs/utils/changeset.h +SOURCES+=../../../../../src/libs/utils/changeset.cpp +INCLUDEPATH+=../../../../../src/libs +DEFINES+=QTCREATOR_UTILS_STATIC_LIB QML_BUILD_STATIC_LIB DEPENDPATH += ../../../../../src/plugins/qmldesigner/core/include DEPENDPATH += .. diff --git a/tests/auto/qml/qmleditor/lookup/lookup.pro b/tests/auto/qml/qmleditor/lookup/lookup.pro index a37ab73133a..ab2edc5d591 100644 --- a/tests/auto/qml/qmleditor/lookup/lookup.pro +++ b/tests/auto/qml/qmleditor/lookup/lookup.pro @@ -1,7 +1,8 @@ TEMPLATE = app CONFIG += qt warn_on console depend_includepath QT += testlib -include(../../../../../src/libs/qml/qml-lib.pri) +include(../../../../../src/shared/qmljs/qmljs.pri) +DEFINES += QML_BUILD_STATIC_LIB EDITOR_DIR=../../../../../src/plugins/qmleditor INCLUDEPATH += $$EDITOR_DIR diff --git a/tests/auto/qml/qmleditor/lookup/tst_lookup.cpp b/tests/auto/qml/qmleditor/lookup/tst_lookup.cpp index 8b66c84d89e..aa0954c12d5 100644 --- a/tests/auto/qml/qmleditor/lookup/tst_lookup.cpp +++ b/tests/auto/qml/qmleditor/lookup/tst_lookup.cpp @@ -3,8 +3,8 @@ #include <QObject> #include <QFile> -#include <qml/qmldocument.h> -#include <qml/parser/qmljsast_p.h> +#include <qmljs/qmldocument.h> +#include <qmljs/parser/qmljsast_p.h> #include <qmllookupcontext.h> -- GitLab