Skip to content

Commit e67eec6

Browse files
author
git apple-llvm automerger
committed
Merge commit '7bb785cc339b' from llvm.org/main into next
2 parents d9e6571 + 7bb785c commit e67eec6

File tree

2 files changed

+41
-11
lines changed

2 files changed

+41
-11
lines changed

clang-tools-extra/clangd/Hover.cpp

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,20 +1058,24 @@ markup::Document HoverInfo::present() const {
10581058
// - `bool param1`
10591059
// - `int param2 = 5`
10601060
Output.addParagraph().appendText("").appendCode(*ReturnType);
1061-
if (Parameters && !Parameters->empty()) {
1062-
Output.addParagraph().appendText("Parameters: ");
1063-
markup::BulletList &L = Output.addBulletList();
1064-
for (const auto &Param : *Parameters) {
1065-
std::string Buffer;
1066-
llvm::raw_string_ostream OS(Buffer);
1067-
OS << Param;
1068-
L.addItem().addParagraph().appendCode(std::move(OS.str()));
1069-
}
1061+
}
1062+
1063+
if (Parameters && !Parameters->empty()) {
1064+
Output.addParagraph().appendText("Parameters: ");
1065+
markup::BulletList &L = Output.addBulletList();
1066+
for (const auto &Param : *Parameters) {
1067+
std::string Buffer;
1068+
llvm::raw_string_ostream OS(Buffer);
1069+
OS << Param;
1070+
L.addItem().addParagraph().appendCode(std::move(OS.str()));
10701071
}
1071-
} else if (Type) {
1072-
Output.addParagraph().appendText("Type: ").appendCode(*Type);
10731072
}
10741073

1074+
// Don't print Type after Parameters or ReturnType as this will just duplicate
1075+
// the information
1076+
if (Type && !ReturnType && !Parameters)
1077+
Output.addParagraph().appendText("Type: ").appendCode(*Type);
1078+
10751079
if (Value) {
10761080
markup::Paragraph &P = Output.addParagraph();
10771081
P.appendText("Value = ");

clang-tools-extra/clangd/unittests/HoverTests.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2680,6 +2680,32 @@ public: def)",
26802680
26812681
// In cls<int>
26822682
protected: int method())",
2683+
},
2684+
{
2685+
[](HoverInfo &HI) {
2686+
HI.Definition = "cls(int a, int b = 5)";
2687+
HI.AccessSpecifier = "public";
2688+
HI.Kind = index::SymbolKind::Constructor;
2689+
HI.NamespaceScope = "";
2690+
HI.LocalScope = "cls";
2691+
HI.Name = "cls";
2692+
HI.Parameters.emplace();
2693+
HI.Parameters->emplace_back();
2694+
HI.Parameters->back().Type = "int";
2695+
HI.Parameters->back().Name = "a";
2696+
HI.Parameters->emplace_back();
2697+
HI.Parameters->back().Type = "int";
2698+
HI.Parameters->back().Name = "b";
2699+
HI.Parameters->back().Default = "5";
2700+
},
2701+
R"(constructor cls
2702+
2703+
Parameters:
2704+
- int a
2705+
- int b = 5
2706+
2707+
// In cls
2708+
public: cls(int a, int b = 5))",
26832709
},
26842710
{
26852711
[](HoverInfo &HI) {

0 commit comments

Comments
 (0)