@@ -1274,10 +1274,10 @@ std::optional<HoverInfo> getHover(ParsedAST &AST, Position Pos,
1274
1274
HoverCountMetric.record (1 , " include" );
1275
1275
HoverInfo HI;
1276
1276
HI.Name = std::string (llvm::sys::path::filename (Inc.Resolved ));
1277
- // FIXME: We don't have a fitting value for Kind.
1278
1277
HI.Definition =
1279
1278
URIForFile::canonicalize (Inc.Resolved , AST.tuPath ()).file ().str ();
1280
1279
HI.DefinitionLanguage = " " ;
1280
+ HI.Kind = index::SymbolKind::IncludeDirective;
1281
1281
maybeAddUsedSymbols (AST, HI, Inc);
1282
1282
return HI;
1283
1283
}
@@ -1483,10 +1483,6 @@ void HoverInfo::sizeToMarkupParagraph(markup::Paragraph &P) const {
1483
1483
}
1484
1484
1485
1485
markup::Document HoverInfo::presentDoxygen () const {
1486
- // NOTE: this function is currently almost identical to presentDefault().
1487
- // This is to have a minimal change when introducing the doxygen parser.
1488
- // This function will be changed when rearranging the output for doxygen
1489
- // parsed documentation.
1490
1486
1491
1487
markup::Document Output;
1492
1488
// Header contains a text of the form:
@@ -1502,45 +1498,108 @@ markup::Document HoverInfo::presentDoxygen() const {
1502
1498
// level 1 and 2 headers in a huge font, see
1503
1499
// https://github.com/microsoft/vscode/issues/88417 for details.
1504
1500
markup::Paragraph &Header = Output.addHeading (3 );
1505
- if (Kind != index::SymbolKind::Unknown)
1501
+ if (Kind != index::SymbolKind::Unknown &&
1502
+ Kind != index::SymbolKind::IncludeDirective)
1506
1503
Header.appendText (index::getSymbolKindString (Kind)).appendSpace ();
1507
1504
assert (!Name.empty () && " hover triggered on a nameless symbol" );
1508
1505
1509
- Header.appendCode (Name);
1506
+ if (Kind == index::SymbolKind::IncludeDirective) {
1507
+ Header.appendCode (Name);
1508
+
1509
+ if (!Definition.empty ())
1510
+ Output.addParagraph ().appendCode (Definition);
1511
+
1512
+ if (!UsedSymbolNames.empty ()) {
1513
+ Output.addRuler ();
1514
+ usedSymbolNamesToMarkup (Output);
1515
+ }
1516
+
1517
+ return Output;
1518
+ }
1519
+
1520
+ if (!Definition.empty ()) {
1521
+ Output.addRuler ();
1522
+ definitionScopeToMarkup (Output);
1523
+ } else {
1524
+ Header.appendCode (Name);
1525
+ }
1510
1526
1511
1527
if (!Provider.empty ()) {
1512
1528
providerToMarkupParagraph (Output);
1513
1529
}
1514
1530
1515
1531
// Put a linebreak after header to increase readability.
1516
1532
Output.addRuler ();
1517
- // Print Types on their own lines to reduce chances of getting line-wrapped by
1518
- // editor, as they might be long.
1519
- if (ReturnType) {
1520
- // For functions we display signature in a list form, e.g.:
1521
- // → `x`
1522
- // Parameters:
1523
- // - `bool param1`
1524
- // - `int param2 = 5`
1525
- Output.addParagraph ().appendText (" → " ).appendCode (
1526
- llvm::to_string (*ReturnType));
1527
- }
1528
1533
1529
1534
SymbolDocCommentVisitor SymbolDoc (Documentation, CommentOpts);
1530
1535
1536
+ if (SymbolDoc.hasBriefCommand ()) {
1537
+ SymbolDoc.briefToMarkup (Output.addParagraph ());
1538
+ Output.addRuler ();
1539
+ }
1540
+
1541
+ // For functions we display signature in a list form, e.g.:
1542
+ // Template Parameters:
1543
+ // - `typename T` - description
1544
+ // Parameters:
1545
+ // - `bool param1` - description
1546
+ // - `int param2 = 5` - description
1547
+ // Returns
1548
+ // `type` - description
1549
+ if (TemplateParameters && !TemplateParameters->empty ()) {
1550
+ Output.addParagraph ().appendBoldText (" Template Parameters:" );
1551
+ markup::BulletList &L = Output.addBulletList ();
1552
+ for (const auto &Param : *TemplateParameters) {
1553
+ markup::Paragraph &P = L.addItem ().addParagraph ();
1554
+ P.appendCode (llvm::to_string (Param));
1555
+ if (SymbolDoc.isTemplateTypeParmDocumented (llvm::to_string (Param.Name ))) {
1556
+ P.appendText (" - " );
1557
+ SymbolDoc.templateTypeParmDocToMarkup (llvm::to_string (Param.Name ), P);
1558
+ }
1559
+ }
1560
+ Output.addRuler ();
1561
+ }
1562
+
1531
1563
if (Parameters && !Parameters->empty ()) {
1532
- Output.addParagraph ().appendText (" Parameters:" );
1564
+ Output.addParagraph ().appendBoldText (" Parameters:" );
1533
1565
markup::BulletList &L = Output.addBulletList ();
1534
1566
for (const auto &Param : *Parameters) {
1535
1567
markup::Paragraph &P = L.addItem ().addParagraph ();
1536
1568
P.appendCode (llvm::to_string (Param));
1537
1569
1538
1570
if (SymbolDoc.isParameterDocumented (llvm::to_string (Param.Name ))) {
1539
- P.appendText (" -" );
1571
+ P.appendText (" - " );
1540
1572
SymbolDoc.parameterDocToMarkup (llvm::to_string (Param.Name ), P);
1541
1573
}
1542
1574
}
1575
+ Output.addRuler ();
1576
+ }
1577
+
1578
+ // Print Types on their own lines to reduce chances of getting line-wrapped by
1579
+ // editor, as they might be long.
1580
+ if (ReturnType &&
1581
+ ((ReturnType->Type != " void" && !ReturnType->AKA .has_value ()) ||
1582
+ (ReturnType->AKA .has_value () && ReturnType->AKA != " void" ))) {
1583
+ Output.addParagraph ().appendBoldText (" Returns:" );
1584
+ markup::Paragraph &P = Output.addParagraph ();
1585
+ P.appendCode (llvm::to_string (*ReturnType));
1586
+
1587
+ if (SymbolDoc.hasReturnCommand ()) {
1588
+ P.appendText (" - " );
1589
+ SymbolDoc.returnToMarkup (P);
1590
+ }
1591
+ Output.addRuler ();
1543
1592
}
1593
+
1594
+ // add specially handled doxygen commands.
1595
+ SymbolDoc.warningsToMarkup (Output);
1596
+ SymbolDoc.notesToMarkup (Output);
1597
+
1598
+ // add any other documentation.
1599
+ SymbolDoc.docToMarkup (Output);
1600
+
1601
+ Output.addRuler ();
1602
+
1544
1603
// Don't print Type after Parameters or ReturnType as this will just duplicate
1545
1604
// the information
1546
1605
if (Type && !ReturnType && !Parameters)
@@ -1561,13 +1620,6 @@ markup::Document HoverInfo::presentDoxygen() const {
1561
1620
calleeArgInfoToMarkupParagraph (Output.addParagraph ());
1562
1621
}
1563
1622
1564
- SymbolDoc.docToMarkup (Output);
1565
-
1566
- if (!Definition.empty ()) {
1567
- Output.addRuler ();
1568
- definitionScopeToMarkup (Output);
1569
- }
1570
-
1571
1623
if (!UsedSymbolNames.empty ()) {
1572
1624
Output.addRuler ();
1573
1625
usedSymbolNamesToMarkup (Output);
@@ -1591,7 +1643,8 @@ markup::Document HoverInfo::presentDefault() const {
1591
1643
// level 1 and 2 headers in a huge font, see
1592
1644
// https://github.com/microsoft/vscode/issues/88417 for details.
1593
1645
markup::Paragraph &Header = Output.addHeading (3 );
1594
- if (Kind != index::SymbolKind::Unknown)
1646
+ if (Kind != index::SymbolKind::Unknown &&
1647
+ Kind != index::SymbolKind::IncludeDirective)
1595
1648
Header.appendText (index::getSymbolKindString (Kind)).appendSpace ();
1596
1649
assert (!Name.empty () && " hover triggered on a nameless symbol" );
1597
1650
Header.appendCode (Name);
@@ -1615,7 +1668,7 @@ markup::Document HoverInfo::presentDefault() const {
1615
1668
}
1616
1669
1617
1670
if (Parameters && !Parameters->empty ()) {
1618
- Output.addParagraph ().appendText (" Parameters: " );
1671
+ Output.addParagraph ().appendText (" Parameters:" );
1619
1672
markup::BulletList &L = Output.addBulletList ();
1620
1673
for (const auto &Param : *Parameters)
1621
1674
L.addItem ().addParagraph ().appendCode (llvm::to_string (Param));
0 commit comments