Support versioned module imports and rationalize module dependencies
Review Request #118795 - Created June 17, 2014 and submitted
This patch is huge (2.1 MB!), but the code changes are not that big. This patch comes from two problems that the QML/JS plugin had: * The version given in QML import statements was not used to find the correct module. An user importing QtQuick 2.0 was therefore able to see components that only appeared in QtQuick 2.1 or 2.2. * The dependencies of the modules were a bit broken. Builtins1.qml and Builtins2.qml were "built-in" types for QtQuick 2.0 and QtQuick 1.0 respectively (not the inversion :-) ), and several modules happily depended on both files. This yielded duplicate components (Item is declared in Builtins2.qml, Builtins1.qml and QtQuick.qml that was exactly the same file as Builtins1.qml) and slowed down the parsing of the modules. Now, the idea is to have one file per module and per version. There is therefore 5 files for QtQuick : QtQuick_1.0.qml, QtQuick_1.1.qml, QtQuick_2.0.qml, QtQuick_2.1.qml and QtQuick_2.2.qml. When the user imports a module X with a version Y, the file X_Y.qml is imported. In order to keep things simple, every file sharing the same major number (1 or 2) is exactly the same. DeclarationBuilder, when asked to parse a module file having a version X.Y, ensures that only the components having exactly the version X.Y are parsed. The others are skipped in a very fast fashion (visit() returns false and no declaration is opened). When a new Qt version comes out, updating QML/JS is as simple as running qmlplugindump and to overwrite QtQuick_2.*.qml with the output. The dump contains every declaration with the versions in which they appeared. No need to run a Python script or something like that to postprocess the dumps. The user is now able to import QtQuick 2.1, that imports QtQuick 2.0, and can see every component that exists in QtQuick 2.1 or 2.0. The components of QtQuick 2.2 are still hidden, though. Moreover, extra modules like QtQuick.Dialog, QtQuick.Controls, etc, depend on the exact QtQuick version they require. For instance, QtQuick.Dialog depends on QtQuick 2.0 while Qt.labs.shaders depends on QtQuick 1.0. The dependency tree of the modules is now really a tree. This avoids duplicate declarations (each declaration lives in exactly one module and one version), and greatly speeds up the parsing of module files. Filetest now takes 0.90 seconds on my computer, instead of 1.90 before this patch. I understand that this patch is fairly complex, so take your time reviewing it :-). I've several exams at the end of this week and not much time to push this stuff, so nothing requires your immediate attention.
Two new tests are added: one ensures that the OpacityAnimator declaration exists in QtQuick 2.2, and the other ensures that OpacityAnimator doesn't exist in QtQuick 2.0 (this declaration has been introduced in QtQuick 2.2). All the other tests still pass.
Maybe producing the patch with --find-copies-harder would help? or at least -M80. Maybe we should think of ways to get these files installed too? Qt should be distributing them rather than having us distributing it with kdevelop. Moreover, if I understand correctly, we'll probably want to produce some for KF5, no?
Review request changed
Diff generated with -M80. It weights 583K instead of 2.1M.
Revision 2 (+15307 -140)
Sorry for taking so long to review this. I don't understand this: First you say "In order to keep things simple, every file sharing the same major number (1 or 2) is exactly the same." and then "The user is now able to import QtQuick 2.1, that imports QtQuick 2.0, and can see every component that exists in QtQuick 2.1 or 2.0. The components of QtQuick 2.2 are still hidden, though.". How does this work together? Otherwise, the patch looks okay.