aboutsummaryrefslogtreecommitdiffstats
path: root/tools
Commit message (Collapse)AuthorAgeFilesLines
* qmltc: Handle (simple) deferred properties correctlyAndrei Golubev2022-02-223-1/+77
| | | | | | | | | | | | | | | | Simple deferred properties occur quite often in QML (throughout Qt Quick, for example), so qmltc should be able to deal with them as with deferred properties Ignore generalized group properties, PropertyChanges and similar types for now. They require more testing and are well out of scope of the tech preview Task-number: QTBUG-100053 Change-Id: I0f3588789d188cd6bec81de0b61d3205b665a917 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 68924be5b5282fb9f0276c743cf450f2e2aa5274) Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmltc: Fix attached property code generationAndrei Golubev2022-02-221-1/+4
| | | | | | | | | | | | | | | | | Attached property code generation is borked so fix accordingly: the compiler used an attached type where an attaching type should've been used. Given the obvious naming ambiguity, this was likely a typo of sorts Partial cherry-pick of a099030009eb8a9262b5e9e7565fe48bc866309b as the unskipped tests still would not work. They need 687609f2f3a98ade4b8e074615c3d1db1228fce0 in 6.3 (and maybe more) Change-Id: I1e4fd4d916ad3bd1bacf2aee1ce2346f9283c70d Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> (cherry picked from commit a099030009eb8a9262b5e9e7565fe48bc866309b) Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Disable qmljs on iOS buildJuha Vuolle2022-02-161-1/+1
| | | | | | | | | | | | When compiling for iOS the linking of qmljs tool fails with: Undefined symbols for architecture arm64 "_qt_main_wrapper" Fixes: QTBUG-100855 Change-Id: I25a3ca9fd9d5efd2d6906087f1580b2679e6745f Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit f3536a202ea124c91dc1ab53bd5c40cdb9b693e7) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* qmltc: Explicitly unsupport singleton typesAndrei Golubev2022-02-141-25/+6
| | | | | | | Change-Id: I05525f884f239c954527f24ad8842b108b32aff1 Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io> (cherry picked from commit 121457933dfa40de188063fefe86fa78881e18cd) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Make qml resizeToItem configuration url resolution work againShawn Rutledge2022-02-051-1/+1
| | | | | | | | | | Amends 0a1e4cc7ec7548f6273befff9cdddb0bc7a58961 Fixes: QTBUG-100469 Change-Id: I6d0f48fb9b02cc9779233bbb2a93107c93b11ca4 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit bc6c16c346aa94f6c4eb9548d256b5c81cdc2a0e) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* qmltc: Rely on QQmlJSResourceFileMapperAndrei Golubev2022-02-031-6/+38
| | | | | | | | | | | | | | | | | Similarly to qmllint, we should use QQmlJSResourceFileMapper in qmltc. This should in theory allow us to avoid implicit import dir vs qmldir path issues (where the former comes from source dir while the latter comes from build dir) At present, it does not seem to be the case, however. But this is to be addressed separately Task-number: QTBUG-100103 Change-Id: Ie85799cb0a4b8b1620964000bc5939e9d046678e Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> (cherry picked from commit 8a72c684464a48595337b01ada5605f612f7971e) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Avoid including self in the generated qmltc codeAndrei Golubev2022-02-021-3/+5
| | | | | | | | | | | | | | | | Somehow this works (?) but is meaningless. In the (special) case of QT_QMLTC_FILE_BASENAME it even works by accident due to the test binary having a suitable include: for the NameConflict.qml, which is renamed to ResolvedNameConflict{.h,.cpp} we still have hand-written nameconflict.h Let's ignore this mess for now (it needs to just be deleted eventually) and just provide minimal changes for the stuff to (continue to) work Change-Id: Ic18f17463d0c60d9b02e3d3824d99605a161ae14 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> (cherry picked from commit 9a30895128728f9f1720ab7cb53e90e5e823a568) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Improve the structure of the output generated by qmltcAndrei Golubev2022-01-313-34/+80
| | | | | | | | | | | | | | | Make an effort to separate user-visible APIs from internal code relevant to qmltc In the process of doing it, make tst_qmltc_examples::helloWorld() test less brittle by using QMap instead of QHash when dumping C++ member functions of the type. QHash does not guarantee that the keys are ordered while QMap does (via operator "<") Change-Id: I1495e1755d3fd77950acb3820ad2b9c5e3cdee33 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> (cherry picked from commit 0ad51325c7432c8a8da38580d26721455252e64f) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* qmltc: Drop half-correct type name collecting procedureAndrei Golubev2022-01-312-31/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | Type resolver can collect (presumably C++) type names which is needed to verify that the QML document we are about to compile is named correctly and does not have name conflicts However, the collection logic gathers everything we can find: C++ names, QML names, names marked with $anonymous$ or under import namespace. At the same time, the way the procedure works involves poking (pretty much) every known QQmlJSScope a.k.a. creates every type (previously some could've been deferred) which usually means that we have a larger than necessary footprint Thus, delete this procedure and simplify the code. We can later revisit the logic and figure the proper way to collect relevant type names. For now this is just overkill though. Note that this change, consequently, should avoid instantiating types imported from implicit import dir, instead of imported from qmldir (there is a difference apparently) Task-number: QTBUG-100103 Change-Id: Iaf65e5f3a9bf53286760af0dc39a1d7036d7c474 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> (cherry picked from commit 25b26452018bde9c569e39e1fd776d25a5412d02) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* qmltc: Simplify internal property name lookup logicAndrei Golubev2022-01-261-23/+20
| | | | | | | Change-Id: I51a7a063e90598dd3c68e5e430f4d73903c42957 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> (cherry picked from commit 900697e9dc3bad54c19c1472ec1aa415a663367b) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QML: qmljsrootgen is host only toolPasi Petäjäjärvi2022-01-241-1/+1
| | | | | | | | | Task-number: QTBUG-100040 Change-Id: I90254b7b8079f027206121c487d974abae144644 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 71a2cdb6fb8674911d3be5554273a72ae6e8cf49) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Turn qmljs into appPasi Petäjäjärvi2022-01-241-13/+12
| | | | | | | | | | | | | | It's tool, which means it's not built when cross-compiling. However, it's to be desired on a target to run QML-only projects. The earlier way to build app for a cross target was to set QT_BUILD_TOOLS_WHEN_CROSSCOMPILING to ON. That seems like overkill. Task-number: QTBUG-100040 Change-Id: I64236fb00a5d69862ce0c34ef9afca092d5d0436 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit 8c6b225f2aec39cfa255a183c28d8a78fa84b840) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QmlCompiler: Respect revisionsUlf Hermann2022-01-211-4/+4
| | | | | | | | | | | | | | | | | | | | | | | The only place where revisions matter is at the boundary between composite and non-composite types. The revision of the first composite type inherited from determines which members of all composite ancestors are available. Therefore, store the revision together with the base type and pass it through the imports to have it available. Then use it to check availability of methods and properties. The test exposes two further problems, which are fixed, too: 1. If no method is found to call, we need to generate an error in the type propagator. We don't know what the call will result in, after all, and the code generator should reject it. 2. We need to check the right scopes for hasOwnMethod(). Otherwise we might not find methods that are available. Fixes: QTBUG-99128 Change-Id: I4c320b8dfb490b140d7b8c16e6b638b32f156faa Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit e19d48d07310708e56cb379124dff193c1a7fa71)
* qmltc: Do not generate bindables and setters for QQmlListPropertyUlf Hermann2022-01-182-10/+14
| | | | | | | | | Assigning to a QQmlListProperty does not do what you think it does. Change-Id: Ie6ac3208d552d8f40d9f2f4d7fb33c1cd64e4b79 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> (cherry picked from commit 134f305b7f96e1a127261bbfac9bdb1f3a22e546) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* qml{plugindump|importscanner}: Don't mix std::cerr and std::wcerrUlf Hermann2022-01-062-14/+4
| | | | | | | | | | | | Apparently that causes output to be suppressed. Fixes: QTBUG-99400 Change-Id: I4ac6a66a10c7d2c27dfc1efa6d52afa60bdc58d6 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 5fa9093191c8a0fbf765f3b51a68dea996fed76e) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* qmltc: Support Component rootsAndrei Golubev2022-01-035-57/+180
| | | | | | | | | | | | | | | | | | | | | | | | | It is a very special case that doesn't undergo a normal compilation but instead just uses QQmlObjectCreator::createComponent() logic. As QQmlObjectCreator::createComponent() returns a new QQmlComponent, we can't use it within the qmltc-generated type's ctor. Instead, just fake the same flow by incorporating the code into the qmltc type setting As a drive-by, fix the code to work correctly with Component roots. This should now pretty much cover all the mystical logic of QQmlComponentAndAliasResolver and, with tests, we can safely simplify the qmltc code generator bits later without introducing bugs Enhance tst_qqmlcomponent::componentTypes test to highlight that property Component p: ComponentDerivedType {} is not marked with QV4::CompiledData::Object::IsComponent flag at all and thus considered to be an ordinary object binding, unlike property Component p: NotComponentDerivedType {} Change-Id: I4ec41952d15f9659d316e44dab4050aa4908327c Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io> (cherry picked from commit 39aee682bf388e191a409485cbbe2e01996bc163) Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmltc: Support different property change handlersAndrei Golubev2021-12-241-24/+51
| | | | | | | | | | | | | | | | | qmltc must be able to compile property change handlers: - for bindable properties (with no notify) - for notifiable properties (with no bindable) - for both bindable and notifiable properties (preferring notify signal) Test the aforementioned cases and some signal handling cases along the way Task-number: QTBUG-84368 Change-Id: I2cd2d0ad6407889942c806e03831dec4c7ce265a Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io> (cherry picked from commit 71084db1df9453aa9c657b91f2dab6766a56903b) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* qmlls: improve documentationFawzi Mohamed2021-12-243-18/+11
| | | | | | Change-Id: I6092dc4f2ab5bd2fcd40e5a708ccabbf2c03eafb Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> (cherry picked from commit 4383a585efe0709104ef43edee7a1adf7d028178)
* qmlls qlanguageserver: clientInfo and serverInfo locking fixesFawzi Mohamed2021-12-241-26/+4
| | | | | | | | correct and more concise double locking or clientInfo and serverInfo. Change-Id: Ib168fc4fd3d5d5b9b8dbc0ff318b1abaaa23517c Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> (cherry picked from commit ee05e35ad3c2866c8fe3bb7d0c6b886813ee0b88)
* qmlls textblock: operator== and != as friend functionsFawzi Mohamed2021-12-242-6/+6
| | | | | | Change-Id: I3efdb3ff7ffa1f7856d818d1cffea52eb3f6c6e8 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> (cherry picked from commit 5baa868f9f5d46e0fd43386468d1bbe07bb124f9)
* qmltc: Remove non-compiled CodeGenerator::compileProperty()Andrei Golubev2021-12-241-86/+0
| | | | | | | | | | | This got missed in-between porting the prototype code to qtdeclarative Amends e7ce5abf24f04d1b071343f07ca28b6a5d9ad4b9 Change-Id: Id722b819f80b4925508bd71bd2f347a4915e330c Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io> (cherry picked from commit 14dda2f1a8169cad4a695e123f006f97d99ce5dd) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* qmltc: Use special name for a special url-returning generated functionAndrei Golubev2021-12-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We can in fact get ambiguity problem (which for some reason only results in an unused-function warning with clang 10) which practically results in UB in the user code relying on qmltc output (due to C++ compiler choosing the wrong function to call) Consider the following: // MyType.qml Component { QtObject{} } is compiled (by qmltc) into // mytype.h class MyType : public QQmlComponent {}; // mytype.cpp static const QUrl &url() { /* return this doc url */ } // ^ warning: unused-function MyType::MyType(/* ... */) { // ... auto compilationUnitUrl = url(); // oops! QQmlComponent::url() is used } Change-Id: Ic754ce90b66e3f371a89e2d3395ca7d6b022c694 Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io> (cherry picked from commit 4355faedee5bb35854019cddfba516b61bd239e3) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* qmltc: Drop duplicate "QQmlContextData::" in context set generationAndrei Golubev2021-12-241-2/+1
| | | | | | | | | | qmltc generates QQmlContextData::QQmlContextData::DocumentRoot so one "QQmlContextData::" is not needed Change-Id: Ice2bb1c221996f04d8107f6f6caec7f52aad3735 Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io> (cherry picked from commit ea829498f4ca70d974058eb6eaa2e9cbcdf93198) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* qmlls qlanguageserver: minor cleanupsFawzi Mohamed2021-12-232-4/+2
| | | | | | | | | Fixes that do not affect the running code: Q_ENUM declaration, default constructor, clarifying comment Change-Id: Ic93dba58b33e4532fd16cabdc450fc3920b1ca55 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> (cherry picked from commit 2947d1a9ee588fda50580623ae9777775dcd20c1)
* qmlls: fix license header (tool -> GPL)Fawzi Mohamed2021-12-2318-281/+81
| | | | | | Change-Id: I6ebd1e8f3ca9fc88f2c92cd10703540154040baf Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> (cherry picked from commit f5ae18639d3f7516af46466d9ed3a467cb2105cb)
* qmlls: qml language server implementationFawzi Mohamed2021-12-2320-0/+3115
| | | | | | | | | | This is the initial commit, with just qmllint integration, but many of the tricky bits and the architecture are already there, see the description in qqmllanguageserver.cpp and qqmlcodemodel.cpp Change-Id: Ie493fed02276f938fde641e8d91c67aed0514d1f Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> (cherry picked from commit 25ac957f6da559333938430eec9cc341823e22cc)
* Unify common logic around QQmlJSScope and friendsAndrei Golubev2021-12-239-153/+28
| | | | | | | | | We have many things duplicated all over the place Change-Id: If929a5d683153781f6db630312240bf9c24ec777 Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io> (cherry picked from commit 1d1ad6cbc79ab5eb3fad5cb604f5d4f5da8f35cd) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* qmltc: Fix explicit import of local QML typesAndrei Golubev2021-12-235-115/+25
| | | | | | | | | | | | | | | | | | qmltc passes re-import local QML types in order to get their URLs and modifiable versions of types. The existing logic seems to work only when we've already imported the types before. But re-import may, in fact, easily load *same* types from a *different* place. This is totally wrong and exceptionally evil (even within the passes). Re-write this logic by looking up the already-imported types from QQmlJSImportVisitor instead This, in particular, fixes a case: import MyOwnModule 1.0 MyOwnType { } // oops, does not include "myowntype.h" Change-Id: I35be7e41094c3bb9e210727a7a59bee33b548698 Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io> (cherry picked from commit 0d40cde68ea89db46eac896a28ff65bd2c3ab40d)
* Add prefer record to the output of qmlimportscannerAlexey Edelev2021-12-201-1/+9
| | | | | | | | Task-number: QTBUG-95984 Change-Id: I2e126db655ef986b23d66a465e8b28b9fb17bbb1 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit e0a6ee877dce82bdeff3fae64af0d4d95426d19a) Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* qmltc: Do not crash on import namespacesAndrei Golubev2021-12-181-0/+8
| | | | | | | Change-Id: I9767857076ea6ae565c7efd75d64cb47a82b7be7 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> (cherry picked from commit 790d257ef01e0f95b776db873ad34bebe16396a3) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* qmltc: Be aware of Component-wrapped typesAndrei Golubev2021-12-186-33/+137
| | | | | | | | | | | | | | | | | | | | | | While implicit components (the ones bound to Component-based property) are covered, cases like `Component { Text{} }` are not, so fix that Revisit the logic in the QmlIR / QQmlJSScope passes and code generator as part of this This might be a fairly used pattern in QML so no reason not to address this right away, especially given that we have most of the infrastructure in place already While at it, bring over extra tests that some other (non-merged) commit introduced. These give good coverage for missing cases and also exercise the feature supported here Task-number: QTBUG-84368 Change-Id: I8f5c74fc79380566475b1139d4cc5560fac123e3 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> (cherry picked from commit 362b4bf3d6df1e1799a163d3e6d7ee39f75ad080) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* qmltc: Explicitly reject inline componentsAndrei Golubev2021-12-172-0/+12
| | | | | | | | | | | Because they seem to be hard and there's little reason to invest in their support immediately Task-number: QTBUG-84368 Change-Id: If056aa401d8f54d067eb583669074cb3f6bfd304 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> (cherry picked from commit 8fac197ba20cca5a85f8caedf4cb3e4f4c7ac553) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* qmltc: Make special functions protectedAndrei Golubev2021-12-176-14/+70
| | | | | | | | | | | | | Special functions are only invoked internally by the qmltc-generated code. There is no reason in making them public as the compiler should know which exact type would use another type (and so can generate meaningful friend declarations) Task-number: QTBUG-84368 Change-Id: I887ca8db7f916dba042f0ccbf19085aa438bf82d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 9cf864654f9154be52a7279a341948eabacfb397) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Add listing of the components and scripts that belongs to the qml moduleAlexey Edelev2021-12-171-4/+38
| | | | | | | | | | | Add qml components and scripts to the qmlimportscanner output to give information about files that actually belong to the qml module. Task-number: QTBUG-97834 Change-Id: I41394ba6fe9d9fe3af74786b4a802903849ae27d Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit 1d135de5cfef6da7457e5caf1612c0c112cfea7b) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Use qmltc compiler prototype as a fallback implementationAndrei Golubev2021-12-1718-17/+4780
| | | | | | | | | | | Task-number: QTBUG-91927 Task-number: QTBUG-96041 Task-number: QTBUG-84368 Change-Id: I47320b5f3ed8efff6fb234778df5fae5be5b64f2 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit e7ce5abf24f04d1b071343f07ca28b6a5d9ad4b9) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Add CMake deploy support for QML module appsCraig Scott2021-12-131-1/+21
| | | | | | | | Task-number: QTBUG-98545 Change-Id: I2d04ccbae0288c88ada399552e8f9c20e221b21d Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit e954a7f69491b72d1ad9144c20f66713b5017940) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Pass qmldir to qmlcachegen, qmllint and qmltc, not the qmltypes fileUlf Hermann2021-12-135-36/+45
| | | | | | | | | | | | | | | | | | | The tools will still grudgingly accept qmltypes files being passed via the -i option. We generally expect qmldir files, though. Ignoring the qmldir file and importing the qmltypes directly, ignores qmldir imports, dependencies and other component entries. This leads to unresolvable types. [ChangeLog][QML Tooling] qmllint expects qmldir files, not qmltypes files to be passed via the -i option now. This enables it to see the imports and dependencies of the module being imported. For backwards compatibility it still accepts qmltypes files, with a warning. Fixes: QTBUG-99043 Change-Id: I5ed32d7e78df1e604aaf1bfa2ebda09d5d57b628 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 576fafd1e69429d7387e4c35f6d15fc42af6513e) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* qmllint: Use fix suggestions in a more structured wayMaximilian Goldstein2021-12-101-1/+1
| | | | | | | | | | | Fix suggestions are now attached to the warnings they are caused by and are also accessible via JSON. This allows us to use the qmllint library for more of tst_qmllint, greatly improving performance. Change-Id: Idd0398028bff1272a75dc1193d2c15a25d335dbf Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Fix diagnostics output for test runUlf Hermann2021-12-071-1/+1
| | | | | | | We do want to see the output if the cleanQmlCode test fails. Change-Id: I6b7e9d3412af9fffac68d2e394418de2faf09626 Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
* Compile QML files ahead of time with qmlcachegenUlf Hermann2021-12-031-33/+83
| | | | | | | | | | | | | | | | | | | | | qmlcachegen compiles bindings and functions to C++ as far as QQmlJSAotCompiler can. It does respect "pragma Strict" and rejects the file if it's violated. Furthermore, it sets up the logger to follow the qt.qml.compiler.aot logging category. By default it's completely silent. Compiling the examples with qmlcachegen exposes a bug in the type resolver where it returns an invalid generic type. It should never do that. Fix it by returning JSValue. [ChangeLog][QtQml][Important Behavior Changes] QML bindings and functions are now compiled to C++ by qmlcachegen, if possible. Use the qt.qml.compiler.aot logging category to receive diagnostics about the compilation. Task-number: QTBUG-98305 Change-Id: I6953812c3fd20b68339617a5714fcbe16a384360 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Add a default implementation for QQmlJSAotCompilerUlf Hermann2021-11-291-1/+3
| | | | | | | | | | | | | | | | The default AOT compiler compiles QML code in indirect, dynamic mode. It uses the logger's Log_Compiler category to determine the verbosity of its output. In addition you can use the qt.qml.compiler.aot category for even more verbosity. In preparation for using QQmlJSAotCompiler with qmlcachegen, the default level of that category is increased to QtFatalMsg. The highest level we actually output is QtDebugMsg, so it doesn't make a difference yet. If the logger's Log_Compiler category is set to produce errors, it will qFatal() on "pragma Strict" violations. Change-Id: Ieb74bfa7cd51cfa8616792ab467c32f6ba0e0702 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Properly handle JavaScript functions with variable argumentsMaximilian Goldstein2021-11-261-0/+1
| | | | | | | | | | | | | Previously calling a JavaScript function with variable arguments could cause the linting process to error out because of a lack of matching function arguments. This is now handled by defaulting to a JavaScript method if no matching function signature can be found. Fixes: QTBUG-98299 Change-Id: I748a60839106243a12bffd8d715b48cbc53d7f57 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Tighten the constness of various method parametersUlf Hermann2021-11-262-5/+3
| | | | | | | | | | The compile passes shouldn't need to change the document, AST, or IR. At least not accidentally. We might add interfaces to explicitly modify things later. As a side effect, you can now use one instance of QQmlJSTypeResolver for multiple documents by re-init()'ing it. Change-Id: Ic3544b3ddedd30d7f8d00b1df9cee3e6292ca7de Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Move type generalization into separate compile passUlf Hermann2021-11-262-4/+3
| | | | | | | | We want to be able to skip it. Task-number: QTBUG-98305 Change-Id: Ibb0293d348f2828a28be4c458cf955b4cc706caa Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Re-enable warning about automatched signal handlerUlf Hermann2021-11-262-5/+4
| | | | | | | | ... and give a hint on what to do about it. In order to not duplicate all the warnings from the importer, make sure it runs only once. Change-Id: Ie2b314ff659664f7c84c20cc7971c094e15c59cf Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
* qmllint: Expand qmllint library APIMaximilian Goldstein2021-11-251-2/+2
| | | | | | | | | | | The API now allows for specifying the file contents yourself for either on-the-fly editing or if you have your own caching scheme. It's now also possible to access the logger directly in order to read diagnostic messages instead of structured JSON output. Change-Id: I4eb8440c7b25068cd09f28a5f3cbd0a318774522 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
* qmllint: Move most code into a separate libraryMaximilian Goldstein2021-11-238-1031/+6
| | | | | | | | | | | | | | | This is necessary step for both making qmllint viable for use in controls' tst_sanity, as well as for integration with the language server. As an additional upside it allows us to run our tests up to 10x faster. Eventually we want to integrate all of this into qmlcompiler but due to the state of some of the code we will keep qmllint in a separate library as to keep qmlcompiler tidier. Change-Id: Ic057ef0cd4424d28aa05e517d74280a442ec9c5a Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* qmlcompiler: Use QT_BEGIN_NAMESPACE / QT_END_NAMESPACE everywhereMaximilian Goldstein2021-11-231-1/+2
| | | | | | | Some code was not properly wrapped in a namespace. Change-Id: If70fd9782391309c511b66ae01eae43cb36292ac Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmltc: Support literal bindingsAndrei Golubev2021-11-235-1/+153
| | | | | | | | | | Ignore type conversions for now. Expect C++ to handle them magically for us. The simple binding type dependent conversions that are performed already should suffice Task-number: QTBUG-84368 Change-Id: I62bd36ccf6c60fd62c2a50b6e011c637c5bcfbce Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmllint: Fix typo in app descriptionMaximilian Goldstein2021-11-191-1/+1
| | | | | | | | | Disabling uses the keyword "disable" not "disabled". Fixed in this change. Pick-to: 6.2 Change-Id: I544a543043627121a11ca3ab56ad3d967707efb6 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>