<div dir="ltr"><div>We planned to start with hard-coding the most common cases. This is obviously hard to generalize, but should work nicely for the common things (mostly STL, maybe other libs if we're good at detecting those, but I'm not sure).</div><div>Annotating the type in the header would be perfect for the tools, but I wonder if people are willing to change the code for the sole purpose of improved tooling (you could argue this also serves documentation purposes). There will always be code that cannot be annotated, because users don't own it.<br></div><div><br></div><div>Alternative approaches that come to mind:</div><div>- Detecting constructor functions during indexing. (By looking at the function bodies or the most common functions used to "create" variables of some type).</div><div>  Pros: does not require any actions from the user.<br></div><div>  Cons: requires preprocessing of the code base to work, might be hard to make it work with index-while-build.</div><div>- Having external annotations (in addition to in-code annotations?), something that could give the tools enough info to do completions, e.g.<br></div><div>'{ type: "std::unique_ptr<$T>", construction: { insert_snippet: "std::make_unique<$T>($0)",  required_include: "<memory>" }' (the syntax can obviously be something else, e.g. C++ with attributes or YAML)</div><div>  Pros: do not need to change the code, potentially allows per-project config</div><div>  Cons: needs design (e.g. should C++ lang standards be taken into account?), agreement on where to put those configs, how to load them, etc.</div><div><br></div><div>We could also do both alternatives if we have infinite time: external annotations and ways to infer them from the code while indexing.</div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Aug 9, 2018 at 1:39 AM Alex L <<a href="mailto:arphaman@gmail.com">arphaman@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Thanks for putting this together!<div><br></div><div>I have one question:</div><div><br></div><div>In the example where an 'std::make_unique<A>' completion was added based on function argument type, how would Clang know that `std::unique_ptr` is constructed using `std::make_unique`? Would that be hardcoded into Clang, or would there be some way to annotate the type in the header (e.g. using an attribute) so that Clang can deduce this (e.g. for supporting `llvm::make_unique`, etc.).<br></div><div><br></div><div>Thanks,</div><div>Alex</div></div><br><div class="gmail_quote"><div dir="ltr">On Wed, 8 Aug 2018 at 02:58, Ilya Biryukov via clangd-dev <<a href="mailto:clangd-dev@lists.llvm.org" target="_blank">clangd-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi clangd-dev,<div><br></div><div>I have just posted a design doc about adding the expected types to the C++ completions:</div><div><a href="https://docs.google.com/document/d/1_BSeTIr2aLA6wKKCRCajSI0AdnjhvgK4BXXJQX-Dsro/edit#" target="_blank">https://docs.google.com/document/d/1_BSeTIr2aLA6wKKCRCajSI0AdnjhvgK4BXXJQX-Dsro/edit#</a><br></div><div><br></div><div>It serves two purposes:<br></div><div>- List possible improvements to code completion that can be gained by using more semantic information available in Clang.</div><div>- Discuss the design of type-based ranking in presence of the index, i.e. when some completions are not from Sema.<br></div><div><div><br></div><div>The first half of the document attempts to enumerate interesting cases where completions can be improved by using type information. It would be great to get ideas from anyone interested in improvements to ClangD completions in general,  the 'Anticipated Improvements' is there to collect a raw list of nice-to-have cases, feel free to contribue!</div><div><br></div><div>The second half is targeted at a narrower audience, specifically anyone who's interested in support of type-based ranking with index enabled in ClangD. If you're interested, please take a look.</div></div><div><br></div><div>Feedback and suggestions are very welcome!<br clear="all"><div><br></div>-- <br><div dir="ltr" class="m_1453174203516780495m_7202047701497240383gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>Regards,</div><div>Ilya Biryukov</div></div></div></div></div></div></div>
_______________________________________________<br>
clangd-dev mailing list<br>
<a href="mailto:clangd-dev@lists.llvm.org" target="_blank">clangd-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/clangd-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/clangd-dev</a><br>
</blockquote></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>Regards,</div><div>Ilya Biryukov</div></div></div></div></div>