Commit Graph

72 Commits

Author SHA1 Message Date
Maximilian Goldstein 15777b94ee qmlformat: Fix trailing newline in if blocks
Fixes: QTBUG-85003
Change-Id: Ie68c838c9bc1d52181a741871279bee5a8020855
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-06-17 13:04:42 +02:00
Maximilian Goldstein 237a0e86c7 qmlformat: Copy string literals verbatim
Copy string literals verbatim instead of reformatting them.

Fixes: QTBUG-84599
Change-Id: I36307eb30faa586f50cf0ce2660fb4e2686a3e4a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-06-17 13:04:42 +02:00
Alexandru Croitor 476d1f5760 CMake: Regenerate qtdeclarative/tools
Includes
 - A bunch of TARGET_DESCRIPTION

Change-Id: I6acfe05187afbdd45cf7e1bf8634f1554a51c791
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-05-29 10:01:19 +02:00
Maximilian Goldstein 1c0c8509da Fix 'as' binary operation using invalid types
Fixes: QTBUG-81392
Change-Id: Ic83091c547a7854b7fa86b44d93c575bd7426bae
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-05-20 13:46:36 +02:00
Qt Forward Merge Bot 2812184e1b Merge remote-tracking branch 'origin/5.15' into dev
Conflicts:
	src/qml/jsruntime/qv4executablecompilationunit.cpp
	src/qml/jsruntime/qv4executablecompilationunit_p.h
	src/qml/qml/qqmlobjectcreator.cpp
	src/qml/qml/qqmlpropertycachecreator_p.h
	src/qml/qml/qqmltypecompiler.cpp
	src/qml/qml/qqmltypedata.cpp
	tests/auto/qml/qmlformat/tst_qmlformat.cpp
	tools/qmllint/scopetree.cpp
	src/qml/qml/qqmlapplicationengine_p.h

Adjusted tools/qmllint/findunqualified.cpp to use newer API

Change-Id: Ibfb4678ca39d626d47527265e3c96e43313873d4
2020-04-09 10:08:41 +02:00
Maximilian Goldstein 8ab467835c qmlformat: Fix inconsistent if statements
Should now produce more consistent output for if statements.

Fixes: QTBUG-82261
Change-Id: I39da0c80c4aadc2c5bdef32953c34ed9f0708a9e
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-03-25 11:24:32 +01:00
Maximilian Goldstein 20370505b3 qmlformat: Improve comment attachment
- Fixes UiPublicMember nodes having a newline between comment and first node
- Implements a Front_Inline type so comments at the beginning of object
  definitions are handled properly

Fixes: QTBUG-82259
Change-Id: I0b40290037ce88a9ffe16390d72cbf3d704db41a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-03-25 09:01:14 +01:00
Maximilian Goldstein 4faf242d1a qmlformat: Add option for alternative line endings
Allows user to decide between native (default), macos (\r), unix (\n) or windows (\r\n)
line endings.

Fixes: QTBUG-82258
Change-Id: Ie1eb365085815cbbebbf0d026c6f72f0ef2acb9d
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-03-25 06:15:13 +01:00
Alexandru Croitor 14492ecee2 CMake: Regenerate and adapt to merge from dev
Change-Id: If8daa6152a563d4309d7342414780ef75b9f5589
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
2020-03-12 14:05:23 +00:00
Qt Forward Merge Bot d51d5ff3c1 Merge remote-tracking branch 'origin/5.15' into dev
Conflicts:
	src/qml/compiler/qqmlirbuilder_p.h
	src/qml/qml/qqmlpropertycachecreator_p.h
	src/qmltyperegistrar/qmltypesclassdescription.cpp
	src/qmltyperegistrar/qmltypesclassdescription.h
	src/qmltyperegistrar/qmltypescreator.cpp
	src/quick/items/qquicktext_p.h
	src/quick/util/qquickvaluetypes_p.h

Change-Id: Ic209741592e7b85820bf3845722023a190ebc1c5
2020-03-09 09:58:49 +01:00
Simon Hausmann 8ab237edf1 Restore offset/length in QQmlJS::DiagnosticMessage
This is needed in a few places outside of declarative, so this change
restores the loc member in DiagnosticMessage and moves
QQmlJS::AST::SourceLocation into common's QQmlJS namespace/directory.
QQmlError is unaffected and retains only line/column.

Amends d4d197d062

Change-Id: Ifb9d344228e3c6e9e26fc4fe112686f9336ea2b2
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-03-02 10:35:50 +01:00
Qt Forward Merge Bot 3e758800b4 Merge remote-tracking branch 'origin/5.15' into dev
Conflicts:
	src/imports/qtqml/plugin.cpp
	src/qml/qml/qqml.h
	src/qml/qml/qqmlmetatype.cpp
	src/qml/qml/qqmlmetatype_p.h
	src/qml/qml/qqmltypeloader.cpp
	src/qml/types/qqmlbind.cpp
	src/quick/items/qquickitemsmodule.cpp
	tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp

Change-Id: I52548938a582cb6510271ed4bc3a9aa0c3c11df6
2020-02-17 10:21:59 +01:00
Fawzi Mohamed 229e3220ef qmlformat: preserve annotations
Change-Id: I22e72d91f6d422e93a7ebc642a8449cb490aec20
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
2020-02-12 18:29:06 +01:00
Maximilian Goldstein 4df2438531 qmlformat: Enforce more of the coding conventions
Now also enforces:
- states and transitions being the last elements in an object
- large bindings being the last bindings

Change-Id: I8be1db4eb2bc9dd429dd5b9abab70a1362f47dfb
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-02-12 12:48:58 +01:00
Ulf Hermann 789929f939 Use QTypeRevision for all versions and revisions
In many places we carry major and minor versions or revisions that are
loosely coupled to minor versions. As the Qt minor version resets now,
we need to handle these things more systematically. In particular, we
need to add a "major" part to revisions.

QTypeRevision can express the current major/minor pairs more efficiently
and can also be used to add a major version to revisions. This change
does not change the semantics, yet, but only replaces the types.

Change-Id: Ie58ba8114d7e4c6427f0f28716deee71995c0d24
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-02-03 15:22:12 +01:00
Maximilian Goldstein e080f48f90 qmlformat: Support even more language features
Adds support (among other things) for:
- Pragmas
- Type annotations
- get / set properties
- Some previously unsupported escape sequences (\b,\v...)
- Calling methods on numeric literals

Also now checks whether the dumped code is still parsable.

Change-Id: Ia142a7c0b3e608115e79c1d98a62b682dce4eec9
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-01-30 08:24:40 +01:00
Maximilian Goldstein 9e674be4fb qmlformat: Fix some language features being unsupported
qmlformat now supports:
- arrow functions
- generator functions
- this expressions
- object patterns
- regex literals
- type expressions
- plain expressions

Aborts if an error occurs during dumping now.

Also now automatically tests qmlformat against all example / test qml
files.

Change-Id: Idc24004c6f2c1cd65289bcad75985a1ef047c8d2
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-01-17 10:02:29 +01:00
Ulf Hermann 728abd1dbc qmlformat: Fix default construction of Comment
m_location would be uninitialized.

Change-Id: Ieeeb0c0783a0b8e6f919019bd2ddcc1752993eaf
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-01-10 21:20:13 +01:00
Maximilian Goldstein 3e92cd7391 qmlformat/dumpastvisitor: Fix a few segfaults
Change-Id: Ic8e95944cf36000a004d010293a532101433c3af
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-01-09 09:16:42 +01:00
Maximilian Goldstein 7d21113b05 qmlformat: Fix whitespace for parameter defaults
Change-Id: I7958bf1546cc5854fc9b9856e36928ea932af0ca
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-01-08 10:43:46 +01:00
Maximilian Goldstein 813d70051c tools/qmlformat: Improve formatting quite a bit
- Fix strings not getting properly escaped
- Fix if/else blocks not getting formatted correctly in some cases
- Remove unnecessary newlines
- Improve comment attachment

Change-Id: Id8264c069315b3c6bd9ba8e8ac991dbdce8581a7
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2019-12-20 14:16:32 +01:00
Maximilian Goldstein 73189151b5 qtdeclarative/tools: Implement qmlformat
qmlformat is a tool that formats qml files according to the QML coding
conventions (https://doc.qt.io/qt-5/qml-codingconventions.html).

Change-Id: I359c4bd3b51f60614535f0e857d7e0b21b1d9033
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2019-12-19 16:45:51 +01:00