Commit bf69b4c4 authored by Przemyslaw Gorszkowski's avatar Przemyslaw Gorszkowski Committed by Nikolai Kosjar
Browse files

C++: wrong tooltip behind function without args



Example code:
float fun()
{
    return 0;
}

Hovering in the area behind the function without args(but in the same line,
in above example after "float fun()") will bring up tooltip with returned
value of this function(in the above example it will be "float").

Fixed by checking this special case after gathering results for tooltip
and don't show confusing tooltip.

Task-number: QTCREATORBUG-4780
Change-Id: Iab2bacddf33a70d5ea941001a2dd317c824d9db5
Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@digia.com>
parent a79d47c8
......@@ -113,7 +113,7 @@ void CppElementEvaluator::execute()
return;
const LookupItem &lookupItem = lookupItems.first(); // ### TODO: select best candidate.
handleLookupItemMatch(snapshot, lookupItem, typeOfExpression.context());
handleLookupItemMatch(snapshot, lookupItem, typeOfExpression.context(), scope);
}
}
......@@ -155,11 +155,17 @@ bool CppElementEvaluator::matchMacroInUse(const CPlusPlus::Document::Ptr &docume
void CppElementEvaluator::handleLookupItemMatch(const Snapshot &snapshot,
const LookupItem &lookupItem,
const LookupContext &context)
const LookupContext &context,
const Scope *scope)
{
Symbol *declaration = lookupItem.declaration();
if (!declaration) {
const QString &type = Overview().prettyType(lookupItem.type(), QString());
// special case for bug QTCREATORBUG-4780
if (scope && scope->isFunction()
&& lookupItem.type().isEqualTo(scope->asFunction()->returnType())) {
return;
}
m_element = QSharedPointer<CppElement>(new Unknown(type));
} else {
const FullySpecifiedType &type = declaration->type();
......
......@@ -76,7 +76,8 @@ private:
bool matchMacroInUse(const CPlusPlus::Document::Ptr &document, unsigned pos);
void handleLookupItemMatch(const CPlusPlus::Snapshot &snapshot,
const CPlusPlus::LookupItem &lookupItem,
const CPlusPlus::LookupContext &lookupContext);
const CPlusPlus::LookupContext &lookupContext,
const CPlusPlus::Scope *scope);
CPPEditorWidget *m_editor;
CppTools::CppModelManagerInterface *m_modelManager;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment