aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qmlformat
diff options
context:
space:
mode:
authorSemih Yavuz <semih.yavuz@qt.io>2023-01-18 15:36:23 +0100
committerSemih Yavuz <semih.yavuz@qt.io>2023-01-23 10:45:39 +0100
commit444d4f1f3f27a81996d9cbcc0642040b68728260 (patch)
tree5909ab84eda18d140eca5d708c368f44e7de3944 /tests/auto/qml/qmlformat
parent33dbd8eb13adced0f24713032502ab11fc275800 (diff)
qmlformat: fix omitting some comments while reformatting
We rewrite comments associated to a node on the preVisit call (if they were marked as preComment), or postVisit( if comments were marked as postComments) of the reformatter. If the comment associated with a patternProperty kind of node, neither of these functions are called. Add missing call to previsit/postVist in the pattern property node visit. Pick-to: 6.4 6.5 Fixes: QTBUG-109074 Change-Id: If57968b3f5dbd83aa23dc2cd2bca3608ee841d49 Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tests/auto/qml/qmlformat')
-rw-r--r--tests/auto/qml/qmlformat/data/dontRemoveComments.formatted.qml13
-rw-r--r--tests/auto/qml/qmlformat/data/dontRemoveComments.qml13
-rw-r--r--tests/auto/qml/qmlformat/tst_qmlformat.cpp3
3 files changed, 29 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlformat/data/dontRemoveComments.formatted.qml b/tests/auto/qml/qmlformat/data/dontRemoveComments.formatted.qml
new file mode 100644
index 0000000000..0c7a2829c9
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/dontRemoveComments.formatted.qml
@@ -0,0 +1,13 @@
+Item {
+ property var test: [{
+ // Testing
+ "foo": "bar"
+ }]
+
+ onTestChanged: {
+ fooBar(test, {
+ // Testing
+ "foo": "bar"
+ });
+ }
+}
diff --git a/tests/auto/qml/qmlformat/data/dontRemoveComments.qml b/tests/auto/qml/qmlformat/data/dontRemoveComments.qml
new file mode 100644
index 0000000000..1797834879
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/dontRemoveComments.qml
@@ -0,0 +1,13 @@
+Item {
+ property var test: [{
+// Testing
+ "foo": "bar"
+ }]
+
+ onTestChanged: {
+ fooBar(test, {
+ // Testing
+ "foo": "bar"
+ });
+ }
+}
diff --git a/tests/auto/qml/qmlformat/tst_qmlformat.cpp b/tests/auto/qml/qmlformat/tst_qmlformat.cpp
index ab67ee9fdb..b69c324fc2 100644
--- a/tests/auto/qml/qmlformat/tst_qmlformat.cpp
+++ b/tests/auto/qml/qmlformat/tst_qmlformat.cpp
@@ -298,6 +298,9 @@ void TestQmlformat::testFormat_data()
QTest::newRow("normalize + functions spacing")
<< "normalizedFunctionsSpacing.qml"
<< "normalizedFunctionsSpacing.formatted.qml" << QStringList { "-n", "--functions-spacing" } << RunOption::OnCopy;
+ QTest::newRow("dontRemoveComments")
+ << "dontRemoveComments.qml"
+ << "dontRemoveComments.formatted.qml" << QStringList {} << RunOption::OnCopy;
}
void TestQmlformat::testFormat()