| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
|
|
|
|
| |
Equivalent to NormalizeOrder but reorder QML categories without
sorting attributes (property definitions, property bindings,
methods, signals, enums)
Fixes: QTBUG-132060
Change-Id: Ib46ce4bb58ce46e3293d14954b0e363837b64b76
Original-patch-by: Oliver Kuss <oliver.kuss@okapp.de>
Reviewed-by: Semih Yavuz <semih.yavuz@qt.io>
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
|
| |
|
|
|
|
|
|
|
|
|
|
| |
The SemicolonRule setting from .qmlformat.ini was not being applied,
only the command line option took effect.
Pick-to: 6.10
Fixes: QTBUG-141638
Change-Id: I471fde37c3650e872a893ce46bb5f55e9cc3158e
Initial-Patch-By: Dmitry Makarenko <kryksyh@gmail.com>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
|
| |
|
|
|
|
| |
Task-number: QTCREATORBUG-33305
Change-Id: I9e23a755da0354ab1d64b7f50ff6f9cc7acbe85a
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
|
| |
|
|
|
|
|
|
|
|
|
| |
Extend qmlformat to allow disabling formatting for script expressions
using // qmlformat off/on comments. Update ScriptFormatter and tests to
verify correct behavior for various scenarios, including fuzzy and
normalized modes.
Task-number: QTBUG-97796
Change-Id: I56d54cca1751d41f4ea5c1d6c562e9e03e760f33
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
code and comment location information is needed by OutWriter to scan
format directives. Allow these to be created at OutWriters'
construction.
Get this informations through ExternalOwningItem
interface. Unfortunately, ExternalOwningItem interface won't provide
comment() or engine(). Use derived types to get that information for JSFile
and QmlFile.
Task-number: QTBUG-97796
Change-Id: I57ef2a3a52579dd5698219a6e6ac9449c113d080
Reviewed-by: Dmitrii Akshintsev <dmitrii.akshintsev@qt.io>
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
|
| |
|
|
|
|
|
|
|
|
|
| |
Implement handling of // qmlformat off and // qmlformat on comments to
allow selective disabling and enabling of formatting in QML files.
Extend OutWriter to track disabled regions and skip formatting output
accordingly.
Task-number: QTBUG-97796
Change-Id: I5a0817f3229bb9916ee077d2d946c54f5dfc0c4f
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Remove the workaround for QmlObject's formatting, and always create the
filelocations for its `{}` tokens in qqmldomastcreator.
Now that our comments are printed at the correct places, fix the wrong
indentation they get by following ScriptFormatter::outWithComments()'s
indentation helper: introduce a new enum IndentedCommentOption, and
automatically set it for `{}[]` regions. This allows to
increase/decrease the indent after/before writing comments, so that the
comments get a correct indent.
Adapt the existing tests to not expect comments to move around qml
objects anymore, and that comments can now attach to QmlObject `{}`
tokens in tst_qmldomitem.h.
Task-number: QTBUG-137944
Task-number: QTBUG-97796
Task-number: QTBUG-123386
Task-number: QTCREATORBUG-33333
Change-Id: Ice3cff8a24f4b55e0b642da00b3081892abdf2a1
Reviewed-by: Semih Yavuz <semih.yavuz@qt.io>
Reviewed-by: Dmitrii Akshintsev <dmitrii.akshintsev@qt.io>
|
| |
|
|
|
|
|
| |
Fixes: QTCREATORBUG-33333
Change-Id: Ia7eca0392418ec9b5cd13de8f6b5e263f4f09e72
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Semih Yavuz <semih.yavuz@qt.io>
|
| |
|
|
|
|
|
|
| |
Add a test to make sure that the keys stay stable, and don't get changed
in the future.
Change-Id: If5a4c06d4f821fd4f6269e61bbb89bd120e79243
Reviewed-by: Semih Yavuz <semih.yavuz@qt.io>
|
| |
|
|
|
|
|
| |
Add a test for the default value of the semicolon rule.
Change-Id: Id2e52bbc277707ef042675a4f91254a072a98c37
Reviewed-by: Semih Yavuz <semih.yavuz@qt.io>
|
| |
|
|
|
|
|
|
|
|
| |
Remove the hand-written keys from the test and use the static strings
instead. One of the previous hand-written key had a typo. Also make sure
that the settings are really set, as QVariant::toBool() returns false
for a unset settings, for example in the case of the key with the typo.
Change-Id: I15da10409fbf374a475dc3930844fd56120f370a
Reviewed-by: Semih Yavuz <semih.yavuz@qt.io>
|
| |
|
|
|
|
|
|
|
|
| |
Amends ff6d16d58bef108b7bbe35aa8e9d79dd3a2ea872 that added the files but
didn't use them.
Task-number: QTBUG-138896
Pick-to: 6.10 6.9 6.8
Change-Id: I1835e2a8db9e374628da7bb8e16c39d876dc9d91
Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
|
| |
|
|
|
|
|
|
|
|
|
| |
Return structured result instead of bool from search(). Update search()
and read() to adapt the return. Add an isValid() convenience method to
return type. Refactor search implementation into separate helper
methods.
Task-number: QTBUG-107212
Change-Id: I858951f0d4a7714eff01a3e6fcf96f92e2684ae1
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
|
| |
|
|
|
|
|
|
| |
Amends a3863b2d8bfdd2a0c138e857d3f119a5f6dfc11e
Pick-to: 6.10 6.9 6.8
Change-Id: I756621e2ac6d57a555395cb69914e2d0b4431d0e
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Add more regions for comments to attach to.
Remove special casing preventing comments to attach to the braces of an
enum. It is no longer needed.
The comma token belong to the enum entry after it. The opposite was
assumpted to be true before which led to comments being attached to the
wrong item and moving around.
Task-number: QTBUG-133315
Task-number: QTBUG-123386
Pick-to: 6.10 6.9 6.8
Change-Id: I32f8c49aff6a4c88c323450beec9aa0f5bc5bbe5
Reviewed-by: Semih Yavuz <semih.yavuz@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
|
| |
|
|
|
|
|
|
| |
Task-number: QTBUG-133315
Task-number: QTBUG-123386
Pick-to: 6.10 6.9 6.8
Change-Id: I65dc2056b46b1b7a2b381805b53a6ef32c457aa3
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
|
| |
|
|
|
|
|
| |
Task-number: QTBUG-133315
Pick-to: 6.10 6.9 6.8
Change-Id: I2c3752fe900c65133a12470c567196640e142b31
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The pointer returned by ensureCommentForNode() is invalidated when the
m_commentedElements map is modified, for example when inserting a new
comment via another ensureCommentForNode().
In the StatementList, we actually don't need to create a comment, we
just need to lookup one comment, so partially revert the apparently
drive-by change from b91ca3e0bc0b7e0b1ec53b41698d2325337dae59.
A separate commit will make ensureCommentForNode() private to avoid
similar crashes in the future.
Fixes: QTBUG-137413
Pick-to: 6.8 6.9 6.10
Change-Id: I6e281cc155e2179a880fa4a876133d90c4afae75
Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Add semicolon option to qmlformat. While --Always always appends
semicolons to the JS statements, --essential removes the semicolons
unless it is not safe to rely on ASI once semicolons are removed.
Change the way EmptyStatements are handled. Prior to this
commit, semicolons following if, for, foreach, while statements
without bodies were added to the new line with some indentation.
Make the semicolon following no-body items stick to the right
paranthesis. If there is a chain of empty statements, write out a
single one.
[ChangeLog][qmlformat] New option semicolon-rule is added and
EmptyStatement formatting behavior has changed.
* Added --semicolon-rule option with modes:
- --semicolon-rule=always: Always appends semicolons to JS statements.
- --semicolon-rule=essential: Removes semicolons unless ASI makes it unsafe.
* Changed handling of EmptyStatements:
- Semicolons after control structures without a body (e.g., if, for, while)
now appear directly after the closing parenthesis, instead of on a new line.
- Consecutive empty statements are collapsed into a single semicolon.
Fixes: QTBUG-107152
Change-Id: Ic95047a1f0077937d4c1f01328d77a3e6a4f22d6
Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
Never use module-wide inclusions. They blow up build times. For QtTest
this is usually just a typo (QTest was meant instead). Add missing
includes as needed.
In the diffs I've spotted other huge inclusions (QtQuick, QtQml), but
those need more attention.
Task-number: QTQAINFRA-7110
Pick-to: 6.9 6.8
Change-Id: I74bf3fe212f50a7a3a6af2b1c80bbcaabc2516d7
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
GCC rightfully complains that
/home/qt/work/qt/qtdeclarative/tests/auto/qml/qmlformat/tst_qmlformat.cpp:263:21: warning: ‘writtenOut’ may be used uninitialized in this function [-Wmaybe-uninitialized]
263 | *didSucceed = writtenOut;
| ~~~~~~~~~~~~^~~~~~~~~~~~
because if we don't enter the if, we never initialize writtenOut.
Initialize it.
Pick-to: 6.9 6.8
Change-Id: I6d3bb8038e524773a11b3333bf65654593f01da9
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
|
| |
|
|
|
|
|
|
|
|
|
|
| |
Add dummy .ini files in the tests to stop tooling (qmllint, qmlls and
qmlformat) from loading global settings.
This avoids false positives where tests fail because the global
configuration of these tools differ from the default one.
Also copy the settings files in tests that copies the qml files into
temporary folders.
Change-Id: Ia904c6d4eda265e2080c1080c6b51849ab568d25
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
|
| |
|
|
|
|
|
|
|
| |
Move the tests that require spawning a qmlformat process into
tst_qmlformat_cli.
Fixes: QTBUG-134669
Change-Id: I38f2e624bcd6152074604663bc4a626783097bda
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
|
| |
|
|
|
|
|
|
|
| |
Prepare for the splitting of tst_qmlformat into tst_qmlformat_cli by
moving the base into a header.
Task-number: QTBUG-134669
Change-Id: I76fbdf2f9d31a2e160d6ae0389a409c2214d36da
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
|
| |
|
|
|
|
|
|
|
| |
Prepare for the splitting of tst_qmlformat into tst_qmlformat_cli by
extracting common functionality into a base class.
Task-number: QTBUG-134669
Change-Id: I66a72b128802a51b0289320e6022bd69c6cfe4ff
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
|
| |
|
|
|
|
|
|
| |
Remove the unused arguments and run clang-format on it.
Task-number: QTBUG-134669
Change-Id: I1aff620feb26a160f4330807a56a5985c7c5fc12
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
|
| |
|
|
|
|
|
|
|
|
|
|
| |
Move all the tests from testFormat() to a newly added qml() function
that do not seem to test any command line parameters.
The qml() function runs the tests in-process instead of spawning extra
qmlformat processes.
Task-number: QTBUG-134669
Change-Id: I99bfd8a840c31cd2b0a4c889c0f0ca39b8c73eb2
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Add a comment anchor to class declarations to preserve comments around
the class identifier and the `{}` braces.
Make sure that invalid sourcelocations are not used as comment anchors.
Also remove extra preVisit()/postVisit() calls that did print comments
twice!
Pick-to: 6.9 6.8
Fixes: QTBUG-133316
Task-number: QTBUG-123386
Change-Id: I04f06fdb4c8f7b69d7483238116f0d0358bf13ed
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
|
| |
|
|
|
|
|
|
| |
Add missing space in JS class methods.
Fixes: QTBUG-119404
Change-Id: Ife43bc86ff51183f9aab79254d3492fba1d8b401
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Add a way to customize where comments are anchored. Prior to this
commit, comments could only be anchored to an AST::Node
firstSourceLocation() or lastSourceLocation().
This commit extends the current functionality to be able to anchor
comments somewhere between firstSourceLocation() and
lastSourceLocation().
This allows to fix the bug where comments would be printed before the
":" in case statements, because they would get attached to the
expression inside the case-statement, instead of getting attached to
the colon of the case-statement.
Extend AstRangesVisitor to add the sourcelocation of the ":" in case-
statements to the list of sourcelocations where comments can be
attached to.
The anchors enum is not meant to be extended: instead, an anchor is
either DefaultAnchor for comments attached to AST::Node*, or
token.begin() for some QQmlJS::SourceLocation token inside an
AST::Node*.
Pick-to: 6.9 6.8 6.5
Fixes: QTBUG-132886
Change-Id: I0a18f09b3631b8798b6697298e532b47ddc7cb20
Reviewed-by: Dmitrii Akshintsev <dmitrii.akshintsev@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
|
| |
|
|
|
|
|
|
|
| |
Note that any actual language support for final will be added in later
commits.
Task-number: QTBUG-98320
Change-Id: I8b8f9fbc998219ed4cd504c10f54bc3483e65f06
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
|
| |
|
|
|
|
|
|
|
| |
The test would leave behind the temporary directory it created and would
fail to detect when qmlformat returns with a non-zero value.
Change-Id: Ib6c5a43599aea5d8f7bfec9d6a13059a7386e133
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
qmlformat now errors out if
-No input is provided as a positional argument and -F is not set
-A positional argument does not exist
-Option -F is set but the file does not exist
-Option -F is set but the file is empty
-Option -F is set but the file points to a file that doesn't exist
TestQmlformat::testFilesOption was modified to no longer try to format
a nonexistent file. That should now get rejected early.
TestQmlformat::settingsFromFileOrCommandLine was modified to pass at
least one file to prevent an error.
[ChangeLog][Qml][qmlformat] qmlformat will now error out if no files are
provided as positional arguments or via the -F option.
Pick-to: 6.9 6.8
Change-Id: I7f900242c3e9e9041c9a08057a7e898e26c17493
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
|
| |
|
|
|
|
|
|
|
|
|
|
| |
The `file` argument of the test is copied to a temporary file which is
then immediately overwritten by the output of the qmlformat process.
Remove the `file` argument and don't copy it.
Pick-to: 6.9 6.8
Change-Id: Ic9ec826cdf521559facf63172f9dc7f08215c199
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Reviewed-by: Semih Yavuz <semih.yavuz@qt.io>
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
From is defined as an identifier with a special meaning in the context
of imports. This means it should generally be accepted as an identifier
in other contexts.
This fixes weird line indentation issues with the IndentingLineWriter.
Fixes: QTBUG-132065
Pick-to: 6.9 6.8
Change-Id: Iea5bf3af5d43af9a97f0f8e7867d12337e4041ca
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The line-by-line formatter would in certain cases considier that a
property definition was completed after having seen only the `property`
token. Fix the state transition to also handle T_RESERVED_WORD tokens.
Picking this back to previous versions is not trivial as this particular
situation seems to break in different ways first.
Fixes: QTBUG-133398
Pick-to: 6.9
Change-Id: I1123fe41e55d2d31c5d245dafe6c8684bca93e39
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When formatting comments we try to preserve the spacing that the user
used around them. We keep track of how many spaces come before and after
a comment and insert them back accordingly.
However, when we continue to write out the following tokens we add
spaces to separate them. This space was being inserted unconditionally.
This could lead to a space being accounted for twice for certain comment
configurations. Once by the recorded amount of spaces after the comment
and once by the standard space to separate tokens. This would lead to
spaces being inserted in the formatted code that weren't there
originally in the user's code. One space would be inserted like this for
every format call.
To solve this, don't unconditionally insert a space to separate the
tokens but only make sure there is a space.
This issue can be reproduced in many "places" of the grammar. This patch
eliminates a good amount of them but not all.
Created QTBUG-133315 and QTBUG-133316.
Fixes: QTBUG-131386
Pick-to: 6.9 6.8
Change-Id: I25ac67f49a0198047912ef3f04dda3afc5cb9f66
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
|
| |
|
|
|
|
| |
Pick-to: 6.8 6.9
Change-Id: I65b430362895259d8b91f064426e34d71eaf2c72
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
|
| |
|
|
|
|
|
|
|
|
|
| |
Options set through commandline should have the precedence over the
settings read from .ini file. Introduce a mapper in the setting, that
marks the option if set by command line input. Add more tests.
Pick-to: 6.8 6.9
Fixes: QTBUG-133225
Change-Id: Id0b18655f7bf64670dab4e38f5aff2fdaa889f1b
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
|
| |
|
|
|
|
|
|
|
|
| |
...Then we can add tests for them. More tests to be added in the next
commit.
Pick-to: 6.8 6.9
Task-number: QTBUG-133225
Change-Id: I3f40ddc3d0895a785d6bce359c63ad6ad4d70606
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
|
| |
|
|
|
|
|
|
|
|
| |
Prior to this commit, --write-defaults was only writing the subset of
the existing settings. In fact, each setting has a default value and
those should be seen in the .qmlformat.ini file to be written.
Pick-to: 6.8 6.9
Change-Id: Ie7f8fac653d0bc7099821136f5ad8ce8ee14c714
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
|
| |
|
|
|
|
|
| |
Fixes: QTBUG-132280
Pick-to: 6.9 6.8
Change-Id: I9307a70eea4640da19124f65e49cb3c661d443a1
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
|
| |
|
|
|
|
|
|
|
|
|
| |
Reorder imports alphabetically.
[ChangeLog][qmlformat] qmlformat now supports sorting of imports,
there is a new commandline option -S that is used to sort imports.
Fixes: QTBUG-132061
Change-Id: Ic163456d2beed84833f7aadef0688d37292ef0f2
Reviewed-by: Semih Yavuz <semih.yavuz@qt.io>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
We don't need m_valid to check if there is an error. Do validity check
by m_error.isEmpty().
Prior to this commit, an invalid command line option given to qmlformat
wouldn't spit out the error message and qmlformat would silently ignore
the error and run with default settings. For example, the command
qmlformat -W -342523 <filepath> should error out with this commit since
a negative line length is given.
Change-Id: Ie7d07e3b2b3714793f9abed4558003cc5ad77b34
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
|
| |
|
|
|
|
|
|
|
|
|
| |
A qml signal can have both a(int x) and a(x: int) form. qmlformat
currently converts the type annotated signal form into type prefixed
form. It should respect the order.
Pick-to: 6.7 6.8
Task-number: QTBUG-128423
Change-Id: I746ea66949abc72e8012974b3fb0a06878950b77
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Figuring out if the enum item has an explicit value is quite error-prone in
dom. Instead, retrieve this information from the parser by checking if
the value token exist. Introduce an enum that tracks if enumitem's value
is explicitly set or not.
Also, fix incorrect region mapping while writing out the enum item dom
element.
Fixes: QTBUG-125914
Pick-to: 6.8 6.7 6.5
Change-Id: I911621b215de09ff3f18279d83881bc9421080c2
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
testExample, normalizeExample and actually most of the tests in
tst_qmlformat are e2e tests and in general QmlFormat lacks
unit test coverage, compensating it with e2e.
The biggest problem atm that some of those tests (namely testExample)
take too much time to execute because it runs QmlFormat over almost
all files in examples and tests directories.
Unfortunately atm our QA&QE infra can't provide tools for an easy
automated setup of potentially time-consuming tests.
As a workaround this commit:
1. "Moves" testExample and normalizeExample to the /manual tests
2. Preserves a very small fraction of testData for automated testing
"just in case"
Steps to repro:
1. configure with the flag `-make manual-tests`
2. `ninja e2e_qmlformat`
3. run ;)
Fixes: QTBUG-122990
Change-Id: Id41baee15e8826f4def5787f62790ed46f00e5dc
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When `qmlformat` processes a `ScriptExpression` such as the `onClicked`
body in the following snippet:
```
import QtQuick
MouseArea {
onClicked: {
console.log("start");
console.log("end");
}
}
```
It will remove every empty lines between statements.
For example, in the above snippet, the two log statements will be on
successive lines in the formatted output, removing the empty line
in-between them in the original version.
`qmlformat` will now, instead, allow up to 1 empty line to be preserved
between statements, if at least one empty line is present in the
original version.
The formatting for `StatementList`s in `ScriptExpression`s is handled by
the relevant overload of `ScriptFormatter::visit`.
The code relative to inserting newlines in-between statements in the
list was modified to take into account the possible presence of
additional empty lines in between the statements, outputting an adequate
amount of newlines to preserve up to 1 empty line.
The utility method `ScriptFormatter::newLine`, which is used to output a
single newline character, was modified to take a parameter representing
the amount of newlines that should be added, allowing multiple newline
characters to be written by a single call.
A non-exhaustive test-case for the new behavior was added to track it.
Certain pre-existing snapshot test-cases were modified to be in line
with the new output of `qmlformat`.
Fixes: QTBUG-123864
Change-Id: I552d1f7ce2c035b9087cb60a3b6e3480c5ae969a
Reviewed-by: Dmitrii Akshintsev <dmitrii.akshintsev@qt.io>
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
|
| |
|
|
|
|
|
|
|
|
| |
Wrap it in QVERIFY if possible. If not possible (e.g. a function
that returns non-void, or not an autotest function) use qFatal
to abort the test.
Change-Id: Ie255024d29507e928a94e67d9af1cd436df4f1df
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
|
| |
|
|
|
|
|
|
|
|
| |
Adding tests for Ecmascript Module formatting
Change-Id: Iaac7be13d9c1ed1119afc5ebdd9b09a990ed944a
Task-number: QTBUG-123386
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
|