when a token is selected, the code completion plug-in tests whether it is a known class, then looks up the corresponding include file. If there is a match, an option is added in contextual menu: "Insert include file".
What do you mean when you say "selected"? Highlighted? Right-clicked? Initially typed?
It sounds like a nice idea, but I can think of many reasons why this would be much more problematic in C++ than it would be in Java.
Everybody knows that the DrewBooWidget library requires you to #include<DrewBooWidgets.h> to use any of it.
Simple!
Even if code-completion knows that the DrewBooWidget::CurlyCue you just instantiated is declared in <DrewBooWidgets/private/curlycue.h>, it won't compile with that include because you need to include other files first.
Whoops #1.And if DEBUG is defined, it should actually include <DrewBooWidgets/private/curlycue_debug.h>
Whoops #2.And when it finds out which header is the correct one to use, where in your source file should the include be added? At the top of the file, it could miss important #defines. Before the first existing #include, it could clobber precompiled headers. After the last existing #include, which happens to be inside an "#if 0" block?
Whoops #3.I agree that it can be a pain to manage these includes in your head, but that seems to be a problem that's very deeply embedded in the C++ language itself.
This might be one of those features that would be easy to implement if you wanted it to work 90% of the time, and would be very difficult just to get close to 100% of the time.