Feature: string filtering for code completion [Patch attached]

Milian Wolff mail at milianw.de
Thu Jul 15 10:39:27 UTC 2010

On Thursday, 15. July 2010 01:29:43 Eduardo Robles Elvira wrote:
> 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!

Wow, I'm surprised that the patch is so small. Pretty cool.

How slow exactly is it, do you notice it?

And another point in favor of using a special shortcut for it, is that your 
code would "fail" (as percieved by the user) in cases where you have a 
member/method starting  with a string, that you actually want to find a 
function for that takes it as a argument or something like that. I mean e.g.:

struct foo {
  String stringVal();
  void append(String);

foo.string => only stringVal() is returned.
Milian Wolff
mail at milianw.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20100715/5095a5dc/attachment.sig>

More information about the KDevelop-devel mailing list