Code completion problem in header files

Maciej Cencora m.cencora at gmail.com
Sun Jan 27 11:46:20 UTC 2013


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).

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.

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?

Regards,
Maciej Cencora

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Fix-completion-in-header-files.patch
Type: text/x-patch
Size: 5770 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20130127/d7a0994c/attachment.patch>


More information about the KDevelop-devel mailing list