CppEditor: Fix "Move Definition to Class" for template member functions

class Foo
{
    template<class T>
    void func();
};

template<class T>
void Foo::func() {} // Move to class

It currently doesn't trigger at all.

Change-Id: I63d561771a8dd455f01e99dd836abbd23eec71b7
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
Orgad Shaneh
2016-07-29 19:07:21 +03:00
committed by Orgad Shaneh
parent e7eac98c7e
commit 65dc6d0fc2
3 changed files with 35 additions and 1 deletions

View File

@@ -5017,7 +5017,17 @@ void MoveFuncDefToDecl::match(const CppQuickFixInterface &interface, QuickFixOpe
if (Class *matchingClass = isMemberFunction(interface.context(), func)) {
// Dealing with member functions
const QualifiedNameId *qName = func->name()->asQualifiedNameId();
for (Symbol *s = matchingClass->find(qName->identifier()); s; s = s->next()) {
for (Symbol *symbol = matchingClass->find(qName->identifier());
symbol; symbol = symbol->next()) {
Symbol *s = symbol;
if (func->enclosingScope()->isTemplate()) {
if (const Template *templ = s->type()->asTemplateType()) {
if (Symbol *decl = templ->declaration()) {
if (decl->type()->isFunctionType())
s = decl;
}
}
}
if (!s->name()
|| !qName->identifier()->match(s->identifier())
|| !s->type()->isFunctionType()