<html>
 <body>
  <div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
   <table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 solid;">
    <tr>
     <td>
      This is an automatically generated e-mail. To reply, visit:
      <a href="https://git.reviewboard.kde.org/r/118168/">https://git.reviewboard.kde.org/r/118168/</a>
     </td>
    </tr>
   </table>
   <br />



<table bgcolor="#e0e0e0" width="100%" cellpadding="8" style="border: 1px gray solid;">
 <tr>
  <td>
   <h1 style="margin-right: 0.2em; padding: 0; font-size: 10pt;">This change has been marked as submitted.</h1>
  </td>
 </tr>
</table>
<br />


<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" style="background-image: url('https://git.reviewboard.kde.org/static/rb/images/review_request_box_top_bg.ab6f3b1072c9.png'); background-position: left top; background-repeat: repeat-x; border: 1px black solid;">
 <tr>
  <td>

<div>Review request for KDevelop.</div>
<div>By Denis Steckelmacher.</div>


<p style="color: grey;"><i>Updated May 18, 2014, 11:34 a.m.</i></p>









<div style="margin-top: 1.5em;">
 <b style="color: #575012; font-size: 10pt;">Repository: </b>
kdev-qmljs
</div>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
 <table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
 <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Enumeration values are handled like this un plugin.qmltypes files:

Enum {
  name: "enumeration"
  values: {
    "first_value": 1,
    "second_value": 2
  }
}

This patch supports this syntax by handling array keys (or dictionary keys, using Pythonic terms). It therefore has two effects:

* Enumeration values are shown in code-completion proposals, and are correctly identified as being values belonging to an enumeration.
* Array keys have their type guessed, even in plain Javascript files.

This patch adds a visit(PropertyNameAndValueList*) method in DeclarationBuilder. The problem with PropertyNameAndValueList is that there is only one such node for the whole array. In my above example, this visit() method is therefore called only once, even if there are two keys in the array. In the JS AST, PropertyNameAndValueList only contains IdentifierNodes and ExpressionNodes. There is no "PropertyNameAndValueEntry" that I can visit. This explain why visit(PropertyNameAndValueList) does strange things, like closing the declaration it has just opened, or calling "visit(node->next)". Normally, things like that should be handled by the nodes themselves, but the JS AST does not do that. If there is a better solution, I would be very glad to implement it!</pre>
  </td>
 </tr>
</table>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
 <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">This patch adds three unit tests. The first ones checks that enumeration values are correctly recognized. The second one verifies that the type of an array key is correctly deduced, and the third one is there just to ensure that DeclarationBuilder explores all the keys in an array and doesn't stop after the first one.</pre>
  </td>
 </tr>
</table>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">

 <li>tests/files/plugins.qml <span style="color: grey">(e2a870c)</span></li>

 <li>duchain/declarationbuilder.cpp <span style="color: grey">(009b90d)</span></li>

 <li>tests/files/helloworld.js <span style="color: grey">(885aaa3)</span></li>

 <li>duchain/declarationbuilder.h <span style="color: grey">(1808e4d)</span></li>

</ul>

<p><a href="https://git.reviewboard.kde.org/r/118168/diff/" style="margin-left: 3em;">View Diff</a></p>







  </td>
 </tr>
</table>




  </div>
 </body>
</html>