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>
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>
Also this fixed "property type checking" for qmllint
in case of QML code like "property double xyz"
Fixes: QTBUG-92566
Change-Id: Ice33be4287ce0eba2cf9dfaabb760406bdca02b7
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>
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>
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>
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>
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>
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>
If we don't return there, the newly imported script is promptly
overwritten by an invalid module.
Change-Id: I788a7275e2c190a20c176da35f5c76ac9f6ad02b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
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>
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>