Review Request 115422: semi-intelligent keyword-based generic code completion model based on syntax files

Sven Brauch svenbrauch at googlemail.com
Mon Feb 3 21:18:51 UTC 2014


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/115422/
-----------------------------------------------------------

(Updated Feb. 3, 2014, 9:18 p.m.)


Review request for Kate and KDevelop.


Changes
-------

Fix issues indicated by Milian.
Re-layout code line to avoid using C++11 advanced brace initializers.

One more issue came across my way while testing this: When the syntax file says that its keywords are case-insensitive, they are converted to lowercase by the highlighting engine; then later it converts the words it compares against to lowercase too and just does "==". This means that the completion items will all be lowercase too. While not an issue for many languages (e.g. in PHP it's fine), in for example Mathematica it's just ugly (you don't want FourierTransform[] to be written fouriertransform[]).
The simplest way to fix that would be to keep the keywords as specified in the xml file in the highlighter's dict, and use Qt::CaseInsensitive when comparing instead of .toLower(). (that's most likely more efficient anyways, even when caching one of the .toLower results)
Is there a reason why that's a bad idea?

Dominik said he'd like Christoph to have a look at this before submission, who will return in ~2 weeks, so there's lots of time to polish it. :)


Repository: kate


Description
-------

This patch provides a new completion model which gathers items from the syntax files. It simply suggests all words which are listed as keywords for the highlighting context which is active at the position where completion was invoked.

To avoid storing all the places where the highlighting context changes, an option was added to the function which calculates the highlight, which allows to optionally get all the context changes in a QVector. When completion is invoked, the current line is re-highlighted, and the context switches are extracted; from that the highlighting context at the cursor position is determined. The keyword items from this context become the items of the completion model.

An option is provided in the settings dialog to turn this new model off.


Diffs (updated)
-----

  part/utils/kateglobal.h 491e8f8 
  part/utils/kateglobal.cpp f322074 
  part/view/kateview.cpp 9d9cff6 
  part/CMakeLists.txt 51af1b8 
  part/completion/katekeywordcompletion.h PRE-CREATION 
  part/completion/katekeywordcompletion.cpp PRE-CREATION 
  part/dialogs/completionconfigtab.ui 7cdb94f 
  part/dialogs/katedialogs.cpp aa0acba 
  part/syntax/katehighlight.h f3eb81b 
  part/syntax/katehighlight.cpp cd8b6a7 
  part/syntax/katehighlighthelpers.h 3f16f87 
  part/syntax/katehighlighthelpers.cpp f5c1823 
  part/utils/kateconfig.h a932533 
  part/utils/kateconfig.cpp 7667aee 

Diff: https://git.reviewboard.kde.org/r/115422/diff/


Testing
-------

Tested with various languages. Checked if there are any obvious interferences with kdevelop's supported languages.


File Attachments
----------------

CSS
  https://git.reviewboard.kde.org/media/uploaded/files/2014/02/01/92f2d072-5263-46c1-9edb-cdb81557b736__css.png
CSS + HTML
  https://git.reviewboard.kde.org/media/uploaded/files/2014/02/01/9c5a98d6-a8ff-4ba8-9deb-f0ab0dc37ec6__mixed.png
lua
  https://git.reviewboard.kde.org/media/uploaded/files/2014/02/01/315da290-5610-4083-8d8c-daaacabb3346__lua.png
bash ;)
  https://git.reviewboard.kde.org/media/uploaded/files/2014/02/01/0e806ffe-902b-4cf5-b750-68bcac80365b__bas.png
PHP
  https://git.reviewboard.kde.org/media/uploaded/files/2014/02/01/94271927-ab7b-4221-bb84-65ead2c1afac__php.png
gnuplot
  https://git.reviewboard.kde.org/media/uploaded/files/2014/02/01/b9aad427-6c1b-4c33-9c9d-c95625e26066__gnuplot.png
gnuplot; note that it has different completion items now, depending on context <3
  https://git.reviewboard.kde.org/media/uploaded/files/2014/02/01/24f9fb51-31ed-4f3f-8d3f-3ad36e698e1a__gnuplot2.png


Thanks,

Sven Brauch

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20140203/c59fc767/attachment.html>


More information about the KDevelop-devel mailing list