Feature: string filtering for code completion [Patch attached]

Eduardo Robles Elvira edulix at gmail.com
Wed Jul 14 23:29:43 UTC 2010


Hello everyone!

First mail to this list =) I use kdevelop a lot so I figured out that
I should start contributing a bit back. I have this idea for code
completion that I want to share with you, so that you can help me give
it form and also hopefully give me some hints about how to implement
it. Kdevelop code completion is awesome, it find possible completion
in many different contexts when working in C++ or PHP.

The idea is to be able to filter the completions when accessing a
member function/var. So say for example a have a QString myString;
then I start writting myString.qbytearray. At the moment, this doesn't
show any completion because there's no function starting with the
filter string  "qbytearray".

If you write instead "QByteArray myArray = s.",  then KDevelop
provides as best matches the QString member functions which return a
QByteArray, and that's really nice. But I might be trying to get a
function that takes a QByteString as an argument, and there' no way to
get best matches for that. That's what I want to do.

Also, best matches sometimes don't help because you might be writing
"QByteArray myArray = s." and get those best matches that provide a
QByteArray, but maybe what you want is to do something like
"QByteArray myArray = s.left(10).toAscii()". For having correct best
matches in that case, I argue it would be nice to write "QByteArray
myArray = s.QString", select in the completion the left function, and
then use the current best matches for QByteArray.

Some argued that it's not really intuitive and it might need it's own
shortcut for this new kind of completion. I'm not really sure about
that, I want to try first as a new way to provide best matches, which
normally is triggered when no other matches are shown (non-constructor
member functions usually are not named as data types :P).

How to implement this? I already did that part ;-) patch attached.
Apply at kdelibs/kate/completion. It's a not review-ready patch, but
more like a proof-of-concept. I tested and it works fine, I love it
already!

Regards,
   Eduardo Robles Elvira.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: string-filtering-completion.patch
Type: text/x-patch
Size: 1888 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20100715/d53c28e6/attachment.patch>


More information about the KDevelop-devel mailing list