aboutsummaryrefslogtreecommitdiffstats
path: root/tools
Commit message (Collapse)AuthorAgeFilesLines
* qmllint: Fix unknown properties on varMaximilian Goldstein2021-03-031-1/+4
| | | | | | | | | | | | Since the type of a var may change at runtime and we thus can't make any good predicitons on its actual underlying type we will ignore it from now on (as already done for variants). Fixes: QTBUG-84060 Change-Id: I36795ef2047629d3c870bf8a9df59dcd3db06633 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> (cherry picked from commit 25ae86d1d98dbf3900eefea152b072939be8ea71) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* qmllint: Check for existence of property typesUlf Hermann2021-02-241-1/+34
| | | | | | | | | | | | | | | | For each binding there should be a property and that property should have a type we recognize. Enums can be property types in C++. We support this by adding child scopes for such enums. The child scopes are then referenced by the QQmlJSMetaEnums and derive from int. The test then reveals that we were missing a few properties in QtQuick.tooling. Add those. Change-Id: I1deef94393ee0e17d34c2dc5980ebfbf25417f36 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 08c8e8ac3ba8eb23ae5c158990f5d029ac9988ed)
* qmllint: Resolve attached property scopesUlf Hermann2021-02-192-16/+22
| | | | | | | | | Previously, all attached property scopes were just ignored. Task-number: QTBUG-84369 Change-Id: I324becf92402eacea9d150e6e51359edae562dde Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit f34ecc8f99522b69d1aaa3d5d233add9ed9b6da9)
* qmllint: Fix false unknown grouped property warningMaximilian Goldstein2021-02-192-9/+0
| | | | | | | | | We seem to be checking grouped properties twice by endVisit(UiObjectBinding*) and endVisit(UiObjectDefinition*). So the UiObjectBinding variant is removed here as this gets run before all type information is available. Change-Id: Idfe23869792f787df6109cde3b6bc1d96cce3dc3 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 4660f51f25a6c56182dff0ea24f7c1ad2bac9cea)
* qmllint: Fix segmentation faultMaximilian Goldstein2021-02-191-1/+1
| | | | | | Change-Id: Ie04ad4221b25628687c2575facf90488b83d21bf Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 5fb34b67b810ca284c216009925f4f38220c4510)
* qmllint: Warn about too many or mismatched signal parametersUlf Hermann2021-02-151-16/+49
| | | | | | | | | | | It's easy to mess this up when you transform your signal handlers into functions. Task-number: QTBUG-89943 Change-Id: If35be2f6828a0e19aada19abb41d8135b0c6ab45 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit f0ecad1e99461109e69cd2b0f6271012c20005dd) Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Use functions as signal handlers when accessing parametersUlf Hermann2021-02-121-1/+1
| | | | | | | | | | Injected signal handlers are bad practice because they aren't declared. Task-number: QTBUG-89943 Change-Id: I3a691f68342a199bd63034637aa7ed438e3a037b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 4cc91a6a0e4f9063233a4d6554ae64855cf99c14) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QML: Warn about variables being used before their declarationUlf Hermann2021-02-121-9/+23
| | | | | | | | | | | | | | | | | | | This collides with injected signal parameters. qmlcachegen cannot tell those cases apart. [ChangeLog][QML][Important Behavior Changes] QML warns about JavaScript variables being used before their declaration now. This is almost always a mistake. It is particularly dangerous in the presence of injected signal parameters because qmlcachegen cannot identify a name collision between an injected signal parameter and a variable being used before its declaration. It therefore miscompiles such code. You can turn off the deprecation warning using the "qt.qml.compiler" logging category. Task-number: QTBUG-89943 Change-Id: I8a9424ca8c6edd562402fe5c560ba7e8344b5585 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit ab71cdafca87513a4e214d3af056d8990bc1eddb) Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* qmlformat: Use a struct to hold the command line optionsFurkan Uzumcu2021-02-101-80/+112
| | | | | | | | | | | | | | | | Keeping the parser and the code that uses the command line options in the same function increases the number of lines for the same function, making it harder to read, and the number of arguments for parseFile function, makes it harder to understand and maintain. This commit adds an `Options` struct to hold on to the command line options and a build function to create the `Options` object. Change-Id: I5dec0a5a5e990f413ee65bf2eba2ea1087e0ea28 Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> (cherry picked from commit 1c35c8f71eb6863498548c6724f82be01d872b33) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* qmlplugindump: Fix overload ambiguityMaximilian Goldstein2021-02-081-5/+6
| | | | | | | | Fixes: QTBUG-89955 Change-Id: I89ce8a146c0ce07c8e308783f79677575458c71c Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 40eaa9509b1c2e430b7617e1b42aa66214ad80df) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QmlCompiler: Allow for multiple extensions per objectUlf Hermann2021-02-011-16/+11
| | | | | | | | | | | | | | | | | | | Previously, the assumption was that each object could only have a single extension object. As proven by the new qqmllanguage test this is not the case. Each registered object in the type hierarchy can have its own extension. Therefore, adjust the algorithms that generate qmltypes and iterate the extension objects when analyzing them. This leads us to the realization that anonymous types can in fact meaningfully carry extensions and implement interfaces. Adapt qmltyperegistrar accordingly. For the test to compile, however, we need to realize that the class declaring interfaces needs to befriend all potential subclass's QmlInterface structs. Fix that, too. The rabbit hole went deep. Change-Id: Ia451897e927e03b95c3062e829edf1dfcd216613 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Complain if member access check fails for namespaced typesUlf Hermann2021-01-261-13/+34
| | | | | | | | Before, we would prepend the namespace to the name, but then continue right away, never checking the new name. Change-Id: If90db7d33536fb4b549321c2d6b677040605b6f0 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Fix auto-importing of qmltypes from same directoryUlf Hermann2021-01-211-1/+3
| | | | | | | Fixes: QTBUG-90513 Pick-to: 6.0 Change-Id: Ic39e72d6df20be30c61123a7f8091d70dbc2d924 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Remove exceptions for most unknown builtinsUlf Hermann2021-01-211-23/+13
| | | | | | | | | | | | All those types are properly defined in the qmltypes files now. We just need to search the enumerations the same way as methods and properties in order to find everything. Also, deduplicate the code that resolves properties, methods, and enums by using a common template for iterating the scopes. Change-Id: I0bf1423974d0ec8f602ecd0342522b3e981a8586 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Support extended typesUlf Hermann2021-01-201-1/+12
| | | | | | | Fixes: QTBUG-90448 Change-Id: I5fb6b3d9223ae95ca7e039c5b9139ed086052c29 Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Remove the qmake project filesFabian Kosmale2021-01-1514-347/+0
| | | | | | | | | Remove all qmake project files, except for examples which are used to test that qmake continues to work. Change-Id: Ic4abb72dc2dcd75df7a797c56056b6b3c5fe62ac Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Don't set properties on a host tool when cross compilingMarianne Yrjänä2021-01-151-1/+6
| | | | | | Task-number: QTQAINFRA-3768 Change-Id: I2e2491e948e996921c068384012e689ab0762a76 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* CMake: add properties when tools are builtSamuli Piippo2021-01-151-1/+1
| | | | | | | | Make sure all properties are added when cross-compiling the tools. Pick-to: 6.0 Change-Id: Ifec0d2e2a1de2c3302ccf71ba897993d57bed205 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* Merge the QtTest and Qt.test.qtestroot QML modulesUlf Hermann2021-01-121-7/+0
| | | | | | | | | | There is no point in having them separate and this way the plugin can be optional. Fixes: QTBUG-89804 Change-Id: Ic7de35f6ee7abde4840841e17d21c2b709f6db7d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Add a -i <qmltypes> option to qmlcachegenUlf Hermann2021-01-121-0/+5
| | | | | | | | | | | | | qmlcachegen needs to see the qmltypes file for the current project so that it can query it for C++ types exposed to QML. This is only relevant when generating C++ code, which qmlcachegen itself cannot do. However, in order to write a compatible drop-in, we need it. Also, hide related ignored options from --help in qmlcachegen. Change-Id: Id2f1b8b1750351c7de8dfe49e4065ef1b29423b7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmlformat: Remove import sortingMaximilian Goldstein2020-12-113-52/+6
| | | | | | | | | | | Remove import sorting due to the fact that sorting imports can break code. [ChangeLog][QML Tooling][qmlformat] Remove import sorting and the (now obsolete) -n parameter to disable it Fixes: QTBUG-89295 Pick-to: 6.0 Change-Id: I5ff13d0ae3c715db7645b412152aadb31811ce5a Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Use load(qt_tool) and qt_internal_add_tool for qmltimeLi Xinwei2020-12-083-7/+41
| | | | | | | | The qmltime should be a tool, not a normal executable or an app. Pick-to: 6.0 5.15 5.12 Change-Id: I64c76877907297a6a817ba5903786bcc7fba8fdd Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* QmlCompiler: Don't add imports with "as" to the contextUlf Hermann2020-12-051-1/+6
| | | | | | | | That is wrong. The context does not contain such objects. Instead, mark the names as namespaces in the imports by giving them an empty type. Change-Id: Ie9d0bba592863878d2220cee59be369ba2534f17 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Allow passing --qmljs-runtime to the qmlcachegen implementationUlf Hermann2020-12-021-0/+2
| | | | | | | | | | | | This signals qmlcachegenplus to not paste the whole JavaScript type system into each generated file. In turn, user projects need to add a dependency in order to build against the JS runtime. qmlcachegen ignores the option. Change-Id: I0f87dedb969e99e94fbb712b7faa23d84f76dfbe Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Allow passing --direct-calls to the qmlcachegen implementationUlf Hermann2020-12-011-0/+2
| | | | | | | | | | | | | qmlcachegenplus has an argument --direct-calls which instructs it to call methods of known C++ types directly rather than through the JS engine or the metaobject. This is faster but requires that all those types are visible to the generated code. Introduce a way to pass this option on a per-target base. Adjust qmlcachegen to ignore the option. Change-Id: I474e577e4a197f6ca4c8b8e868dfd39983e77041 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Find qml imports inside subdirectories of symlinksJeroen Oomkes2020-11-301-1/+1
| | | | | | | | | | Added QDirIterator::FollowSymlinks flag in function findQmlImportsInDirectory. This is to find qml imports in subdirectories of symlinks. Reason is that qwindeployqt does not scan imports inside directories following symlinks and therefore might skip dependencies that are needed for the application. And this is caused by the qmlimportscanner. [ChangeLog][tools][qmlimportscanner] Follow sybmolic links in findQmlImportsInDirectory Change-Id: I9739164e50cf48ec9e67f63a110e99da83facc2c Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmlformat: Add indent optionsMaximilian Goldstein2020-11-243-12/+41
| | | | | | | | | | | | Adds the ability to use tabs or any amount of spaces for indentation instead of the default of 4 spaces. [ChangeLog][QML][qmlformat] Added option to customize indentation. Fixes: QTBUG-86413 Change-Id: I3c370dda2d0069ef61202a2d862ce15bc513e55e Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Replace qt_make_unique with std::make_uniqueAllan Sandfeld Jensen2020-11-181-4/+3
| | | | | | | So we can remove it. Change-Id: I037373f85c696ce04c55920b41377cc9843b0da3 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QmlCompiler: Allow more convenient access to enums in QQmlJSScopeUlf Hermann2020-11-121-2/+2
| | | | | Change-Id: Ibac4dd7641a89b686bee63cf974b2257a35631a2 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Standardize QJsonArray iterationDavid Skoland2020-10-281-1/+1
| | | | | | | | | When using refs as loop variables, the clang compiler complains (with default settings). This prevents that. Note that QJsonValueRef is used "behind the scenes", which makes this iteration method correct. Change-Id: I5a5f58ca8ad3887bce2009231cbae5a57c107697 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* qmllint: Check identifiers before giving up in case of previous errorsUlf Hermann2020-10-271-4/+2
| | | | | | | | The identifier check might yet yield more information. Change-Id: I96f700acf257736fea7e9c2023b9e8797f702f7c Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
* QmlCompiler: Add JS scopes for script bindingsUlf Hermann2020-10-271-3/+5
| | | | | | | | This is necessary to identify the available QML and JS scopes for the binding, and to add any identifiers found there. Change-Id: Ic966e7817ccd1fdc064dd433d16fa6c42c9110cc Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Introduce grouped scopesUlf Hermann2020-10-272-0/+35
| | | | | | | | This way we can analyze the left hand part of things like "anchors.fill: parent" in qmllint. Change-Id: I0f58312566c3d5062e0fb301c2bad908ab8b8cbb Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Replace deprecated DataLocation with AppDataLocationShawn Rutledge2020-10-251-1/+1
| | | | | | Task-number: QTBUG-87037 Change-Id: I1cb6cd15fbb5fe08a0280ed83d01fc1b49249524 Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
* qmlcachegen: Move functions to compile QML/JS files to QmlCompilerUlf Hermann2020-10-231-375/+13
| | | | | | | | We need to re-use them. Also, provide a way to insert AOT compiled functions into the C++ code. Change-Id: I7b0d13cb307e8f979745f096a9614f087d135f68 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmlcachegen: Add empty AOT built functions to the loaderUlf Hermann2020-10-231-1/+11
| | | | | | | | This enables us to use the same generateloader.cpp for qmlcachegen and any replacement that actually produces AOT compiled functions. Change-Id: I12fe81236e4ef16a627729c644d54b6c171b3860 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Move generateloader.cpp to QmlCompilerUlf Hermann2020-10-235-244/+7
| | | | | | | We need to be able to generate the loader code from multiple places. Change-Id: I9e04fd3583b535bc5f7d5fb293cb61309c1e199a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Properly discern between inherited and own namesUlf Hermann2020-10-222-43/+48
| | | | | | | | | | | Previously, we would mix them up on importExportedNames(), which was also misnamed. Now we keep them in their proper place in the scope hierarchy, so that we can identify which scope a property came from. Exceptions are the qmllint-specific treatment of parent properties and Connections elements. Change-Id: I7c012388b16c83439d6f2de2e83fac0da4940d30 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: fix typoUlf Hermann2020-10-221-1/+1
| | | | | | Change-Id: Ia661141095a865191945f41bad91429ef952e16c Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Remove dead codeUlf Hermann2020-10-211-3/+0
| | | | | Change-Id: I5898402604fe29731dc518d42a441ff852706af3 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Compile with Clang11Lars Knoll2020-10-211-0/+4
| | | | | Change-Id: I9f3a4a6b6c7a2fbfca0a572209f398a23c26b37b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmlcachegen: Move resourcefilter.cpp into QmlCompilerUlf Hermann2020-10-205-179/+3
| | | | | | | | For backwards compatibility, a replacement for qmlcachegen will need to provide the same functionality. Change-Id: I22664230ea636d384190122223d15819ebee930c Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Pass source location to all scopes from QML filesUlf Hermann2020-10-151-2/+2
| | | | | Change-Id: Ic0aeb152acb0d90d15cc48a55c0ad5b15a60a6eb Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Further unify findwarnings.cpp and qqmljsimportvisitor.cppUlf Hermann2020-10-152-248/+58
| | | | | | | | Most of the logic in findwarnings.cpp applies also to imported files and should live in the base class. Change-Id: I65f326f50a8bfab0dff4b5b31f7bee7300b20704 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Unify QQmlJSImportVisitor and FindWarningsVisitorUlf Hermann2020-10-154-184/+21
| | | | | | | | | They are both pretty much doing the same thing, except that the import visitor is not as thorough. We need the full analysis in QtQmlCompiler, so we successively move the code over. Change-Id: If7fb47f88165fd8b61f4ccc408ccfbb7dad533e6 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Defer resolution of types read from QML filesUlf Hermann2020-10-152-6/+6
| | | | | | | | | | When importing a directory we most likely don't need all of the files in the directory. Therefore we now parse them only when they are accessed. This speeds up the execution and will allow us to process imports recursively without running into infinite recursion. Change-Id: I0c79313de792249e6bb86144b5014a7787dbdc5b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Unify the printing of diagnosticsUlf Hermann2020-10-152-30/+63
| | | | | | | | We can use QQmlJS::DiagnosticMessage to carry message, type, and location. Change-Id: I3868bc8035b4da13efad0d1b7d2f8dfeff1ef234 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Don't register the component we're just parsing as importUlf Hermann2020-10-141-4/+0
| | | | | | | | | I can't think of a scenario where this actually makes sense and none of the autotests exercise it. Change-Id: I6361d38e02f1cdac60ee5a4e1b8287491c3b05e6 Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Allow optional imports in qmldir filesUlf Hermann2020-10-081-1/+1
| | | | | | | | | | This is useful for modules that select their imports at runtime using qmlRegisterModuleImport(). We can list all possible variants as optional imports so that tools can see what types might be available. Task-number: QTBUG-87130 Change-Id: I8a37bdde79aef3619fd1f05e5ea6781d521afa88 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmlformat: Make arrow functions one linersMaximilian Goldstein2020-10-081-4/+16
| | | | | | Fixes: QTBUG-87179 Change-Id: Ieb7dffab59923bcb2ce8745c499eff7de44134b1 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>