Commit 68a463cf authored by Erik Verbruggen's avatar Erik Verbruggen
Browse files

Switched QML designer to use the ast for loading.

parent 8b7eacc1
......@@ -401,7 +401,7 @@ private:
QString _className;
};
class QmlObjectValue: public ObjectValue
class QMLJS_EXPORT QmlObjectValue: public ObjectValue
{
public:
static const int NoVersion;
......
......@@ -22,5 +22,6 @@ will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.</license>
<dependencyList>
<dependency name="Core" version="1.3.82"/>
<dependency name="TextEditor" version="1.3.82"/>
<dependency name="QmlJSEditor" version="1.3.82"/>
</dependencyList>
</plugin>
......@@ -36,6 +36,10 @@
#include <texteditor/basetexteditor.h>
namespace QmlJS {
class Snapshot;
} // namespace QmlJS
namespace QmlDesigner {
class CORESHARED_EXPORT BaseTextEditModifier: public PlainTextEditModifier
......@@ -46,6 +50,8 @@ public:
virtual void indent(int offset, int length);
virtual int indentDepth() const;
static QmlJS::Snapshot getSnapshot();
};
} // namespace QmlDesigner
......
......@@ -29,9 +29,13 @@
#include "basetexteditmodifier.h"
#include <extensionsystem/pluginmanager.h>
#include <qmljs/qmljsdocument.h>
#include <qmljseditor/qmljsmodelmanagerinterface.h>
#include <texteditor/tabsettings.h>
using namespace QmlDesigner;
using namespace QmlJSEditor;
BaseTextEditModifier::BaseTextEditModifier(TextEditor::BaseTextEditor *textEdit):
PlainTextEditModifier(textEdit)
......@@ -63,3 +67,13 @@ int BaseTextEditModifier::indentDepth() const
return 0;
}
}
QmlJS::Snapshot BaseTextEditModifier::getSnapshot()
{
ExtensionSystem::PluginManager *pluginManager = ExtensionSystem::PluginManager::instance();
QmlJSEditor::ModelManagerInterface *modelManager = pluginManager->getObject<QmlJSEditor::ModelManagerInterface>();
if (modelManager)
return modelManager->snapshot();
else
return QmlJS::Snapshot();
}
......@@ -34,6 +34,7 @@
#include "import.h"
#include "nodelistproperty.h"
#include "modelnode.h"
#include <qmljs/qmljsdocument.h>
#include <private/qdeclarativedom_p.h>
......@@ -43,6 +44,7 @@ class CORESHARED_EXPORT RewriterView;
namespace Internal {
class ReadingContext;
class DifferenceHandler;
class TextToModelMerger
......@@ -54,7 +56,7 @@ public:
TextToModelMerger(RewriterView *reWriterView);
bool isActive() const;
void setupImports(QDeclarativeDomDocument &doc, DifferenceHandler &differenceHandler);
void setupImports(const QmlJS::Document::Ptr &doc, DifferenceHandler &differenceHandler);
bool load(const QByteArray &data, DifferenceHandler &differenceHandler);
RewriterView *view() const
......@@ -65,25 +67,51 @@ protected:
public:
void syncNode(ModelNode &modelNode,
const QDeclarativeDomObject &qmlObject,
QmlJS::AST::UiObjectMember *astNode,
ReadingContext *context,
DifferenceHandler &differenceHandler);
void syncProperty(AbstractProperty &modelProperty,
const QDeclarativeDomProperty &qmlProperty,
const QDeclarativeDomDynamicProperty &qmlDynamicProperty,
DifferenceHandler &differenceHandler);
void syncNodeId(ModelNode &modelNode, const QString &astObjectId,
DifferenceHandler &differenceHandler);
void syncNodeProperty(AbstractProperty &modelProperty,
QmlJS::AST::UiObjectBinding *binding,
ReadingContext *context,
DifferenceHandler &differenceHandler);
void syncExpressionProperty(AbstractProperty &modelProperty,
const QString &javascript,
DifferenceHandler &differenceHandler);
void syncArrayProperty(AbstractProperty &modelProperty,
QmlJS::AST::UiArrayBinding *array,
ReadingContext *context,
DifferenceHandler &differenceHandler);
void syncVariantProperty(AbstractProperty &modelProperty,
const QString &astName,
const QString &astValue,
const QString &astType,
DifferenceHandler &differenceHandler);
void syncNodeListProperty(NodeListProperty &modelListProperty,
const QDeclarativeDomList &domList,
const QList<QmlJS::AST::UiObjectMember *> arrayMembers,
ReadingContext *context,
DifferenceHandler &differenceHandler);
ModelNode createModelNode(const QDeclarativeDomObject &domObject,
ModelNode createModelNode(const QString &typeName,
int majorVersion,
int minorVersion,
QmlJS::AST::UiObjectMember *astNode,
ReadingContext *context,
DifferenceHandler &differenceHandler);
static QVariant convertToVariant(const ModelNode &node,
const QDeclarativeDomProperty &qmlProperty,
const QDeclarativeDomDynamicProperty &qmlDynamicProperty);
const QString &astName,
const QString &astValue,
const QString &astType);
private:
static bool isSignalPropertyName(const QString &signalName);
void setupComponent(const ModelNode &node);
static QString textAt(const QmlJS::Document::Ptr &doc,
const QmlJS::AST::SourceLocation &location);
static QString textAt(const QmlJS::Document::Ptr &doc,
const QmlJS::AST::SourceLocation &from,
const QmlJS::AST::SourceLocation &to);
private:
RewriterView *m_rewriterView;
bool m_isActive;
......@@ -100,15 +128,32 @@ public:
virtual void modelMissesImport(const Import &import) = 0;
virtual void importAbsentInQMl(const Import &import) = 0;
virtual void bindingExpressionsDiffer(BindingProperty &modelProperty, const QString &QDeclarativeBinding) = 0;
virtual void shouldBeBindingProperty(AbstractProperty &modelProperty, const QString &QDeclarativeBinding) = 0;
virtual void shouldBeNodeListProperty(AbstractProperty &modelProperty, const QDeclarativeDomList &domList) = 0;
virtual void bindingExpressionsDiffer(BindingProperty &modelProperty,
const QString &javascript) = 0;
virtual void shouldBeBindingProperty(AbstractProperty &modelProperty,
const QString &javascript) = 0;
virtual void shouldBeNodeListProperty(AbstractProperty &modelProperty,
const QList<QmlJS::AST::UiObjectMember *> arrayMembers,
ReadingContext *context) = 0;
virtual void variantValuesDiffer(VariantProperty &modelProperty, const QVariant &qmlVariantValue, const QString &dynamicTypeName) = 0;
virtual void shouldBeVariantProperty(AbstractProperty &modelProperty, const QVariant &qmlVariantValue, const QString &dynamicTypeName) = 0;
virtual void shouldBeNodeProperty(AbstractProperty &modelProperty, const QDeclarativeDomObject &qmlObject) = 0;
virtual void shouldBeNodeProperty(AbstractProperty &modelProperty,
const QString &typeName,
int majorVersion,
int minorVersion,
QmlJS::AST::UiObjectMember *astNode,
ReadingContext *context) = 0;
virtual void modelNodeAbsentFromQml(ModelNode &modelNode) = 0;
virtual ModelNode listPropertyMissingModelNode(NodeListProperty &modelProperty, const QDeclarativeDomObject &qmlObject) = 0;
virtual void typeDiffers(bool isRootNode, ModelNode &modelNode, const QDeclarativeDomObject &domObject) = 0;
virtual ModelNode listPropertyMissingModelNode(NodeListProperty &modelProperty,
ReadingContext *context,
QmlJS::AST::UiObjectMember *arrayMember) = 0;
virtual void typeDiffers(bool isRootNode,
ModelNode &modelNode,
const QString &typeName,
int majorVersion,
int minorVersion,
QmlJS::AST::UiObjectMember *astNode,
ReadingContext *context) = 0;
virtual void propertyAbsentFromQml(AbstractProperty &modelProperty) = 0;
virtual void idsDiffer(ModelNode &modelNode, const QString &qmlId) = 0;
......@@ -127,15 +172,32 @@ public:
virtual void modelMissesImport(const Import &import);
virtual void importAbsentInQMl(const Import &import);
virtual void bindingExpressionsDiffer(BindingProperty &modelProperty, const QString &QDeclarativeBinding);
virtual void shouldBeBindingProperty(AbstractProperty &modelProperty, const QString &QDeclarativeBinding);
virtual void shouldBeNodeListProperty(AbstractProperty &modelProperty, const QDeclarativeDomList &domList);
virtual void bindingExpressionsDiffer(BindingProperty &modelProperty,
const QString &javascript);
virtual void shouldBeBindingProperty(AbstractProperty &modelProperty,
const QString &javascript);
virtual void shouldBeNodeListProperty(AbstractProperty &modelProperty,
const QList<QmlJS::AST::UiObjectMember *> arrayMembers,
ReadingContext *context);
virtual void variantValuesDiffer(VariantProperty &modelProperty, const QVariant &qmlVariantValue, const QString &dynamicTypeName);
virtual void shouldBeVariantProperty(AbstractProperty &modelProperty, const QVariant &qmlVariantValue, const QString &dynamicTypeName);
virtual void shouldBeNodeProperty(AbstractProperty &modelProperty, const QDeclarativeDomObject &qmlObject);
virtual void shouldBeNodeProperty(AbstractProperty &modelProperty,
const QString &typeName,
int majorVersion,
int minorVersion,
QmlJS::AST::UiObjectMember *astNode,
ReadingContext *context);
virtual void modelNodeAbsentFromQml(ModelNode &modelNode);
virtual ModelNode listPropertyMissingModelNode(NodeListProperty &modelProperty, const QDeclarativeDomObject &qmlObject);
virtual void typeDiffers(bool isRootNode, ModelNode &modelNode, const QDeclarativeDomObject &domObject);
virtual ModelNode listPropertyMissingModelNode(NodeListProperty &modelProperty,
ReadingContext *context,
QmlJS::AST::UiObjectMember *arrayMember);
virtual void typeDiffers(bool isRootNode,
ModelNode &modelNode,
const QString &typeName,
int majorVersion,
int minorVersion,
QmlJS::AST::UiObjectMember *astNode,
ReadingContext *context);
virtual void propertyAbsentFromQml(AbstractProperty &modelProperty);
virtual void idsDiffer(ModelNode &modelNode, const QString &qmlId);
};
......@@ -151,15 +213,32 @@ public:
virtual void modelMissesImport(const Import &import);
virtual void importAbsentInQMl(const Import &import);
virtual void bindingExpressionsDiffer(BindingProperty &modelProperty, const QString &QDeclarativeBinding);
virtual void shouldBeBindingProperty(AbstractProperty &modelProperty, const QString &QDeclarativeBinding);
virtual void shouldBeNodeListProperty(AbstractProperty &modelProperty, const QDeclarativeDomList &domList);
virtual void bindingExpressionsDiffer(BindingProperty &modelProperty,
const QString &javascript);
virtual void shouldBeBindingProperty(AbstractProperty &modelProperty,
const QString &javascript);
virtual void shouldBeNodeListProperty(AbstractProperty &modelProperty,
const QList<QmlJS::AST::UiObjectMember *> arrayMembers,
ReadingContext *context);
virtual void variantValuesDiffer(VariantProperty &modelProperty, const QVariant &qmlVariantValue, const QString &dynamicType);
virtual void shouldBeVariantProperty(AbstractProperty &modelProperty, const QVariant &qmlVariantValue, const QString &dynamicTypeName);
virtual void shouldBeNodeProperty(AbstractProperty &modelProperty, const QDeclarativeDomObject &qmlObject);
virtual void shouldBeNodeProperty(AbstractProperty &modelProperty,
const QString &typeName,
int majorVersion,
int minorVersion,
QmlJS::AST::UiObjectMember *astNode,
ReadingContext *context);
virtual void modelNodeAbsentFromQml(ModelNode &modelNode);
virtual ModelNode listPropertyMissingModelNode(NodeListProperty &modelProperty, const QDeclarativeDomObject &qmlObject);
virtual void typeDiffers(bool isRootNode, ModelNode &modelNode, const QDeclarativeDomObject &domObject);
virtual ModelNode listPropertyMissingModelNode(NodeListProperty &modelProperty,
ReadingContext *context,
QmlJS::AST::UiObjectMember *arrayMember);
virtual void typeDiffers(bool isRootNode,
ModelNode &modelNode,
const QString &typeName,
int majorVersion,
int minorVersion,
QmlJS::AST::UiObjectMember *astNode,
ReadingContext *context);
virtual void propertyAbsentFromQml(AbstractProperty &modelProperty);
virtual void idsDiffer(ModelNode &modelNode, const QString &qmlId);
};
......
......@@ -4,6 +4,7 @@ TARGET = QmlDesigner
include(../../qtcreatorplugin.pri)
include(../private_headers.pri)
include(qmldesigner_dependencies.pri)
include(../qmljseditor/qmljseditor.pri)
include(core/core.pri)
include(components/integration/integration.pri)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment