aboutsummaryrefslogtreecommitdiffstats
path: root/tools/qmllint
Commit message (Collapse)AuthorAgeFilesLines
* Pass qmldir to qmlcachegen, qmllint and qmltc, not the qmltypes fileUlf Hermann2021-12-131-25/+34
| | | | | | | | | | | | | | | | | | | The tools will still grudgingly accept qmltypes files being passed via the -i option. We generally expect qmldir files, though. Ignoring the qmldir file and importing the qmltypes directly, ignores qmldir imports, dependencies and other component entries. This leads to unresolvable types. [ChangeLog][QML Tooling] qmllint expects qmldir files, not qmltypes files to be passed via the -i option now. This enables it to see the imports and dependencies of the module being imported. For backwards compatibility it still accepts qmltypes files, with a warning. Fixes: QTBUG-99043 Change-Id: I5ed32d7e78df1e604aaf1bfa2ebda09d5d57b628 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 576fafd1e69429d7387e4c35f6d15fc42af6513e) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* qmllint: Use fix suggestions in a more structured wayMaximilian Goldstein2021-12-101-1/+1
| | | | | | | | | | | Fix suggestions are now attached to the warnings they are caused by and are also accessible via JSON. This allows us to use the qmllint library for more of tst_qmllint, greatly improving performance. Change-Id: Idd0398028bff1272a75dc1193d2c15a25d335dbf Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Fix diagnostics output for test runUlf Hermann2021-12-071-1/+1
| | | | | | | We do want to see the output if the cleanQmlCode test fails. Change-Id: I6b7e9d3412af9fffac68d2e394418de2faf09626 Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
* qmllint: Expand qmllint library APIMaximilian Goldstein2021-11-251-2/+2
| | | | | | | | | | | The API now allows for specifying the file contents yourself for either on-the-fly editing or if you have your own caching scheme. It's now also possible to access the logger directly in order to read diagnostic messages instead of structured JSON output. Change-Id: I4eb8440c7b25068cd09f28a5f3cbd0a318774522 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
* qmllint: Move most code into a separate libraryMaximilian Goldstein2021-11-238-1031/+6
| | | | | | | | | | | | | | | This is necessary step for both making qmllint viable for use in controls' tst_sanity, as well as for integration with the language server. As an additional upside it allows us to run our tests up to 10x faster. Eventually we want to integrate all of this into qmlcompiler but due to the state of some of the code we will keep qmllint in a separate library as to keep qmlcompiler tidier. Change-Id: Ic057ef0cd4424d28aa05e517d74280a442ec9c5a Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* qmlcompiler: Use QT_BEGIN_NAMESPACE / QT_END_NAMESPACE everywhereMaximilian Goldstein2021-11-231-1/+2
| | | | | | | Some code was not properly wrapped in a namespace. Change-Id: If70fd9782391309c511b66ae01eae43cb36292ac Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Fix typo in app descriptionMaximilian Goldstein2021-11-191-1/+1
| | | | | | | | | Disabling uses the keyword "disable" not "disabled". Fixed in this change. Pick-to: 6.2 Change-Id: I544a543043627121a11ca3ab56ad3d967707efb6 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Remove QQmlJSTypeResolver::SemanticsUlf Hermann2021-11-181-2/+1
| | | | | | | | We only support dynamic semantics here. Task-number: QTBUG-98305 Change-Id: I520da912062917e40e5628d003558fe80b612948 Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
* qmllint: Add option for logging absolute pathsMaximilian Goldstein2021-11-171-6/+15
| | | | | | | | | | | | Some IDEs might want to parse qmllints logging messages directly instead of using the structured JSON output. For these a hidden --absolute-path option has been introduced so the messages can more easily be mapped to the actual files. Task-number: QTCREATORBUG-17224 Change-Id: I23c4272a45adcb2bf7aeb6ae7b130839b9f05b72 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Phrase the shadow check as separate passUlf Hermann2021-11-171-2/+7
| | | | | | | | | ... and add a test to qmllint to check that it actually does something. Task-number: QTBUG-98305 Change-Id: Ib14bc6822cc15200018646c3a0395d0786ec28a8 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Introduce compile passesUlf Hermann2021-11-172-73/+50
| | | | | | | | | | | | Concentrate code likely to be used by more than one pass in a base class, and adapt the existing users. Also, stub out all the byte code visitors so that we can easily implement passes that only target part of the byte code. Task-number: QTBUG-98305 Change-Id: Ib1e16daf678bf478d9d2d11b3604ded3749f2096 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* qmllint: Use the raw type for type inference, not the stored oneUlf Hermann2021-11-151-5/+3
| | | | | | | If we use the stored type, we lose important information. Change-Id: I09264642cee8da2bd9103d01488855ebbc5648b5 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Explicitly include qloggingcategory.hKai Köhne2021-11-151-0/+1
| | | | | | | | | Do not rely on QLoggingCategory being implicitly declared through other headers. Pick-to: 6.2 Change-Id: Ib6cda43f281d31a7127dd591be2540fb00a0a699 Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
* qmllint: Decouple the parenting mode from the QML semanticsUlf Hermann2021-11-101-4/+9
| | | | | | | | qmllint wants only the parenting. It should still warn about shadowing (once it can). Change-Id: If49a11cd086643f9626754fdeaaf6a9a7c1bc626 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Fix some settings not being checked properlyMaximilian Goldstein2021-10-291-19/+44
| | | | | | | | | | | Previously some settings were only checked before any settings file could be loaded, thus resulting in misapplied settings. Now every settings option will be applied on a per-file basis as it should be. Pick-to: 6.2 Change-Id: Ib7c8a8d7dbec2d4379f634488e3899e1746c0c51 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Fix crash when builtins are not foundMaximilian Goldstein2021-10-291-0/+3
| | | | | | | | | Previously builtins not being found would lead to an endless loop that crashes qmllint. Now missing builtins are handled gracefully, aborting linting without crashing as this an unrecoverable error. Change-Id: Ia585b1e0e5c972dad0eeabf8df06edf71eaea0c7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Fix crash when no Connections parent can be foundMaximilian Goldstein2021-10-201-1/+4
| | | | | | | | | | When a Connections component is the root component, we are unable to find a parent component which used to lead to a crash. This change fixes this issue. While this usage cannot be analyzed by qmllint at the moment it should at the very least not lead to a crash. Fixes: QTBUG-97600 Pick-to: 6.2 Change-Id: If831d9c5ec822693896d48d65689d12628a6690e Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Skip unnecessary commands when cross-building toolsJoerg Bornemann2021-10-081-0/+1
| | | | | | | | | | Call qt_internal_return_unless_building_tools() directly after qt_internal_add_tool() to avoid having to special-case code for when this function only creates imported targets in cross-builds. Task-number: QTBUG-85084 Change-Id: I5c8f2ecdf4936cfd15cb530e896bc4e5b5531620 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* QQmlJSTypePropagator: Remove isLoggerMessageUlf Hermann2021-10-011-1/+1
| | | | | | | | | It was used to determine visibility of messages in the compiler category, but that category is off by default anyway. If it is on, we indeed want to see all the messages. Change-Id: I8b647d0df2c43c3a04235f7b77e7111ea3cb0f31 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Don't leak the QQmlJSTypeInfo objectUlf Hermann2021-09-303-4/+6
| | | | | | | | We want it to be mutable even where Codegen itself is const. Therefore, it needs to live outside Codegen. Change-Id: Ie4997118a1fdf8d60bd5670baa506ed0bfb98bad Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
* Remove obsolete bootstrap codeFabian Kosmale2021-09-301-6/+0
| | | | | Change-Id: Ifcbf81b5ee04753af916dc1ef1177617785c961d Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmllint: Add ability to warn about not reusing attached typesMaximilian Goldstein2021-09-292-1/+3
| | | | | | | | This is mostly useful as an replacement for Quick Controls' tst_sanity but might also be useful in some other instances. Fixes: QTBUG-96572 Change-Id: I5cf414bfeb369cbc394563c5c5ed807599b09a2f Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Pass file name and code to the qmllint codegen loggerUlf Hermann2021-09-291-3/+3
| | | | | | | | | We need the file name in order to see when the file we're examining is a qmltypes file. Change-Id: I72b6c3fe63e721b2b2a116fcafcb55e45b23ae39 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
* qmllint: Remove checkidentifiers.cppMaximilian Goldstein2021-09-211-279/+0
| | | | | | | | This file is completely unused now but we forgot to remove it. Change-Id: I653469be0bfc7ee9288f24d3120223b037b1169a Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* QQmlJSImportVisitor: Recognize grouped property scopes with bracesUlf Hermann2021-09-201-3/+0
| | | | | | | | | | | | UiObjectDefinitions with lower case names are not QML elements, but grouped properties. Using this information, we can now properly warn about invalid names for grouped properties. Pick-to: 6.2 Fixes: QTBUG-96147 Change-Id: Ib02705b28f6324d0b98bb66c09cb4708c18943bd Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
* qmllint: Put warning options at the topMaximilian Goldstein2021-08-261-11/+12
| | | | | | | | | This puts them right below the description of warning levels and hopefully makes the whole help easier to read. Task-number: QTBUG-95971 Change-Id: Iff6062e700c2c277fc4c69a8130ba6b2dd5e35c0 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Decouple QQmlJSLogger from QQmlImportVisitorAndrei Golubev2021-08-194-30/+41
| | | | | | | | | | | | | | | | | QQmlImportVisitor was accepting ctor paratemeters for the QQmlJSLogger, creating own logger internally. This seems wrong since in that case we kind of have separate logger for visitor and type resolver (among other entities) On top of this, the import visitor had a silent logging by default (and the QQmlJSLogger is not silent on the contrary) which in fact hid some issues that should've been reported by qmllint (but they weren't) For consistency, the silent logger is still used. And the ultimate fix would be to use FindWarningsVisitor instead of QQmlJSImportVisitor as currently we do 2 AST traversals in qmllint Change-Id: I4c54b76d130e7e8f31c90a148edc1c02f7e86ab8 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Make QQmlJSTypeResolver derivableAndrei Golubev2021-08-181-3/+6
| | | | | | | | | | | | | | | While migrating to QQmlJSTypeResolver in qmltc, some minor things didn't match exactly with the currently used type resolver. I'm not planning to submit those things just yet so it's easier to just make the class subclassable by making its members protected On top of this, decouple the QQmlJSImportVisitor from the type resolver to allow arbitrary visitor to be used for document traversal. This would anyway be needed for qmltc later on (it seems) as several qmltc-specific visitor passes are needed, yet they aren't that useful for e.g. qmllint Change-Id: I9fabcf6c0f2119b0d064bb27157b7085275e7665 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint/findwarnings: Move PatternElement logic to qqmljsimportvisitorMaximilian Goldstein2021-08-062-22/+0
| | | | | Change-Id: Ied9909687640d555fd6ec2f3ce6ace955f603bd1 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint/findwarnings: Move used type logic to qqmljsimportvisitorMaximilian Goldstein2021-08-062-22/+0
| | | | | | Change-Id: I68c2b4558473964f20d4946d6b54dd0388abaa0b Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Remove checkidentifiersMaximilian Goldstein2021-08-054-130/+4
| | | | | | | Since all of the warnings have been moved out of checkidentifiers we can now simply remove it. Change-Id: Ie59e306b69ca397c1e191a0fe379bc084f98cf73 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Move use-before-declaration warning out of checkidentifiersMaximilian Goldstein2021-08-045-15/+96
| | | | | | | Another step to making checkidentifiers obsolete. Change-Id: I14be7491387200101b66e0930faf16e9b61d4159 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Move restricted kind warnings to qmlcompilerMaximilian Goldstein2021-08-041-48/+2
| | | | | | | Moves the last remaining warnings of checkidentifiers into the qmlcompiler. Change-Id: I8e4330d3c054620463dc0462c272c3577fd10c8d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Move missing base type warning to qmlcompilerMaximilian Goldstein2021-08-041-9/+1
| | | | | | | Also changes the error message to be a bit clearer about what went wrong and does not involve the unrelated follow up property not being able to be resolved. Change-Id: I7071ca718b85d1282adacf40ba2bdc62fe5aad6d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Move 'type not found in namespace' warning to qmlcompilerMaximilian Goldstein2021-08-041-19/+0
| | | | | | Change-Id: Ibe7ae9afbfb7754d16cd0ce13185961e9ae2c769 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Move 'type of property' warning to qmlcompilerMaximilian Goldstein2021-08-031-7/+2
| | | | | | Change-Id: I6ee8233da9e2c0ea1be37b3961259d2efa38ddfa Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Move unknown property logic to compilerMaximilian Goldstein2021-08-022-7/+4
| | | | | | | Moves another warning to qmlcompiler so we can remove checkidentifiers. Change-Id: If8a72796b205ae1948b9cd9a24f11e62ea28b15a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Move deprecation logic to qmlcompilerMaximilian Goldstein2021-07-281-38/+1
| | | | | | | | Moves the remaining logic for handling deprecation warnings to qmlcompiler furthering the goal of removing checkidentifiers for good. Change-Id: I21ac524ea9c02b2e8c8f65962011976927fd7432 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Use type propagator to provide unqualfied access warningsMaximilian Goldstein2021-07-273-84/+15
| | | | | | | | Do not rely on checkidentifiers to provide unqualified access warnings anymore. Using the type propagator ought to be more accurate and will help remove the relatively hacky checkidentifiers code completely later on. Change-Id: I40cc040b9455962abbd2ec84cdb494fcec1ab79d Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qqmljstypepropagator: Ignore try/catch instructionsMaximilian Goldstein2021-07-211-1/+1
| | | | | | | This is necessary in order for qmllint to still be able to analyze unqualified accesses even when unsupported try/catch blocks occur. Change-Id: I878ebad4427f4b208432aaeba7433ce0314db107 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Allow direct access to parent object in static modeUlf Hermann2021-07-091-2/+0
| | | | | | | | | | In static mode, we assume that the "parent" property denotes the document parent. If the document parent then matches the expected type, we allow access to its properties. Task-number: QTBUG-93662 Change-Id: Iaf213492aa52571876c80f85faa04d8f76ab1254 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Do not store references to stringsUlf Hermann2021-07-091-1/+1
| | | | | | | | | | | This is extremely dangerous and offers very little benefit over just copying the string. QString is implicitly shared after all. If the string copying really becomes our bottleneck, we can revisit this, but that won't happen anytime soon. Change-Id: I274c89aec0a59067d03bb1b58dae4cf2c029b475 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQmlJSTypePropagator: Add a separate switch for shadowable membersUlf Hermann2021-07-091-1/+1
| | | | | | | | | When following static semantics we assume that properties and methods cannot be shadowed and just access them. This is independent of wrapping all non-primitive types in QVariant. Change-Id: Ic037148c74d5e157ec2ecbaac6089f7d70386638 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qqmljstypepropagator: Use logger systemMaximilian Goldstein2021-07-073-7/+12
| | | | | | | | In order to properly integrate the type propagator into qmllint we need to use the logging system instead of qWarning(). Change-Id: Ie9840066f8afa3d7f8a63a69444b6dc20c41a706 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmllint: Integrate type inference warningsMaximilian Goldstein2021-07-074-0/+463
| | | | | | | | | | | This change helps bring in type inference and compiler warnings previously only generated by qmlcachegen+. These warnings are disabled by default and have to be enabled manually via the --compiler option. Also makes the logger handle zero length SourceLocations properly by just highlighting the entire line instead of hitting an assert. Change-Id: Iebad6e9236214d9367f97487e7b5787592edab7d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* CMake: Run qmllint on the qml files in the source treeCraig Scott2021-07-071-8/+9
| | | | | | | | | | | | | | | | | | | | | | | In order to use the source tree files, qmllint needs to know where they will end up in the resource system. The source files could be at any arbitrary location and have their resource path set by a QT_RESOURCE_ALIAS source file property. Therefore, we have to give the generated .qrc files to qmllint so it can work out where each source file will end up. The qmllint command previously only supported a single --resource option, but now we need to potentially pass more than one .qrc file. Extend qmllint to allow multiple --resource options to be given, in the same way that multiple -I options can be given. Task-number: QTBUG-94761 Pick-to: 6.2 Change-Id: Ibeb6541e1f54bea6eeeccd07426dd238b0459ff2 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
* qmllint: Implement severity levelsMaximilian Goldstein2021-07-023-38/+38
| | | | | | | qmllint now supports logging levels of different severities. Still lacking a good way to toggle the verbosity more granularly though (i.e. disabling only info messages while still receiving the rest). Change-Id: I71abddcdf1adf60315a87d776af8085acf7aeffe Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* qmllint: Remove deprecated optionsMaximilian Goldstein2021-07-021-35/+0
| | | | | | | | | We kept these around for compatibility in Qt 6.2 but now it's time to get rid off them [ChangeLog][QtQuick][qmllint] The deprecated --no-[category] options from Qt 6.1 are now fully removed, use the new style of options as outlined in --help. Change-Id: Ie564a8262fdefa2685fe86b59b46dc3aa25d4958 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* replace devtools library with QtQmlFawzi Mohamed2021-07-021-1/+0
| | | | | | | | | | | | | | | qmldevtools was needed when building with qmake, and to avoid circular dependencies in the tools (before making QtQml minimal). Now it can be avoided. This change will make qmldom, qmlformat, qmlimportscanner and qmllint depend on QtQml (just like the other Qml tools) and not be always completely static (qmldevtools was always a static library, QtQml normally isn't). Change-Id: Idfa0a70e51f0d4999fb9753121c6c228ae69c9bb Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* qmllint: Formalize fix suggestionsMaximilian Goldstein2021-07-011-30/+36
| | | | | | | | | They are now handled by the logger instead of being done by external classes using the ColorOutput directly. This will allow for modernizing the logger and for automatically applying those suggested fixes. Fixes: QTBUG-94170 Change-Id: I90b960d22cb91203b8e8a5c69b0fdaf6fca2fc0c Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>