Commit Graph

148 Commits

Author SHA1 Message Date
Fawzi Mohamed
fd89043de2 qmljs: (QString -> Utils::FilePath)++
convert more QString containing paths to Utils::FilePath

Change-Id: I1219d7d147993e48cfa641dc9bea72ab38c90f51
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-07-13 17:13:23 +00:00
Fawzi Mohamed
a235aa29a1 qmljs: avoid linking to files in the build directory
cmake creates a consistent uri structure in the build directory.
We use that as import path, but when we find a type in them we should
refer back to the original file, as editing those is dangerous because
any edit are lost with the next build.
To find the original file we use the qrc, as the qrc path is mostly
the same of as the uri path.
It is possible to add prefixes which would make an exact match fail,
so we compare the paths from the right to the left and find the
longest match.

To acheive this:
 * QrcParser keeps a reversedResources, so the match from right can be
   done efficiently, and provides a longestReverseMatches method
 * the model manager keeps a list of all common prefixes of the
   application paths (build directories), and identify all files in
   build directories
 * the method fileToSource identifies the files in the build directory
   and tries to find the corresponding source file, warning if he
   cannot find it
 * fileToSource is used for follow Symbol and find usages

We could use fileToSource much more aggressively, to use to in editor
content for the files in the build directory, increasing the
consistency, but that is a more dangerous change for later.

Fixes: QTCREATORBUG-27173
Change-Id: Iea61b9825e5f6e433a7390cf2de9564b792458a5
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-06-21 10:39:52 +00:00
Eike Ziller
fc636755af Fix crash of tst_ImportCheck
We don't have a PluginManager instance when running the autotests.

Change-Id: Ib36ea2bb58e500a2ad4b601cedfb8d426fda7e4e
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2022-06-10 13:21:28 +00:00
Maximilian Goldstein
9a28edfd87 qmljs: Scan application directories for QML libraries
We need to search application directories as well since the new
QML Module API will generate modules there.

Task-number: QTCREATORBUG-24987
Change-Id: Ie67233ffece692c62921db13c49ae8cc2184422f
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
2021-12-16 15:34:23 +00:00
Fawzi Mohamed
ce82c058df add .mjs as extension for javascript files in defaultLanguageMapping
Change-Id: I40d43193ba9b7dac38d7a474aad2d739e6c39dc6
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-12-06 09:16:22 +00:00
hjk
761ce1feb1 QmlJS: Proliferate FilePath use, part 2
Change-Id: I631df6ba5e782e2db9e03de4e5df843d15c19f37
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-10-28 14:08:13 +00:00
hjk
d68bb4687c QmlJS: Proliferate FilePath and QtcProcess use in QmlJSPluginDumper
Change-Id: Ie483bb2e9b5d812d380470949564a6bc57801fa9
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-10-27 07:57:13 +00:00
Orgad Shaneh
5365dd531b Fix some MSVC warnings
* Implicit conversion of size_t to int
* Comparing bool with operator >

Change-Id: I4bc5bef57bfa0125b1c82953a7a2cfc24066bc8c
Reviewed-by: hjk <hjk@qt.io>
2021-10-15 06:22:23 +00:00
Ulf Hermann
fdaa9b1c10 QmlJS: Destroy local snapshot before modifying its original
If we keep the copy of the snapshot around while it's being modified, we
trigger the copy-on-write mechanism. That is expensive, and destroying
the snapshot afterwards is also expensive.

Task-number: QTCREATORBUG-25899
Change-Id: I9b7e26baf63a4b47c85457e5657fee971a6ce132
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-08-17 08:55:31 +00:00
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
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
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
Jarek Kobus
d05d9fc65c QmlJS: Inline getter
Change-Id: Ife8a2b0d6eb67ee28a4de808c1c848dbf633c49b
Reviewed-by: hjk <hjk@qt.io>
2021-02-19 08:46:57 +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
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
Jarek Kobus
6d5e302157 Use typed syntax in calls to QMetaObject::invokeMethod
We do it wherever possible. Some places can't be fixed
since they still rely on dynamic introspection
(mainly QQuickItem cases).

Change-Id: Ia00b4a04d8b995c9a43b7bf2dbe76a60364bb8ca
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2020-11-16 13:45:02 +00:00
Eike Ziller
8b031c8c05 Merge remote-tracking branch 'origin/4.13' into master
Change-Id: I3f2a6c553819e992da7e9f538dc44b95b482359e
2020-10-02 10:47:07 +02:00
Fawzi Mohamed
45716a4ccc QmlJS: set and propagate qtVersion in ProjectInfo
Change-Id: Icbeb3679c8a76c111a5e3503b2c496c28c830342
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-09-29 14:24:14 +00:00
hjk
43b658e9e7 Utils: Drop Utils::SkipEmptyParts again
We require Qt 5.14 nowadays.

Change-Id: Iff245257d3cb19207007c0445ee13814e66152dd
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-07-21 12:42:27 +00:00
Christian Stenger
6e29adaae7 QmlJS: Replace QRegExp by QRegularExpression
Task-number: QTCREATORBUG-24098
Change-Id: I70157bcbee67cf493e28b5bad97248877a25e5c6
Reviewed-by: hjk <hjk@qt.io>
2020-07-20 10:23:52 +00:00
Eike Ziller
b18711da91 Merge remote-tracking branch 'origin/4.12' into 4.13
Conflicts:
	share/qtcreator/debugger/lldbbridge.py

Change-Id: Ia444f6424fb35b9a539e157afcee868161535272
2020-07-06 16:23:13 +02:00
Christian Kamm
2c2cd08761 QmlJS: Fix codemodel reset
The QML import paths weren't scanned for modules when the code model was
reset.

Task-number: QTCREATORBUG-24082
Change-Id: If818ebf4ef123529e5fe8de40e6b5d0154c84680
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
2020-06-30 08:57:28 +00:00
hjk
54575fe42d QmlJS: More Qt6
Mostly QRegExp, one QHash::unite.

Change-Id: Ia2816fee65b9459c0f89419161f44c38cd572c36
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-06-19 07:13:06 +00:00
Miikka Heikkinen
7f4bf437da QmlJS: Add a way to return just the context of the project of a file
Added ModelManagerInterface::projectVContext() method to return just
the context of the project the file belongs to and nothing more.

To make this possible, fixed caching the file-to-project relationships
and removed automatically adding the currently active project to
list of projects the file belongs to in allProjectInfos().

Task-number: QDS-1495
Change-Id: I949c0202d0280264b6856562a2e7abc2f93d13c0
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-06-11 12:42:20 +00:00
Christian Kamm
338fa26bc3 QmlJS: Scan import paths, even if there is only one
Previously a single QML import path would not be scanned. This did not
usually happen to users, as there's almost always more than one path.
But it could lead to unexpected behavior in tests that explicitly
controled import paths.

Change-Id: I015f44f183ad484c333ab7a4e5e98b87098620a7
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-05-21 07:53:24 +00:00
Christian Kamm
96c860159b QmlJS: Track futures to allow testing
Tests often want to wait for all async tasks to finish before
progressing.

Change-Id: I61738df730ca341b5c9d227569d961cd1991b296
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Philip Van Hoof <philip@codeminded.be>
2020-05-21 07:53:11 +00:00
Christian Kamm
037ff590e6 QmlJS: Fix loading builtin library info
The condition was always false, since projectInfoForPath always returns
an empty project member. This meant the the fallback builtins that ship
with Qt Creator were used, instead of the builtins that shipped with the
Qt version.

Change-Id: I9c3bf949d0046bcf687c913e32ddac95734f6c43
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
2020-05-21 07:52:51 +00:00
Maximilian Goldstein
2392f29a59 qmljs: Do not use app.qmltypes and lib.qmltypes anymore
Task-number: QTBUG-82710
Change-Id: I876ec2b8e2b668a239248511b0fbd58389098de6
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2020-03-27 08:17:07 +00:00
Ulf Hermann
1e587831d1 QmlJS: Scan app.qmltypes and lib.qmltypes for type information
app.qmltypes is being added as a new convention to Qt 5.15. These files
are to be found next to application binaries, and contain the QML types
those application register themselves, in contrast to QML types
registered from plugins loaded via the regular import mechanism.

lib.qmltypes works the same way, in principle, for libraries. This
change only adds it to the possible names for qmltypes files, though.

Change-Id: I1d7c5835c8c3e988d214c5cdb949ca677b48dfc5
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2019-10-31 09:07:57 +00:00
Ulf Hermann
58c023e7c4 QmlJS: Clean up qmljsmodelmanagerinterface.{h|cpp}
Avoid foreach, fix linter warnings, simplify types, apply coding style.

Change-Id: I7cec65e775ee14ce60e1e57077e917285d58c152
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2019-10-29 11:45:32 +00:00
Ulf Hermann
6371725dbf QmlJS: Clean up ViewerContext
The special ctor wasn't used anywhere, the default ctor can be replaced
by inline initialization, maybeAddPath is only meaningful in the model
manager and the language compatibility check should definitely not
pretend to be a general rule either.

Change-Id: I11cf25fe1c696550d33b56ce57316100321d564b
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2019-10-23 10:14:47 +00:00
hjk
e3b1106afa Compile fix with recent Qt dev
The reasoning in 1b4766e26c did not take into account that the scope
of QT_NO_JAVA_STYLE_ITERATORS may change over time, as done with
f70905448f6 in Qt base.

Change-Id: Ib1966ff26c4d36d5f62e149d6b45baa4aecf825d
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-07-29 08:54:18 +00:00
hjk
251287f0d3 Avoid warning on empty expressions
For some reason, Q_UNUSED includes already a semicolon, adding one
on the user side creates an additional empty statement.

Change-Id: I9c5e8fac381345a60792cb75e2938fd53958d3b0
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-07-23 11:55:59 +00:00
hjk
473a741c9f Utils: Rename FileName to FilePath
More in line with QFileInfo terminonlogy which appears to be
best-of-breed within Qt.

Change-Id: I1d051ff1c8363ebd4ee56376451df45216c4c9ab
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2019-05-28 12:23:26 +00:00
Christian Kandeler
2f7f1aaec3 Move qrc parser from QmlJS to Utils
We'd like to make use of it in a more general context, and it's not
directly related to QML.

Change-Id: I025ec67829f85544667684cdb8c99d1ee4c18197
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-02-13 11:48:27 +00:00
Tim Jenssen
87746b5906 QmlJS: improve code
- no behavior change

Change-Id: I61e515876be768309e5647261ffbe2732de423b9
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2019-01-23 10:06:36 +00:00
Tim Jenssen
372e239d2d QmlJS: remove qtquick1 leftovers
QT_INSTALL_IMPORTS and the used ProjectInfo.qtImportsPath variable
were only used for QtQuick1.

Change-Id: I34da0cfc77effa84f3a7578e7f91fed0768a9bf4
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
2019-01-18 13:16:30 +00:00
Tim Jenssen
0157e009be QmlJS: fix nullptr warnings
Change-Id: Id546a9a5c065ae8b0cc9c251051b2fd36e34803a
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
2019-01-17 16:14:21 +00:00
Orgad Shaneh
bdc2b4b59f Remove hard-coded disabling of debug logs
Instead, set the default level of all logs to QtWarningMsg.

The call to setFilterRules overrides the user preferences in qtlogging.ini.

Change-Id: Id5f6cd550d14ff7f45ae04c5d3110e0bafb0f072
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2018-10-13 16:36:58 +00:00
Orgad Shaneh
eea6a7c3b3 Utils: Purge qtcfallthrough.h
No longer needed.

Change-Id: I9b0bee014df89d4c567f1d2431b5ff9404f5f925
Reviewed-by: hjk <hjk@qt.io>
2018-04-09 09:04:13 +00:00
Marco Benelli
b9d72a5737 qmljs: remove remaining references to QtQuick1
This patch removes all references to QtQuick1 in qml library,
plugin, designer, profiler and tests.

Change-Id: Ie286fad96060299caae3ef328330597cf53e90d3
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2018-04-03 14:40:30 +00:00
Friedemann Kleint
f482270432 Introduce Q_FALLTHROUGH()
Silence g++ 7.X warnings.

Change-Id: I9d06d04b496c9ec060e13e1be6f43d8fbadb1f3b
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2018-01-24 14:50:43 +00:00
Ulf Hermann
d81c6c7403 QmlJS: Don't parse files we cannot open
This rids us of the "Issues" about various wizard files when opening
qtcreator.pro

Change-Id: Ib49e87ded791bcc9155e65a77cac523c1f67de56
Reviewed-by: Marco Benelli <marco.benelli@qt.io>
2017-12-07 08:26:28 +00:00