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










<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
 <p style="margin-top: 0;">On Sierpień 26th, 2015, 8:29 po południu 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/124934/diff/1/?file=398792#file398792line343" style="color: black; font-weight: bold; text-decoration: underline;">language/duchain/duchainutils.cpp</a>
    <span style="font-weight: normal;">

     (Diff revision 1)

    </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; ">KTextEditor::Range DUChainUtils::itemRangeUnderCursor(const QUrl& url, const KTextEditor::Cursor& cursor)</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">343</font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">          <span class="n">decl</span> <span class="o">=</span> <span class="n">declarationUnderCursor</span><span class="p">(</span><span class="n">c</span><span class="p">,</span> <span class="n">ctx</span><span class="o">-></span><span class="n">parentContext</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;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">can you give me an example code and explicit instructions to trigger this bug? recursive functions e.g. should work fine - and they do in principal just what you say: finding the function in its own context.</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">also, this should be a separate commit. ideally, it should also be covered by a unit test in oldcpp or kdev-clang, depending on what you used for testing.</p></pre>
 </blockquote>



 <p>On Sierpień 27th, 2015, 7:43 rano UTC, <b>Maciej Cencora</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;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">By function name I meant function identifier in its declaration/definition. I'm using kdev-clang.</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">example code:
int fun(float param)
{
    bool local;
}</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">duchainify output:
Context:
  Top-Context "Global" (owner:  0x0 ) 0x122cb90 "" [ "" ] [ (0, 0)  ->  (2147483647, 2147483647) ] "/home/mcencora/projects/test/main2.cpp" 
     Declaration: "int fun (float)" [ "fun" ] 0x1296b30 (internal ctx: 0x12968d0 ) [ (0, 4)  ->  (0, 7) ] , defined,  0 use(s). 
      Definition: [ (0, 4)  ->  (0, 7) ] 
    Context "Function" (owner:  0x1296b30 ) 0x12968d0 "fun" [ "fun" ] [ (0, 0)  ->  (3, 1) ] "" 
       Declaration: "float param" [ "fun::param" ] 0x1296ac0 (internal ctx: 0x0 ) [ (0, 14)  ->  (0, 19) ] , no definition,  0 use(s). 
      Context "Other" (owner:  0x0 ) 0x1296990 "" [ "fun" ] [ (1, 0)  ->  (3, 1) ] "" 
         Declaration: "bool local" [ "fun::local" ] 0x1296a50 (internal ctx: 0x0 ) [ (2, 9)  ->  (2, 14) ] , no definition,  0 use(s).</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">The algorithm inside itemRangeUnderCursor is "greedy" - it tries to find the most specific context.
When moving mouse over the "fun" identifier, it finds that "Function" context contains the range of this identifier, and later it tries to find a declaration named "fun" inside it which of course fails.</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">I think the ideal fix would be to store a map of (range, declaration/use ptr) instead of traversing the context tree, but I don't know if that wouldn't break other cases.</p></pre>
 </blockquote>





 <p>On Sierpień 28th, 2015, 9:58 rano UTC, <b>Sergey Kalinichev</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;">I'm wondering whether 99772579 in kdev-clang (duchain/clanghelpers.cpp) is the reason for that. If so, we should probably add a similar fix here too.</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;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">Most probably. Where should I put test for this? In tests/test_duchain.cpp</p></pre>
<br />




<p>- Maciej</p>


<br />
<p>On Sierpień 27th, 2015, 1:08 po południu UTC, Maciej Cencora wrote:</p>








<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="12" style="border: 1px #888a85 solid; border-radius: 6px; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
 <tr>
  <td>

<div>Review request for KDevelop.</div>
<div>By Maciej Cencora.</div>


<p style="color: grey;"><i>Updated Sie 27, 2015, 1:08 po południu</i></p>









<div style="margin-top: 1.5em;">
 <b style="color: #575012; font-size: 10pt;">Repository: </b>
kdevplatform
</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;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">Actually make use of ActiveToolTip::addExtendedRect (renamed to setHandleRect).
This functionality was lost with d77a4ecda51c324eec589167da3214d21a1eff42</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">Minor change was also needed in itemRangeUnderCursor:
DUContext::findContextAt for cursor at function name returns the function's context, searching for function's name inside it will fail - we need to search in parent context.</p></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;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">Manual</p></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>language/duchain/duchainutils.cpp <span style="color: grey">(a1ff0f5)</span></li>

 <li>util/activetooltip.cpp <span style="color: grey">(e45116c)</span></li>

</ul>

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






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







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