aboutsummaryrefslogtreecommitdiffstats
path: root/tools/qmllint
Commit message (Collapse)AuthorAgeFilesLines
* qmllint: Fix unknown properties on varMaximilian Goldstein2021-03-031-1/+4
| | | | | | | | | | | | Since the type of a var may change at runtime and we thus can't make any good predicitons on its actual underlying type we will ignore it from now on (as already done for variants). Fixes: QTBUG-84060 Change-Id: I36795ef2047629d3c870bf8a9df59dcd3db06633 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> (cherry picked from commit 25ae86d1d98dbf3900eefea152b072939be8ea71) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* qmllint: Check for existence of property typesUlf Hermann2021-02-241-1/+34
| | | | | | | | | | | | | | | | For each binding there should be a property and that property should have a type we recognize. Enums can be property types in C++. We support this by adding child scopes for such enums. The child scopes are then referenced by the QQmlJSMetaEnums and derive from int. The test then reveals that we were missing a few properties in QtQuick.tooling. Add those. Change-Id: I1deef94393ee0e17d34c2dc5980ebfbf25417f36 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 08c8e8ac3ba8eb23ae5c158990f5d029ac9988ed)
* qmllint: Resolve attached property scopesUlf Hermann2021-02-192-16/+22
| | | | | | | | | Previously, all attached property scopes were just ignored. Task-number: QTBUG-84369 Change-Id: I324becf92402eacea9d150e6e51359edae562dde Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit f34ecc8f99522b69d1aaa3d5d233add9ed9b6da9)
* qmllint: Fix false unknown grouped property warningMaximilian Goldstein2021-02-192-9/+0
| | | | | | | | | We seem to be checking grouped properties twice by endVisit(UiObjectBinding*) and endVisit(UiObjectDefinition*). So the UiObjectBinding variant is removed here as this gets run before all type information is available. Change-Id: Idfe23869792f787df6109cde3b6bc1d96cce3dc3 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 4660f51f25a6c56182dff0ea24f7c1ad2bac9cea)
* qmllint: Fix segmentation faultMaximilian Goldstein2021-02-191-1/+1
| | | | | | Change-Id: Ie04ad4221b25628687c2575facf90488b83d21bf Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 5fb34b67b810ca284c216009925f4f38220c4510)
* qmllint: Warn about too many or mismatched signal parametersUlf Hermann2021-02-151-16/+49
| | | | | | | | | | | It's easy to mess this up when you transform your signal handlers into functions. Task-number: QTBUG-89943 Change-Id: If35be2f6828a0e19aada19abb41d8135b0c6ab45 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit f0ecad1e99461109e69cd2b0f6271012c20005dd) Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* QML: Warn about variables being used before their declarationUlf Hermann2021-02-121-9/+23
| | | | | | | | | | | | | | | | | | | This collides with injected signal parameters. qmlcachegen cannot tell those cases apart. [ChangeLog][QML][Important Behavior Changes] QML warns about JavaScript variables being used before their declaration now. This is almost always a mistake. It is particularly dangerous in the presence of injected signal parameters because qmlcachegen cannot identify a name collision between an injected signal parameter and a variable being used before its declaration. It therefore miscompiles such code. You can turn off the deprecation warning using the "qt.qml.compiler" logging category. Task-number: QTBUG-89943 Change-Id: I8a9424ca8c6edd562402fe5c560ba7e8344b5585 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit ab71cdafca87513a4e214d3af056d8990bc1eddb) Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* QmlCompiler: Allow for multiple extensions per objectUlf Hermann2021-02-011-16/+11
| | | | | | | | | | | | | | | | | | | Previously, the assumption was that each object could only have a single extension object. As proven by the new qqmllanguage test this is not the case. Each registered object in the type hierarchy can have its own extension. Therefore, adjust the algorithms that generate qmltypes and iterate the extension objects when analyzing them. This leads us to the realization that anonymous types can in fact meaningfully carry extensions and implement interfaces. Adapt qmltyperegistrar accordingly. For the test to compile, however, we need to realize that the class declaring interfaces needs to befriend all potential subclass's QmlInterface structs. Fix that, too. The rabbit hole went deep. Change-Id: Ia451897e927e03b95c3062e829edf1dfcd216613 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Complain if member access check fails for namespaced typesUlf Hermann2021-01-261-13/+34
| | | | | | | | Before, we would prepend the namespace to the name, but then continue right away, never checking the new name. Change-Id: If90db7d33536fb4b549321c2d6b677040605b6f0 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Fix auto-importing of qmltypes from same directoryUlf Hermann2021-01-211-1/+3
| | | | | | | Fixes: QTBUG-90513 Pick-to: 6.0 Change-Id: Ic39e72d6df20be30c61123a7f8091d70dbc2d924 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Remove exceptions for most unknown builtinsUlf Hermann2021-01-211-23/+13
| | | | | | | | | | | | All those types are properly defined in the qmltypes files now. We just need to search the enumerations the same way as methods and properties in order to find everything. Also, deduplicate the code that resolves properties, methods, and enums by using a common template for iterating the scopes. Change-Id: I0bf1423974d0ec8f602ecd0342522b3e981a8586 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Support extended typesUlf Hermann2021-01-201-1/+12
| | | | | | | Fixes: QTBUG-90448 Change-Id: I5fb6b3d9223ae95ca7e039c5b9139ed086052c29 Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Remove the qmake project filesFabian Kosmale2021-01-151-18/+0
| | | | | | | | | Remove all qmake project files, except for examples which are used to test that qmake continues to work. Change-Id: Ic4abb72dc2dcd75df7a797c56056b6b3c5fe62ac Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QmlCompiler: Don't add imports with "as" to the contextUlf Hermann2020-12-051-1/+6
| | | | | | | | That is wrong. The context does not contain such objects. Instead, mark the names as namespaces in the imports by giving them an empty type. Change-Id: Ie9d0bba592863878d2220cee59be369ba2534f17 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Allow more convenient access to enums in QQmlJSScopeUlf Hermann2020-11-121-2/+2
| | | | | Change-Id: Ibac4dd7641a89b686bee63cf974b2257a35631a2 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Check identifiers before giving up in case of previous errorsUlf Hermann2020-10-271-4/+2
| | | | | | | | The identifier check might yet yield more information. Change-Id: I96f700acf257736fea7e9c2023b9e8797f702f7c Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
* QmlCompiler: Add JS scopes for script bindingsUlf Hermann2020-10-271-3/+5
| | | | | | | | This is necessary to identify the available QML and JS scopes for the binding, and to add any identifiers found there. Change-Id: Ic966e7817ccd1fdc064dd433d16fa6c42c9110cc Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Introduce grouped scopesUlf Hermann2020-10-272-0/+35
| | | | | | | | This way we can analyze the left hand part of things like "anchors.fill: parent" in qmllint. Change-Id: I0f58312566c3d5062e0fb301c2bad908ab8b8cbb Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Properly discern between inherited and own namesUlf Hermann2020-10-222-43/+48
| | | | | | | | | | | Previously, we would mix them up on importExportedNames(), which was also misnamed. Now we keep them in their proper place in the scope hierarchy, so that we can identify which scope a property came from. Exceptions are the qmllint-specific treatment of parent properties and Connections elements. Change-Id: I7c012388b16c83439d6f2de2e83fac0da4940d30 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: fix typoUlf Hermann2020-10-221-1/+1
| | | | | | Change-Id: Ia661141095a865191945f41bad91429ef952e16c Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Remove dead codeUlf Hermann2020-10-211-3/+0
| | | | | Change-Id: I5898402604fe29731dc518d42a441ff852706af3 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Compile with Clang11Lars Knoll2020-10-211-0/+4
| | | | | Change-Id: I9f3a4a6b6c7a2fbfca0a572209f398a23c26b37b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Pass source location to all scopes from QML filesUlf Hermann2020-10-151-2/+2
| | | | | Change-Id: Ic0aeb152acb0d90d15cc48a55c0ad5b15a60a6eb Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Further unify findwarnings.cpp and qqmljsimportvisitor.cppUlf Hermann2020-10-152-248/+58
| | | | | | | | Most of the logic in findwarnings.cpp applies also to imported files and should live in the base class. Change-Id: I65f326f50a8bfab0dff4b5b31f7bee7300b20704 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Unify QQmlJSImportVisitor and FindWarningsVisitorUlf Hermann2020-10-154-184/+21
| | | | | | | | | They are both pretty much doing the same thing, except that the import visitor is not as thorough. We need the full analysis in QtQmlCompiler, so we successively move the code over. Change-Id: If7fb47f88165fd8b61f4ccc408ccfbb7dad533e6 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Defer resolution of types read from QML filesUlf Hermann2020-10-152-6/+6
| | | | | | | | | | When importing a directory we most likely don't need all of the files in the directory. Therefore we now parse them only when they are accessed. This speeds up the execution and will allow us to process imports recursively without running into infinite recursion. Change-Id: I0c79313de792249e6bb86144b5014a7787dbdc5b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Unify the printing of diagnosticsUlf Hermann2020-10-152-30/+63
| | | | | | | | We can use QQmlJS::DiagnosticMessage to carry message, type, and location. Change-Id: I3868bc8035b4da13efad0d1b7d2f8dfeff1ef234 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Don't register the component we're just parsing as importUlf Hermann2020-10-141-4/+0
| | | | | | | | | I can't think of a scenario where this actually makes sense and none of the autotests exercise it. Change-Id: I6361d38e02f1cdac60ee5a4e1b8287491c3b05e6 Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Capitalize importer warningsUlf Hermann2020-10-074-52/+59
| | | | | | | Refactor the "prefixed message" mechanism into ColorOutput. Change-Id: Ie982e641771f3367406f48a8bcfd2bd3da122b16 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* CMake: Regenerate projects to use new qt_internal_ APIAlexandru Croitor2020-10-062-2/+2
| | | | | | | | Modify special case locations to use the new API as well. Task-number: QTBUG-86815 Change-Id: I3b964e3baf0cc7040830156dac30358ea1152801 Reviewed-by: Cristian Adam <cristian.adam@qt.io>
* QmlCompiler: Split importFileOrDirectory() in twoUlf Hermann2020-10-061-5/+10
| | | | | | | | | | | importing a file and importing a directory are really quite different things and the code paths inside the function were completely separate. We also don't have to create a map of ImportedTypes if we are only going to return a single one. Change-Id: Ifbb0caa70e9272dfde2d9f1cf5ed1b102e02f5cc Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Move ScopeType and JavaScriptIdentifier into QQmlJSScopeUlf Hermann2020-10-053-36/+44
| | | | | | | | They don't begin with 'Q' and they are not very useful outside of QQmlJSScope. Change-Id: I3363ac4d29be7a9cb5c9f7f3af1727c99e886825 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Rename TypeDescriptionReaderUlf Hermann2020-10-052-2/+2
| | | | | | | The names should begin with a common prefix. Change-Id: Ibd832ebe7a778c7af8ee3b75253e04491ded28be Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Rename QmlJSTypeReaderUlf Hermann2020-10-051-1/+1
| | | | | | | Add an extra 'Q' for consistency. Change-Id: I81324f3b6e4d26a29f3bcc40b03abfa137292ea0 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Rename QmlJSImporterUlf Hermann2020-10-052-6/+6
| | | | | | | Add an extra 'Q' for consistency. Change-Id: Idd34e0c898c9a7ac70b1ec3856a8af6829ec6fb7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Rename ImportedMembersVisitorUlf Hermann2020-10-051-1/+0
| | | | | | | The class names should start with a common prefix. Change-Id: I645ef476f8493d38c2f4c5241d4a2903543f09e8 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Rename metatypes_p.hUlf Hermann2020-10-053-11/+11
| | | | | | | Those are specific to QML/JS. Change-Id: I45a5d4eb6c53bd5ca4026e042af83c4afaa4953c Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Rename ScopeTree to QQmlJSScopeUlf Hermann2020-10-054-34/+34
| | | | | | | That is a better name. Change-Id: I34a6867692a236dd16ed8e3a68866f994eab02d2 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Long live libQtQmlCompiler!Ulf Hermann2020-10-056-30/+14
| | | | | | | | Move all the code from tools/shared into src/qmlcompiler and build a static library from it so that we can re-use it in external tools. Change-Id: I7c8d8e59063dc7c711f4072f103a01095e6f5997 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Remove member access chains from ScopeTreeUlf Hermann2020-10-024-11/+28
| | | | | | | | | What we need there is a proper type inference. This should be added separately. For now, keep the member access chains local in qmllint and don't pollute ScopeTree with them. Change-Id: I9f50aa4e54b285bd93e7bd4cd17797509df0c168 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Remove ScopeTree::m_unmatchedSignalHandlersUlf Hermann2020-10-023-23/+23
| | | | | | | | Rather, immediately output the warnings when we encounter them. Change-Id: I4bd1a5491a47cb0232bfdd4e325f8f122593aa39 Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Unify injected and "normal" JavaScript identifiersUlf Hermann2020-10-024-57/+103
| | | | | | | | The specifics of how to warn about the injected identifiers are moved out of ScopeTree as that is not related to the structure of the scopes. Change-Id: I26418c3fa492da8339abf045a4034a8464b7bbb8 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Remove ComponentVersionUlf Hermann2020-10-022-2/+0
| | | | | | | QTypeRevision does all we need there. Change-Id: Ib27ae2d58167a7a45fac31262a45e387d047af89 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Remove ScopeTree::isVisualRootScope()Ulf Hermann2020-10-021-2/+8
| | | | | | | | This is not a property of the ScopeTree itself, but rather a property of how qmllint sets up its scopes. Change-Id: Ifb7c0f1f841046a6ae68e246fbd706f67bedb2af Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Remove C++ types from the importer interfaceUlf Hermann2020-10-022-20/+20
| | | | | | | | We don't use them anymore. Now we can also make all the ScopeTrees const again as we don't need to modify them anymore after importing. Change-Id: I3ece767f4f62f06cb0640f1f191eb8d98400717c Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Don't use C++ names of QML typesUlf Hermann2020-10-022-42/+23
| | | | | | | | | The C++ names are an implementation detail of the importer, and qmllint has no business messing with them. All the types are supplied as ScopeTree by the importer now. Change-Id: I3ef2b5da1dc19f95c7f2a5d80fa1297ba10bef8f Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Remove exportedQmlNames from import resultsUlf Hermann2020-10-022-21/+21
| | | | | | | We don't need to expose them anymore. Change-Id: Ibb25f688459972f718f9a051fbb7265c7e5b5f92 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Uncruftify the importing of base qmltypesUlf Hermann2020-10-023-20/+37
| | | | | | | | | | | | | | builtins.qmltypes are imported separately now. Any other bare qmltypes files without qmldir should be specified explicitly. If none are specified, qmllint looks in the current directory for qmltypes files, not in all possible import paths. This is still somewhat weird, but admittedly it's handy for qmltypes files generated for application binaries. For the same reason, we unconditionally include the current directory in the list of default import paths. Previously this was done if no explicit qmltypes files were specified, which makes little sense. Change-Id: Iaa56f8b40b3ec3045f55928251d7efea5616d23b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* tools: Remove QmlJSImporter::m_currentDirUlf Hermann2020-10-021-5/+8
| | | | | | | | It was only used to make paths passed to importFileOrDirectory absolute. We can do that before passing them. Change-Id: I0798d38080596fc6eb314259e81702b81a7743dd Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Move the import handling code out of qmllintUlf Hermann2020-10-026-342/+9
| | | | | | | We want to re-use this logic in other places. Change-Id: I63cbee86a83265ddd241a4fae9ce8c48f38b5f18 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>