aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThomas Hartmann <thomas.hartmann@qt.io>2017-11-15 15:43:28 +0100
committerTim Jenssen <tim.jenssen@qt.io>2017-11-16 08:10:21 +0000
commit17b761ce86e9fdfadff49b35858533d06ba0d05b (patch)
tree9e60745c9f52acccb6b7e227e5782a3e9f545107 /src
parent09f02013e5b28e8bc1d74f593b7580c7e9f131c0 (diff)
QmlDesigner: Ignore indentation for multi line expressions
If expressions cover multiple lines they might be altered by the indenter. This means the expression differs slighlty in white spaces. This did assert before, but is a false alarm. For now we just treat the white spaces in th beginning of the line as a special case. Eventually we have to fully normalize expressions. Task-number: QTCREATORBUG-19284 Change-Id: Icc57ef08d1c889deded7cca08ccfba66f09f3115 Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp b/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp
index 47ce2bad15..6255fd85fd 100644
--- a/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp
+++ b/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp
@@ -55,6 +55,7 @@
#include <QSet>
#include <QDir>
#include <QLoggingCategory>
+#include <QRegularExpression>
using namespace LanguageUtils;
using namespace QmlJS;
@@ -330,6 +331,19 @@ static inline QString extractComponentFromQml(const QString &source)
return result;
}
+static QString normalizeJavaScriptExpression(const QString &expression)
+{
+ static const QRegularExpression regExp("\\n(\\s)+");
+
+ QString result = expression;
+ return result.replace(regExp, "\n");
+}
+
+static bool compareJavaScriptExpression(const QString &expression1, const QString &expression2)
+{
+ return normalizeJavaScriptExpression(expression1) == normalizeJavaScriptExpression(expression2);
+}
+
} // anonymous namespace
namespace QmlDesigner {
@@ -1379,7 +1393,7 @@ void TextToModelMerger::syncExpressionProperty(AbstractProperty &modelProperty,
{
if (modelProperty.isBindingProperty()) {
BindingProperty bindingProperty = modelProperty.toBindingProperty();
- if (bindingProperty.expression() != javascript
+ if (!compareJavaScriptExpression(bindingProperty.expression(), javascript)
|| astType.isEmpty() == bindingProperty.isDynamic()
|| astType != bindingProperty.dynamicTypeName()) {
differenceHandler.bindingExpressionsDiffer(bindingProperty, javascript, astType);
@@ -1574,7 +1588,7 @@ void ModelValidator::bindingExpressionsDiffer(BindingProperty &modelProperty,
Q_UNUSED(modelProperty)
Q_UNUSED(javascript)
Q_UNUSED(astType)
- Q_ASSERT(modelProperty.expression() == javascript);
+ Q_ASSERT(compareJavaScriptExpression(modelProperty.expression(), javascript));
Q_ASSERT(modelProperty.dynamicTypeName() == astType);
Q_ASSERT(0);
}