Commit b87edd82 authored by Leandro Melo's avatar Leandro Melo
Browse files

Tooltips and help ids: Fix for templates.

Tooltips can still be improved.
parent 9ebbac63
......@@ -192,6 +192,8 @@ void CppElementEvaluator::handleLookupItemMatch(const Snapshot &snapshot,
} else if (declaration->isDeclaration() && type.isValid()) {
m_element = QSharedPointer<CppElement>(
new CppVariable(declaration, context, lookupItem.scope()));
} else if (declaration->isTemplate() && declaration->asTemplate()->declaration()) {
m_element = QSharedPointer<CppElement>(new CppTemplate(declaration));
} else {
m_element = QSharedPointer<CppElement>(new CppDeclarableElement(declaration));
}
......@@ -491,3 +493,31 @@ CppVariable::CppVariable(Symbol *declaration, const LookupContext &context, Scop
CppVariable::~CppVariable()
{}
// CppTemplate
CppTemplate::CppTemplate(CPlusPlus::Symbol *declaration) : CppDeclarableElement(declaration)
{
Template *templateSymbol = declaration->asTemplate();
if (templateSymbol->declaration()->isClass() ||
templateSymbol->declaration()->isForwardClassDeclaration()) {
m_isClassTemplate = true;
setHelpCategory(TextEditor::HelpItem::ClassOrNamespace);
setTooltip(qualifiedName());
} else {
m_isClassTemplate = false;
setHelpCategory(TextEditor::HelpItem::Function);
}
}
CppTemplate::~CppTemplate()
{}
bool CppTemplate::isClassTemplate() const
{
return m_isClassTemplate;
}
bool CppTemplate::isFunctionTemplate() const
{
return !m_isClassTemplate;
}
......@@ -233,6 +233,19 @@ public:
virtual ~CppVariable();
};
class CppTemplate : public CppDeclarableElement
{
public:
CppTemplate(CPlusPlus::Symbol *declaration);
virtual ~CppTemplate();
bool isClassTemplate() const;
bool isFunctionTemplate() const;
private:
bool m_isClassTemplate;
};
} // namespace Internal
} // namespace CppEditor
......
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