Review Request 118398: Properly handle the class hierarchy of QML components

Denis Steckelmacher steckdenis at yahoo.fr
Thu May 29 14:12:58 UTC 2014


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

Review request for KDevelop.


Repository: kdev-qmljs


Description
-------

QML components can be considered as classes and instances at the same time. This is a bit strange, but QML is a declarative language that allows the user to subclass components, modify them and give them IDs (thus instantiating the subclasses they have just created).

This is expressed in DUChain by using an anonymous class:

* When a QML component is declared, for instance with "Button {", a new class having no name is opened. This class inherits from Button.
* When an "id:" script binding is seen, the identifier given by the user is used to instantiate the anonymous class surrounding the id: statement. This patch also handles the "exports:" script binding, that is used by plugin.qmltypes files to declare exported subclasses of components. This is a small cleanup that was needed for all the DUContext opened by the classes to be correct.

This patch adds several methods that are used by the two aforementioned features: one adds a base class to a class declaration (addBaseClass), and one imports in a context the inner context of all the base classes of a class declaration (registerBaseClasses).


Diffs
-----

  duchain/declarationbuilder.h e0c3539 
  duchain/declarationbuilder.cpp 8d9687a 
  duchain/tests/testdeclarations.cpp 199a566 
  tests/files/plugins.qml eda5388 
  tests/files/test.qml dc9efe4 

Diff: https://git.reviewboard.kde.org/r/118398/diff/


Testing
-------

The testsuite still passes, but needed to be heavily modified as it was previously built around the idea that "Button { id: foo }" declares a class foo that inherits from nothing. Now, the class that is declared has no name (because "Item { }" is still a valid component declaration and the user wants to be able to use code-completion without having to give an id to every component).


Thanks,

Denis Steckelmacher

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20140529/a12d8975/attachment.html>


More information about the KDevelop-devel mailing list