summaryrefslogtreecommitdiff
path: root/tools
Commit message (Collapse)AuthorAgeFilesLines
* qmltyperegistrar: Improve the file open error messageHEADdevFriedemann Kleint2023-05-171-1/+4
| | | | | | Pick-to: 6.5 Change-Id: I196d66c438067ac31a99dbcedea57a8a53a60364 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qml tool: Use QCommandLineParser::process() rather than parse()Shawn Rutledge2023-05-161-10/+3
| | | | | | | | | | | | This handles the --version, --help and --help-all options. Apparently there's no other way to handle --help-all, because addHelpOption() adds two options but only returns one of them. Amends bb6602bca2b20d98f24320b10c7a039e605c9a05 Fixes: QTBUG-100678 Pick-to: 6.2 6.5 5.15 Change-Id: Iddd1ba2dae975d7256935d8d357e2f3ac6c013d6 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Remove the 'qml-devtools' featureAlexey Edelev2023-05-091-14/+12
| | | | | | | | | | | | | | | The meaning of the feature has changed and tools that depends on this feature now need to be built unconditionally. So the feature should be removed to avoid confusing users. [ChangeLog][QtQml][Tools] The 'qml-devtools' feature is removed. All tools that depend on this feature are mandatory and need to be build unconditionally. Fixes: QTBUG-113221 Pick-to: 6.5 Change-Id: Ia026684703d847ce777d7a2916f04b3c90727695 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qml: Straighten out configuration QML moduleUlf Hermann2023-05-086-41/+24
| | | | | | | | | | | | Use qt_add_qml_module correctly, apply a standard resource path, and move the files into the same directory as the module. Use upper case file names for the (re-usable) container definitions and lower case file names for the configuration entry points. This way we only need one directory and therefore only one QML module. Change-Id: Ic45dd0e8866f8f62bbaa639b6f138e9a75e05863 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* qml: Construct QQmlApplicationEngine only when we need itUlf Hermann2023-04-271-1/+3
| | | | | | | | | | Otherwise we leak a lot of memory if any of the exit() calls is triggered. Change-Id: I338abe2ef63217e6b80ffc2f8fe65d9cac03d994 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Semih Yavuz <semih.yavuz@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmlcachegen: Add a --verbose command line optionUlf Hermann2023-04-241-6/+5
| | | | | | | | | This replaces the logging category magic to determine whether we should output warnings. Change-Id: Ibc95ed70227e3438504e921693aa4af9a1d0376e Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Remove DomItem::loadFile code-duplication and use correct environmentsSami Shalayel2023-03-292-2/+2
| | | | | | | | | | | | | | | | | | The loadFile overload (in DomItem, DomEnvironment and DomUnivers) for different files (in-memory files and files that needs to be loaded from disk) are either copypasted or just calling the other overload. Encapsulate the file-related arguments of all loadFile overloads into a new struct called FileToLoad, such that the copypasted overloads can be removed. Use the static factory function FileToLoad::fromMemory and FileToLoad::fromFileSystem to create the FileToLoad struct. In addition, FileToLoad allows to specify the environment in which a file should be loaded. Prior this commit, myEnv.loadFile() was creating a new environment for each loaded file. Change-Id: I3b6acb681cb77faefdaa447d985bdfbe4f6a9ce2 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Doc: Rename and rephrase pages for QML {script|type} compilerUlf Hermann2023-03-281-1/+1
| | | | | | | | | | | | | | | | They describe the user facing concepts, not the actual tools. In the case of QML script compiler there are two tools that implement it. Clarify what qmlsc and qmlcachegen actually do and highlight the differences. Also, lower case all references to type compiler and script compiler. They are not product names and therefore should not be upper cased. Pick-to: 6.5 Change-Id: If800d368c904bd829d88b7376b107b1c5351a1ed Reviewed-by: Andreas Eliasson <andreas.eliasson@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qml tool: Fix incorrect mapping of --transparent to MSAALaszlo Agocs2023-03-171-1/+1
| | | | | Change-Id: Ief9f12c1b3dfab928b110278c1d49abb1028efe0 Reviewed-by: Christian Strømme <christian.stromme@qt.io>
* qmltyperegistrar: Guard against file system failuresUlf Hermann2023-02-171-1/+5
| | | | | | | Pick-to: 6.5 Coverity-Id: 404703 Change-Id: Icf3fd90e392891bcc0c48f4ce6be8731abbeb1aa Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Fix attached property re-use detectionUlf Hermann2023-02-142-2/+2
| | | | | | | | | | | | | | | | | | | | | Move the detection into the QtQuick lint plugin. It's mostly meant for QQC, so let's auto-enable it for attached types derived from QQuickAttachedPropertyPropagator. To this end, two new categories are introduced: The Quick lint plugin gets its own attached-property-reuse category which is synonymous to the default category of the same name. Furthermore, we add a controls-attached-property-reuse category for only checking controls. That one is implied by either of the others. Finally, fix the id vs. scope resolution to actually do something. This way we can give appropriate hints when the outer type has an ID already. Pick-to: 6.5 Fixes: QTBUG-110834 Change-Id: Ib71a9e3bbc10bac77f36db6cc441af88df20fd33 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* bin/qml: Fix broken handling of --translation commandline argumentJan Arve Sæther2023-02-081-2/+1
| | | | | | | | | The QTranslator was destructed right after it was loaded because it was inside a scope Pick-to: 6.5 Change-Id: I8c9d1604652f18f7d15aa7a0045f580cd8a25063 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmlls: move into own private static librarySami Shalayel2023-02-0730-3680/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Qmlls was completely implemented in the ./tools directory, which made its code complicated to test and try out. Also, it required some "dirty" hacks in the actual tests (including files from others targets to be able to use them) and made testing new features for qmlls more complicated. To remedy this, the qmlls code was split into a tool (qmlls) and a static library (QmlLSPrivate). The tool only contains tools/qmlls/qmllanguageservertool.cpp (which has the qmlls main method) and links to QmlLSPrivate, that contains all the other qmlls-related code. This way, the tests can also link to QmlLSPrivate and test out individual functions there without needing to include files from other targets. Also rename all the files to make syncqt happy (adding "_p" to headers and prepending "q" to headers and files and includeguards), and use QString::fromUtf8() to silence the QString()-constructor deprecation warnings. On the way, move tools/shared/qqmltoolingsettings.* into its own private static library, instead of recompiling it for each tool that requires it. Move the qqmltoolingsettings stuff into the qt namespace to be usable. Also, add qmlls as a dependency to the qmlls tests to avoid testing an outdated qmlls-binary. This commit prepares qmlls's code to implement the go-to and find-usages features. Task-number: QTBUG-109006 Change-Id: I91eed689c68a0c53fb88006de335b0f852cc1a83 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Bring QSurfaceFormat configurability to qmlscene's level in the qml toolLaszlo Agocs2023-02-071-12/+39
| | | | | | | | | | | | | | | | | | | Restore the --transparent and --multisample options. Also make the default QSurfaceFormat setting universal (no need to tie it to the option of forcing a core profile context), and prevent the warning that is printed when the default surfaceformat is changed after the application is already created with AA_ShareOpenGLContexts set. This involves having to handle the relevant arguments manually early on, not through QCommandLineParser. All this matches the qmlscene behavior. NB qmlscene requests 16 samples with --multisample which is completely pointless in practice. Use the common 4 now. Change-Id: I671e5f22846a715675ea936bb7cf2a31a849dc28 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* qml tool: Disable shader caching by defaultPaul Olav Tvete2023-02-071-0/+8
| | | | | | | | | | When shaders are generated dynamically, such as with QtQuick3D, cached shaders may get out of date if the QML file is changed. Change-Id: I2c5484765e30da5c13fd175a9fcbad2473d55e62 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> Reviewed-by: Christian Strømme <christian.stromme@qt.io> Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* qmllint: Provide import paths and resource files when linting modulesUlf Hermann2023-02-071-1/+2
| | | | | | | | | Those are just as important for modules as for single files. Pick-to: 6.5 Change-Id: I201d62c61988abc2dfba6300a1cfc355203fec75 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* qmltc: export generated classesSami Shalayel2023-02-026-5/+30
| | | | | | | | | | | | | | | | | | | | | | Add QMLTC_EXPORT_MACRO_NAME and QMLTC_EXPORT_FILE_NAME arguments to qt_add_qml_module() that allows the user to export qmltc-generated code from its library. The qmltc-generated code will include the header-file specified in QMLTC_EXPORT_FILE_NAME and will be exported with the macro specified by QMLTC_EXPORT_MACRO_NAME. Leave both options unspecified to not export the code generated by qmltc. Describe the options in the documentation and write a test to see if the class really has an export macro in the generated code: 1) tst_qmltc_qprocess will test if the macro and the header are correctly inserted in the generated code. 2) tst_qmltc_{no,}diskcache will test if the generated code can still be used from a static library. Fixes: QTBUG-106840 Task-number: QTBUG-96040 Change-Id: I554f03bcdf043e8114e42f51a7289a5c00de4f89 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QML: Turn singleton/type mismatch into a run time type errorUlf Hermann2023-01-273-4/+26
| | | | | | | | | | | | | | | | | | | | | | | There are many ways to "hide" the qmldir from the engine at run time, which turns singletons into regular types. While all of this is invalid, we should not assert on it, but rather produce a legible warning. Furthermore, sharpen the importing of extra modules from qrc as implicit imports. We should really only import modules the file in question can ever be part of. Otherwise we needlessly produce the above situation and hide legitimate warning messages. Amends commit 7517c1b3ae9aa92f36b19d74a4b2de5e8531309b. Now we need to teach our tools about the default import paths in the resorurce file system. They cannot guess any type they may find in any resource file anymore. Pick-to: 6.5 Task-number: QTBUG-106929 Change-Id: Ic8c02396d10830a7f461e8a81649bb8c9a1add1f Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* qmllint: Move qmlControlSanity loggers into a pluginSemih Yavuz2023-01-231-2/+1
| | | | | | | | | | | | | | QmlImportVisitor has some log messages that is only used for controls sanity tests. Move these loggers into a QuickControlsSanity plugin. Move the relevant tests from tst_qmllint to tst_sanity as we link the plugin to tst_sanity. Also remove qmlControlsSanity category from the default categories of QQmlJsLogger as it should be only utilised by this plugin. Task-number: QTBUG-103276 Change-Id: Iacc624711a2cd00aeb9d89fbde7c0131896d30ce Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qml: Fix object countingUlf Hermann2023-01-231-17/+3
| | | | | | | | | | | | We're not actually interested in whether an object is a window, and we don't really care how many objects are created. The only thing we need to know is whether at least one object is alive after all files have been processed. Pick-to: 6.5 Fixes: QTBUG-110112 Change-Id: I8d79359f3fb7ec5a54545dc5858cf310b0f52935 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmlls, qmllint: Avoid memory leaksUlf Hermann2023-01-161-6/+6
| | | | | | | Pick-to: 6.5 Fixes: QTBUG-104643 Change-Id: I5ca0fea2ef6f822b70c08bc6e49f0d07a732b299 Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* qmltc: generate code into namespacesSami Shalayel2023-01-061-10/+14
| | | | | | | | | | | | | | | | | | | | | Generate code into namespaces to avoid clashes between qmltc-generated and user code. Code generated by qmltc will by default be put in the URI_OF_MODULE namespace, and will generate subnamespaces to follow the module hierarchy if URI_OF_MODULE contains dots('.'). Also fix the test to use the new namespaces. [ChangeLog][Qml][qmltc] The type compiler will generate C++-code into a namespace by default. The new default namespace is inferred from the module's URI, where dots are interpreted as separating subnamespaces from each other, e.g., a type in module MyCompany.MyModule.Sub will be generated in the namespace MyCompany::MyModule::Sub. Fixes: QTBUG-109274 Change-Id: I3bfe2697b81e90bb63a079dc44c2810fc9925f97 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Fix some qsizetype vs. quint32 problemsUlf Hermann2023-01-061-1/+6
| | | | | | | | | | On 32bit platforms you cannot losslessly convert quint32 to qsizetype. However, in the places we are facing here, we are only interested in signed 32bit numbers anyway. Pick-to: 6.5 6.2 Change-Id: I93a07c2847bd5bfae426dccbb6c0e33c5758442d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmlplugindump: Don't crash on value types with extensionsUlf Hermann2023-01-041-1/+2
| | | | | | | | | | | We have some internal value types without their own base metaobjects, but with extensions. qmlplugindump is not designed to handle those. Skip them. Pick-to: 6.5 Fixes: QTBUG-109562 Change-Id: I3c4925790ac905077e6ea07724c898b32dd6e59a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmake: Fix generated *_qmlcache.cpp file pathsJoerg Bornemann2022-12-141-0/+1
| | | | | | | | | | | | | | | | | ...for source files that are outside of the source directory. Having QML files that are generated in the build directory led to *_qmlcache.cpp files with very long file names, hitting file system limitations on Windows. Apply the same fix that was done for generated qmlcache.qrc files in commit 5d7710a623ecde64316c42fd097db386ac28dd51. Pick-to: 6.2 6.4 6.5 Task-number: QTBUG-108150 Change-Id: Icef9dbf40fc7ade54b584bcdc8799c4cc95ac76d Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmlls: Remove unused variablePeter Varga2022-12-141-2/+0
| | | | | | | | | | Fixes Clang -Wunused-but-set-variable warning. Amends 25ac957f6da559333938430eec9cc341823e22cc Pick-to: 6.5 6.4 Change-Id: If959b846a211796297ee2e05923e9ba3d32ae15f Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Remove Qt keywords from all headersYuhang Zhao2022-12-0916-26/+20
| | | | | | | It's good practice to do so. Change-Id: I72435ff99aaee942c1d3b488ec5dedd7e82d1047 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmltc: fix handlers for c++-signalsSami Shalayel2022-12-072-7/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Allow qmltc to generate handlers for c++-defined signals with const parameters by changing the safeguard to avoid type mismatch between slots and signals. First, remove the qOverload in the generated QObject::connect call to be able the connect slots and signals with different types (namely, pass by const references and pass by value should be interchangeable but is not allowed by qOverload). Second, save in QQmlJSMetaParameter when types are passed by pointer. Like this, qqmljsimportvisitor can check if a value type is indeed passed by value or const reference in a C++ signal. The same for reference types that need to be passed by (const and non-const) pointer. Print a message when an type is passed by argument in an incompatible way instead of letting qmltc generate uncompilable code, which makes the compiler print out cryptical messages. Third, add a qqmlcpptypehelpers template that decides if value types should be passed by value or reference, by letting the c++ compiler check if sizeof(T) > 3*sizeof(void*). Fixes: QTBUG-107625 Fixes: QTBUG-107622 Change-Id: I1a00532df591d10f74c1fd00dff5b7fccf40cb22 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QQmlJSMetaParameter: Encapsulate parameter informationSami Shalayel2022-12-022-26/+14
| | | | | | | | | | | | | | | | | | | Previously, there were four lists that contained each one entry for each parameter. There was one list responsible for the names, types, type names and const-qualifiers but this was quite bothersome to use (e.g. they not always had the same length). This commit introduces QQmlJSMetaParameter to encapsulate all the information required when manipulating parameters. This reduce the 4 lists to one, making parameters easier to handle and QQmlJSMetaMethod easier to read. This is a purely refactoring change, no new functionality was added. Task-number: QTBUG-107625 Change-Id: Ia41b823c9e6294ee26e828071b802cac6b4058ce Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmltc: error out when encoutering invalid filenamesSami Shalayel2022-12-021-0/+10
| | | | | | | | | | | | | | | | | | | | Dashes and other special characters in qml filenames makes life quite complicated, the generated cpp file will contain everywhere and be uncompilable. Instead, directly print an error message explaoining which names are allowed for type compilation and return. Reasoning: The name of the qml file is also the name of the qml object. For example, using a dash in the filename makes the corresponding qml type have a dash in its name and renders the type mostly unsuable in qml. Therefore, only allow characters, digits and underscores. Pick-to: 6.4 Fixes: QTBUG-107079 Change-Id: I4bff12e4a644b479213e7cc578207c8a443fc517 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmllint: document new behavior of --jsonSami Shalayel2022-11-281-1/+2
| | | | | | | | | | | | | | | Amends 5c04d174282a9a36ce12b26e1807d3d5051a7f33. The behavior of qmllint changed in the above-mentioned commit, as it started expecting a file argument for the --json option. Before, it was not expecting any and always writing to stdout. Document the new behavior in the docs and in the --help command, especially the part about using '-' to restore the old behavior. Fixes: QTBUG-108913 Pick-to: 6.4 Change-Id: I3a69a794a5362a575437d3d832d6e038c7a0755a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Build: install the metatypes inside Qt's own arch-specific data dirThiago Macieira2022-11-241-1/+1
| | | | | | | | We don't want it in /lib64/metatypes, but instead /lib64/qt6/metatypes Pick-to: 6.4 Change-Id: Id8e48e8f498c4a029619fffd17293602d7fd8bd8 Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* qmlformat: add 'ensure new line between functions' optionXavier BESSON2022-11-241-0/+11
| | | | | | Fixes: QTBUG-108659 Change-Id: I3e21727bd946089d89ce9c42f640f05230de8c8e Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QQmlJSImportVisitor: warn when uncreatables are createdSami Shalayel2022-11-231-1/+4
| | | | | | | | | | | | | | | | | | | | | | isCreatable in qqmljsscope just returns the value of the flag as it was read from the qmltypes, which is slightly confusing as isCreatable is an opt-out option. Instead, isCreatable should reflect whether the type is creatable or not. A type is uncreatable if and only if it is a singleton, an attached type, a c++ type with QML_UNCREATABLE and types without default constructor. This uncreatibility can also be inherited to composite types. Types without default constructor require QML_UNCREATABLE or QML_ANONYMOUS, and will be handled in another commit. Now that uncreatable types can be detected, emit a warning when a singleton or an uncreatable type is created: up to now no such warning was emitted. This warning can be seen when using qmllint or qmltc. By the way, also fix qmltc to not assert when something goes wrong (e.g. because an uncreatable or singleton type was created). Change-Id: I9a82106a801d14063407eb4e54858b1ca9fd578b Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmltc: add singleton supportSami Shalayel2022-11-233-7/+29
| | | | | | | | | | | | Add singleton support to qmltc. Add the QML_SINGLETON annotation to the class, generate a static T* create(QQmlEngine*, QJSEngine*) method for the engine and also add test this new functionality. Fixes: QTBUG-106828 Change-Id: I7b6b39ab0c8a427b3166562c3f04cf4a7eaa20e2 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* tooling: silence -Wextra-semi-stmtTim Blechmann2022-11-162-10/+10
| | | | | | | | silence clang's -Wextra-semi-stmt Pick-to: 6.4 Change-Id: I5dee9ec46b44076f0fc0590399131b1b267e1ad2 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmlformat: add 'ensure new line between objects' optionXavier BESSON2022-11-141-0/+12
| | | | | | | | This option allows to format files into more 'refreshing' ones. It improves readability thanks to a clearer visualization of objects inside files. Change-Id: Ic3592e87ae16d14d70317d09d819cc5d331be822 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmltyperegistrar: add IsConstant for method parametersSami Shalayel2022-11-111-6/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Mark method parameters with IsConstant instead of including "const " in the typename, which makes type resolution in the qml compilers impossible. This also avoids a crash in qmltc happening when qmltc sees a signal defined in C++ that has a const parameter. When qmltyperegistrar writes out the types in the qmltypes, check if it starts with a const, remove it and add instead IsConstant: true. The name returned by MOC is normalized so no need to check for "volatile const" or "const volatile" (its always the latter) and no need to filter out for extra whitespace. Once the const is read by the qmltypes reader, propagate the const-information around using a newly introduced enum called QQmlJSMetaMethod::PConstness that can currently be Const or NonConst. Also add the isConstant property to the Parameter.qml in the tooling module. Add a test to see if the IsConstant information is written into the qmltypes. This is also required for QTBUG-107625. Fixes: QTBUG-108147 Task-number: QTBUG-107625 Change-Id: I13bda0a27fe83867f259b751468788128fec82ed Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QmlCompiler: Allow lists as arguments to methodsUlf Hermann2022-11-103-18/+20
| | | | | | | | | | | | | | | | | | | Since lists are allowed as property types, you should be able to pass them as arguments to methods, too. For now we only handle QML-defined methods, implemented by adding JavaScript functions to your QML elements. The usual type coercion rules apply if you pass JavaScript arrays to such methods. That is, it usually works. We now resolve properties with the "list" flag to their actual types (QQmlListProperty or QList) already when populating the QQmlJSScope, and store the list types as members of QQmlJSScope rather than as a special map in QQmlJSTypeResolver. This allows us to do the same to lists passed as arguments and simplifies some of the type analysis. Fixes: QTBUG-107171 Change-Id: Idf71ccdc1d59f472c17084a36b5d7879c4d959c0 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmltc: support inline components from different qml filesSami Shalayel2022-10-311-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | Make qmltc aware that inline components can be shared between files such that it does not complain about not finding them. Typical usage are `MyOtherFile.MyInlineComponent {}` and `ModuleName.MyOtherFile.MyInlineComponent {}` for an an inline component called MyInlineComponent defined in MyOtherFile.qml, maybe also in a module called ModuleName. Make QQmlJSScope::findType() aware that inline components exists (and potentially that they might also appear in namespaced types). They can also be "imported" or reexported from basetypes and/or deeply nested in some children scopes. Also make it public so that qqmljsimportvisitor can use it when processing property types. Added some tests testing both notations (with and without the qualifed module name). Also add a test to see if there is no confusion between the enums and the inline components (due to their very similar notations). Fixes: QTBUG-106592 Change-Id: I8f2d4790729902ffa664fd0eb1b7c3279af8ddca Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmltc: Add some sugar for generated reference-type-list propertiesSami Shalayel2022-10-282-2/+117
| | | | | | | | | | | | | | | When compiling a reference type list with qmltc into a QQmlListProperty, also generate helper methods to make the manipulation of those lists by the user easier in c++. For a list myList, generate the methods myListAt(), myListAppend(), ... as shown in the Birthdayparty example. Also add some documentation about the ownership of the arguments, and tests to see if the list can be accessed from C++. Task-number: QTBUG-107570 Change-Id: Iec0041015311639ead39660fdccf147749566592 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmltc: extend QmltcMethod with optional commentsSami Shalayel2022-10-282-1/+8
| | | | | | | | | | | | | | | | The methods generated with Qmltc are facing the user: therefore add the possibility to add internal comments before generating the method call such that the user can be warned or informed about certain unclear behaviors. For example, the methods asked for in QTBUG-107570 needs to warn the user about ownership issues on the arguments to avoid dangling pointer references. Task-number: QTBUG-107570 Change-Id: Id04ff7f9a36daad1da836bb421901b9b706a05e7 Reviewed-by: Semih Yavuz <semih.yavuz@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmlformat: do not generate backup filesSemih Yavuz2022-10-241-1/+2
| | | | | | | | | | qmlformat used to backup the original input file up to 2 copies when used with --inplace mode. Change this hardcoded number into 0 and generate no backup file. Fixes: QTBUG-107685 Change-Id: Ifca86968fa65be0fd678012fc2e41b9ed8601d21 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Clean up comments after porting to Q_UNREACHABLE_RETURN()Marc Mutz2022-10-201-2/+0
| | | | | | | These are no longer needed. Change-Id: Id923f71e3452c7ac78a03ea5defeed4b189dc799 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Port to new Q_UNREACHABLE_RETURN()Marc Mutz2022-10-203-6/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator to convert sequences of Q_UNREACHABLE() + return into Q_UNREACHABLE_RETURN(), newly added to qtbase. const std::string unr = "unr", val = "val", ret = "ret"; auto makeUnreachableReturn = cat("Q_UNREACHABLE_RETURN(", ifBound(val, cat(node(val)), cat("")), ")"); auto ignoringSwitchCases = [](auto stmt) { return anyOf(stmt, switchCase(subStmt(stmt))); }; makeRule(stmt(ignoringSwitchCases(stmt(isExpandedFromMacro("Q_UNREACHABLE")).bind(unr)), nextStmt(returnStmt(optionally(hasReturnValue(expr().bind(val)))).bind(ret))), {changeTo(node(unr), cat(makeUnreachableReturn, ";")), // TODO: why is the ; lost w/o this? changeTo(node(ret), cat(""))}, cat("use ", makeUnreachableReturn)); a.k.a qt-use-unreachable-return. subStmt() and nextStmt() are non-standard matchers. There was one false positive, suppressed it with NOLINTNEXTLINE. It's not really a false positiive, it's just that Clang sees the world in one way and if conditonal compilation (#if) differs for other compilers, Clang doesn't know better. This is an artifact of matching two consecutive statements. Change-Id: I3855b2dc8523db1ea860f72ad9818738162495c6 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Add a separate flag for the "pragma Strict" checkUlf Hermann2022-10-201-1/+2
| | | | | | | | | | | | | We want to trigger the qFatal() when running qmlcachegen or qmlsc, but we don't want to trigger it in qmllint, even if we are using the same QtMsgType for the severity of the messages. In turn, demote qmlCompiler messages to QtWarningMsg in qmlcachegen. Pick-to: 6.4 Task-number: QTBUG-107168 Change-Id: Ib660df41742b2d426241eb29ac4c91f4933c5ba1 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Port from container::count() and length() to size() - V5Marc Mutz2022-10-132-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator as in qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8, but extended to handle typedefs and accesses through pointers, too: const std::string o = "object"; auto hasTypeIgnoringPointer = [](auto type) { return anyOf(hasType(type), hasType(pointsTo(type))); }; auto derivedFromAnyOfClasses = [&](ArrayRef<StringRef> classes) { auto exprOfDeclaredType = [&](auto decl) { return expr(hasTypeIgnoringPointer(hasUnqualifiedDesugaredType(recordType(hasDeclaration(decl))))).bind(o); }; return exprOfDeclaredType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes)))); }; auto renameMethod = [&] (ArrayRef<StringRef> classes, StringRef from, StringRef to) { return makeRule(cxxMemberCallExpr(on(derivedFromAnyOfClasses(classes)), callee(cxxMethodDecl(hasName(from), parameterCountIs(0)))), changeTo(cat(access(o, cat(to)), "()")), cat("use '", to, "' instead of '", from, "'")); }; renameMethod(<classes>, "count", "size"); renameMethod(<classes>, "length", "size"); except that on() was replaced with a matcher that doesn't ignoreParens(). a.k.a qt-port-to-std-compatible-api V5 with config Scope: 'Container'. Change-Id: I58e1b41b91c34d2e860dbb5847b3752edbfc6fc9 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmlplugindump: Warn if we can't change the directoryUlf Hermann2022-10-111-1/+4
| | | | | | | | | | | It's unclear why we even have to change to the import path, but given the brittle nature of qmlplugindump, let's keep it that way and simply output a message if it fails. The static analyzer complains about a missing return value check. Coverity-Id: 401048 Change-Id: I72e6258dceb7df76a87584b6fe4f5236d754f7cc Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qqmljsimportvisitor: rename m_currentInlineComponent to m_currentRootSami Shalayel2022-10-101-4/+4
| | | | | | | | | | | Small refactor to improve readability: rename qqmljsimportvisitor::m_currentInlineComponentName to m_currentRootName as it denotes the current inline component OR the document root. The previous naming implied wrongly that it was useless when outside an inline component. Change-Id: Ie3c9aa10182f0c9e50650cecaa3e3eb1e37e90eb Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmltc: fix code generation for implicit componentsSami Shalayel2022-10-101-15/+35
| | | | | | | | | | | | | | | | | | | | Do not check if a type is implictly wrapped during visitation, as this information is only made available by QQmlJSImportVisitor after(!) the visit. Move this into the postvisit step of qmltc, and write some internal documentation so this error will hopefully not be done again by some qmltc contributor (e.g., me). Now that implicit components are correctly recognized as such, they can be compiled correctly and the c++-code generated by qmltc can again be compiled. Added also a test to see if all childrens of the repeater are correctly instantiated. Pick-to: 6.4 Fixes: QTBUG-107091 Change-Id: I8fce018b83316f8786ae5ca15e5af27c30bb1d37 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>