Commit Graph

1390 Commits

Author SHA1 Message Date
Fawzi Mohamed
af88a7876b qmljs: update Qml parser to parser of Qt 6.2
this is needed (among other things) for
 * null coalescing
 * shebang support

Change-Id: I1b37fd86593f143de8b39c0daf433831a8785568
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-07-20 09:02:15 +00:00
Fawzi Mohamed
dc654cfcba qmljs: use SourceLocation::length in reformatter instead of isValid
isValid becomes more strict in Qt6.2, meaning invalid (default
initialized) SourceLocation.
Reformatter used it to check for absent (i.e. 0 length) tokens, which
might still be valid (according to the new definition) as they mark
the start or end of an AST element.
Thus use length != 0 instead of isValid() in these places.

Change-Id: I4fbc1466ccef6b4b4e2c1d6b5169189b34dc6ae3
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-07-20 08:43:18 +00:00
Thomas Hartmann
c395e52c2b QmlDesigner: Disallow ApplicationWindow
ApplicationWindow is not properly working in the design mode
and files using ApplicationWindow are usually not written with
the design mode in mind.

Task-number: QTCREATORBUG-25984
Task-number: QTCREATORBUG-25983
Change-Id: Ia30ec26e9078ca0a9c1da11970202983e15ce4c8
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2021-07-16 13:11:47 +00:00
Jarek Kobus
fd6ec7da25 Remove unused ModelManagerInterface:isIdle()
Change-Id: I7c607bcc0a03219d7d6205a0c5fbdd3d46f9e9fa
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-06-23 14:01:50 +00:00
Jarek Kobus
5b0889777a Add a test for a crash in ModelManagerInterface
Task-number: QTCREATORBUG-25350
Change-Id: I4ea31e7936cc77dcd8f3fc494b5ecbd83858a766
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-06-22 12:42:53 +00:00
Jarek Kobus
7762cc745c Make ModelManagerInterface::instance() a bit safer
Currently, in d'tor of ModelManagerInterface, when joinAllThreads()
has finished, we were setting the g_instance to nullptr. However,
just after the joinAllThreads() has finished and before setting
the g_instance to nullptr some other thread could still add a
new future and this thread could potentially still assume that
instance() will return valid pointer.

The fix is to make joinAllThreads() and setting the g_instance to
nullptr in an atomic way. We ensure, that when there are still
pending futures, we don't clear the instance, but call joinAllThreads()
again for them.

The implementation is similar to what we do in test_joinAllThreads().

Change-Id: I99dc341228aee710a958a0fbc6c5ec1fbe132e7f
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
2021-06-21 15:11:06 +00:00
Jarek Kobus
ca09774181 Add more thread safety to ModelManagerInterface
Add ModelManagerInterface *ModelManagerInterface::instanceForFuture()
method. If the returned instance is not null, it's guaranteed
that it will be valid at least as long as the passed QFuture object
isn't finished.

Use instanceForFuture() in Link c'tor, as it's called from
non-gui thread.

Change-Id: I7e5ee6ad27e8f71cc0cef7fd9a91b710e2f8f662
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
2021-06-21 12:22:08 +00:00
Jarek Kobus
54f3232f63 Fix a crash inside ModelManagerInterface on Creator shutdown
Synchronize all the running futures on shutdown. It's enough
that all threads started by runAsync() just finish, without the
need for delivering the results of these futures to onFinished
handlers.

Fixes: QTCREATORBUG-25350
Change-Id: Iac5ae3834bb02ef0a77b063c59097471ec7e757d
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
2021-06-21 12:20:16 +00:00
Jarek Kobus
fe7b5458eb Refactor tst_joinAllThreads, to be used in ModelManager d'tor
The idea in this approach is that we only collect those futures,
which have resulted from runAsync. The assumption is that
all tasks associated with those futures may sooner or
later finish, without the need to call qApp->processEvents().

OTOH, we don't collect fake futures coming from Utils::onFinished,
as these requires the spinning event loop in order to deliver
the onFinished signal.

So, the new joinAllThreads() method waits for all collected
futures to finish. We also _do_ want canceled and not finished
futures to finish, since even when they are canceled,
they may still be running and using the internals
of possibly destructed ModelManager. This means, we are only
waiting for other threads to be finished, without reporting
their results to e.g. onFinished() handlers.

Some tests require that all onFinished handlers are also processed.
In order to achieve this, we create a loop inside
tst_joinAllThreads() method and we call joinAllThreads(), so
it will wait for all pending queue to finish, and then we call process
events, in order to let finished futures propagate their results
to their respective onFinished() handlers.
Some handlers may have stared another threads when being processed,
so we may expect that some new futures will appear.
So, after processing the events we check if any new events
appeared, and in this case we repeat the loop.
Otherwise, we finish synchronization.

Amends: 96c860159b

Task-number: QTCREATORBUG-25350
Change-Id: I5e44150c55f6be00445a5695938482d948990c94
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
2021-06-21 12:19:17 +00:00
Kai Köhne
bf04c98c1c Do not pass QStringView by const reference
That's what the documentation says:

  https://doc.qt.io/qt-6/qstringview.html#details

Change-Id: I0b41fc4abad1601c0ed416a505534cf7ae7633e1
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-06-17 09:54:42 +00:00
David Schulz
a13aef759e Utils: filepathify fileutils
Change-Id: Ic9048369f64d793f5f567cdb0c715488fb5a4ff6
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-05-18 14:30:53 +00:00
Eike Ziller
bf5b1d714c Revert "Revert "Merge remote-tracking branch 'origin/4.15'""
This reverts commit f0a86d4510.

Reverting a merge doesn't "undo" it - the changes would be lost
forever even with subsequent merges.
So we need to revert the revert to get the changes.

Change-Id: I65928f876f4dc886561bed17c4b2aa42b388c1e3
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2021-05-07 09:07:40 +00:00
Marco Bubke
f0a86d4510 Revert "Merge remote-tracking branch 'origin/4.15'"
This reverts commit 888ca0dd20.

Reason for revert: wrong patchset

Change-Id: I1291789938601aaf606c59917ff938e3c24c78dd
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2021-05-06 15:30:02 +00:00
Tim Jenssen
888ca0dd20 Merge remote-tracking branch 'origin/4.15'
Conflicts:
	src/libs/sqlite/sqlitebasestatement.h
	src/plugins/qmldesigner/qmldesignerplugin.cpp

Change-Id: I0fa0a8a7feffed24c0d2bc26eca86590f1156755
2021-05-06 13:07:48 +02:00
Christian Stenger
fd64253a62 QmlJS: Suppress wrong warning
When a type is created inside a file with the same name
do not warn if the created type is namespaced.

Fixes: QTCREATORBUG-24615
Change-Id: Icb2b1a9fd1a02ee222084b676ee818eed65a7c93
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-05-06 09:31:12 +00:00
Christian Stenger
2447d1d69c QmlJS: Restrict warnings of blocks
Warn only if the block contains a var statement
as this is discouraged.

Fixes: QTCREATORBUG-24214
Change-Id: Ib96c6723e82b6ddce0b7b63f23d3408f45ae7d58
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-05-05 10:32:59 +00:00
Christian Stenger
845afb25fc QmlJS: Fix checking for case and default blocks
case and default blocks inside a switch statement are just
special statement lists which need proper handling to avoid
wrong warnings regarding using standalone blocks.

Task-number: QTCREATORBUG-24214
Change-Id: Ia682b13ed4df21c5831308193d5abaf5163bde59
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-05-05 10:32:49 +00:00
Eike Ziller
3d1ad9db60 Merge remote-tracking branch 'origin/4.15'
Change-Id: I1d13f3543ab4bb17f0cbfe26bbea3f154f856ca6
2021-04-20 10:42:55 +02:00
Thomas Hartmann
35118c2520 QmlJsCheck: Do not allow print as id
Task-number: QDS-4162
Change-Id: I425c75cd42c0842ead27a6c801c3a483284407ea
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2021-04-16 07:53:00 +00:00
Christian Stenger
7d3a23a693 QmlJS: Fix compile for Qt5.14
Amends 5ad724a3ac.

Change-Id: Ie53a738b61e2de84083fc6c9d3422451df9358c6
Reviewed-by: Erik Verbruggen <erik.verbruggen@me.com>
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-03-23 09:44:40 +00:00
Erik Verbruggen
5ad724a3ac Support for QML module mapping
QUL uses module mapping for theming of QtQuick.Controls: during
code-generation the compiler is pointed to the Controls implementation
it should use. This is done by rewriting any import of QtQuick.Controls
with the given module name. The CMake build scripts will write a file
for each target to the directory "qml_module_mappings" in the build dir,
and those files will contain the mappings used.

Fixes: QTCREATORBUG-25356
Change-Id: I3f74897836dde7717b03bd6dffa46dcc0689ffdd
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
2021-03-19 10:43:23 +00:00
Erik Verbruggen
e960062b80 QMLJS: Fix usage of default project info
The defaultProjectInfo in the model manager is used as fallback for
cases where no applicable ProjectInfo is found. There were a couple of
places where this should have been used, but wasn't. This showed when
adding a autotest that only used a defaultProjectInfo with no projects
defined.

Change-Id: If446212dbbdff02fbf1f220d401405d5f99d2de6
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
2021-03-18 14:34:04 +00:00
Fawzi Mohamed
9e4e44d180 qmljs: preserve default arguments when reformatting QML
Fixes: QTCREATORBUG-23009
Change-Id: I9949fe26a91a063c4804fddcca4e26d14bc5cd61
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-03-02 08:29:42 +00:00
Fawzi Mohamed
0ff75a721f qmljs: reformat inline components
Fixes: QTCREATORBUG-25381
Change-Id: I472105cd6436d4d0ae7369880c332b8f4a2321ad
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-03-02 08:29:29 +00:00
Fawzi Mohamed
c57f6a703b qmljs: correctly handle required and readonly properties
* correct indentation after required property QTCREATORBUG-24144
* handle required <name> statement
* allow default readoly required reordering
* more permissive than the actual parser (which then will show errors
for invalid sequences)
* backport form QmlDom

Fixes: QTCREATORBUG-24144
Change-Id: I19166ca65d108d533a1ed3748c09e35bcfdbc56d
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-03-02 08:29:13 +00:00
hjk
528f08cad1 QmlJS: Compile fix
Amends bd05384765.

Change-Id: I45475798cdc1d4de997e694596f0c18009241492
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-02-25 10:09:54 +00:00
Fawzi Mohamed
bd05384765 qmljs: handle string templates in scanner
* add (multiline) template string support
  templates can be nested, which means that the scanner/lexer cannot
  be a simple state machine anymore, but should have a stack to store
  the state (the number of open braces in the current template
  string).
  The lexer stare is currently stored in an int, so we abuse that and
  store a the number of open braces (maximum 0x7f = 127) for at most 5
  nested templates in the int after the flags for the multiline
  comments and strings.
* improve representation of delimiters (==, <=, ||,... not split in
separate delimiters)
* (QmlDom backport)

Change-Id: I2b4d23b65febedef29a748f4c5f377fde27bd7fd
Fixes: QTCREATORBUG-22766
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-02-25 08:37:12 +00:00
Fawzi Mohamed
c0f9f29097 qmljs: correctly reformat js spread operator (...)
Fixes: QTCREATORBUG-23402
Change-Id: I6b4bd0846dac67116711b7ed046bd52d137b7674
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-02-23 12:38:55 +00:00
Jarek Kobus
d05d9fc65c QmlJS: Inline getter
Change-Id: Ife8a2b0d6eb67ee28a4de808c1c848dbf633c49b
Reviewed-by: hjk <hjk@qt.io>
2021-02-19 08:46:57 +00:00
Jarek Kobus
d74edd2806 Remove unused includes of mutex classes
Change-Id: I5a34cda0b27786cb37e642479b11fbd24b8b5c36
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2021-02-18 07:02:07 +00:00
Christian Kandeler
7d4a632cb2 qbs build: Remove code for creating deployment packages
Not a use case anymore, and if it were, we'd do it using built-in
capabilities.

Change-Id: I4c588ad7fb282530880210cb4c5795677074b1e0
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-02-17 16:11:49 +00:00
Alessandro Portale
97a45f7512 Libs: Use qAsConst with non-const Qt containers in range-loops
Change-Id: I00d9f7c1634bbb62191470d58158e1fd150533c0
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2021-02-17 14:45:05 +00:00
Maximilian Goldstein
5943215d99 qmltypes: Handle extension property
Previously Qt Creator ignored the extension property in qmltypes leading to
auto-complete being unavailable for some properties of extended types among other things.

Change-Id: I1bc13b3daf9bbd0a835e9a25f52b9589ad942e75
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-02-05 08:38:52 +00:00
Fawzi Mohamed
d5fc1acf67 qmljs: convert QStringView -> QString in +=
+= using QStringView is available only in newer Qt

Change-Id: I67e1cbbfcba07cca826ee4353d0cac08bf46defe
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-02-03 15:05:29 +00:00
Fawzi Mohamed
7015ef04b7 qmljs: add check for comparisons not depending on values
currently we mainly try to warn about primitive == null/undefined or
primitive === non primitive.
There are other that we could warn about null==null null==undefined,
but I feel that they might be triggered too much by clean code.

Change-Id: Id43d838d60a4e13f361be34e4bb38211777a081e
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-02-03 14:05:16 +00:00
Fawzi Mohamed
cc00af8334 qmljs: fix qmljscheck
* fix ASTVariableReference::value: correctly get reference value type
by using either initialiser of bindingTarget (broken since a codemodel
update in 2018)
* disable warning for casting in bool to null comparison (it does not
cast, is always false)
* fix property checks (where skipped without default of readonly)
* remove non relevant checks (ErrInvalidPropertyType for lowercase  now that custom
value types are supported, and for properties called data)
* updated import version

Change-Id: I38407acf327d0f773b38dda4c02fb4d95a420851
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-02-03 14:03:44 +00:00
Fawzi Mohamed
5c1cbf6b3f qmljs: support inline components
* add inline components to bind.
* inserts inline components in the component that contains them (makes
  Context:lookupType simpler)
* unify Context:lookupType overloads without adding extra heap allocations
  using a template (avoid code duplication)
* add tests for inline components
* warn about nested components
* use model manager to load dependencies in tst_check (old test did
  not load dependencies and simply skipped all checks on imports)

Fixes: QTCREATORBUG-24766
Fixes: QTCREATORBUG-24705
Change-Id: Ibcade7752cdaa08e960f66db3a724ab7fb3268cf
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-02-03 09:53:08 +00:00
Fawzi Mohamed
b8d99af6fd qmljs: fix arrow function reformatting
This is mainly just making sure that token that are "empty" are really
empty (to avoid writing them out in the reformatter), but still
contain the correct location (for error messages using for example
firstSourceLocation()).

Introduce a SourceLocation::zeroLength() method to make this change
simpler to do.

QtCreator does not run qlalr automatically, so it is "polluted" by the
updated generated files.

Fixes: QTCREATORBUG-25198
Change-Id: I0ab19fb380ee3d9a7d9e05d104fe313468f52703
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-02-03 09:52:40 +00:00
Fawzi Mohamed
30c6f44031 qmljs: fix check for version check in import
Change-Id: I77d0bdfdaeb79f8881bdf9ec52077cf1b70faf64
Fixes: QDS-3667
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-01-28 10:19:57 +00:00
Fawzi Mohamed
fecb0a4c83 qmljs: Suppress "package requires a version number" with unknown Qt
Assume Qt6 instead of the version creator was built against when we
cannot get the qtVersion one builds against.
This is a better default and avoiding spurious warnings for example
when building qt.

Fixes: QTCREATORBUG-24533
Change-Id: I53dc6387229c510c390b41af8866c2e9b2ece3de
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-01-22 20:03:54 +00:00
Christian Stenger
6ea088c02f QmlJS: Fix handling multiple import paths into same module
It is possible to import components of different paths to fill
a module.
Take further paths into account when looking up types.

Fixes: QTCREATORBUG-24405
Change-Id: I8d6bf0a324ea9c0d1fe9d91b40857f91f00dd662
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
2021-01-21 13:47:45 +00:00
Tim Jenssen
b801a9339d Merge remote-tracking branch 'origin/4.14'
Change-Id: I70504e096be620434f38cd990c593950da8b24ba
2021-01-07 14:23:46 +00:00
Tim Jenssen
e809f665e4 qmljs: add ImportsBenchmarker
To see the results use
QT_LOGGING_RULES=qtc.qmljs.imports.benchmark.*=true

Change-Id: I07fe7b71d893423f3dfe5f9c0f1410bd29312943
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
2021-01-06 17:04:29 +00:00
Tim Jenssen
306cadc643 qmljs: fix matchImport method
This is a guess fix without understanding what the
algorithm should do.

Change-Id: I06e258045ab966fd016295c1d8830bc6bdc83dca
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
2021-01-06 15:36:09 +00:00
Tim Jenssen
8f79503ed2 qmljs: avoid quadratic explosion
Change-Id: Icb184fd5c54a5398ed91b926841f7945dc8a81ec
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
2021-01-06 15:13:06 +00:00
Eike Ziller
d95e1f940a Merge remote-tracking branch 'origin/4.14'
Conflicts:
	cmake/QtCreatorIDEBranding.cmake
	qbs/modules/qtc/qtc.qbs
	qtcreator_ide_branding.pri

Change-Id: I5b8d93f2f08b62626c3f3447728c64d198b601ff
2021-01-04 09:09:21 +01:00
Leander Schulten
771e269a3b QmlJs: Fix reformatter for template strings
Change-Id: Ie0b7909d634d1e2e735377b053f7a1c1c2518f78
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
2020-12-17 12:31:48 +00:00
Leander Schulten
7e526d9b05 QmlJs: Fix reformatter for arrow functions
Fixes: QTCREATORBUG-23019
Change-Id: I6c6bee7092cb12f225ad744df2b3834dfd4bbc8f
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
2020-12-17 12:17:20 +00:00
Kevin Funk
34e20e641f qmljs: Handle qmlRegisterSingletonInstance
Parse qmlRegisterSingletonInstance to support types created this way in
QML.

Change-Id: I08440de52097faae5fd05ab32157279ee2ca2942
Reviewed-by: Kevin Funk <kevin.funk@kdab.com>
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
2020-12-11 14:47:25 +00:00
Kevin Funk
e2668f4bbf qmljsfindexportedcpptypes: Minor optimization
Change-Id: Ie9c3a18fab6aa0ea0d054a118cb2864b15d240f2
Reviewed-by: hjk <hjk@qt.io>
2020-12-11 14:46:53 +00:00