Some warnings caused by the children of custom parser elements also need to be ignored.
Change-Id: Iff3c6e5ce2ea334c6de7a14c8592ee1ebf80bb58
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This doesn't actually properly process them yet but at least it's a step in the right direction and makes sure array elements aren't just added to the parent scope.
Task-number: QTBUG-93358
Change-Id: I3d400abd10df032ee16c9c1dfc13562d36c22169
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Fixes that inherited attached properties are not found.
Also fixes that unresolved attached properties were not detected as such by isResolved().
Fixes: QTBUG-93231
Change-Id: I8917721f1e578af22997d676457fe52b21041c51
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Previously qmllint would land in an endless loop when going over self-attaching types.
This is now fixed and we also ensure that other cyclic type relationships can't cause the same issue.
Change-Id: I788139a9632abe48c470f5f4e2dfb0cd96699d90
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Previously "on" bindings were handled like normal property assignments, this is obviously wrong.
Fixes: QTBUG-93189
Change-Id: Ifda51103cafeb2488c54e0ac702e564771767f18
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
We stored whether something was assigned a default property in the scope the property stems from rather than the one where it occurs.
This leads to issues when two destinct elements both share the same base type and want to assign a default property.
Task-number: QTBUG-93189
Change-Id: I0560a0ffc6f83849333f8f5fad8e760bd05bec9a
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Adds a macro called QML_CUSTOMPARSER which will result in a hasCustomParser flag to be set in qmltypes.
Also ensures qmllint does not warn about unknown properties when a class utilizes custom parsers.
Fixes: QTBUG-93027
Change-Id: I7559d79c9bf06a0a7a93f54370948f12d09dd64e
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
In the past the type of a property's bindings would override the base type.
This would lead to incompatible type warnings when trying to override that binding with another value that was compatible with the property type but not the binding one.
Change-Id: Ie0c0843e34f24e05aae7bbb429899fbe076e7262
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
- Fixes the issue of QQmlComponent properties showing a type mismatch that isn't there
- Fixes duplicate scopes with the same internal name not being recognized as type matches
- Does not warn about incomplete / unresolvable types being incompatible anymore
Task-number: QTBUG-92571
Change-Id: Ia4399c44b87fee6614f2b8c95cb28fcaeec780b4
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Now qmllint will also warn when functions have a Deprecated annotation which previously only applied to properties and elements.
Task-number: QTBUG-84895
Fixes: QTBUG-79857
Change-Id: Ie1436822dc06bfd1ee4305a8468900409c3f8b0a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
qmltyperegistrar used to omit change signals from qmltype files if they
had neither a version nor arguments.
This does however cause issues with the semantic analysis of signal
handlers, who in this case would not find the matching signal. Instead
of adding additional logic in qmllint and any other place which might
need that information, we now simply write out those signals, too.
Pick-to: 6.1
Fixes: QTBUG-92372
Change-Id: Iaa6137c5d45f94e4874dc285e23a24f9c8319bb6
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Before children of Component caused errors about a non-existing default property.
Task-number: QTBUG-92571
Change-Id: I702ea79cf18221c35be48a86c6da35e809de073f
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This way it actually generates interesting data about the JavaScript
types, for example the functions of the String prototype. Add a helper
method to create a symbol to QJSEngine. This should be generally useful.
Change-Id: I6c7b253b9d6cdb61602ceeae0955aed8d942c139
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Visit UiObjectBinding shouldn't create any properties, otherwise we end
up having invalid QQmlJSScope state in cases with attached properties
(and maybe somewhere else)
property QtObject prop: QtObject {...} is parsed as two AST elements:
1. As UiPublicMember, which handles a property definition
"property QtObject prop" (and, consequently, creates the property)
2. As UiObjectBinding, which handles a property assignment
"prop: QtObject {...}"
As a drive-by, refine the endVisit(UiObjectBinding *), which sets
the property type. Now, only update the property when property
already exists and when the new property type has the same type
hierarchy (in other words, property type must be a base of a new type).
At the moment endVisit() issues an error if either of the
preconditions is not satisfied
Test the fix through tst_qmllint
Change-Id: I149090ffe46ae86268dd2c3b0ec3713b6bde0627
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Assigning any element to a QQmlComponent property implictly wraps it into a Component.
Thus checking for compatible types does not make sense here.
Fixes: QTBUG-92571
Change-Id: Id72f69d30d8506193c52a51b038b9c218ac85917
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
It seems that in cases of grouped and attached properties we don't want
to create a new scope every time, but instead reuse the created one,
falling back to create if the scope doesn't exist
Consider:
```qml
QtObject {
myGroup.property1: 42 // case 1
myGroup.property2: "hello" // case 2
MyAttached.property1: 42 // case 3
MyAttached.property2: "hello" // case 4
}
```
The intuition tells that cases 1 and 2 should use the same shared
scope "myGroup" and so should cases 3 and 4 both use the same "MyAttached".
Creating a new scope each time for attached and grouped properties seems
erroneous
As a drive-by, add attached property type to tst_qmllint and test
that this still works after the changes to the related code
Change-Id: Ib1ae85b404a7954a3a3211cbd267c414b98ac59d
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
At the moment, qmllint only check the types of objects and classes
being imported, it totally ignored types of properties that should be
also imported.
Fixes: QTBUG-92449
Change-Id: Ia5173bed84640d93fc48f6239179604ceb5db2cd
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
If the very first component in the member access chain is already a
QString, we need to expect "length" as only valid property from the
beginning. Like we do for lists.
Task-number: QTBUG-92447
Change-Id: I4549f4da52cb1c0968b24813f0a921a129da28ee
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Otherwise we end up with a mixture of QML and C++ names.
Pick-to: 6.0 6.1
Task-number: QTBUG-92447
Change-Id: I94c44307d8dd762d11cfd8f178f33ab6a895ee83
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
The "length" property is special cased because it's the only own
property of any JavaScript built-in type. As we've changed the internal
name of the string type in builtins.qmltypes, we need to reflect this in
qmllint.
Fixes: QTBUG-92447
Pick-to: 6.0 6.1
Change-Id: I9a5c7e9ab3da686bb6ac3fdffa36269abb0eb6ea
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Import warnings will now always be clearly associated with the line and import that
caused them. They're also visually separated now and don't redundantly show the importing files name in every warning.
Some type of imports such as file or URI based imports never had their warnings processed which is also fixed by this change.
Change-Id: I63d720fcf198ff5302c2566a91cde4c716697f7e
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Change-Id: Id49d4b66bb5c5f907666ab2e990e7bb0f267e13f
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
qmllint will now warn about bindings on deprecated properties as opposed to only warning when the property itself referenced.
Fixes: QTBUG-92207
Change-Id: I93c54d55e2ab2ca0648f67ac967c792d3ba60844
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Improves the logging situation greatly by allowing all logging messages to be assigned different severities,
highlighting the code that caused them and by now ensuring a qmllint warning will always result in a non-zero exit code.
A later patch will expose more of these options to the user.
Change-Id: Id9b036fe3ba80dd18e9f8cb1b05efa891713d5a8
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
qmllint will now show an information line pointing out import statements that are not needed.
It will not warn about imports that are redundant however, since there are legitimate reasons for having these.
Fixes: QTBUG-83237
Change-Id: I9588b5fa8a8efd37b48c9b349a448e580efb1452
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This change adds jsroot.qmltypes which represents QJSEngine's global / root object and a tool to generate it (qmlsjrootgen).
If you wish to regenerate jsroot.qmltypes run the following commands:
qmljsrootgen jsroot.json
qmltyperegistrar jsroot.json --generate-qmltypes src/imports/builtins/jsroot.qmltypes --import-name QJSEngine --major-version 1 --minor-version 0
Fixes: QTBUG-90807
Change-Id: I5ba0a048586d2dd945009d65c2b51be8ead85feb
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Warn when an import fails instead of silently ignoring them.
Without these it was impossible to tell whether a type was not resolved due to an unresolvable import or due to other reasons.
It also fixes the previous behavior of just dumping the types of qmltypes into the rootScope if manually imported.
Now they are only are present when actually importing one of the modules mentioned in the type's export statement.
Change-Id: I62bdd99828702ed02512eaac30f7f99b98d1df28
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
When ever a attached type lookup fails we have check whether combining it with the next member would make it work.
Fixes: QTBUG-83762
Change-Id: I8d159ccc07442f3939b40ea5f6b737da18439615
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
A linter should not return zero if it has found problems.
Change-Id: If949c5b01cd9c617d760c2c72cc7bfe29f3d3f95
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
We only discern imports if they live in different directories. Versions
are not handled, yet. If we add support for versions, the versioning
should be applied on processImport().
Done-with: Ulf Hermann <ulf.hermann@qt.io>
Change-Id: I2243452457e76a91042d1556edc5d36826560758
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Implement the check for default properties
Default aliases are not included in this patch
[ChangeLog][QML][qmllint] Add support for default properties
Change-Id: I2d0330e32c1f49c83d3a4ed602250b6bfd4ec674
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Make qmllint warn about @Deprecated {} annotations.
Also adds support for annotations in qmlcompiler.
[ChangeLog][QML][qmllint] Add support for deprecation annotations.
Task-number: QTBUG-84895
Change-Id: Ia506a6c0077a2b9ab3bf4fdac207bd0540635b30
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
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
Pick-to: 6.1
Change-Id: I36795ef2047629d3c870bf8a9df59dcd3db06633
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
If a file is part of the resource file system, the implicit directory is
also in the resource file system. We can use QQmlJSResourceFileMapper to
figure this out.
Change-Id: I48d86c308c7ec38d9971b84e7f059daa3baf63ee
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Otherwise qmllint and other tools won't know what QQuickItem is in this
context.
Pick-to: 6.1
Change-Id: I68da08cf2c41f17a2623f30303ac8f66b7b9329a
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
In qmltypes, enum types can be scoped, just like in C++. Resolve those
scopes.
Also, resolve the enum scopes only once, in order not to duplicate the
types.
Pick-to: 6.1
Change-Id: I095ec11f0ffec8e0e5f1034023c8956d2d39f660
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
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.
Pick-to: 6.1
Change-Id: I1deef94393ee0e17d34c2dc5980ebfbf25417f36
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
If we don't declare the dependency our tools won't figure out where
QQuickItem comes from when analyzing the dependency hierarchy of
layouts.
Pick-to: 6.1
Change-Id: I389c9e513a3a65143aa6b6fbf508eee584970181
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
"on" assignments are assignments to the default property, with the
property given interpreted as the target for the inner object.
Pick-to: 6.1
Change-Id: Ia93a171f759964d2c00d6c0293a5434f588123af
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
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>
It's easy to mess this up when you transform your signal handlers into
functions.
Task-number: QTBUG-89943
Pick-to: 6.1
Change-Id: If35be2f6828a0e19aada19abb41d8135b0c6ab45
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
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.
Pick-to: 6.1
Task-number: QTBUG-89943
Change-Id: I8a9424ca8c6edd562402fe5c560ba7e8344b5585
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
The "2" is meaningless and there is a better name available now.
Task-number: QTBUG-85064
Change-Id: I65d26b06712ed7dcf2825f16dffaa6060dd86985
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>