Code completion problem in header files

Milian Wolff mail at milianw.de
Tue Jan 29 00:14:30 UTC 2013


On Sunday 27 January 2013 12:46:20 Maciej Cencora wrote:
> Hi,
> 
> code completion in header files is somewhat broken.
> For file header.hpp like this:
> #ifndef HEADER_HPP
> #define HEADER_HPP
> 
> #include <vector>
> namespace a{{invoke manual code completion here}}
> {
> }
> 
> #endif
> 
> code completion suggests everything that was declared in included vector
> file. That's not really what we want (and that's not what is suggested when
> in cpp file - i.e. no header guards).

I've fixed that now by only showing namespaces in such cases.

> The problem seems to be in Cpp::preprocess which imports all macros defined
> in the passed file. Since in this case the file is header.hpp, parsing its
> text with the macros defined in it (esp. header guard) results in empty
> string. CodeCompletion will not be able to find the context code lines and
> it will report unuseful data.

To me it more looks like the issue was no existing code to handle this special 
case? See patch 12686bac5382838dfd0ddeb96b26952a83271798 to see how I did it.

> Attached patch fixes the problem, but I'm not sure that this is the right
> approach since the Cpp::preprocess function is used also in other places
> besides CodeCompletionContext::preprocess.
> 
> Could someone more familiar with cpp plugin take a look at this?

In the future please report bugs on bugs.kde.org and put patches up for review 
on reviewboard.kde.org.

Thanks
-- 
Milian Wolff
mail at milianw.de
http://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/20130129/2aa9f048/attachment.sig>


More information about the KDevelop-devel mailing list