Review Request 118465: Provide code completion items for field member expressions

Denis Steckelmacher steckdenis at
Mon Jun 2 13:57:51 UTC 2014

This is an automatically generated e-mail. To reply, visit:

(Updated June 2, 2014, 1:57 p.m.)

Review request for KDevelop.


Use un-balanced braces to find where a valid sub-expression could start in a partial expression.

Repository: kdev-qmljs


This patch adds support for field member expressions ("base.identifier") to the QML/JS code-completion. When "something." is typed by the user, KDevelop displays the list of symbols accessible from the inner context of something. "something" can be any expression recognized by ExpressionVisitor, so this will continue to work when ExpressionVisitor will be able to recognize "table["test"][repository.getIndice()].".

The patch is inspired from how Python handles such completion. The idea is to try to parse as much as possible of the line being edited, in order to have the most complete AST possible. When this is done, ExpressionVisitor is given the current context and visits this partial AST. The declaration it returns (if any) is used to get the code-completion items.

The only thing that doesn't quite please me in this patch is that I parse the current line several times (each time with one character removed from the left). It means that if the user is editing a very long line (say 200 characters), QmlJS::Document::parse will be called up to 200 times! Is there another mean to detect which part of the current line contains a valid expression? Do you think that it would be worth it to complexify the code by trying to skip more than one character each time (for instance, by skipping directly to the next dot or bracket).

Diffs (updated)

  codecompletion/CMakeLists.txt 9b62fb4 
  codecompletion/context.h 0683974 
  codecompletion/context.cpp 1e57197 



Manual testing shows that everything work as expected. For instance, the completions shown at the cursor (|) in this snippet are all the completions valid in button:

Label {
    id: foo
    bar: "baz"

    Button {
        id: button

        property int my_property;

    onTest: {
        console.log(button.|); // my_property listed


Denis Steckelmacher

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the KDevelop-devel mailing list