forked from qt-creator/qt-creator
QmlDesigner: Use span for static property names
Since we change much of the API to PropertyNameView we can generate it at compile time. Change-Id: Ifb4482c346b6e50af74987a9c2ec03a6e75e6e1d Reviewed-by: Aleksei German <aleksei.german@qt.io>
This commit is contained in:
@@ -12,7 +12,7 @@ AddObjectVisitor::AddObjectVisitor(QmlDesigner::TextModifier &modifier,
|
|||||||
quint32 parentLocation,
|
quint32 parentLocation,
|
||||||
quint32 nodeLocation,
|
quint32 nodeLocation,
|
||||||
const QString &content,
|
const QString &content,
|
||||||
const PropertyNameList &propertyOrder)
|
Utils::span<const PropertyNameView> propertyOrder)
|
||||||
: QMLRewriter(modifier)
|
: QMLRewriter(modifier)
|
||||||
, m_parentLocation(parentLocation)
|
, m_parentLocation(parentLocation)
|
||||||
, m_nodeLocation(nodeLocation)
|
, m_nodeLocation(nodeLocation)
|
||||||
|
@@ -15,7 +15,7 @@ public:
|
|||||||
quint32 parentLocation,
|
quint32 parentLocation,
|
||||||
quint32 nodeLocation,
|
quint32 nodeLocation,
|
||||||
const QString &content,
|
const QString &content,
|
||||||
const PropertyNameList &propertyOrder);
|
Utils::span<const PropertyNameView> propertyOrder);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool visit(QmlJS::AST::UiObjectBinding *ast) override;
|
bool visit(QmlJS::AST::UiObjectBinding *ast) override;
|
||||||
@@ -28,7 +28,7 @@ private:
|
|||||||
quint32 m_parentLocation;
|
quint32 m_parentLocation;
|
||||||
quint32 m_nodeLocation;
|
quint32 m_nodeLocation;
|
||||||
QString m_content;
|
QString m_content;
|
||||||
PropertyNameList m_propertyOrder;
|
Utils::span<const PropertyNameView> m_propertyOrder;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -13,7 +13,7 @@ AddPropertyVisitor::AddPropertyVisitor(TextModifier &modifier,
|
|||||||
PropertyNameView name,
|
PropertyNameView name,
|
||||||
const QString &value,
|
const QString &value,
|
||||||
QmlRefactoring::PropertyType propertyType,
|
QmlRefactoring::PropertyType propertyType,
|
||||||
const PropertyNameList &propertyOrder,
|
Utils::span<const PropertyNameView> propertyOrder,
|
||||||
const TypeName &dynamicTypeName)
|
const TypeName &dynamicTypeName)
|
||||||
: QMLRewriter(modifier)
|
: QMLRewriter(modifier)
|
||||||
, m_parentLocation(parentLocation)
|
, m_parentLocation(parentLocation)
|
||||||
|
@@ -18,7 +18,7 @@ public:
|
|||||||
PropertyNameView name,
|
PropertyNameView name,
|
||||||
const QString &value,
|
const QString &value,
|
||||||
QmlRefactoring::PropertyType propertyType,
|
QmlRefactoring::PropertyType propertyType,
|
||||||
const PropertyNameList &propertyOrder,
|
Utils::span<const PropertyNameView> propertyOrder,
|
||||||
const TypeName &dynamicTypeName);
|
const TypeName &dynamicTypeName);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -33,7 +33,7 @@ private:
|
|||||||
PropertyNameView m_name;
|
PropertyNameView m_name;
|
||||||
QString m_value;
|
QString m_value;
|
||||||
QmlRefactoring::PropertyType m_propertyType;
|
QmlRefactoring::PropertyType m_propertyType;
|
||||||
PropertyNameList m_propertyOrder;
|
Utils::span<const PropertyNameView> m_propertyOrder;
|
||||||
TypeName m_dynamicTypeName;
|
TypeName m_dynamicTypeName;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -21,7 +21,7 @@ public:
|
|||||||
PropertyNameView targetPropertyName,
|
PropertyNameView targetPropertyName,
|
||||||
bool targetIsArrayBinding,
|
bool targetIsArrayBinding,
|
||||||
TextModifier::MoveInfo moveInfo,
|
TextModifier::MoveInfo moveInfo,
|
||||||
const PropertyNameList &propertyOrder)
|
Utils::span<const PropertyNameView> propertyOrder)
|
||||||
: QMLRewriter(modifier)
|
: QMLRewriter(modifier)
|
||||||
, targetParentObjectLocation(targetParentObjectLocation)
|
, targetParentObjectLocation(targetParentObjectLocation)
|
||||||
, targetPropertyName(targetPropertyName)
|
, targetPropertyName(targetPropertyName)
|
||||||
@@ -127,7 +127,7 @@ private:
|
|||||||
PropertyNameView targetPropertyName;
|
PropertyNameView targetPropertyName;
|
||||||
bool targetIsArrayBinding;
|
bool targetIsArrayBinding;
|
||||||
TextModifier::MoveInfo moveInfo;
|
TextModifier::MoveInfo moveInfo;
|
||||||
PropertyNameList propertyOrder;
|
Utils::span<const PropertyNameView> propertyOrder;
|
||||||
};
|
};
|
||||||
|
|
||||||
MoveObjectVisitor::MoveObjectVisitor(TextModifier &modifier,
|
MoveObjectVisitor::MoveObjectVisitor(TextModifier &modifier,
|
||||||
@@ -135,7 +135,7 @@ MoveObjectVisitor::MoveObjectVisitor(TextModifier &modifier,
|
|||||||
PropertyNameView targetPropertyName,
|
PropertyNameView targetPropertyName,
|
||||||
bool targetIsArrayBinding,
|
bool targetIsArrayBinding,
|
||||||
quint32 targetParentObjectLocation,
|
quint32 targetParentObjectLocation,
|
||||||
const PropertyNameList &propertyOrder)
|
Utils::span<const PropertyNameView> propertyOrder)
|
||||||
: QMLRewriter(modifier)
|
: QMLRewriter(modifier)
|
||||||
, objectLocation(objectLocation)
|
, objectLocation(objectLocation)
|
||||||
, targetPropertyName(targetPropertyName)
|
, targetPropertyName(targetPropertyName)
|
||||||
|
@@ -16,7 +16,7 @@ public:
|
|||||||
PropertyNameView targetPropertyName,
|
PropertyNameView targetPropertyName,
|
||||||
bool targetIsArrayBinding,
|
bool targetIsArrayBinding,
|
||||||
quint32 targetParentObjectLocation,
|
quint32 targetParentObjectLocation,
|
||||||
const PropertyNameList &propertyOrder);
|
Utils::span<const PropertyNameView> propertyOrder);
|
||||||
|
|
||||||
bool operator ()(QmlJS::AST::UiProgram *ast) override;
|
bool operator ()(QmlJS::AST::UiProgram *ast) override;
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ private:
|
|||||||
PropertyNameView targetPropertyName;
|
PropertyNameView targetPropertyName;
|
||||||
bool targetIsArrayBinding;
|
bool targetIsArrayBinding;
|
||||||
quint32 targetParentObjectLocation;
|
quint32 targetParentObjectLocation;
|
||||||
PropertyNameList propertyOrder;
|
Utils::span<const PropertyNameView> propertyOrder;
|
||||||
|
|
||||||
QmlJS::AST::UiProgram *program;
|
QmlJS::AST::UiProgram *program;
|
||||||
};
|
};
|
||||||
|
@@ -20,10 +20,12 @@ using namespace QmlJS;
|
|||||||
using namespace QmlDesigner;
|
using namespace QmlDesigner;
|
||||||
using namespace QmlDesigner::Internal;
|
using namespace QmlDesigner::Internal;
|
||||||
|
|
||||||
QmlRefactoring::QmlRefactoring(const Document::Ptr &doc, TextModifier &modifier, const PropertyNameList &propertyOrder):
|
QmlRefactoring::QmlRefactoring(const Document::Ptr &doc,
|
||||||
qmlDocument(doc),
|
TextModifier &modifier,
|
||||||
textModifier(&modifier),
|
Utils::span<const PropertyNameView> propertyOrder)
|
||||||
m_propertyOrder(propertyOrder)
|
: qmlDocument(doc)
|
||||||
|
, textModifier(&modifier)
|
||||||
|
, m_propertyOrder(propertyOrder)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -25,7 +25,9 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QmlRefactoring(const QmlJS::Document::Ptr &doc, QmlDesigner::TextModifier &modifier, const PropertyNameList &propertyOrder);
|
QmlRefactoring(const QmlJS::Document::Ptr &doc,
|
||||||
|
QmlDesigner::TextModifier &modifier,
|
||||||
|
Utils::span<const PropertyNameView> propertyOrder);
|
||||||
|
|
||||||
bool reparseDocument();
|
bool reparseDocument();
|
||||||
|
|
||||||
@@ -57,7 +59,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
QmlJS::Document::Ptr qmlDocument;
|
QmlJS::Document::Ptr qmlDocument;
|
||||||
TextModifier *textModifier;
|
TextModifier *textModifier;
|
||||||
PropertyNameList m_propertyOrder;
|
Utils::span<const PropertyNameView> m_propertyOrder;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace QmlDesigner
|
} // namespace QmlDesigner
|
||||||
|
@@ -197,10 +197,23 @@ void QMLRewriter::includeLeadingEmptyLine(int &start) const
|
|||||||
start = prevBlock.position();
|
start = prevBlock.position();
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: duplicate code in the QmlJS::Rewriter class, remove this
|
namespace {
|
||||||
QmlJS::AST::UiObjectMemberList *QMLRewriter::searchMemberToInsertAfter(QmlJS::AST::UiObjectMemberList *members, const QmlDesigner::PropertyNameList &propertyOrder)
|
int indexOf(Utils::span<const QmlDesigner::PropertyNameView> properties,
|
||||||
|
QmlDesigner::PropertyNameView name)
|
||||||
{
|
{
|
||||||
const int objectDefinitionInsertionPoint = propertyOrder.indexOf(PropertyName()); // XXX ????
|
auto found = std::ranges::find(properties, name);
|
||||||
|
if (found == properties.end())
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return static_cast<int>(std::distance(properties.begin(), found));
|
||||||
|
}
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
// FIXME: duplicate code in the QmlJS::Rewriter class, remove this
|
||||||
|
QmlJS::AST::UiObjectMemberList *QMLRewriter::searchMemberToInsertAfter(
|
||||||
|
QmlJS::AST::UiObjectMemberList *members, Utils::span<const PropertyNameView> propertyOrder)
|
||||||
|
{
|
||||||
|
const int objectDefinitionInsertionPoint = indexOf(propertyOrder, ""); // XXX ????
|
||||||
|
|
||||||
QmlJS::AST::UiObjectMemberList *lastObjectDef = nullptr;
|
QmlJS::AST::UiObjectMemberList *lastObjectDef = nullptr;
|
||||||
QmlJS::AST::UiObjectMemberList *lastNonObjectDef = nullptr;
|
QmlJS::AST::UiObjectMemberList *lastNonObjectDef = nullptr;
|
||||||
@@ -212,13 +225,13 @@ QmlJS::AST::UiObjectMemberList *QMLRewriter::searchMemberToInsertAfter(QmlJS::AS
|
|||||||
if (QmlJS::AST::cast<QmlJS::AST::UiObjectDefinition*>(member))
|
if (QmlJS::AST::cast<QmlJS::AST::UiObjectDefinition*>(member))
|
||||||
lastObjectDef = iter;
|
lastObjectDef = iter;
|
||||||
else if (auto arrayBinding = QmlJS::AST::cast<QmlJS::AST::UiArrayBinding*>(member))
|
else if (auto arrayBinding = QmlJS::AST::cast<QmlJS::AST::UiArrayBinding*>(member))
|
||||||
idx = propertyOrder.indexOf(toString(arrayBinding->qualifiedId).toUtf8());
|
idx = indexOf(propertyOrder, toString(arrayBinding->qualifiedId).toUtf8());
|
||||||
else if (auto objectBinding = QmlJS::AST::cast<QmlJS::AST::UiObjectBinding*>(member))
|
else if (auto objectBinding = QmlJS::AST::cast<QmlJS::AST::UiObjectBinding*>(member))
|
||||||
idx = propertyOrder.indexOf(toString(objectBinding->qualifiedId).toUtf8());
|
idx = indexOf(propertyOrder, toString(objectBinding->qualifiedId).toUtf8());
|
||||||
else if (auto scriptBinding = QmlJS::AST::cast<QmlJS::AST::UiScriptBinding*>(member))
|
else if (auto scriptBinding = QmlJS::AST::cast<QmlJS::AST::UiScriptBinding*>(member))
|
||||||
idx = propertyOrder.indexOf(toString(scriptBinding->qualifiedId).toUtf8());
|
idx = indexOf(propertyOrder, toString(scriptBinding->qualifiedId).toUtf8());
|
||||||
else if (QmlJS::AST::cast<QmlJS::AST::UiPublicMember*>(member))
|
else if (QmlJS::AST::cast<QmlJS::AST::UiPublicMember*>(member))
|
||||||
idx = propertyOrder.indexOf("property");
|
idx = indexOf(propertyOrder, "property");
|
||||||
|
|
||||||
if (idx < objectDefinitionInsertionPoint)
|
if (idx < objectDefinitionInsertionPoint)
|
||||||
lastNonObjectDef = iter;
|
lastNonObjectDef = iter;
|
||||||
@@ -234,7 +247,7 @@ QmlJS::AST::UiObjectMemberList *QMLRewriter::searchMemberToInsertAfter(QmlJS::AS
|
|||||||
QmlJS::AST::UiObjectMemberList *QMLRewriter::searchMemberToInsertAfter(
|
QmlJS::AST::UiObjectMemberList *QMLRewriter::searchMemberToInsertAfter(
|
||||||
QmlJS::AST::UiObjectMemberList *members,
|
QmlJS::AST::UiObjectMemberList *members,
|
||||||
PropertyNameView propertyName,
|
PropertyNameView propertyName,
|
||||||
const QmlDesigner::PropertyNameList &propertyOrder)
|
Utils::span<const PropertyNameView> propertyOrder)
|
||||||
{
|
{
|
||||||
if (!members)
|
if (!members)
|
||||||
return nullptr; // empty members
|
return nullptr; // empty members
|
||||||
@@ -256,15 +269,15 @@ QmlJS::AST::UiObjectMemberList *QMLRewriter::searchMemberToInsertAfter(
|
|||||||
orderedMembers[QStringLiteral("property")] = iter;
|
orderedMembers[QStringLiteral("property")] = iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
int idx = propertyOrder.indexOf(propertyName);
|
int idx = indexOf(propertyOrder, propertyName);
|
||||||
if (idx == -1)
|
if (idx == -1)
|
||||||
idx = propertyOrder.indexOf(PropertyName());
|
idx = indexOf(propertyOrder, "");
|
||||||
if (idx == -1)
|
if (idx == -1)
|
||||||
idx = propertyOrder.size() - 1;
|
idx = static_cast<int>(propertyOrder.size()) - 1;
|
||||||
|
|
||||||
for (; idx > 0; --idx) {
|
for (; idx > 0; --idx) {
|
||||||
const QString prop = QString::fromLatin1(propertyOrder.at(idx - 1));
|
const QString prop = QString::fromLatin1(propertyOrder[static_cast<std::size_t>(idx - 1)]);
|
||||||
QmlJS::AST::UiObjectMemberList *candidate = orderedMembers.value(prop, 0);
|
QmlJS::AST::UiObjectMemberList *candidate = orderedMembers.value(prop, nullptr);
|
||||||
if (candidate != nullptr)
|
if (candidate != nullptr)
|
||||||
return candidate;
|
return candidate;
|
||||||
}
|
}
|
||||||
@@ -273,14 +286,14 @@ QmlJS::AST::UiObjectMemberList *QMLRewriter::searchMemberToInsertAfter(
|
|||||||
}
|
}
|
||||||
|
|
||||||
QmlJS::AST::UiObjectMemberList *QMLRewriter::searchChildrenToInsertAfter(
|
QmlJS::AST::UiObjectMemberList *QMLRewriter::searchChildrenToInsertAfter(
|
||||||
QmlJS::AST::UiObjectMemberList *members, const PropertyNameList &propertyOrder, int pos)
|
QmlJS::AST::UiObjectMemberList *members, Utils::span<const PropertyNameView> propertyOrder, int pos)
|
||||||
{
|
{
|
||||||
if (pos < 0)
|
if (pos < 0)
|
||||||
return searchMemberToInsertAfter(members, propertyOrder);
|
return searchMemberToInsertAfter(members, propertyOrder);
|
||||||
|
|
||||||
// An empty property name should be available in the propertyOrder List, which is the right place
|
// An empty property name should be available in the propertyOrder List, which is the right place
|
||||||
// to define the objects there.
|
// to define the objects there.
|
||||||
const int objectDefinitionInsertionPoint = propertyOrder.indexOf(PropertyName());
|
const int objectDefinitionInsertionPoint = indexOf(propertyOrder, "");
|
||||||
|
|
||||||
QmlJS::AST::UiObjectMemberList *lastObjectDef = nullptr;
|
QmlJS::AST::UiObjectMemberList *lastObjectDef = nullptr;
|
||||||
QmlJS::AST::UiObjectMemberList *lastNonObjectDef = nullptr;
|
QmlJS::AST::UiObjectMemberList *lastNonObjectDef = nullptr;
|
||||||
@@ -295,13 +308,13 @@ QmlJS::AST::UiObjectMemberList *QMLRewriter::searchChildrenToInsertAfter(
|
|||||||
if (objectPos++ == pos)
|
if (objectPos++ == pos)
|
||||||
break;
|
break;
|
||||||
} else if (auto arrayBinding = QmlJS::AST::cast<QmlJS::AST::UiArrayBinding *>(member))
|
} else if (auto arrayBinding = QmlJS::AST::cast<QmlJS::AST::UiArrayBinding *>(member))
|
||||||
idx = propertyOrder.indexOf(toString(arrayBinding->qualifiedId).toUtf8());
|
idx = indexOf(propertyOrder, toString(arrayBinding->qualifiedId).toUtf8());
|
||||||
else if (auto objectBinding = QmlJS::AST::cast<QmlJS::AST::UiObjectBinding *>(member))
|
else if (auto objectBinding = QmlJS::AST::cast<QmlJS::AST::UiObjectBinding *>(member))
|
||||||
idx = propertyOrder.indexOf(toString(objectBinding->qualifiedId).toUtf8());
|
idx = indexOf(propertyOrder, toString(objectBinding->qualifiedId).toUtf8());
|
||||||
else if (auto scriptBinding = QmlJS::AST::cast<QmlJS::AST::UiScriptBinding *>(member))
|
else if (auto scriptBinding = QmlJS::AST::cast<QmlJS::AST::UiScriptBinding *>(member))
|
||||||
idx = propertyOrder.indexOf(toString(scriptBinding->qualifiedId).toUtf8());
|
idx = indexOf(propertyOrder, toString(scriptBinding->qualifiedId).toUtf8());
|
||||||
else if (QmlJS::AST::cast<QmlJS::AST::UiPublicMember *>(member))
|
else if (QmlJS::AST::cast<QmlJS::AST::UiPublicMember *>(member))
|
||||||
idx = propertyOrder.indexOf("property");
|
idx = indexOf(propertyOrder, "property");
|
||||||
|
|
||||||
if (idx < objectDefinitionInsertionPoint)
|
if (idx < objectDefinitionInsertionPoint)
|
||||||
lastNonObjectDef = iter;
|
lastNonObjectDef = iter;
|
||||||
|
@@ -51,13 +51,16 @@ protected:
|
|||||||
bool includeSurroundingWhitespace(int &start, int &end) const;
|
bool includeSurroundingWhitespace(int &start, int &end) const;
|
||||||
void includeLeadingEmptyLine(int &start) const;
|
void includeLeadingEmptyLine(int &start) const;
|
||||||
|
|
||||||
static QmlJS::AST::UiObjectMemberList *searchMemberToInsertAfter(QmlJS::AST::UiObjectMemberList *members, const PropertyNameList &propertyOrder);
|
static QmlJS::AST::UiObjectMemberList *searchMemberToInsertAfter(
|
||||||
|
QmlJS::AST::UiObjectMemberList *members, Utils::span<const PropertyNameView> propertyOrder);
|
||||||
static QmlJS::AST::UiObjectMemberList *searchMemberToInsertAfter(
|
static QmlJS::AST::UiObjectMemberList *searchMemberToInsertAfter(
|
||||||
QmlJS::AST::UiObjectMemberList *members,
|
QmlJS::AST::UiObjectMemberList *members,
|
||||||
PropertyNameView propertyName,
|
PropertyNameView propertyName,
|
||||||
const PropertyNameList &propertyOrder);
|
Utils::span<const PropertyNameView> propertyOrder);
|
||||||
static QmlJS::AST::UiObjectMemberList *searchChildrenToInsertAfter(
|
static QmlJS::AST::UiObjectMemberList *searchChildrenToInsertAfter(
|
||||||
QmlJS::AST::UiObjectMemberList *members, const PropertyNameList &propertyOrder, int pos = -1);
|
QmlJS::AST::UiObjectMemberList *members,
|
||||||
|
Utils::span<const PropertyNameView> propertyOrder,
|
||||||
|
int pos = -1);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool didRewriting() const
|
bool didRewriting() const
|
||||||
|
@@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
#include <qmljs/parser/qmljsengine_p.h>
|
#include <qmljs/parser/qmljsengine_p.h>
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
|
#include <utils/array.h>
|
||||||
|
#include <utils/span.h>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
enum {
|
enum {
|
||||||
@@ -355,52 +357,53 @@ QmlRefactoring::PropertyType ModelToTextMerger::propertyType(const AbstractPrope
|
|||||||
return QmlRefactoring::Invalid;
|
return QmlRefactoring::Invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
PropertyNameList ModelToTextMerger::propertyOrder()
|
Utils::span<const PropertyNameView> ModelToTextMerger::propertyOrder()
|
||||||
{
|
{
|
||||||
static const PropertyNameList properties = {PropertyName("id"),
|
static constexpr auto propertyNames = Utils::to_array<PropertyNameView>(
|
||||||
PropertyName("name"),
|
"id",
|
||||||
PropertyName("target"),
|
"name",
|
||||||
PropertyName("property"),
|
"target",
|
||||||
PropertyName("x"),
|
"property",
|
||||||
PropertyName("y"),
|
"x",
|
||||||
PropertyName("width"),
|
"y",
|
||||||
PropertyName("height"),
|
"width",
|
||||||
PropertyName("opacity"),
|
"height",
|
||||||
PropertyName("visible"),
|
"opacity",
|
||||||
PropertyName("position"),
|
"visible",
|
||||||
PropertyName("color"),
|
"position",
|
||||||
PropertyName("radius"),
|
"color",
|
||||||
PropertyName("text"),
|
"radius",
|
||||||
PropertyName("elide"),
|
"text",
|
||||||
PropertyName("value"),
|
"elide",
|
||||||
PropertyName("border.color"),
|
"value",
|
||||||
PropertyName("border.width"),
|
"border.color",
|
||||||
PropertyName("anchors.verticalCenter"),
|
"border.width",
|
||||||
PropertyName("anchors.left"),
|
"anchors.verticalCenter",
|
||||||
PropertyName("anchors.right"),
|
"anchors.left",
|
||||||
PropertyName("anchors.top"),
|
"anchors.right",
|
||||||
PropertyName("anchors.bottom"),
|
"anchors.top",
|
||||||
PropertyName("anchors.fill"),
|
"anchors.bottom",
|
||||||
PropertyName("anchors.margins"),
|
"anchors.fill",
|
||||||
PropertyName("anchors.leftMargin"),
|
"anchors.margins",
|
||||||
PropertyName("anchors.rightMargin"),
|
"anchors.leftMargin",
|
||||||
PropertyName("anchors.topMargin"),
|
"anchors.rightMargin",
|
||||||
PropertyName("anchors.bottomMargin"),
|
"anchors.topMargin",
|
||||||
PropertyName("font.letterSpacing"),
|
"anchors.bottomMargin",
|
||||||
PropertyName("font.pixelSize"),
|
"font.letterSpacing",
|
||||||
PropertyName("horizontalAlignment"),
|
"font.pixelSize",
|
||||||
PropertyName("verticalAlignment"),
|
"horizontalAlignment",
|
||||||
PropertyName("source"),
|
"verticalAlignment",
|
||||||
PropertyName("lineHeight"),
|
"source",
|
||||||
PropertyName("lineHeightMode"),
|
"lineHeight",
|
||||||
PropertyName("wrapMode"),
|
"lineHeightMode",
|
||||||
PropertyName(),
|
"wrapMode",
|
||||||
PropertyName("states"),
|
"",
|
||||||
PropertyName("to"),
|
"states",
|
||||||
PropertyName("from"),
|
"to",
|
||||||
PropertyName("transitions")};
|
"from",
|
||||||
|
"transitions");
|
||||||
|
|
||||||
return properties;
|
return propertyNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ModelToTextMerger::isInHierarchy(const AbstractProperty &property) {
|
bool ModelToTextMerger::isInHierarchy(const AbstractProperty &property) {
|
||||||
|
@@ -52,7 +52,7 @@ protected:
|
|||||||
{ return m_rewriteActions; }
|
{ return m_rewriteActions; }
|
||||||
|
|
||||||
static QmlDesigner::QmlRefactoring::PropertyType propertyType(const AbstractProperty &property, const QString &textValue = QString());
|
static QmlDesigner::QmlRefactoring::PropertyType propertyType(const AbstractProperty &property, const QString &textValue = QString());
|
||||||
static PropertyNameList propertyOrder();
|
static Utils::span<const PropertyNameView> propertyOrder();
|
||||||
|
|
||||||
static bool isInHierarchy(const AbstractProperty &property);
|
static bool isInHierarchy(const AbstractProperty &property);
|
||||||
|
|
||||||
|
@@ -72,7 +72,7 @@ static QString unicodeEscape(const QString &stringValue)
|
|||||||
return stringValue;
|
return stringValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlTextGenerator::QmlTextGenerator(const PropertyNameList &propertyOrder,
|
QmlTextGenerator::QmlTextGenerator(Utils::span<const PropertyNameView> propertyOrder,
|
||||||
const TextEditor::TabSettings &tabSettings,
|
const TextEditor::TabSettings &tabSettings,
|
||||||
const int startIndentDepth)
|
const int startIndentDepth)
|
||||||
: m_propertyOrder(propertyOrder)
|
: m_propertyOrder(propertyOrder)
|
||||||
@@ -220,7 +220,7 @@ QString QmlTextGenerator::propertiesToQml(const ModelNode &node, int indentDepth
|
|||||||
PropertyNameList nodePropertyNames = node.propertyNames();
|
PropertyNameList nodePropertyNames = node.propertyNames();
|
||||||
bool addToTop = true;
|
bool addToTop = true;
|
||||||
|
|
||||||
for (const PropertyName &propertyName : std::as_const(m_propertyOrder)) {
|
for (const auto propertyName : m_propertyOrder) {
|
||||||
if (propertyName == "id") {
|
if (propertyName == "id") {
|
||||||
// the model handles the id property special, so:
|
// the model handles the id property special, so:
|
||||||
if (!node.id().isEmpty()) {
|
if (!node.id().isEmpty()) {
|
||||||
|
@@ -16,7 +16,7 @@ namespace Internal {
|
|||||||
class QmlTextGenerator
|
class QmlTextGenerator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit QmlTextGenerator(const PropertyNameList &propertyOrder,
|
explicit QmlTextGenerator(Utils::span<const PropertyNameView> propertyOrder,
|
||||||
const TextEditor::TabSettings &tabSettings,
|
const TextEditor::TabSettings &tabSettings,
|
||||||
const int startIndentDepth = 0);
|
const int startIndentDepth = 0);
|
||||||
|
|
||||||
@@ -33,7 +33,7 @@ private:
|
|||||||
QString propertyToQml(const AbstractProperty &property, int indentDepth) const;
|
QString propertyToQml(const AbstractProperty &property, int indentDepth) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PropertyNameList m_propertyOrder;
|
Utils::span<const PropertyNameView> m_propertyOrder;
|
||||||
TextEditor::TabSettings m_tabSettings;
|
TextEditor::TabSettings m_tabSettings;
|
||||||
const int m_startIndentDepth;
|
const int m_startIndentDepth;
|
||||||
};
|
};
|
||||||
|
@@ -11,9 +11,10 @@ namespace Internal {
|
|||||||
class RewriteActionCompressor
|
class RewriteActionCompressor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RewriteActionCompressor(const PropertyNameList &propertyOrder, ModelNodePositionStorage *positionStore) :
|
RewriteActionCompressor(Utils::span<const PropertyNameView> propertyOrder,
|
||||||
m_propertyOrder(propertyOrder),
|
ModelNodePositionStorage *positionStore)
|
||||||
m_positionStore(positionStore)
|
: m_propertyOrder(propertyOrder)
|
||||||
|
, m_positionStore(positionStore)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void operator()(QList<RewriteAction *> &actions, const TextEditor::TabSettings &tabSettings) const;
|
void operator()(QList<RewriteAction *> &actions, const TextEditor::TabSettings &tabSettings) const;
|
||||||
@@ -31,7 +32,7 @@ private:
|
|||||||
void compressSlidesIntoNewNode(QList<RewriteAction *> &actions) const;
|
void compressSlidesIntoNewNode(QList<RewriteAction *> &actions) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PropertyNameList m_propertyOrder;
|
Utils::span<const PropertyNameView> m_propertyOrder;
|
||||||
ModelNodePositionStorage *m_positionStore;
|
ModelNodePositionStorage *m_positionStore;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user