ClangCodeModel: Properly parse function types for outline

Fixes: QTCREATORBUG-27587
Change-Id: Icf663e386fa90c209aa998d2d7ab7ae0fcb40792
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Kandeler
2022-05-25 17:33:01 +02:00
parent 603ea1c679
commit c6c919e671

View File

@@ -1550,11 +1550,29 @@ QString ClangdClient::displayNameFromDocumentSymbol(SymbolKind kind, const QStri
case SymbolKind::Constructor:
return name + detail;
case SymbolKind::Method:
case LanguageServerProtocol::SymbolKind::Function: {
const int parenOffset = detail.indexOf(" (");
if (parenOffset == -1)
case SymbolKind::Function: {
const int lastParenOffset = detail.lastIndexOf(')');
if (lastParenOffset == -1)
return name;
return name + detail.mid(parenOffset + 1) + " -> " + detail.mid(0, parenOffset);
int leftParensNeeded = 1;
int i = -1;
for (i = lastParenOffset - 1; i >= 0; --i) {
switch (detail.at(i).toLatin1()) {
case ')':
++leftParensNeeded;
break;
case '(':
--leftParensNeeded;
break;
default:
break;
}
if (leftParensNeeded == 0)
break;
}
if (leftParensNeeded > 0)
return name;
return name + detail.mid(i) + " -> " + detail.left(i);
}
case SymbolKind::Variable:
case SymbolKind::Field: