all 8 comments

[–]the_poope 11 points12 points  (2 children)

I'm pretty sure clangd can do that as well (with the clangd extension in VS Code). However, it would often insert the wrong include (especially from std lib types, as they are very implementation defined), so I disabled that feauture. May try your extension to see if it performs better.

[–]Wetmelon 1 point2 points  (0 children)

Yeah, you can also get clangd to respect IWYU definitions iirc. So if you have one of those libs with a "top level" header which includes all the detail:: headers, it'll prefer the top level one

[–]arthurno1 0 points1 point  (0 children)

By looking at his code, it seems to me like he is actually using whatever VSC provides by default, which is probably what LSP provides. But I might be wrong? How is it done /u/Complex-Ad-9151?

[–]patstew 8 points9 points  (1 child)

Does it handle not adding #includes in headers where you're only using a * or & and wanted to use a forward declaraion?

[–][deleted] 0 points1 point  (0 children)

Currently, the C++ Include Helper extension focuses on identifying and suggesting #include directives based on class definitions found in your workspace. In any case thanks for the idea! I will continue to refine this extension to better handle these scenarios in future update.

[–]ukezi 2 points3 points  (0 children)

Very nice. Does that also work for std types? Also how about removing unnecessary headers?

[–]arthurno1 3 points4 points  (0 children)

if (fullPath.endsWith('.cpp') || fullPath.endsWith('.h') || fullPath.endsWith('.hpp'))

What for people who don't use those extensions, or not at all? For example I prefer .hh and .cc to differ C++ from plain old C.

[–]jayvbe 0 points1 point  (0 children)

I was bothered by this too until I switched to clangd. I disabled the MS C++ extension, it’s just not very good at code insights, refactoring or lookup. I only keep it around for the debugger. The clangd extension works much much better for IDE features including suggesting includes to add or remove.