[clangd-dev] additional TextEdits on code completion

Sam McCall via clangd-dev clangd-dev at lists.llvm.org
Wed Apr 3 05:57:04 PDT 2019


Sorry about that :-( +Eric Liu <ioeric at google.com> who may have thoughts.
I don't think we have an option to disable includes today, maybe we should
add one...

But we don't expect the inserted includes to create compile errors - *this
is probably a bug, it'd be great if you could provide more details* (is it
the right header but spelled wrong, or the wrong header entirely, etc). It
may be that you'd like this feature if it worked properly.

---

For turning this off, there are a few cases to consider.
Completions come from the current AST and clangd's index, header insertions
always comes from clangd's index.
A) the suggestion comes from the AST, not the index
B) the suggestion comes from both the AST and the index, and the suggested
header is already directly included
C) the suggestion comes from both the AST and the index, and the suggested
header is not directly included
D) the suggestion comes from the index only, and the suggested header is
directly included
E) the suggestion comes from the index only, and the suggested header is
not directly included

Currently we insert #includes in cases C and E.
Possible alternative behaviors (that could be controlled by a flag, or be
the default):
 - never insert. Allows completions of type E to break the code if the
header is not transitively included.
 - never insert, and disallow completions of type E. This will lose a lot
of essential completions.
 - insert in case E only. In case C, the code will still compile. This is
somewhat a style question (include-what-you-use), but has some other subtle
implications (e.g. for completions of incomplete class types).


On Wed, Apr 3, 2019 at 11:38 AM Aneesh Kumar K.V via clangd-dev <
clangd-dev at lists.llvm.org> wrote:

>
> Hi All,
>
> I am finding that with clangd after a function name code completion it
> adds a header to the top of the file. This almost always results in
> compilation error with my project and I would like to disable that
> header file addition to the .c file. I don't see a command line option
> that will help disable the feature. Any option i can use to disable?
> this?
>
> -aneesh
>
> _______________________________________________
> clangd-dev mailing list
> clangd-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/clangd-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/clangd-dev/attachments/20190403/7c51d924/attachment-0001.html>


More information about the clangd-dev mailing list