aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmlcompiler
Commit message (Collapse)AuthorAgeFilesLines
...
* QmlCompiler: Properly handle uncertain component statusUlf Hermann2025-09-188-73/+274
| | | | | | | | | | | | | | | | | | | | | | | | | | | In order to determine whether an ID is visible from a referrer we need not only determine the component boundaries of the referrer, but also those of the candidate elements with the respective ID. Rewrite the logic to have QQmlJSScopesById handle this. It has to iterate the respective elements anyway and can therefore easily check if one of them is assigned to an unknown property. It now provides low-level methods that output all possible candidates for an ID, while also stating the confidence associated with them. The plain id() and scope() methods only return results we are actually certain about. In places where we generate warnings or can allow for some fuzzy results, we use the low-level methods, since those generally produce more informative results. The QML DOM was passing the JavaScript global object as referrer to the scope() method before. This happened to work but was, of course, wrong. Make sure that ID elements in the DOM receive a proper QML scope to avoid that. Pick-to: 6.10 6.9 6.8 Task-number: QTBUG-140041 Change-Id: I41cf8603ae6a5d5461d3c12d74521e68b5e28ea4 Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* Tests: Clean up includesUlf Hermann2025-09-171-1/+2
| | | | | | | | | | | | | We shouldn't include qtqml-config_p.h manually since it's not header-guarded. And especially we shouldn't include it twice. Also, sort and split the includes. In order to resolve QT_CONFIG, we include qtqmlglobal_p.h or qtqmlglobal.h. Change-Id: I933d8eff8581e91859a8a178bf92caeec2959215 Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* Add security header for src/qmlcompilerOlivier De Cannière2025-09-1780-0/+81
| | | | | | | | | | | | | | | | | | We assume that QML or JS code comes from a trusted source. Therefore, most files are deemed to be significant even if they parse data. This includes the source code itself but also the associated metadata or cache files. However, the QML compiler also generates C++ code. Extra care needs to be taken with the generator as a vulnerability there could propagate and have a disproportionate effect on the program's security. It is marked as critical. QUIP: 23 Fixes: QTBUG-136195 Pick-to: 6.10 6.9 6.8 Change-Id: I70630361ec8e9cb3969f78a3fdf36a41334a33b3 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qml compiler: avoid `interface` as var/parameter nameTim Blechmann2025-09-092-32/+33
| | | | | | | | | | | The win32 system headers define `interface` to `struct`. When using unity builds, this define can leak between source files and cause compile errors. This patch fixes unity builds. Pick-to: 6.10 Change-Id: I72192f406ace2bdb26e18d61fd80add26345d34a Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QmlCompiler: Ensure QObjects returned to AOT-compiled code are wrappedUlf Hermann2025-09-023-10/+23
| | | | | | | | | | | | If a QObject is returned from a method call, the QML engine takes ownership of it and it needs to be deleted by the garbage collector. Our generated C++ code so far did not actually take ownership of the object and thereby caused it to leak. Pick-to: 6.10 6.9 6.8 Fixes: QTBUG-138919 Change-Id: I7bd57b3612bf4b98937756e8a7a7c03aff1c9b32 Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* QtQml: Mark values on the AOT-compiled stack during gcUlf Hermann2025-09-021-8/+45
| | | | | | | | | | Keep them in a special generated struct with virtual method that gets called from the GC for each frame. Pick-to: 6.10 6.9 6.8 Fixes: QTBUG-139059 Change-Id: I81bcbeab6531e174a5207d03f57d241461ae9ba3 Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* QmlCompiler: Fix access to optional QVariantMapUlf Hermann2025-09-012-5/+21
| | | | | | | | | | Without this, it tries to resolve the metaObject of QVariantMap, which crashes. Fixes: QTBUG-139626 Pick-to: 6.10 6.9 6.8 Change-Id: I9248f57c428810024f9983df959f475e6557576c Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* QmlCompiler: Rename sequences' "valueType" to "elementType"Ulf Hermann2025-08-318-57/+59
| | | | | | | | | "valueType" is ambiguous. The prevailing meaning is a type that's passed by value in QML. We mean the type of the list contents (or elements) here. Change-Id: Iaf4c0efe272dc6ec7511d2361e7e5ce475936fba Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* qmllint: Do not warn about QQmlPropertyMap accessFabian Kosmale2025-08-252-1/+6
| | | | | | | | | | A QQmlPropertyMap can store anything, and we can't know what is available. Treat it like QVariantMap as far as qmllint is concerned. Task-number: QTBUG-139240 Pick-to: 6.10 Change-Id: I9ebc0a963159cfc930ff14300df50b6fab5b7035 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmllint: disable unqualified warning on user context property callSami Shalayel2025-08-222-27/+18
| | | | | | | | | | | | Amends 6575b0e835357dbf4f2a04c6df50abee4bda08ba that forgot to disable unqualified warnings on context property calls `myContext()`. Rename warnAboutContextPropertyUsage() into handleUnqualifiedAccessAndContextProperties() and make it handle unqualified access warnings when needed. Fixes: QTBUG-138061 Change-Id: I2fe3ab2a9c2ed1329589ce67a03c1f905542793e Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: load .contextPropertyDump.ini from build folderSami Shalayel2025-08-213-7/+46
| | | | | | | | | | | | | | Make QQmlJSLinter read heuristic context properties (.contextPropertyDump.ini) files from the build directory, by searching them with QQmlToolingSettings::Searcher. Add a test that writes a .qrc file such that qmllint can find the "build" folder that contains the .contextPropertyDump.ini, and make sure that QQmlJSLinter warns about at least one context property. Task-number: QTBUG-128232 Change-Id: I52569acc38d2fcda5015fe38ef84967353dbc21d Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* HeuristicContextProperties: don't grep on empty argumentSami Shalayel2025-08-211-0/+3
| | | | | | | | | In HeuristicContextProperties::collectFromDirs, early return when an empty list is given, instead of running grep without directories (which defaults to the working directory). Change-Id: I96647112eab74e9d68c96aaf14511f06774009d4 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmlcontextpropertydump: add extra feature flag to disable/enableSami Shalayel2025-08-211-5/+6
| | | | | | | | | Introduce a new feature flag to disable the qmlcontextpropertydump tool (that will be introduced in a later commit). Task-number: QTBUG-128232 Change-Id: I68436f1007ec40c6b3c8e1059319156251ecdef4 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* heuristic context properties: write and load to/from diskSami Shalayel2025-08-212-1/+130
| | | | | | | | | | | | | | | | | Add methods to write and load context properties on disk. Use the .ini format to provide human readable files and to be able to reuse QQmlToolingSettings for finding the setting file. Implement a simple (de)serialization of SourceLocations for the .ini files, and use QSetting to dump/read the lists of properties. Add a test to see if the (de)serialization works. Add equality operators where required for the test's Q_COMPARE(). Task-number: QTBUG-138061 Task-number: QTBUG-128232 Change-Id: I23bd2db0aacad3d395c2909efb209277f7f1d4bd Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmllint: Update JSON format to include hints into fix suggestionsOlivier De Cannière2025-08-201-15/+2
| | | | | | | | | | | | | Hints are no longer their own fix suggestion but instead are part of an existing one. This breaks compatibility with the existing format but as the output is not documented and is versioned this should be ok. This change will enable having multiple fix suggestions per warning in a future change. Pick-to: 6.10 Change-Id: Iedf275507554a2d70399757396e278999874cd53 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QQmlJSLogger: Also print out hints of fixSuggestionsOlivier De Cannière2025-08-201-6/+8
| | | | | | | | It otherwise went unused. Pick-to: 6.10 6.9 6.8 6.5 Change-Id: I255a53247d0cfce29d958425d1f8f2895eb093e7 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Compiler: Enable color output on supported consoles on WindowsOlivier De Cannière2025-08-191-6/+16
| | | | | | | | | | | | Windows 10 enabled support for ANSI escape sequences. Let's use them. [ChangeLog][QML] Color ouput for qmllint and qmlcachegen is now also enabled on Windows on terminals that support it. Fixes: QTBUG-139228 Change-Id: I5e48e1052823ef4d0e6005482c9a1bee210e0929 Reviewed-by: Zhao Yuhang <2546789017@qq.com> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* qmlls: find C++ & QML definitions of enumSami Shalayel2025-08-181-0/+1
| | | | | | | | | | | | | Implement go to definition for enums (values and keys) defined from C++ or QML. This allows user to jump to their own C++ files, and does not jump to headers outside the project folder, like private/qquickitem_p.h for example, as it might get confusing for the user to open a file in the editor that they are not supposed to edit. Task-number: QTBUG-128393 Change-Id: I0410ecf4cf810e6c6072038bffc4564eb787c7fc Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* qmltyperegistrar: add line numbers to methods, properties and signalsSami Shalayel2025-08-182-6/+23
| | | | | | | | | | Add line numbers to qmltyperegistrar's output now that MOC includes this information in its output. Task-number: QTBUG-119143 Task-number: QTBUG-128393 Change-Id: Id77ef37f1503bd17fa42a355770a1ffeb348b46e Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQmlJSTypeResolve: Support T -> QmlListProperty<T> conversionFabian Kosmale2025-08-101-0/+6
| | | | | | | | | | The engine handles this just fine, and we had examples (and probably documentation) shownig this pattern. If we want to warn about it, it should have a dedicated warning. Pick-to: 6.10 Change-Id: I105f4a49ecfc6fbd5f00c683e0dbef7d34a64a1d Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* qmllint: allow mixing ID based with text based translationMasoud Jami2025-08-084-95/+0
| | | | | | | | | | | | | Since 6.10 Qt i18n component allows mixing id based with text based translation and this is reflected in lrelease, lupdate, and documentation. This patch is a partial revert of 8b61addfa42525c1bd5f27febbe62dcbdb645fc9 and removes the qmllint warning in the case of mixing these two. Pick-to: 6.10 Change-Id: Iae2407da2bc5cc21fc3664051834c99b8c72fe58 Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* QmlCompiler: Pass QQmlJSSaveFunction as const refUlf Hermann2025-08-072-7/+7
| | | | | | | | std::function is quite heavy-weight. Coverity-Id: 486648 Change-Id: Ia7c61a726bde9c9d6a02412b9aa5f683bb4d355a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Remove pointless null checkUlf Hermann2025-08-071-5/+4
| | | | | | | | | We have already dereferenced passMan a few lines before and that obviously succeeded. Coverity-Id: 486649 Change-Id: I36dcef5757013acf98d665396a3f8f3d289bfee1 Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* qmllint: don't grep twice for context propertiesSami Shalayel2025-08-051-4/+12
| | | | | | | | | It seems that we grep twice when grep returns 1. From the manual, a return code of 1 means nothing was found and in this case we shouldn't run the fallback grep method. Change-Id: Id8993ca914cefb8bb806f77334508be46fb60fbe Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: make contextproperties a real class and renameSami Shalayel2025-08-056-51/+81
| | | | | | | | | | | | | | | | | | | | | | | | | Prepares for QTBUG-138061 where we need a way to load user-defined context properties into QQmlJS::ContextProperties. Rename QQmlJS::ContextProperties into HeuristicContextProperties to avoid confusions with the UserContextProperties. Make HeuristicContextProperties a real class so that we can add methods to load and save context properties to and from disk. Make the heuristics be saved in a list instead of a QHash, as the order of the property matters as we write them out into a file and testing becomes complicated when the order changes between different runs. Also note that it might be confusing for qmlls users if their warnings change orders during multiple runs. Rename some methods for clarity. Task-number: QTBUG-138061 Task-number: QTBUG-128232 Change-Id: Ib6302f609e182e622015293366c8b42425566a0e Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Compiler: Skip type propagation for functions returning ScriptStringOlivier De Cannière2025-08-051-0/+4
| | | | | | | | | We cannot know in what context the binding will be executed. Task-number: QTBUG-138188 Pick-to: 6.10 6.9 6.8 Change-Id: I018e931cc43cdaea052cfad41d45018fcd1193fa Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QQmlJSLogger: Don't trigger assert in QColorOutputFabian Kosmale2025-08-051-1/+2
| | | | | | | | | | | | | As a comment already points out, having an empty replacement message is possible. In that case, we shouldn't attempt to print it. Add a dedicated test-setup for QQmlJSLogger, to make it easier to expand tests there. Pick-to: 6.10 6.9 6.8 Fixes: QTBUG-138871 Change-Id: I55c5de140fe8175e9deaca519bb734654dc366f4 Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* qmllint: Introduce UserContextPropertiesSami Shalayel2025-07-319-32/+159
| | | | | | | | | | | | | | | | | | | | | | | | | | Allow the user to specify context property names in .contextProperties.ini files so that they can disable all warnings or only the unqualified warning on their defined context properties by name. I remember some use cases where checking the .qmllint.ini into a users project repository is unwanted, so use a new setting file for the context properties that does not mess with global/system-wide .qmllint.ini files when checked into the repository. Create a new class called UserContextPropertiesSettings that is in charge of loading user context properties setting files, and use it inside of QQmlJSLinter. Introduce a ContextPropertyInfo class that contains both the heuristic information and the user-provided information. ContextPropertyInfo is used to pass the ContextProperty information down the type propagator. Also add some documentation for the new settings file. Task-number: QTBUG-138061 Task-number: QTBUG-128232 Change-Id: Icd700154dc89219f115fa3187c037d65451d0059 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Do not warn about BINDABLE only properties (just now)Fabian Kosmale2025-07-301-1/+2
| | | | | | | | | | | | | | | | While there is a goal to phase out BINDABLE only properties in QML, and require NOTIFY (if they participate in a binding), we are not there yet. Given that this is not documented outside of wiki.qt.io, and we still had Qt internal properties without NOTIFY (but with BINDABLE), we shouldn't warn about it right now. In the future, we should provide a more specific warning; which then can also add more details about the integration of signals with QProperty. Pick-to: 6.10 Change-Id: I5070c47124787938ef3ba5143a02574663de1cf6 Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* qmllint: fix '.,' in qmllint outputKai Köhne2025-07-291-3/+3
| | | | | | | | | | | wasNotFound is defined as "was not found.". Let's just duplicate the string. Also remove double space due to signalName() replacement. Pick-to: 6.10 Change-Id: Ieec4d4c02e1af16adc04b7cb0f7329a268c48c59 Reviewed-by: Semih Yavuz <semih.yavuz@qt.io>
* qmllint: don't warn about fall-throughs where they don't happenSami Shalayel2025-07-291-5/+71
| | | | | | | | | | | | | | | | Iterate through the statements of the case-statements and don't warn about a fall-through if the code path of the case-statements return or break or throw before reaching the end of the case-block. Amends 65804aaa928bbf6467e22da4bd35fcae1373af2d that introduced the warning and only didn't check recursively for break, return or throw statements inside of case blocks. Pick-to: 6.10 Fixes: QTBUG-138532 Change-Id: I545898ebd52a4ec8f0ea58ca4ab5519e7137b6b0 Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io> Reviewed-by: Lars Schmertmann <SmallLars@t-online.de>
* qmllint: Do not warn about unknown signal handlers in custom parsersFabian Kosmale2025-07-281-0/+5
| | | | | | | | | | | | A custom parser can do arbitrary things with signal handlers inside it, even if no corresponding signal exists in itself. For instance, PropertyChanges allows to set signals on its target. Task-number: QTBUG-138173 Pick-to: 6.10 Change-Id: I8b92cb92dad8d9a53cb57b4a9ad3d2d48b24c08a Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* qmllint: emit parser warnings via QQmlJSLoggerSami Shalayel2025-07-281-13/+7
| | | | | | | | | | | | | | | | | We emit all warnings with QQmlJSLogger, so don't use qWarning() for parser warnings. This makes our parser warnings more beautiful because QQmlJSLogger can print the code around the invalid token, for example on unexpected token errors. Also make sure that we use the correct logger to emit the parser warning. Pick-to: 6.8 6.9 6.10 Fixes: QTBUG-137029 Change-Id: Ibf2a24cd17c20edac3c20dd44185f18e891eab66 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* qmllint: Give root scope the correct typeFabian Kosmale2025-07-251-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | So far, resolving the id of a root element would have yielded the base type, which is problematic when you want to expose a property of the new type initially pointing to that id (as we do in some examples). Fix this by inserting a mapping from the element to m_exportedRootScope, which is the scope of the actual root type. This is similar to what we do with inline components. Some care needs to be taken, though: if the file name does not yield a valid QML type, this export should not happen. We also must be careful to do this early, before processing non-base imports, otherwise we would end up shadowing types with the same name from explicit imports (e.g. there's a Connections.qml file in the qmltc test suite using Connections from QtQuick). We also must not expose types which are lowercase; not only are those not importable according to QML semantics, but we'd also would run into issues with "var.qml" shadowing the var type. Pick-to: 6.10 Fixes: QTBUG-138515 Change-Id: Ie4a2c160cf9eda847da87816a88b17f6a5f3a8a3 Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* QQmlJSImortVisitor: Cleanup global scope setupFabian Kosmale2025-07-251-14/+19
| | | | | | | | | | | | | | | | | | | | This commit attempts to make the setup of the global scope more readable, and fixes a few (currently harmless) inconsistencies: - There's now a comment why we're creating a scope representing the global object in the constructor. - The setup happens on the actual scope representing the global scope, not on m_currentScope. m_currentScope still points to the global scope, but we prevent accidents should that ever change. - We use enterRootScope also for plain JS files (in visit(Program *)), not only for modules and QML filse. - We only call setIsRootFileComponentFlag for QML files, the concept of a root component is only well defined for QML after all. Pick-to: 6.10 Task-number: QTBUG-138515 Change-Id: I27c0a93a201a9d25609543d6ff250f701cbeb94f Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* QQmlJSImportVisitor: Avoid faulty unknown property warningFabian Kosmale2025-07-251-1/+23
| | | | | | | | | | | | | | | | | | | In QQmlJSImportVisitor::processPropertyBindingObjects, we can encounter grouped properties. So far, we used the whole compount expression to look up the property. That would of course not find any property. We now instead traverse the individual parts of the name, and look up the property chain correctly on the corresponding types. We adjust the previously added test for unknown duplicate properties to work with _really_ unknown properties (that don't exist), and instead use an adjusted version to prove that the example is completely warning free – mirroring the issue from QTBUG-138164 in a more minimal way. Task-number: QTBUG-138498 Task-number: QTBUG-138164 Pick-to: 6.10 Change-Id: I75d17c3c412159f3f6da082f54d99bdf6b3b08e4 Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* QColorOutput: flush stderr on destructionSami Shalayel2025-07-221-0/+2
| | | | | | | | | | We write via fwrite into stderr, but we never flush. Flush stderr on destruction. Pick-to: 6.8 6.9 6.10 Task-number: QTBUG-137029 Change-Id: I72ff1fe4461b35412539120d3418037dbee84c0d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qqmljsimportvisitor: give base types to attached scopesSami Shalayel2025-07-213-8/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It seems that our attached scopes have no base type: they don't inherit the attached properties or methods because their baseTypeName is not set. Therefore, set their baseTypeName, and move the resolveTypes calls inside of setScopeName() instead of potentially forgetting them after enterEnvironment/RootScope() calls. With the (resolved) base type, we know about inherited signals, like in: ``` Keys.onPressed: { /*here is the "event" argument available*/ } ``` for example where we can insert the "event" JS identifier inside the QQmlJSScope of the block of the signal handler, now that we now that "Keys" has a "pressed"-method with one argument "event" on its base type. Add a test to make sure that the body of an attached signal handler contains the JS identifier of the arguments of the attached signal to be handled. This JS identifier is used later on in qmlls to provide completions in the body of the attached signal handler. Also fix LinterVisitor::leaveEnvironment() that starts complaining about "Component" attached properties that have no child, now that attached properties have base types. Pick-to: 6.10 6.9 6.8 Fixes: QTBUG-137736 Change-Id: I8de0158ca9946d5e0e4f4f0a46614385f0edca69 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Avoid spurious warnings when file selectors are usedFabian Kosmale2025-07-186-2/+66
| | | | | | | | | | | | | | | | When file selectors are used, we loose too much information currently, as we completely discard everything we know about the type. [ChangeLog][qmllint] qmllint and the LSP now no longer print warnings about ambiguous types if file selectors are used, and instead use the "plain" version. The QML script compiler will still conservatively reject such QML files. If warnings about such cases are desired, the new "importFileSelector" warning category can be enabled. Task-number: QTBUG-137075 Pick-to: 6.10 Change-Id: Ia87d5ab62003fe8d7d2ab9569fac2942fb1c7c14 Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* qmllint: Avoid confusing duplicate property assignment warningFabian Kosmale2025-07-171-1/+11
| | | | | | | | | | | | | | | | | | | | | If we have no clue what a certain property might be, do not warn about duplicate binding assignments to it. It might be a genuine error, but it might also be: - a property of a type we couldn't resolve; that should warn about the type, but not here – it might after all be a list property if we were able to resolve the type - a binding assignment to an instance of a custom parsed type Note that the attached test case currently would still complain about the property being unknown, as it fails to correctly handle the grouped binding. That will be addressed in a follow-up commit; for now we silence that additional warning with a qmllint comment, putting the focus on the duplicate list warning. Pick-to: 6.10 Task-number: QTBUG-138164 Change-Id: Ib06a4baaef0813a45a20738cbb6efe4cf5e5952c Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* QQmlImportVisitor::setAllBindings: Change misleading variable nameFabian Kosmale2025-07-171-4/+4
| | | | | | | | | m_foundBindings is not, in fact, a meber variable, but function local. Adjust the name accordinglgy. Pick-to: 6.10 Change-Id: I989ea73b5304a269425fa133c7e08a6dd9d0e765 Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* QQmlSA: Fix doc typoOlivier De Cannière2025-07-161-2/+2
| | | | | | | Amends cca050c3d4a3d1c053390e44cc174bea2c54f41d Change-Id: I39738939343045e3534074a5525aa85cef78feb5 Reviewed-by: Luca Di Sera <luca.disera@qt.io>
* QQmlJSImporter: Port away from QDirIteratorFabian Kosmale2025-07-151-8/+12
| | | | | | | | | QDirListing is the new, preferred API. More importantly, it supports calling completeBaseName without requiring the construction of a QFileInfo, which shouldn't actually be necessary. Change-Id: Ia2d60b8e3326a0628e7547154c002125c45c8dc1 Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* QQmlJSImporter: Rename method to avoid ScopeTree referenceFabian Kosmale2025-07-152-7/+7
| | | | | | | | | | | When we renamed ScopeTree to QQmlJSScope, we didn't catch localFile2ScopeTree. Avoid any confusion over which "tree" there might be by adjusting the name now. Amends d200ccf92017ebc10a4ccdb5d944e1d803b87c1d. Change-Id: I34b99b91504d4b7a004bb80c600b4d9b8ba29fee Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* QQmlJSTypeResolver: Simlify canPrimitivelyConvertFromToFabian Kosmale2025-07-151-6/+4
| | | | | | | | | Given that anything is convertible to bool (and we check that at a later point), there's no reason to do some more narrow checks earlier. Change-Id: I6239c66435005da427c98dc56cac2607cb45aac7 Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QQmlSA/compiler: Introduce new scope typesFabian Kosmale2025-07-107-15/+48
| | | | | | | | | Instead of doing string comparisons, encode the information in the scope type for bindings and signal handler functions. Add a helper function to check whether a scope represents any kind of functions. Change-Id: I41ad1316852dd484ac54c02f99bb25e618099e62 Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* qmllint: Do not warn about unnotifiable properties outside bindingsFabian Kosmale2025-07-102-3/+20
| | | | | | | | | | | | | | | | | | | | | | | | It doesn't cause any harm if we are not inside a binding. There's a slight issue with the fact that we now don't warn if one extracts the read into a separate function, and calls the function inside a binding, but that is still better than spurious warnings. Fix this by checking in which context the read occurs. We currently rely on a "magic" name we give to the function's scope if it as a binding, but this will be fixed in a follow up commit introducing new scope types. We don't want to do introduce them here, as they would be new API not suitable for picking back to 6.10. Another open issue is that the onRead handler gets the outer QML scope as the context, which necessiates that we traverse its child scopes to find the actual function. Fixing that would necessiate some larger work in the QQmlTypePropagator, and is consequently deferred to another patch, too. Pick-to: 6.10 Fixes: QTBUG-138346 Change-Id: I29ea39eb32a18d9b54ded8d5e2c9a5f66051374f Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Relax duplicate binding checkFabian Kosmale2025-07-091-6/+25
| | | | | | | | | | | | It is actually possible to have mutliple ValueSources on the same propery, as long as they are not all active at the same time. We can't really know whether that's the case (that can only be known at runtime), but we can employ a heuristic to avoid most spurious warnings. Pick-to: 6.10 Task-number: QTBUG-137946 Change-Id: Ie39a1368c68e1ba9aecf582df00680ae3e8c68f3 Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* qqmljsscope: add line number for ComponentsSami Shalayel2025-07-074-1/+16
| | | | | | | | | | | | | | | | | | | | | | | | | Add Component line number information from MOC into QQmlJSScopes. That is needed for qmlls to find definitions of QML components defined in C++ headers. This change adds the line number information into the generated qmltypes from MOCs JSON, and reads it back into a QQmlJSScope. Instead of adding an extra member, re-use the QQmlJSSourceLocation that is inside the QQmlJSScope. Set the column to 1 for it to be valid and to simplify some code on the qmlls side. This allows to treat a sourcelocation in the same way, independently if the component described by the QQmlJSScope was defined in QML or C++. Avoid an assertion in QQmlJSImportVisitor::checkRequiredProperties() where printFix assumes that a file can be opened if its source location is valid: this change adds have valid sourcelocations to qml components defined in C++, but QQmlJSScope::filePath() can't be opened because it only contains the filename, not the file path. Task-number: QTBUG-128393 Change-Id: Idf4acc32cff60730528322286ad4ba726b502ac1 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Add a comment on what mergeRegister() doesUlf Hermann2025-06-271-0/+20
| | | | | | | | Amends commit 6b14ba5c2fbc2810bb62a87008e338cca571acf6 Change-Id: Ie5ea3f735785b8acc0e4cca5de2f13e96b5cfe18 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>