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: Nikolai Kosjar <nikolai.kosjar@digia.com>
This commit is contained in:
Przemyslaw Gorszkowski
2013-08-18 21:47:14 +02:00
committed by Nikolai Kosjar
parent a79d47c888
commit bf69b4c444
2 changed files with 10 additions and 3 deletions

View File

@@ -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();

View File

@@ -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;