duchain: on updating the duchain

David nolden zwabel at googlemail.com
Fri Jan 23 06:56:46 UTC 2009


Am Donnerstag 22 Januar 2009 04:17:24 schrieb Aleix Pol:
> hi list,
> CMake's having some problem with the smart cursors (I think).
>
> I can load and edit a cmake file just fine, but if I add N lines (for
> example) and I save (then reparse) the file, the highlighted ranges are
> located N lines after where they should be.
>
> Any hint about how to solve that? :)
>
> Thanks,
> Aleix
As hamish said, you have to make sure you use the correct document revision, 
and also that you actually retrieve the document from the editor if it has 
been edited! In the moment you retrieve the text, you have to call something 
like "(KTextEditor::SmartInterface* smart = 
dynamic_cast<KTextEditor::SmartInterface*>(document); (Lock smart-interface 
using editor-integrator here) if(smart) { revision = smart->currentRevision(); 
smart->useRevision(revision); }; QString textToPart = document->text(); ". 
Then your smart-ranges will be translated with all the changes you've done in 
between. But make sure that you also clear the revision again, by calling 
smart->clearRevision().

Actually the issue you mention nearly sounds as if useRevision(..) is called, 
without calling clearRevision(). This would lead to all created ranges being 
translated falsely.

You should check whether KDevelop creates a ParseJob for the CMakeLists.txt, 
because ParseJob does that part of calling useRevision automatically. Since 
you don't use the parsing framework, you should make sure this never happens.

Greetings, David






More information about the KDevelop-devel mailing list