Commit Graph

9 Commits

Author SHA1 Message Date
Fawzi Mohamed
9e4e44d180 qmljs: preserve default arguments when reformatting QML
Fixes: QTCREATORBUG-23009
Change-Id: I9949fe26a91a063c4804fddcca4e26d14bc5cd61
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-03-02 08:29:42 +00:00
Fawzi Mohamed
bd05384765 qmljs: handle string templates in scanner
* add (multiline) template string support
  templates can be nested, which means that the scanner/lexer cannot
  be a simple state machine anymore, but should have a stack to store
  the state (the number of open braces in the current template
  string).
  The lexer stare is currently stored in an int, so we abuse that and
  store a the number of open braces (maximum 0x7f = 127) for at most 5
  nested templates in the int after the flags for the multiline
  comments and strings.
* improve representation of delimiters (==, <=, ||,... not split in
separate delimiters)
* (QmlDom backport)

Change-Id: I2b4d23b65febedef29a748f4c5f377fde27bd7fd
Fixes: QTCREATORBUG-22766
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-02-25 08:37:12 +00:00
Fawzi Mohamed
c0f9f29097 qmljs: correctly reformat js spread operator (...)
Fixes: QTCREATORBUG-23402
Change-Id: I6b4bd0846dac67116711b7ed046bd52d137b7674
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-02-23 12:38:55 +00:00
Leander Schulten
771e269a3b QmlJs: Fix reformatter for template strings
Change-Id: Ie0b7909d634d1e2e735377b053f7a1c1c2518f78
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
2020-12-17 12:31:48 +00:00
Leander Schulten
7e526d9b05 QmlJs: Fix reformatter for arrow functions
Fixes: QTCREATORBUG-23019
Change-Id: I6c6bee7092cb12f225ad744df2b3834dfd4bbc8f
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
2020-12-17 12:17:20 +00:00
Uladzislau Paulovich
70fecd518e qml | Fix functions and loops formatting
Bugs fixed in this change:

1. Incorrect function arguments formatting:
function(a, b, c) -> function(abc)
2. Incorrect foreach loop formatting:
for (var a in b) -> for (a in b)
3. Incorrect for loop formatting:
for (var a = 1; a < 100; ++a) -> for(; a < 100; ++a)

Change-Id: I8afef6e5f2485a2225931b7ecb7210506e06dc6c
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2019-06-11 15:23:42 +00:00
Uladzislau Paulovich
69cd74f25d qml | Fix let/const variables formatting
Change-Id: Ia2a4ee482e84a6c24abea7ea6fe05925eee11d1d
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
2019-06-11 10:03:57 +00:00
Christian Kamm
a24c49720a QmlJS reformatter: Fix object literals.
The comma token seems to be invalid.

Change-Id: I859fa58ba0ba1e975e0cf1105c2b53aac848fb0d
Reviewed-by: Leandro Melo <leandro.melo@nokia.com>
2011-11-30 10:11:28 +01:00
Christian Kamm
a5b26a32b3 QmlJS: Add 'reformat' action which regenerates the whole file.
Change-Id: I0aed6c6e197e122200d720eb9291a083095a6299
Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
2011-11-15 11:31:40 +01:00