Review Request 118215: Declare QML components and component instances in the top-level context of their document

Denis Steckelmacher steckdenis at yahoo.fr
Tue May 20 12:02:02 UTC 2014



> On May 20, 2014, 11:40 a.m., Sven Brauch wrote:
> > I'm not sure about this. It looks like it would break when you try to re-open the declarations on subsequent parser passes. If you like you can submit it (since it's so simple), and if we run into issues with completion later we'll know why it is. ;)

Humm, yes, you're right. If I move the declarations, then openDeclaration() will not be able to see that a declaration has already been encountered and will re-create it. It does not feel particularly efficient, and if you say that it may cause problems in code-completion, then I prefer to avoid committing this patch.

I will not commit this for the moment. I'll try to work around the problem of Module::Rectangle when a module is imported (it should be as simple as "importing" the first sub-context of the module file instead of its top-level context, because every component is declared in the same Module context). If this does not work, then I will have to apply this patch.

Thanks!


- Denis


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


On May 20, 2014, 11:33 a.m., Denis Steckelmacher wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://git.reviewboard.kde.org/r/118215/
> -----------------------------------------------------------
> 
> (Updated May 20, 2014, 11:33 a.m.)
> 
> 
> Review request for KDevelop.
> 
> 
> Repository: kdev-qmljs
> 
> 
> Description
> -------
> 
> In QML, component instances (identified by an "id" property) are globally visible and can even be used before they are declared. This patch ensures that QML component instances are declared in the top-level context of their document, but does not address the problem of components used before they are declared.
> 
> QML components themselves must also be declared in the top-level context of their module. For instance, a Rectangle component declared like this:
> 
> Module {
>     Component {
>         name: "Rectangle"
>     }
> }
> 
> Must be declared as "Rectangle", and not "Module::Rectangle" as is the case without this patch. Having Rectangle declared in the top-level context will allow import statements to work as expected (if you import a module, you expect Rectangle to be available, not Module.Rectangle).
> 
> 
> Diffs
> -----
> 
>   duchain/declarationbuilder.cpp a0a34af 
>   duchain/tests/testdeclarations.cpp 476c673 
> 
> Diff: https://git.reviewboard.kde.org/r/118215/diff/
> 
> 
> Testing
> -------
> 
> Two C++ unit tests have been changed, because every QML component instance is now declared in the top-level context (and not only the top-level component). All the other unit tests pass unchanged.
> 
> 
> Thanks,
> 
> Denis Steckelmacher
> 
>

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


More information about the KDevelop-devel mailing list