Commit 9e3e5b4b authored by Leandro Melo's avatar Leandro Melo
Browse files

C++ tooltip: Fixing name qualification.

To conform with recent changes that affected LookupContext::fullyQualifiedName.
parent 0adadf0f
...@@ -283,37 +283,23 @@ void CppHoverHandler::handleLookupItemMatch(const LookupItem &lookupItem, const ...@@ -283,37 +283,23 @@ void CppHoverHandler::handleLookupItemMatch(const LookupItem &lookupItem, const
overview.setShowFullyQualifiedNamed(true); overview.setShowFullyQualifiedNamed(true);
if (!matchingDeclaration && assignTooltip) { if (!matchingDeclaration && assignTooltip) {
m_toolTip = overview.prettyType(matchingType, QLatin1String("")); m_toolTip = overview.prettyType(matchingType, QString());
} else { } else {
QString qualifiedName; QString qualifiedName;
HelpCandidate::Category helpCategory;
if (matchingDeclaration->enclosingSymbol()->isClass() || if (matchingDeclaration->enclosingSymbol()->isClass() ||
matchingDeclaration->enclosingSymbol()->isNamespace() || matchingDeclaration->enclosingSymbol()->isNamespace() ||
matchingDeclaration->enclosingSymbol()->isEnum()) { matchingDeclaration->enclosingSymbol()->isEnum()) {
// Fully qualify the name if enclosed by a class, namespace or enum. const QList<const Name *> &names =
QList<const Name *> names = LookupContext::fullyQualifiedName(matchingDeclaration); LookupContext::fullyQualifiedName(matchingDeclaration);
if (matchingDeclaration->isNamespace() || const int size = names.size();
matchingDeclaration->isClass() || for (int i = 0; i < size; ++i) {
matchingDeclaration->isForwardClassDeclaration()) { qualifiedName.append(overview.prettyName(names.at(i)));
// In this case the declaration name appears in the fully qualified name. Remove if (i < size - 1)
// it since it is already considered below. qualifiedName.append(QLatin1String("::"));
names.removeLast();
helpCategory = HelpCandidate::ClassOrNamespace;
} else if (matchingDeclaration->isEnum()) {
helpCategory = HelpCandidate::Enum;
} else if (matchingDeclaration->isTypedef()) {
helpCategory = HelpCandidate::Typedef;
} else if (matchingDeclaration->isStatic() && !matchingDeclaration->isFunction()) {
helpCategory = HelpCandidate::Var;
} else {
helpCategory = HelpCandidate::Function;
}
foreach (const Name *name, names) {
qualifiedName.append(overview.prettyName(name));
qualifiedName.append(QLatin1String("::"));
} }
} else {
qualifiedName.append(overview.prettyName(matchingDeclaration->name()));
} }
qualifiedName.append(overview.prettyName(matchingDeclaration->name()));
if (assignTooltip) { if (assignTooltip) {
if (matchingDeclaration->isClass() || if (matchingDeclaration->isClass() ||
...@@ -326,6 +312,21 @@ void CppHoverHandler::handleLookupItemMatch(const LookupItem &lookupItem, const ...@@ -326,6 +312,21 @@ void CppHoverHandler::handleLookupItemMatch(const LookupItem &lookupItem, const
} }
} }
HelpCandidate::Category helpCategory;
if (matchingDeclaration->isNamespace() ||
matchingDeclaration->isClass() ||
matchingDeclaration->isForwardClassDeclaration()) {
helpCategory = HelpCandidate::ClassOrNamespace;
} else if (matchingDeclaration->isEnum()) {
helpCategory = HelpCandidate::Enum;
} else if (matchingDeclaration->isTypedef()) {
helpCategory = HelpCandidate::Typedef;
} else if (matchingDeclaration->isStatic() && !matchingDeclaration->isFunction()) {
helpCategory = HelpCandidate::Var;
} else {
helpCategory = HelpCandidate::Function;
}
// Help identifiers are simply the name with no signature, arguments or return type. // Help identifiers are simply the name with no signature, arguments or return type.
// They might or might not include a qualification. This is why two candidates are // They might or might not include a qualification. This is why two candidates are
// created. // created.
......
Supports Markdown
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