aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmlcompiler/qqmljslinter.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* QmlCompiler: Avoid unnecessary copies in loopsUlf Hermann2022-08-291-3/+3
| | | | | | | | Coverity-Id: 397268 Coverity-Id: 397269 Change-Id: Iacbf6c8a57dbdee02e75f4faeed0a0f31d37500f Reviewed-by: Sami Shalayel <[email protected]> Reviewed-by: Fabian Kosmale <[email protected]>
* qmllint: Also check methods when linting modulesMaximilian Goldstein2022-08-011-0/+29
| | | | | | | | | | Also lint methods in addition to properties when verifying whether any types are missing or not fully resolved. Change-Id: Ia7629d2b2427053c497bffca2b5d5b3a3f0bb027 Reviewed-by: Fabian Kosmale <[email protected]> Reviewed-by: Andrei Golubev <[email protected]> Reviewed-by: Ulf Hermann <[email protected]>
* Fix warning from iterating over referencesVolker Hilsheimer2022-07-261-3/+3
| | | | | | | | | | | Apple clang says: error: loop variable 'kv' is always a copy because the range of type 'QtPrivate::QKeyValueRange<const QHash...> &>' does not return a reference [-Werror,-Wrange-loop-analysis] Change-Id: I4dc43805d3d3f723e5ec8cc504969cda3d99fb43 Reviewed-by: Fabian Kosmale <[email protected]>
* qmllint: Implement module lintingMaximilian Goldstein2022-07-251-76/+203
| | | | | | | | | | | | | | | | This change allows for modules to be linted via the -M flag. This will check whether an individual module has a sound qmldir and qmltypes. It will also verify whether all its types and the types of properties can be resolved. It does not lint individual QML files. [ChangeLog][qmllint][New Feature] Individual modules can now be linted via the -M option Fixes: QTBUG-103264 Change-Id: I3ced4b0bc05358e9216c9819f1dca67af909405e Reviewed-by: Ulf Hermann <[email protected]>
* qqmljslogger: Print ids of warningsMaximilian Goldstein2022-07-131-6/+8
| | | | | | | | Also exposes the id information in the Message object and adds it to the JSON output. Change-Id: I6b27e644583408cca3e39b75210610db09fefa8b Reviewed-by: Fabian Kosmale <[email protected]>
* qmljscompiler: Replace categories with more specific warning idsMaximilian Goldstein2022-07-081-4/+4
| | | | | | | | | | This change replaces a lot of generic category names with several warning ids to replace them. Change-Id: I9b13b931e7ed3d56b71d6292a6a77bec69647ffd Reviewed-by: Fabian Kosmale <[email protected]> Reviewed-by: Qt CI Bot <[email protected]> Reviewed-by: Ulf Hermann <[email protected]>
* Fix the compilation errorTimur Pocheptsov2022-07-061-1/+1
| | | | | | | Clang does not like the ref. and says: "note, use non-reference type ..." Change-Id: I838f81e2b02ebaac57295ca7d662a0a6db4ac056 Reviewed-by: Oliver Eftevaag <[email protected]>
* QQmlJSLogger: Switch to an ID based systemMaximilian Goldstein2022-06-301-22/+66
| | | | | | | | | | | | | | | | This change makes qmljslogger use an ID based system for categorizing logging entries instead of using an enum. This allows plugins to register their own logging categories after the fact. It's also necessary for us to later show the warning ID when printing warnings and for creating documentation for each ID entry. Currently not every ID maps cleanly to only one type of warning, this has to be cleaned up in a follow-up change. Task-number: QTBUG-103453 Change-Id: I4cac6be7ca165b938e0ea032d077823bf17baf75 Reviewed-by: Fabian Kosmale <[email protected]>
* Use SPDX license identifiersLucie Gérard2022-06-111-27/+2
| | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Pick-to: 6.4 Task-number: QTBUG-67283 Change-Id: I63563bbeb6f60f89d2c99660400dca7fab78a294 Reviewed-by: Shawn Rutledge <[email protected]>
* Reimplement PropertyPass to evaluate bindingsMaximilian Goldstein2022-05-161-3/+8
| | | | | | | | | | | | | | | | | | | | | | This change reimplements the PropertyPass to be based on bindings rather than on just iterating over elements. This is a lot less cost intensive than iterating over all properties regardless of whether they are actually used. You may still achieve the same thing with the more flexible element pass, just with the benefit that you can choose what properties you want to iterate over instead of iterating over all of them. To demonstrate the passes usefulness the existing attached property warnings are ported to use the binding pass and can now also warn when an attached property is read or written in a context where it's not supposed to be used. Fixes: QTBUG-102860 Fixes: QTBUG-102418 Task-number: QTBUG-102859 Change-Id: Iea87a1b05b954429b8bf00fd27b60487940af679 Reviewed-by: Ulf Hermann <[email protected]> Reviewed-by: Qt CI Bot <[email protected]>
* qqmljstyperesolver: Allow for disabling cloningMaximilian Goldstein2022-05-091-0/+4
| | | | | | | | | | Previously it was not possible to disable cloning of types but we need to do this in order for linting to not be disturbed. This patch adds a flag that can be toggled to disable it, although it is still enabled by default. Change-Id: I5b19a48395e27975343fb1999d8106e0bb07d53a Reviewed-by: Ulf Hermann <[email protected]>
* Replace uses of deprecated _qs with _s/QStringLiteralSona Kurazyan2022-04-291-27/+29
| | | | | | Task-number: QTBUG-101408 Change-Id: Ic925751b73f52d8fa5add5cacc52d6dd6ea2dc27 Reviewed-by: Ulf Hermann <[email protected]>
* Move literal types check out of QQmlJSTypeResolverUlf Hermann2022-04-271-0/+4
| | | | | | | | | | | | | | | | | The type resolver should not do any semantic analysis on its own. This fixes a bug triggered by invoking the literal type analysis from qmlcachegen (which is not interested in literal bindings at all). While this doesn't fix the root cause, qmlcachegen will definitely not crash in this place anymore. There will be a follow-up bug to figure out what is actually happening. Pick-to: 6.3 Fixes: QTBUG-102598 Change-Id: Ic5b1f1cdebc960e0ec56f54d8bdd11bac08f0521 Reviewed-by: Andrei Golubev <[email protected]> Reviewed-by: Fabian Kosmale <[email protected]> Reviewed-by: Maximilian Goldstein <[email protected]>
* qmllint: Add option to disable individual pluginsMaximilian Goldstein2022-04-211-1/+1
| | | | | | | | | | Adds a command line option and settings entry in order to disable individual plugins. Previously you could only disable all of them. Fixes: QTBUG-102420 Change-Id: I5a35093c32f5f86eef1e31dd42b77c95e38bb01f Reviewed-by: Fabian Kosmale <[email protected]>
* qqmljslinter: Warn about duplicate plugin namesMaximilian Goldstein2022-04-211-4/+26
| | | | | | | | | If two plugins have the same name, warn about it and don't load the second one. Fixes: QTBUG-102421 Change-Id: If386acf9fbbfc12cec8ce708516c11940ef2856e Reviewed-by: Fabian Kosmale <[email protected]>
* qqmljslinter: Run plugin passes earlierMaximilian Goldstein2022-04-121-17/+14
| | | | | | | | | | Turns out just cloning the root scope is not enough to avoid the duplicated scopes after all. We'll just have to have the plugins run before the compiler logic for now. Change-Id: I5f44c7d14b5c3ade8e7fff0fbc98d14e34b875ec Reviewed-by: Andrei Golubev <[email protected]> Reviewed-by: Ulf Hermann <[email protected]>
* qqmljslinter: Fix codechecker warningsMaximilian Goldstein2022-04-111-2/+2
| | | | | Change-Id: Ifbc2858093ad2374fc9a2e3d6904cfaef6aad6d3 Reviewed-by: Ulf Hermann <[email protected]>
* Turn the QtQuick qmllint plugin into a proper shared libraryMaximilian Goldstein2022-04-111-1/+1
| | | | | | | | | | | Previously it was just a static library that we linked qmllint against now it's properly installed in the qmllint plugins folder and can be utilized in the language server as well. Fixes: QTBUG-102278 Change-Id: I4aec42d1e2ba113237ee5ba148085e69b7251506 Reviewed-by: Qt CI Bot <[email protected]> Reviewed-by: Fabian Kosmale <[email protected]>
* qmllint: Integrate plugin infrastructureMaximilian Goldstein2022-04-051-2/+155
| | | | | | | | | | | | | Integrates the plugin and pass infrastructure into qmlcompiler and qmllint proper. Plugins are searched for in the "qmllint" subfolder of the Qt installation's plugin directory. In addition we also support loading statically linked plugins. [ChangeLog][qmllint][New Feature] qmllint can now be extended via plugins. Use --plugins to get a list of available plugins. Original-patch-by: Fabian Kosmale <[email protected]> Change-Id: I75a09dd978fc7724aca4931f055cc71c7ced971b Reviewed-by: Fabian Kosmale <[email protected]>
* Avoid copying QQmlJSScopeUlf Hermann2022-04-041-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | The factory should populate the pre-existing scope rather than copy it into place. This way we can detect inheritance cycles involving the pre-existing scope. However, now we may detect the inheritance cycles earlier, when resolving the types inside the lazy loading. We have the right pointers available there now, after all. Therefore, add a way to propagate base type errors out of the factory. When clearing the base type, we can now give a reason for that. When checking the inheritance cycles we retrieve that reason and log it. We also remove the special casing of the ScopeType property of QQmlJSScope. There is no real reason to set it in the ctor. As we delay the population of QQmlJSScope now, we have to set it later. Pick-to: 6.2 6.3 Task-number: QTBUG-102153 Change-Id: I49cf6e20f59fbdb6ed98a82040b3b159676f5975 Reviewed-by: Andrei Golubev <[email protected]> Reviewed-by: Qt CI Bot <[email protected]> Reviewed-by: Fabian Kosmale <[email protected]>
* qmllint: Represent fix suggestion filename in JSONMaximilian Goldstein2022-03-241-0/+2
| | | | | | | | | | Previously this information didn't get exposed in the JSON interface. Now if a file other than the one the message belongs to has a fix suggestion it will be properly represented in JSON. Change-Id: I48f0f555dadd471ccfc58a5c9627c52f28b5e112 Reviewed-by: Fabian Kosmale <[email protected]> Reviewed-by: Qt CI Bot <[email protected]>
* qmllint: Support automatically applying suggestionsMaximilian Goldstein2022-03-141-6/+117
| | | | | | | | | | | | | We now support automatically applying fix suggestions that don't need any additional user input. This allows us to automatically solve issues such as unqualified access and multiline strings. [ChangeLog][qmllint][New Feature] Added the ability to automatically fix some warnings, use -f to automatically fix your files or add --dry-run to see what changes would be made first. Change-Id: I2dc7587137d74267f60c08bb94a035f1a85a62b1 Reviewed-by: Fabian Kosmale <[email protected]>
* qmlcompiler: Allow for logging other files and add auto-fix infrastructureMaximilian Goldstein2022-03-031-0/+1
| | | | | | | | | | | | This change makes sure the logger can write messages and show excerpts from files other than the current one. This is necessary in order to give users hints about problems that arise due to other components. It also adds a field to FixSuggestion::Fix which specifies whether a suggested fix can be applied automatically or is only a hint. Change-Id: I94a929d3fc3fc966591cffb99e67309d264c38e7 Reviewed-by: Fabian Kosmale <[email protected]>
* qmldir: Allow for specifying default importsMaximilian Goldstein2022-02-141-1/+1
| | | | | | | | | | | | | | | | | Adds the option to specify default optional imports in qmldir for tooling to load. Previously we would just load all entries. This allows code that that relies on modules utilizing optional imports (i.e. everything utilizing QtQuick.Controls) to still be supported in a limited capacity. This change also adds the necessary CMake API to add these entries to qmldir files. It also disables loading optional imports by default and only leaves them enabled for qmllint. Change-Id: Iff6aaac9cb0ec72b7a2853b60840a4d28c84aa25 Reviewed-by: Fabian Kosmale <[email protected]> Reviewed-by: Ulf Hermann <[email protected]>
* Redesign QQmlJSLogger internalsAndrei Golubev2022-02-121-10/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | High-level goal: be able to reuse existing infrastructure "as is" to configure semantic analysis categories in tools (qmllint, qmltc, qmlsc, etc.) To achieve that, simplify the logging to always "log" something, without explicitly specifying the severity. The severity is now baked into the category (and we can extend those to cover different cases) One slight deviation is the cache generation which likes to do its own thing at present. Provide a "forced logging" option where we can specify which severify we want. The hope is that this gets removed at some point Particular list of (noteworthy) changes: * No more "thresholding" by the level (this is rarely needed and is actually questionable). Instead, we can ignore a particular category explicitly * Category levels are repurposed as category severities (at least from the high-level picture that always should've been this way) * log{Warning,Info,Critical} removed. We use category severity instead * "category error" makes zero sense so removed: if our severity is: - QtWarningMsg (qmllint), it is already an "error" - QtCriticalMsg (compilers), it is already an "error" * Align m_output and m_{infos,warnings,errors} stored information * Accept the fact that we don't support QtDebugMsg and QtFatalMsg * Additional categories added to cover for places where the same category would be both an error and not an error Task-number: QTBUG-100052 Change-Id: I3cd5d17d58be204f48428877bed053f756ac40a8 Reviewed-by: Ulf Hermann <[email protected]>
* qmlcompiler: Remove qmllint libraryMaximilian Goldstein2022-02-031-0/+386
Since all of the superfluous components of qmllint have been removed now, we can just move what little custom linter logic remains to qmlcompiler. Change-Id: I91c752cb895e7d6c6f2dd4e2ccafb6cd05afa225 Reviewed-by: Andrei Golubev <[email protected]> Reviewed-by: Fabian Kosmale <[email protected]>