Review Request 118795: Support versioned module imports and rationalize module dependencies

Denis Steckelmacher steckdenis at yahoo.fr
Sun Jun 22 11:08:51 UTC 2014



> On June 22, 2014, 10:33 a.m., Sven Brauch wrote:
> > 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.

No problem for the delay, my week was also busy with exams (and I still have one on Monday), so you did not delay my KDevelop-related work :-) .

Each component of a module is declared like this:

Component {
  name: "QMyComponent"
  exports: ["MyModule/MyComponent 1.0", "MyModule/MyComponent 1.1"]
}
Component {
  name: "QOther"
  exports: ["MyModule/Other 1.1"]
}

Two files can contain this code: MyModule_1.0.qml and MyModule_1.1.qml. When MyModule_1.0.qml is parsed, Other is skipped because it isn't yet available in MyModule 1.0. When MyModule_1.1.qml is parsed, Other is kept, but MyComponent is skipped because is has already been declared in MyModule 1.0 (the lowest version of MyComponent is 1.0, and that does not match the 1.1 module version). This way, even if the files are the same, each version of a module declares only the components that appeared in this version. The parsing is very fast and maintenance is easy, no need to manually remove components from module versions.


- Denis


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/118795/#review60688
-----------------------------------------------------------


On June 17, 2014, 2:55 p.m., Denis Steckelmacher wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://git.reviewboard.kde.org/r/118795/
> -----------------------------------------------------------
> 
> (Updated June 17, 2014, 2:55 p.m.)
> 
> 
> Review request for KDevelop.
> 
> 
> Repository: kdev-qmljs
> 
> 
> Description
> -------
> 
> 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.
> 
> 
> Diffs
> -----
> 
>   duchain/parsesession.cpp 9ef32a0 
>   duchain/declarationbuilder.cpp d0f8772 
>   duchain/declarationbuilder.h dc132d9 
>   codecompletion/tests/qmlcompletiontest.cpp cef0254 
>   qmlplugins/Builtins1.qml 6677c03 
>   qmlplugins/Builtins2.qml 6672239 
>   qmlplugins/Qt.labs.folderlistmodel.qml ee1e58e 
>   qmlplugins/Qt.labs.gestures.qml 675eeb1 
>   qmlplugins/Qt.labs.particles.qml 9150529 
>   qmlplugins/Qt.labs.settings.qml e3cc0f7 
>   qmlplugins/Qt.labs.shaders.qml d357277 
>   qmlplugins/QtAudioEngine.qml 1416717 
>   qmlplugins/QtBluetooth.qml 9cef5cb 
>   qmlplugins/QtBluetooth_5.2.qml PRE-CREATION 
>   qmlplugins/QtMultimedia.qml 0dbf3b7 
>   qmlplugins/QtNfc.qml e49a811 
>   qmlplugins/QtNfc_5.2.qml PRE-CREATION 
>   qmlplugins/QtPositioning.qml 30b203f 
>   qmlplugins/QtPositioning_5.2.qml PRE-CREATION 
>   qmlplugins/QtQuick.Controls.qml 6045273 
>   qmlplugins/QtQuick.Controls_1.1.qml PRE-CREATION 
>   qmlplugins/QtQuick.Dialogs.qml 5541c5c 
>   qmlplugins/QtQuick.Dialogs_1.1.qml PRE-CREATION 
>   qmlplugins/QtQuick.Layouts.qml 2263401 
>   qmlplugins/QtQuick.LocalStorage.qml cbf8a4d 
>   qmlplugins/QtQuick.Particles.qml 711c7a2 
>   qmlplugins/QtQuick.PrivateWidgets.qml 9947c2b 
>   qmlplugins/QtQuick.PrivateWidgets_1.1.qml PRE-CREATION 
>   qmlplugins/QtQuick.Window.qml 302e27c 
>   qmlplugins/QtQuick.Window_2.1.qml PRE-CREATION 
>   qmlplugins/QtQuick.XmlListModel.qml 7e24088 
>   qmlplugins/QtQuick.qml e00676d 
>   qmlplugins/QtQuick_2.1.qml PRE-CREATION 
>   qmlplugins/QtQuick_2.2.qml PRE-CREATION 
>   qmlplugins/QtSensors.qml ada6d52 
>   qmlplugins/QtSensors_5.1.qml PRE-CREATION 
>   qmlplugins/QtTest.qml 3a0e449 
>   qmlplugins/makedeps.sh 7723c94 
>   tests/files/test.qml 86e55d1 
> 
> Diff: https://git.reviewboard.kde.org/r/118795/diff/
> 
> 
> Testing
> -------
> 
> 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.
> 
> 
> Thanks,
> 
> Denis Steckelmacher
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20140622/68008aa7/attachment-0001.html>


More information about the KDevelop-devel mailing list