<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/118700/">https://git.reviewboard.kde.org/r/118700/</a>
     </td>
    </tr>
   </table>
   <br />










<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
 <p style="margin-top: 0;">On June 12th, 2014, 8:33 p.m. UTC, <b>Milian Wolff</b> wrote:</p>
 <blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
  



<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; border-collapse: collapse; margin: 2px padding: 2px;">
 <thead>
  <tr>
   <th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; font-size: 9pt; padding: 4px 8px; text-align: left;">
    <a href="https://git.reviewboard.kde.org/r/118700/diff/2/?file=280573#file280573line200" style="color: black; font-weight: bold; text-decoration: underline;">duchain/expressionvisitor.cpp</a>
    <span style="font-weight: normal;">

     (Diff revision 2)

    </span>
   </th>
  </tr>
 </thead>

 <tbody style="background-color: #e4d9cb; padding: 4px 8px; text-align: center;">
  <tr>

   <td colspan="4"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">void ExpressionVisitor::encounter(IntegralType::CommonIntegralTypes type)</pre></td>

  </tr>
 </tbody>



 
 

 <tbody>

  <tr>
    <th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
    <th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">200</font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">    <span class="k">if</span> <span class="p">(</span><span class="n">declaration</span> <span class="o">==</span> <span class="n">QLatin1String</span><span class="p">(</span><span class="s">"parent"</span><span class="p">)</span> <span class="o">&&</span> <span class="n">m_context</span><span class="o">-></span><span class="n">topContext</span><span class="p">()</span><span class="o">-></span><span class="n">url</span><span class="p">().</span><span class="n">byteArray</span><span class="p">().</span><span class="n">endsWith</span><span class="p">(</span><span class="s">".qml"</span><span class="p">))</span> <span class="p">{</span></pre></td>
  </tr>

 </tbody>

</table>

  <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">use QmlJS::Document::Language here instead

also, the access pattern is broken, you first have to lock the duchain, then look at m_context->...

Maybe you added more of these issues elsewhere? please double-check!</pre>
 </blockquote>



 <p>On June 12th, 2014, 8:35 p.m. UTC, <b>Sven Brauch</b> wrote:</p>
 <blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
  <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">But you're holding the URL lock for that top context, right? So what would happen to it if you access it that way?</pre>
 </blockquote>





 <p>On June 12th, 2014, 9:09 p.m. UTC, <b>Sven Brauch</b> wrote:</p>
 <blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
  <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">As discussed in IRC, nobody knows for sure if this is safe ;) so it's probably better to hold the lock.</pre>
 </blockquote>







</blockquote>
<pre style="margin-left: 1em; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Regarding QmlJS::Document::Language, all ExpressionVisitor has is a DUContext (from which a TopDUContext can be retrieved), but QmlJS::Document::Language is only used in ParseSession, that doesn't seem to be stored somewhere (it is instantiated on the stack in QmlJsParseJob and is never stored anywhere else).

I was looking at parsing environments (ParsingEnvironmentFile and ParsingEnvironment), but adding a new parsing environment type and a new subclass of ParsingEnvironment seems a bit complex just to avoid half a dozen byteArray() calls ("parent" is never used in big plugin.qmltypes files and only rarely used in normal QML files). Do you have any suggestion on how I can get back the language of the file?</pre>
<br />




<p>- Denis</p>


<br />
<p>On June 12th, 2014, 7:27 p.m. UTC, Denis Steckelmacher wrote:</p>








<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 June 12, 2014, 7:27 p.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;">This patch adds a special-case for "parent" in ExpressionVisitor. Even if every QML object has a "parent" property of type QQuickItem, the user most of the time wants to refer to the enclosing QML component when he/she types "parent". If there is no enclosing QML component (the current component is a top-level one or something else happened), then ExpressionVisitor falls back to the old behavior and returns a QQuickItem instance.

I would like to be able to activate this special handling of "parent" only for QML files, because Javascript files may use "parent" for something else. Is it possible, given a DUContext, to find its language? (or is there a way for the QML/JS plugin to store in the DUContext that the file is a Javascript one or a QML one?)</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;">A new unit test has been added. "parent" is used to refer to the enclosing component of a sub-component, and uses are correctly built. The rest of the unit tests pass. Manual testing shows that the highlighting of "parent" and the code-completion for "parent." is as expected.</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>codecompletion/tests/qmlcompletiontest.cpp <span style="color: grey">(1b5cdee)</span></li>

 <li>duchain/expressionvisitor.cpp <span style="color: grey">(6545997)</span></li>

 <li>tests/files/test.qml <span style="color: grey">(2d3dc7d)</span></li>

</ul>

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







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








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