[PATCH] D35894: [clangd] Code hover for Clangd

Ilya Biryukov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 12 08:59:19 PST 2018


ilya-biryukov added a comment.

In https://reviews.llvm.org/D35894#1003356, @simark wrote:

> In https://reviews.llvm.org/D35894#1003342, @simark wrote:
>
> > The only problem I see is that when hovering a function/struct name, it now prints the whole function/struct definition.  When talking with @malaperle, he told me that you had discussed it before and we should not have the definition in the hover, just the prototype for a function and the name (e.g. "struct foo") for a struct.  Glancing quickly at the PrintingPolicy, I don't see a way to do that.  Do you have any idea?
>
>
> Arrg, Sorry, I just re-read your comment and saw that you used TerseOutput which does that.  I did not catch that when transcribing the code (I did not want to copy paste to understand the code better, but got bitten).


Yeah, the `TerseOutput` bit was important :-)

In https://reviews.llvm.org/D35894#1003342, @simark wrote:

> The only problem I see is that when hovering a function/struct name, it now prints the whole function/struct definition.  When talking with @malaperle, he told me that you had discussed it before and we should not have the definition in the hover, just the prototype for a function and the name (e.g. "struct foo") for a struct.  Glancing quickly at the PrintingPolicy, I don't see a way to do that.  Do you have any idea?


I'm not aware of the code that pretty-prints macros. There's a code that dumps debug output, but it's not gonna help in that case.
Alternatively, we could simply print the macro name and not print the definition. That's super-simple and is in line with hovers for the AST decls. Let's do that in the initial version.

For macros using the source code is also less of a problem, so we may try to do it. C++ doesn't allow to generate a macro inside another macro, so we don't run into the same problems we may hit with the AST. And the overall syntax is much simpler than for AST, so we can hope to get string manipulation right with reasonable effort. (Simply reindenting should do the trick).


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D35894





More information about the cfe-commits mailing list