Commit Graph

40 Commits

Author SHA1 Message Date
Qt Forward Merge Bot 2812184e1b Merge remote-tracking branch 'origin/5.15' into dev
Conflicts:
	src/qml/jsruntime/qv4executablecompilationunit.cpp
	src/qml/jsruntime/qv4executablecompilationunit_p.h
	src/qml/qml/qqmlobjectcreator.cpp
	src/qml/qml/qqmlpropertycachecreator_p.h
	src/qml/qml/qqmltypecompiler.cpp
	src/qml/qml/qqmltypedata.cpp
	tests/auto/qml/qmlformat/tst_qmlformat.cpp
	tools/qmllint/scopetree.cpp
	src/qml/qml/qqmlapplicationengine_p.h

Adjusted tools/qmllint/findunqualified.cpp to use newer API

Change-Id: Ibfb4678ca39d626d47527265e3c96e43313873d4
2020-04-09 10:08:41 +02:00
Ulf Hermann eb5aa8d9c1 qmllint: Consistently use shared pointers for ScopeTree
ScopeTree keeps a weak pointer to its parent scope and strong shared
pointers to its children. Avoid passing bare pointers around, so that we
cannot create multiple shared pointers independently from the same bare
pointer.

Change-Id: Id0faece550b1878363004d843a8fa5c1164794ae
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-04-01 10:29:29 +02:00
Ulf Hermann c38ea80c5d Move qmllint's metatype support to tools/shared
We want to read qmltypes files and analyze scopes also from other tools.
Furthermore, restructure the shared directory, so that each tool only
includes what it needs.

Change-Id: I96a2dcc8b1c5fac613592fb1867bf51fa5ef3a6e
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2020-04-01 10:29:29 +02:00
Ulf Hermann 72bbed4544 qmllint: Drop support for "ModuleApi"
This is some ancient, pre-Qt5 way of describing singletons. We don't
need it anymore.

Change-Id: I6355acf187b8ede4298a7026229a587cd1a12f1b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2020-03-30 15:06:55 +02:00
Maximilian Goldstein a5b4d3dbab qmltyperegistrar: Use target instead of template name
Due to the fact that multiple targets may be present in the same
directory we have to ensure they all get a unique qmltypes.

Fixes: QTBUG-82710
Change-Id: I4d7966035644b68f7d3330a4c974369503c48bf2
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-03-26 13:41:46 +01:00
Qt Forward Merge Bot 1eef06e64f Merge remote-tracking branch 'origin/5.15' into dev
Change-Id: I6f320ea43b5837444226228c118e57c4bda8702a
2020-03-20 01:00:59 +01:00
Ulf Hermann f726d23727 qmllint: Break inheritance cycles
Previously we would run into infinite loops on those. Mind that qmllint
will reject a file called Window.qml that imports QtQuick.Window and
then instantiates a Window {}. Such a thing is bad style.

Task-number: QTBUG-82817
Change-Id: I6db82ca1794c3020dcb7d7e837fe44f72bca5029
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-03-19 16:37:44 +01:00
Qt Forward Merge Bot 13caf26b29 Merge remote-tracking branch 'origin/5.15' into dev
Conflicts:
	tools/qmllint/findunqualified.cpp

Change-Id: I2593b5cc0db1d14e0c944aec4b88a80f46f5b0c1
2020-03-18 12:37:04 +01:00
Ulf Hermann afe20375ba qmllint: Use fully qualified QML type names as superClass
Otherwise we miss subtleties such as Label vs. T.Label.

Task-number: QTBUG-82817
Change-Id: Idc2131426b2fd96f279dab83292a348b9295d5c0
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-03-16 14:57:13 +01:00
Qt Forward Merge Bot d51d5ff3c1 Merge remote-tracking branch 'origin/5.15' into dev
Conflicts:
	src/qml/compiler/qqmlirbuilder_p.h
	src/qml/qml/qqmlpropertycachecreator_p.h
	src/qmltyperegistrar/qmltypesclassdescription.cpp
	src/qmltyperegistrar/qmltypesclassdescription.h
	src/qmltyperegistrar/qmltypescreator.cpp
	src/quick/items/qquicktext_p.h
	src/quick/util/qquickvaluetypes_p.h

Change-Id: Ic209741592e7b85820bf3845722023a190ebc1c5
2020-03-09 09:58:49 +01:00
Edward Welbourne 744246b112 Use Qt::SplitBehavior in preference to QString::SplitBehavior
The Qt version was added in 5.14 "for use as eventual replacement for
QString::SplitBehavior." Move another step cloaser to that goal.

Change-Id: I3214ad6ccaca9dfd4a026589cabeb40cbf4a6298
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2020-03-02 15:58:47 +01:00
Ulf Hermann 789929f939 Use QTypeRevision for all versions and revisions
In many places we carry major and minor versions or revisions that are
loosely coupled to minor versions. As the Qt minor version resets now,
we need to handle these things more systematically. In particular, we
need to add a "major" part to revisions.

QTypeRevision can express the current major/minor pairs more efficiently
and can also be used to add a major version to revisions. This change
does not change the semantics, yet, but only replaces the types.

Change-Id: Ie58ba8114d7e4c6427f0f28716deee71995c0d24
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-02-03 15:22:12 +01:00
Lars Knoll f215d00f60 Make QtQml work with the latest changes in qtbase
Adjust the code to work with the new QString and QVector data
structures that have inlined size and data pointers.

Fix a large bunch of compiler warnings from QFlags.

Update dependencies for qtbase and qtsvg

Change-Id: Iba237aed90c140b822e0cf501b9fb7156ec27c2d
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-01-14 14:54:02 +01:00
Ulf Hermann 3dc5b937c4 qmllint: Consider failure to find imports an error
There is no real reason to tolerate it. We can generate all qmltypes at
build time, and if we can't find them, the results are likely to be off.

Change-Id: Id935d76ac3ca6b601381b40a73d7fbacca342c4d
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-01-13 16:54:35 +01:00
Ulf Hermann 01b865411d qmllint: parse simple type assertions
Change-Id: Ic24018137d8f989686d4a8f927efb824453d114b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-01-13 16:54:22 +01:00
Ulf Hermann 2677de3c79 qmllint: Assume "parent" property is always document parent
... except if the document parent is Component. Then leave the type
alone.

Change-Id: Id7b2e6efdefe18a8d375967ddedcdf9e07a07946
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-01-13 16:54:17 +01:00
Ulf Hermann 6c68a39a56 qmllint: Resolve aliases
Change-Id: Ida53af9774dc72559395064169113d0ee1f47f24
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-01-13 16:54:13 +01:00
Ulf Hermann d0b2a3b5eb qmllint: Analyze member access
We can analyze access to many field member expressions and figure out if
the accessed members exist. There are limits to this, of course. Generic
JavaScript values are out of scope here.

Change-Id: Id2e7613e56f06555cc3a2ba1c51683d9ea0bb84b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-01-13 16:54:08 +01:00
Ulf Hermann 0989e5a2b7 qmllint: parse JS files for methods
Change-Id: I3888231ac82f9babd51e6332af3c5457bf3c9141
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-01-10 21:19:07 +01:00
Ulf Hermann 55a645a5ec qmllint: Clean up access to m_exportedName2Scope
Don't accidentally overwrite the anonymous scope, and clearly mark where
we want to modify the scopes and where we just want to retrieve them.

Change-Id: I801d378ccaea6eb2548875766a9d3141dcb9f5e5
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-01-10 12:03:34 +01:00
Ulf Hermann d07a5221ce qmllint: Handle unversioned import statements in qmldir files
The import statements in qmldir files are not required to have a version
attached to them anymore.

Change-Id: I925d5f965c73685874c23510cf2e569d1528d8c1
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2019-12-11 16:34:01 +01:00
Ulf Hermann 355fd4bf5c qmllint: Read app.qmltypes files for extra type resolution
Change-Id: I7f19b39dd65063ae26b93bf1b40b0be0b0e15c6d
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-11-18 13:48:17 +01:00
Ulf Hermann 6b1f42c72f qmllint: Remove special cases for Component, QtObject, and Connections
The plugins.qmltypes for QtQml have proper descriptions for those. They
do have some interesting properties, after all.

Change-Id: I7f0922dd14c66c64fe88b55087fd55cb992d33db
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2019-11-18 13:48:09 +01:00
Ulf Hermann 6fb335ebce qmllint: Cleanup
qmllint needed to be refactored before we can add any new functionality:
* Fix all the (C++) linter warnings
* Remove pointless namespaces
* Merge ScopeTree and FakeMetaObject into one class
* Remove the "Fake" from class and variable names
* Remove dead code
* Add "We mean it" warnings everywhere
* Unify #include style

This also "accidentally" fixes the automatic matching of signal handlers
in Connections elements to signals in their parent scopes.

Change-Id: Idf8daae34dfd6c0ee00da28b017f921da3eba25c
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-11-18 10:39:23 +01:00
Qt Forward Merge Bot 2573190795 Merge remote-tracking branch 'origin/5.14' into 5.15
Change-Id: Iaa7dbbe9926d25cfb1b1c51e7013e58cb71d86b5
2019-10-26 01:00:13 +02:00
Fabian Kosmale 3467d829d4 qmllint: fix typo
Change-Id: I02a6f4dd1804251e0420f2fbc334ee9c38d3dc49
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2019-10-24 13:36:38 +02:00
Ulf Hermann b6075d7a4b qmllint: Parse variable declarations from PatternElements
Change-Id: If8b4f5302cc1ee3a4193b354503b304534d7dfd9
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2019-10-01 09:30:16 +02:00
Ulf Hermann 531cf90305 Make qmllint read qmldir files and qmltypes files in app directory
This makes it possible to resolve components which were either directly
registered in the application or specified as composite types in qmldir
files.

Change-Id: I42482563f31ac780d6b37e62375d09d122c4a308
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-09-25 10:03:07 +02:00
Ulf Hermann 33635f60a7 qmllint: Honor --silent argument
Change-Id: Ie63654139aeb7bfd241be865f33c399c23e08cc3
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-09-19 11:28:10 +02:00
Ulf Hermann c2535eb7f8 qmllint: Take prefix into account when inserting names
Change-Id: I2c13e8fc173e5e155d07a1bbf8547df65605ba10
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-08-30 10:35:02 +02:00
Ulf Hermann c3fa4a2d39 qmllint: Consider methods from the current scope as valid IDs
Change-Id: I71e9e2d5b4623938605d7afbfc79ae5c7d4251fc
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-08-30 10:34:51 +02:00
Ulf Hermann 8f5f363ce8 qmllint: Handle the default import and .ui.qml files
Change-Id: I9d86daa737d30ea0f76af431c59f44d59d4786e4
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-08-30 10:34:38 +02:00
Ulf Hermann 8b396cb216 qmllint: Warn about magic signal handlers
Those are typically part of Connections elements. We want to use
functions instead.

Change-Id: I08b65eae8b8a6ba95f7a3570f5465961abbb506e
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-08-30 10:34:25 +02:00
Jarkko Koivikko 218e14a897 qmllint: Fix compiler warning
findunqualified.cpp(776) : warning C4172: returning address of local variable or temporary: dbg

Change-Id: Ifce7ccdcce9ed629a2a9dd4759620d02804812b7
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2019-08-19 12:16:03 +03:00
Fabian Kosmale ac78adffa9 qmllint: do not warn about the identifier of a catch statement
Change-Id: I2e679fe4fbebff7d8252da6ea69aed3cc9ffab41
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2019-08-19 10:01:13 +02:00
Ulf Hermann fc820ca494 qmllint: Fail on recursion depth errors
Change-Id: I815f82ed8c005ed83ceecff6ce80106a9ad9b21d
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2019-08-19 09:58:31 +02:00
Fabian Kosmale cbe445dd91 linter: Cover all supported JavaScript functions
+ qDebug/commented out code cleanup

Change-Id: Id6a4410391eed2fbf6ff0dd7aaffa1de4d5b892c
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-07-26 11:14:35 +02:00
Fabian Kosmale 66368ffdd9 qmllint: Improve parent handling
- Do not warn about parent access in unknown components
  This avoids false positive warnings when an imported component could not
  be found (or when it actually was not imported).
  We still warn about the component which could not be found, so the user
  is still informed that something is not right.

  We also still emit a warning when we know the properties of a component,
  and parent is not one of them.
- Do not recommend the use of parent to address the root components
  properties. For this to work, we would need to know whether the root
  component reparents its children or not. Moreover, id lookups are
  actually faster than parent lookups.

Change-Id: I83d0e71e4bf20d34a3e6d836c2b123b2bf0d416e
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-07-26 09:00:07 +02:00
Fabian Kosmale 53e7927fdf qmllint: Improve signal handler recommendations
- Fix the case where multiple unqualified accesses would be mapped to
  the same signal (wrong in all but one cases), as the event parameter
  has the same name and we were using a QHash. Fixed by using QMultiHash
  and searching for the matching signal handler (by location)
- Recommend arrow functions for single line event handlers

Change-Id: I3cbb85fe0e49b454908ca03b4c86318ef02e364c
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-07-25 13:13:16 +02:00
Fabian Kosmale 392521048c Extend linter to check for unqualified ids
The linter has gained a new option (-U/--check-unqualified).
If run with this option, it warns about occurrences of unqualified identifiers.
Furthermore, it attempts to detect the reason for why the identifier can be
used unqalified:

- If the id originates from the root element, it suggests to qualify the
  access either with the root element's id, or with "parent" if applicable.

- If the id is the parameter of a signal, it suggests to use functions in the
  handler, instead of relying on the signal parameters to be "magically"
  injected into scope.

The linter does not attempt to handle with statements, but warns the
user instead that they are a bad idea.

Change-Id: I9aaf28c37595d84886a1071d49b86799b222a617
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-07-12 15:31:16 +02:00