This is very useful when inlay hints are disabled.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang-tools-extra/clangd/Hover.cpp | ||
---|---|---|
812 | (I also modified this function, so I added this forward declaration for easier review. If this patch gets accepted, I'd move the definition up to here before landing) | |
831 | HoverInfo::present has an assertion that the Name has to be non-empty. I'm open for other name suggestions here (Or we could of course adjust HoverInfo::present instead) |
clang-tools-extra/clangd/Hover.cpp | ||
---|---|---|
782 | nit: "contents" seems a bit strange now that this is no longer necessarily the entirety of the hover contents (nor is it the string literal's contents) maybe name it addStringLiteralInfo? | |
827 | nit: for consistency with non-literal expressions, maybe the CalleeArgInfo should come after the other contents of the hover? | |
831 | It at least seems no worse than "expression" for other expressions. I think the expression's value would be more useful (and despite the "not much value" comment above, I think there can be value in showing this if e.g. the expression is written as hex and the hover shows you the decimal value), but that can be left for a later change. | |
848 | Any reason not to also add CalleeArgInfo in this branch? I know this branch is not for literals so I'm suggesting to expand the scope of the patch, feel free to leave this for later, but conceptually I don't see why the CalleeArgInfo would be any less useful for non-literal expressions that take this branch. |
Do you want to add a simple test case for a non-literal expression? Something like hovering over the + in 2 + 3 should work.
Also, this is pre-existing, but I noticed that in a case like this:
void bar(int); void func() { int x = 42; bar(x); }
the hover for x includes a line that just says Passed -- is that useful in any way? Should we just omit the CalleeArgInfo a case like that?
Will do!
Also, this is pre-existing, but I noticed that in a case like this:
void bar(int); void func() { int x = 42; bar(x); }the hover for x includes a line that just says Passed -- is that useful in any way? Should we just omit the CalleeArgInfo a case like that?
Hmm, the thing is that if the function signature is void bar(int&), then "Passed by reference" would be useful again, so we can't just add a if (!CalleeArgInfo->Name.empty()) around the OS << "Passed "; Maybe we could instead display "Passed by value" if and only if the name is empty?
nit: "contents" seems a bit strange now that this is no longer necessarily the entirety of the hover contents (nor is it the string literal's contents)
maybe name it addStringLiteralInfo?