aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/parser
diff options
context:
space:
mode:
authorSemih Yavuz <semih.yavuz@qt.io>2023-04-02 23:44:50 +0200
committerSemih Yavuz <semih.yavuz@qt.io>2023-04-12 15:56:01 +0200
commitb5274d073bf015b764c12ce4121d3be6d2378cc9 (patch)
tree370263342e419212599dd08cbefb880de86a76bc /src/qml/parser
parent9e83e0caff6936bba92e0dc4650f14f6dce2a388 (diff)
qmlformat: change comment handling behavior
Cumulative commit for adding zero-length comments in qmljsengine and also handling of empty lines after comments. qmljsengine only adds comments if the relavant comment length is larger than 0. Allow adding zero length comments since empty comments might be useful and required in some situations. Unlike the other formatting tools (clang-format, rustfmt) qmlformat didnt respect the emptylines after comments and stick the comments to the associated element. Change this behavior such that a newline/ blankline is added(but no more than one). A few tests in qmldom/reformatter needed to be edited due to this new behavior. Pick-to: 6.5 Fixes: QTBUG-111231 Change-Id: I2fcdda0bfe569b7a1d19c4058e1604cb0d73291d Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Diffstat (limited to 'src/qml/parser')
-rw-r--r--src/qml/parser/qqmljsengine_p.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/qml/parser/qqmljsengine_p.h b/src/qml/parser/qqmljsengine_p.h
index 568bf4d35b..37f78a30e1 100644
--- a/src/qml/parser/qqmljsengine_p.h
+++ b/src/qml/parser/qqmljsengine_p.h
@@ -71,8 +71,8 @@ public:
void addComment(int pos, int len, int line, int col)
{
- if (len > 0)
- _comments.append(QQmlJS::SourceLocation(pos, len, line, col));
+ Q_ASSERT(len >= 0);
+ _comments.append(QQmlJS::SourceLocation(pos, len, line, col));
}
QList<SourceLocation> comments() const { return _comments; }