From 049291504d493ee8126f7da723068c3d3c9c298e Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Tue, 2 Oct 2018 13:02:08 +0200 Subject: [PATCH] Fix function extraction for nested classes If the function is added to a class inside a class, these must be prepended before the inner class name. Fixes: QTCREATORBUG-7271 Change-Id: I07042cdd4927af3b630c6ab1b5587971754e1199 Reviewed-by: Nikolai Kosjar --- src/plugins/cppeditor/cppquickfixes.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/plugins/cppeditor/cppquickfixes.cpp b/src/plugins/cppeditor/cppquickfixes.cpp index b0442e0a2a9..afc777be1a8 100644 --- a/src/plugins/cppeditor/cppquickfixes.cpp +++ b/src/plugins/cppeditor/cppquickfixes.cpp @@ -3302,9 +3302,17 @@ public: // Write class qualification, if any. if (matchingClass) { - const Name *name = rewriteName(matchingClass->name(), &env, control); - funcDef.append(printer.prettyName(name)); - funcDef.append(QLatin1String("::")); + Class *current = matchingClass; + QVector classes{matchingClass->name()}; + while (current->enclosingScope()->asClass()) { + current = current->enclosingScope()->asClass(); + classes.prepend(current->name()); + } + for (const Name *n : classes) { + const Name *name = rewriteName(n, &env, control); + funcDef.append(printer.prettyName(name)); + funcDef.append(QLatin1String("::")); + } } // Write the extracted function itself and its call.