summaryrefslogtreecommitdiff
path: root/src/libs/qmljs/qmljsmodelmanagerinterface.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Utils: Rename asynctask.{cpp,h} -> async.{cpp,h}Jarek Kobus2023-05-031-1/+1
| | | | | | | Follows AsyncTask -> Async rename. Change-Id: I37f18368ab826c9960a24087b52f6691bb33f225 Reviewed-by: hjk <hjk@qt.io>
* QmlJS: Use QtConcurrent invocation for async runJarek Kobus2023-03-141-47/+48
| | | | | | | | | | Add ModelManagerInterface::importScan() overload to avoid instantiating dummy QPromise arg on caller side. Change-Id: Idf836d30b2167d8840cc4e7ac6f95377c9d5622a Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
* QmlJS: Tr::TrAlessandro Portale2023-02-011-5/+7
| | | | | | | | Excluding the Qml parser, which needs to remain in sync with it's copy in Qt. Change-Id: I22f475f265dd74687e3239c4d6916c777798a447 Reviewed-by: hjk <hjk@qt.io>
* QmlJS: Reduce number of for loopsMarcus Tillmanns2023-01-261-17/+18
| | | | | | | | | | Removes some unnecessary contains() by using the QSet directly. Fetch all required paths at once instead of calling generatedQrc(...) multiple times. Change-Id: I0a6f65d11d92a4ec4f6655a87e30df6a5c4d6545 Reviewed-by: hjk <hjk@qt.io>
* Remove GPL-3.0+ from license identifiersKai Köhne2023-01-061-1/+1
| | | | | | | | | | | | | | | Since we also license under GPL-3.0 WITH Qt-GPL-exception-1.0, this applies only to a hypothetical newer version of GPL, that doesn't exist yet. If such a version emerges, we can still decide to relicense... While at it, replace (deprecated) GPL-3.0 with more explicit GPL-3.0-only Change was done by running find . -type f -exec perl -pi -e "s/LicenseRef-Qt-Commercial OR GPL-3.0\+ OR GPL-3.0 WITH Qt-GPL-exception-1.0/LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0/g" {} \; Change-Id: I5097e6ce8d10233993ee30d7e25120e2659eb10b Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Merge remote-tracking branch 'origin/qds/dev'Tim Jenssen2022-12-221-1/+1
|\ | | | | | | | | | | | | | | | | Conflicts: src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp src/plugins/updateinfo/updateinfoplugin.cpp src/tools/qml2puppet/CMakeLists.txt src/tools/qml2puppet/qml2puppet/instances/qt5rendernodeinstanceserver.cpp Change-Id: I6b65ce2d603453fcebc2291574d55db80853f247
| * qmljs: improve readabilityTim Jenssen2022-12-141-1/+1
| | | | | | | | | | Change-Id: I110c2b08bcdfc29b310b84378cd3b119ee7f5f91 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* | Merge remote-tracking branch 'origin/qds/dev'Tim Jenssen2022-12-141-2/+2
|\ \ | |/ | | | | | | | | | | | | Conflicts: src/plugins/qmldesigner/components/assetslibrary/assetslibrarymodel.cpp src/plugins/qmldesigner/components/contentlibrary/contentlibrarytexturesmodel.cpp Change-Id: Ieda6242b845387100022b08251283891fb0fbda7
| * qmljs: fix warningTim Jenssen2022-11-251-1/+1
| | | | | | | | | | | | Change-Id: I69714d6626d9135c5489258346f79b1c4bfbcd19 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
| * QmlJS: std::set instead of QListThomas Hartmann2022-11-231-2/+2
| | | | | | | | | | | | | | | | | | This reduces the CPU time of Export::visibleInVContext() from 50% to 15% on Windows, when switching files. Change-Id: Iff82924c47d1b696c9d3d7ca40f49d9d02bcb3e6 Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
| * Merge remote-tracking branch 'origin/9.0' into qds/devTim Jenssen2022-11-091-12/+12
| |\ | | | | | | | | | Change-Id: I02fd6f492c27d85b88af7ec8bc18ff62f2c6ed14
* | | Utils: Add std::expected implementationMarcus Tillmanns2022-12-141-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adds a std::expected implementation that is compatible with >= C++11. FilePath::fileContents and FilePath::writeFileContents as well as FilePath::copyFile are changed to return std::expected. A couple of macros have been added to aid in using the expected types. An auto test was added showing how to use the library. Change-Id: Ibe3aecfc1029a0cf13b45bf5184ff03a04a2393b Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* | | CPlusPlus: Proliferate FilePath usehjk2022-11-221-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The starts with CppDocument::filePath(), plus a bit of the fallout This is one patch of potentially many. It is hard to draw the line where to stop this kind of chunk, this here converts a few additional functions for which including it in the patch looked like less churn than without. Converting is mostly fromString/toString, with a few exceptions for "already seem" like caches, that use cheaper "path()" to avoid likely performance regressions (on Windows FilePath comparison is currently case-insenstive, and more expensive). There should be no difference for local operation with this patch. Change-Id: I7b35f98a0a6f0bfed4ea0f8f987faf586f7a8f2b Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* | | Merge remote-tracking branch 'origin/9.0'Eike Ziller2022-11-101-12/+12
|\ \ \ | |/ / |/| / | |/ Change-Id: Ie069f3b2a1200b3e665341b1d56ce836024b0d29
| * QmlJS: Fix Follow under cursorMarcus Tillmanns2022-11-081-12/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When trying to jump to a symbol in a qml file the Qml Model may find the location in a generated .qml file in the build folder. QtCreator searches in all generated .qrc files to try and find the source file so it can jump to it instead. Previously not all auto-generated ".rcc" folders would be found as only the folders of targets (executables) were searched. Plugins or Static Libraries were not searched. With this fix, all projects nodes are searched for the ".rcc" folder and therefore also finds them for Dynamic / Static libraries and plugins. Fixes: QTCREATORBUG-27173 Change-Id: Ic51ac8fbc82c15785cbefd76787942a512ecf3db Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: hjk <hjk@qt.io>
* | Automatic qmlls support (experimental)Fawzi Mohamed2022-10-121-0/+19
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Looks for qmlls (the qml language server of Qt) and if available and set in the preferences uses it instead of the embedded code model for the supported features. Its usage is driven by two flags that can be set in the QtQuick > QML/JS Editing preferences: "use qmlls" activates the use of qmlls if available; "use latest qmlls" always uses the qmlls of the latest Qt, instead of the one of the target (with the one used to compile QtCreator as fallback). To support disabling/enabling of qmlls as soon as one changes the preferences the singleton QmllsSettingsManager can emit a signal on changes. It also keeps track of the latest qmlls binary known. QmlJS::ModelmanagerInterface::ProjectInfo is also extended to keep track of the qmlls binary. QmlJSEditorDocument uses the ProjectInfo and QmllsSettingsManager to decide if a LanguageClient::Client should be started for that document. The client uses the QmllsClient subclass to keep track of the path of the qmlls clients and use the same qmlls process or all files that use the same binary. Currently qmlls <6.4.0 are not considered because they might have too many issues. The enabling/disabling of warnings and highlight is a bit cumbersome because they are handled together in the semantic highlighter, but must be handled separately depending on the qmlls capabilities. The disabling is done at the latest moment stopping the visualization of the embedded model warnings/highlights/suggestions. The computation of the semantic info is not suppressed to support the other features (find usages, semantic highlighting if active,...). When qmlls supports more features a complete removal of the semantic info construction could be evaluated. Change-Id: I3487e1680841025cabba6b339fbfe820ef83f858 Reviewed-by: David Schulz <david.schulz@qt.io>
* Use more Utils::isMainThread()Jarek Kobus2022-10-111-2/+1
| | | | | Change-Id: Ia3c6f6dca53c5d7487b0813de16f06c52af47aa5 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Port from qAsConst() to std::as_const()Marc Mutz2022-10-071-25/+25
| | | | | | | | | | | | | | We've been requiring C++17 since Qt 6.0, and our qAsConst use finally starts to bother us (QTBUG-99313), so time to port away from it now. Since qAsConst has exactly the same semantics as std::as_const (down to rvalue treatment, constexpr'ness and noexcept'ness), there's really nothing more to it than a global search-and-replace. Task-number: QTBUG-99313 Change-Id: I88edd91395849574436299b8badda21bb93bea39 Reviewed-by: hjk <hjk@qt.io>
* FilePath: Return optional bytearray for file contentsEike Ziller2022-09-121-4/+6
| | | | | | | For differentiating between "error" and "empty file". Change-Id: I2c019ceac625e7be3180afa4d47ae3a24df91c1d Reviewed-by: hjk <hjk@qt.io>
* QmlJS: Avoid an occurrence of FilePath::toFileInfo()hjk2022-09-081-5/+3
| | | | | Change-Id: I1c7573caf07e6259115b2d748301d20ec389e6bd Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* Utils: Replace FilePath part settershjk2022-09-011-1/+1
| | | | | | | | | | ... by a combined version. This will make it easier to store the parts in one QString object. Change-Id: Ie85a77e3957c78a30e49998fe2e617af35a8ad17 Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io> Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
* Use SPDX license identifiersLucie Gérard2022-08-261-24/+2
| | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Task-number: QTBUG-67283 Change-Id: I708fd1f9f2b73d60f57cc3568646929117825813 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Merge remote-tracking branch 'origin/8.0'Eike Ziller2022-08-261-3/+12
|\ | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/libs/qmljs/qmljsmodelmanagerinterface.cpp src/plugins/clangcodemodel/clangdclient.cpp src/plugins/qmldesigner/components/edit3d/edit3dwidget.cpp src/plugins/qmldesigner/components/materialbrowser/materialbrowserview.cpp src/plugins/qmldesigner/designercore/include/modelnode.h src/plugins/qmldesigner/designercore/model/modelnode.cpp src/plugins/qmldesigner/designercore/model/rewriterview.cpp Change-Id: I93c57879b79f27325321bfc045ca618bd835af93
| * qmljs: reduce used threadsTim Jenssen2022-08-231-5/+17
| | | | | | | | | | | | Change-Id: I8f27037d0cfefd65f1ac060e1505328ea705a670 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
* | Utils: Port some FilePath part accessors to QStringViewhjk2022-08-221-1/+1
| | | | | | | | | | | | Change-Id: Ib5cc262e44c73880b6538eed714365e3d685870a Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* | Utils: Use FilePaths alias instead of QList<FilePath>Alessandro Portale2022-07-211-4/+4
| | | | | | | | | | | | Change-Id: I2eb0956377e46a34e73208b301eb662704a25e8b Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* | qmljs: (QString -> Utils::FilePath)++Fawzi Mohamed2022-07-131-167/+175
|/ | | | | | | | | 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>
* qmljs: avoid linking to files in the build directoryFawzi Mohamed2022-06-211-6/+95
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Fix crash of tst_ImportCheckEike Ziller2022-06-101-1/+2
| | | | | | | | 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>
* qmljs: Scan application directories for QML librariesMaximilian Goldstein2021-12-161-1/+3
| | | | | | | | | | 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>
* add .mjs as extension for javascript files in defaultLanguageMappingFawzi Mohamed2021-12-061-0/+1
| | | | | | Change-Id: I40d43193ba9b7dac38d7a474aad2d739e6c39dc6 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QmlJS: Proliferate FilePath use, part 2hjk2021-10-281-14/+14
| | | | | Change-Id: I631df6ba5e782e2db9e03de4e5df843d15c19f37 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* QmlJS: Proliferate FilePath and QtcProcess use in QmlJSPluginDumperhjk2021-10-271-12/+10
| | | | | Change-Id: Ie483bb2e9b5d812d380470949564a6bc57801fa9 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* Fix some MSVC warningsOrgad Shaneh2021-10-151-2/+2
| | | | | | | | * Implicit conversion of size_t to int * Comparing bool with operator > Change-Id: I4bc5bef57bfa0125b1c82953a7a2cfc24066bc8c Reviewed-by: hjk <hjk@qt.io>
* QmlJS: Destroy local snapshot before modifying its originalUlf Hermann2021-08-171-8/+13
| | | | | | | | | | | 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>
* qmljs: update Qml parser to parser of Qt 6.2Fawzi Mohamed2021-07-201-1/+1
| | | | | | | | | this is needed (among other things) for * null coalescing * shebang support Change-Id: I1b37fd86593f143de8b39c0daf433831a8785568 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Remove unused ModelManagerInterface:isIdle()Jarek Kobus2021-06-231-6/+0
| | | | | | Change-Id: I7c607bcc0a03219d7d6205a0c5fbdd3d46f9e9fa Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Add a test for a crash in ModelManagerInterfaceJarek Kobus2021-06-221-0/+14
| | | | | | Task-number: QTCREATORBUG-25350 Change-Id: I4ea31e7936cc77dcd8f3fc494b5ecbd83858a766 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* Make ModelManagerInterface::instance() a bit saferJarek Kobus2021-06-211-4/+12
| | | | | | | | | | | | | | | | | | | 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>
* Add more thread safety to ModelManagerInterfaceJarek Kobus2021-06-211-2/+16
| | | | | | | | | | | | | 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>
* Fix a crash inside ModelManagerInterface on Creator shutdownJarek Kobus2021-06-211-1/+3
| | | | | | | | | | | 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>
* Refactor tst_joinAllThreads, to be used in ModelManager d'torJarek Kobus2021-06-211-42/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: 96c860159b862460e21be16a6e2839c0b591e016 Task-number: QTCREATORBUG-25350 Change-Id: I5e44150c55f6be00445a5695938482d948990c94 Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
* QmlJS: Fix compile for Qt5.14Christian Stenger2021-03-231-1/+3
| | | | | | | | Amends 5ad724a3ac345. Change-Id: Ie53a738b61e2de84083fc6c9d3422451df9358c6 Reviewed-by: Erik Verbruggen <erik.verbruggen@me.com> Reviewed-by: David Schulz <david.schulz@qt.io>
* Support for QML module mappingErik Verbruggen2021-03-191-0/+1
| | | | | | | | | | | | | 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>
* QMLJS: Fix usage of default project infoErik Verbruggen2021-03-181-0/+10
| | | | | | | | | | | 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>
* QmlJS: Inline getterJarek Kobus2021-02-191-7/+2
| | | | | Change-Id: Ife8a2b0d6eb67ee28a4de808c1c848dbf633c49b Reviewed-by: hjk <hjk@qt.io>
* Libs: Use qAsConst with non-const Qt containers in range-loopsAlessandro Portale2021-02-171-1/+1
| | | | | Change-Id: I00d9f7c1634bbb62191470d58158e1fd150533c0 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
* QmlJS: Fix handling multiple import paths into same moduleChristian Stenger2021-01-211-1/+3
| | | | | | | | | | | 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>
* Use typed syntax in calls to QMetaObject::invokeMethodJarek Kobus2020-11-161-3/+2
| | | | | | | | | 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>
* Merge remote-tracking branch 'origin/4.13' into masterEike Ziller2020-10-021-2/+7
|\ | | | | | | Change-Id: I3f2a6c553819e992da7e9f538dc44b95b482359e