[cfe-dev] libclang's code completion APIs give unexpected results for Objective-C

Michael Bolin bolinfest at gmail.com
Wed Apr 23 17:13:58 PDT 2014


Here I have a very small .m file where I have typed "NSL" and would expect
the top code completion suggestion to be "NSLog()":

https://gist.github.com/bolinfest/11236613

Here is my C code that calls libclang and uses it to get suggested code
completions:

https://gist.github.com/bolinfest/11236626

Here are the suggestions I get when I run my C code (the command that I ran
is `./main.o Hello.m 5 6`):

https://gist.github.com/bolinfest/11236652

Some surprising results:

(1) libclang gives me over 5000 suggestions.
(2) NSLog() is in the list, but its priority is 50. There are all sorts of
other suggestions that seem less relevant, but have a lower priority
(counterintuitively, this means higher probability of being clicked on:
http://clang.llvm.org/doxygen/group__CINDEX__CODE__COMPLET.html#ga46e843acdf63d9a7a0c7341a2d222c49).
Search for "priority=40" in the gist to see examples of results with a
lower priority that seem less relevant.
(3) The order in which things appear in the results appears to be random. I
see that clang has a convenience function to sort results alphabetically,
but not by priority.

Are there additional arguments that I need to pass to libclang to tune
things so that the results I get from clang_codeCompleteAt() are more in
line with what I expect?

Thank you,
Michael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140423/48063bd4/attachment.html>


More information about the cfe-dev mailing list