Review Request 117971: Use QML qualified identifiers to build uses

Denis Steckelmacher steckdenis at yahoo.fr
Sat May 3 13:05:02 UTC 2014



> On May 3, 2014, 11:21 a.m., Sven Brauch wrote:
> > Nice! Add a unit test and then ship it.
> > 
> > You can do that for example like this:
> > 
> >     int useIndex = top->findUseAt(Cursor(3, 5));
> >     QVERIFY(useIndex != -1);
> >     QVERIFY(useIndex < top->usesCount());
> >     const Use* u = &(top->uses()[useIndex]);
> >     Declaration* d = u->usedDeclaration(top->topContext());
> >     // ...
> 
> Sven Brauch wrote:
>     Ah, you use those json tests. Not sure how to do it there. I'll try talking to olijg.
> 
> Sven Brauch wrote:
>     Ok, apparently you can do this:
>     /// "useCount" : 1
>     var i = 0
>     a += i
>     
>     or so.

Thanks! I've added a json test because there were already many json files. There are C++ tests for declarations and contexts, but it would have made the patch a bit too big to add a complete testsuite for the use builder. I'm happy that json-based tests can be extensive enough!


- Denis


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


On May 3, 2014, 1:03 p.m., Denis Steckelmacher wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://git.reviewboard.kde.org/r/117971/
> -----------------------------------------------------------
> 
> (Updated May 3, 2014, 1:03 p.m.)
> 
> 
> Review request for KDevelop.
> 
> 
> Repository: kdev-qmljs
> 
> 
> Description
> -------
> 
> The Javascript parser builds IdentifierExpression AST nodes in Javascript files and UiQualifiedId AST nodes in QML files. This patch adds support for the latter ones in UseBuilder. This enables the QML/JS plugin to detect the use of QML components in QML files.
> 
> 
> Diffs
> -----
> 
>   duchain/usebuilder.h 39605ac 
>   duchain/usebuilder.cpp 3e5d0a1 
> 
> Diff: https://git.reviewboard.kde.org/r/117971/diff/
> 
> 
> Testing
> -------
> 
> I don't know how to unit test the use builder, and I would welcome any hint about that :-) . I manually tested that the use of "Foo" in this snippet is correctly detected:
> 
> Component {
>     name: "Foo"
> }
> 
> Foo {}
> 
> When I put my cursor on Foo, "Component" gets highlighted (because the declaration of Foo is located on the Component keyword). If I click on "show uses" in the information popup of "Component", the first line and the line instantiating Foo are listed.
> 
> 
> Thanks,
> 
> Denis Steckelmacher
> 
>

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


More information about the KDevelop-devel mailing list