forked from qt-creator/qt-creator
ClangCodeModel: Show value in tool tips, if possible
When hovering over a constant expression, it's probably helpful to show that value to the user. Requires clang 11 to fully work. For now, it only shows the value for variable initializations. Fixes: QTCREATORBUG-23967 Change-Id: I6b844231bac50993c2fa2fa82c552ad9cef590df Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
@@ -181,6 +181,22 @@ void ClangHoverHandler::processToolTipInfo(const CppTools::ToolTipInfo &info)
|
||||
|
||||
if (!info.sizeInBytes.isEmpty())
|
||||
text.append("\n\n" + tr("%1 bytes").arg(info.sizeInBytes));
|
||||
if (info.value.isValid()) {
|
||||
text.append("\n\n" + tr("Value: "));
|
||||
switch (info.value.type()) {
|
||||
case static_cast<QVariant::Type>(QMetaType::LongLong):
|
||||
text.append(QString::number(info.value.toLongLong()));
|
||||
break;
|
||||
case static_cast<QVariant::Type>(QMetaType::ULongLong):
|
||||
text.append(QString::number(info.value.toULongLong()));
|
||||
break;
|
||||
case static_cast<QVariant::Type>(QMetaType::Double):
|
||||
text.append(QString::number(info.value.toDouble()));
|
||||
break;
|
||||
default:
|
||||
QTC_CHECK(false);
|
||||
}
|
||||
}
|
||||
|
||||
setToolTip(text);
|
||||
m_reportPriority(priority());
|
||||
|
||||
Reference in New Issue
Block a user