KDev-Clang and missing include-support

Jørgen Kvalsvik jorgekva at stud.ntnu.no
Thu Mar 20 14:18:29 UTC 2014


On 03/20/2014 02:38 PM, Todd Nowacki wrote:
> Hi,
> 
> Progress has been slow as I have been trying to understand the Clang
> API, but I think it is starting to get there.
You and me both.

> So far, I haven't seen as much functionality in the clang-c API for
> these two cases for missing includes as Milian might have hoped. 
I've poked a bit around in libclang as well, and there really doesn't
seem to be anything there to single out a missing include or forward
declaration. I still think we can be able to figure it out or make a
pretty good approximation.

The action that triggers a "missing include"-style thing is whenever a
type is used, but never declared. Clang reports this as "use of
undeclared identifier". In libclang you can query for error category,
and this is a semantic error. We can probably use this as an assumption
to suggest a missing include.

> As of yesterday, my current plan is to use the clang_codeCompleteAt to
> see if the type of CXCursor is of the kind CXCursor_NoDeclFound. From
> there, we might be able to proceed as Milian suggested in his last two
> paragraphs.
> 
> In short, I would love some help with this. I will probably not be able
> to work on this again until this Sunday, but if you have any ideas or if
> you have any partial solutions, let me know.
I think adding a problem/fixit in the duchain could be a solution. This
way it can both be exposed to the codecompleter as well as any other
solution browser. To me it seems like the better architectural choice,
rather than having the codecompleter deal with semantical analysis.

Of course, then the codecompleter could tap into the duchain and suggest
types from possible includes as well.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: OpenPGP digital signature
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20140320/9531b00f/attachment.sig>


More information about the KDevelop-devel mailing list