aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmlcompiler/qqmljsimportvisitor.cpp
Commit message (Collapse)AuthorAgeFilesLines
* CodeChecker: Assert that pointer canot be nullFabian Kosmale2021-02-221-2/+3
| | | | | | | | In the AST, the type always has a name. Change-Id: Ifc299573132b9edeb4c0b96054a101d95332236a Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> (cherry picked from commit c6c37d12633cc9fc3be1a1aa8e18d1013f3ab2d9)
* qmllint: Resolve attached property scopesUlf Hermann2021-02-191-7/+9
| | | | | | | | | 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: Don't create properties for "on" assignmentsUlf Hermann2021-02-161-12/+15
| | | | | | | | | | | "on" assignments are assignments to the default property, with the property given interpreted as the target for the inner object. Change-Id: Ia93a171f759964d2c00d6c0293a5434f588123af Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 67c8afff346eae27c6fb833661d179326dd8b153) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QmlCompiler: Return after importing a scriptUlf Hermann2021-01-261-1/+1
| | | | | | | | If we don't return there, the newly imported script is promptly overwritten by an invalid module. Change-Id: I788a7275e2c190a20c176da35f5c76ac9f6ad02b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Remove exceptions for most unknown builtinsUlf Hermann2021-01-211-1/+1
| | | | | | | | | | | | 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>
* QmlCompiler: Don't add imports with "as" to the contextUlf Hermann2020-12-051-5/+0
| | | | | | | | 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: Mark the global scope as compositeUlf Hermann2020-11-261-0/+1
| | | | | | | | All non-C++ scopes are composite. Now that we can return the global scope, when parsing a script, this matters. Change-Id: I6c9a17bdd3acf80fce728b1df5c3d9e66035bd33 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Unify parsing of QML components, JS programs, ES modulesUlf Hermann2020-11-251-21/+74
| | | | | | | | | There is no reason to duplicate the code for retrieving method signatures 3 times over. As an added benefit, the types on those methods are resolved now. Change-Id: I2f9681911b938c4a260b6593ab49e9cc5098c546 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Fix resolution of method and property typesUlf Hermann2020-11-181-5/+13
| | | | | | | | | | | | | | | | We need to resolve the types for QML elements in two passes because only after finishing the parsing we have the QML-declared methods and properties available. We already need the base type before, though. Also, there can be multiple methods of the same name. We need API to access them. It also turns out that the internal name of the "var" type has to be QVariant in order to match reality. "var" properties and unnamed arguments to JS functions are implemented as QVariant. Change-Id: I541f11e96db72d832f4e4443d3a5d31079a56575 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Store values QQmlJSMetaEnum when availableUlf Hermann2020-11-121-1/+3
| | | | | | | | | | | | | When parsing QML files, we need to keep the enum values around as this is the only place where we can find them (without parsing the same file again, that is). With C++ types we don't strictly need them as they are also available from the C++ header, but if the qmltypes file is nice enough to provide them, we can use them. (Which will be for types that are not actually C++ types, but rather types produced by registering a QML file with qmlRegisterType()). Change-Id: Ibcc93b30e523a00e1eeb80029943c48b83d0e1b5 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Allow more convenient access to enums in QQmlJSScopeUlf Hermann2020-11-121-1/+1
| | | | | Change-Id: Ibac4dd7641a89b686bee63cf974b2257a35631a2 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Use the name of a QML object as its locationUlf Hermann2020-11-031-1/+3
| | | | | | | This is in line with what the IR does. Change-Id: I9808d6e070a19e749e43c4abf612556485eb080b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Add JS scopes for script bindingsUlf Hermann2020-10-271-1/+16
| | | | | | | | 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-271-2/+23
| | | | | | | | 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-221-35/+7
| | | | | | | | | | | 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: Resolve aliases in nested objectsUlf Hermann2020-10-221-20/+27
| | | | | | | So far we've just ignored them. Change-Id: I2ca522ef825a341a3f4bf1c2a42fb0376180cdda Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQmlJSImporter: Pass the source location to the resultUlf Hermann2020-10-201-0/+1
| | | | | Change-Id: I8c52efc752fbeae4485d7cc2112d615707e2afd1 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Read the "bindable" attribute from plugins.qmltypesUlf Hermann2020-10-161-17/+16
| | | | | | | | | And refactor QQmlJSMetaProperty to use setters rather than a gigantic constructor. Also, notice that we don't have to construct the same property twice just to update its type. Change-Id: Ia6c195fa7088f6ecdff868daae17d4284c1edb22 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Pass source location to all scopes from QML filesUlf Hermann2020-10-151-18/+29
| | | | | Change-Id: Ic0aeb152acb0d90d15cc48a55c0ad5b15a60a6eb Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Further unify findwarnings.cpp and qqmljsimportvisitor.cppUlf Hermann2020-10-151-4/+179
| | | | | | | | 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-151-40/+155
| | | | | | | | | 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-151-1/+1
| | | | | | | | | | 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-151-5/+11
| | | | | | | | We can use QQmlJS::DiagnosticMessage to carry message, type, and location. Change-Id: I3868bc8035b4da13efad0d1b7d2f8dfeff1ef234 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Rename QQmlJSImportedMembersVisitorUlf Hermann2020-10-121-0/+173
We need to make this a general import visitor. Change-Id: I735378fc9139cb4891f8b113d86395df856fb4e9 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>