diff options
author | Eike Ziller <eike.ziller@qt.io> | 2018-10-02 13:02:08 +0200 |
---|---|---|
committer | Eike Ziller <eike.ziller@qt.io> | 2018-10-02 13:31:48 +0000 |
commit | 049291504d493ee8126f7da723068c3d3c9c298e (patch) | |
tree | 12f24b015dd271e895e6637455032bc756679bd8 /src/plugins/cppeditor/cppquickfixes.cpp | |
parent | 7a7898e2c928f0b3c52a97deea9dbd65b11ad516 (diff) |
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 <nikolai.kosjar@qt.io>
Diffstat (limited to 'src/plugins/cppeditor/cppquickfixes.cpp')
-rw-r--r-- | src/plugins/cppeditor/cppquickfixes.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/plugins/cppeditor/cppquickfixes.cpp b/src/plugins/cppeditor/cppquickfixes.cpp index b0442e0a2a..afc777be1a 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<const Name *> 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. |