forked from qt-creator/qt-creator
CppEditor: Do not offer generated QObject functions
... in "create implementations" quickfix. Change-Id: Ie8aa00e432afdf1338d4897ad211c15fef753404 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -610,15 +610,11 @@ public:
|
|||||||
// - virtual int qt_metacall(QMetaObject::Call, int, void **);
|
// - virtual int qt_metacall(QMetaObject::Call, int, void **);
|
||||||
bool skip = false;
|
bool skip = false;
|
||||||
for (const Function *firstVirtual : qAsConst(firstVirtuals)) {
|
for (const Function *firstVirtual : qAsConst(firstVirtuals)) {
|
||||||
if (printer.prettyName(firstVirtual->enclosingClass()->name())
|
if (printer.prettyName(firstVirtual->enclosingClass()->name()) == "QObject"
|
||||||
== QLatin1String("QObject")) {
|
&& magicQObjectFunctions().contains(
|
||||||
const QString funcName = printer.prettyName(func->name());
|
printer.prettyName(func->name()))) {
|
||||||
if (funcName == QLatin1String("metaObject")
|
skip = true;
|
||||||
|| funcName == QLatin1String("qt_metacast")
|
break;
|
||||||
|| funcName == QLatin1String("qt_metacall")) {
|
|
||||||
skip = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (skip)
|
if (skip)
|
||||||
|
@@ -29,14 +29,25 @@
|
|||||||
|
|
||||||
#include <cpptools/cpprefactoringchanges.h>
|
#include <cpptools/cpprefactoringchanges.h>
|
||||||
|
|
||||||
using namespace CppEditor;
|
|
||||||
using namespace CppEditor::Internal;
|
|
||||||
using namespace CppTools;
|
using namespace CppTools;
|
||||||
using namespace TextEditor;
|
using namespace TextEditor;
|
||||||
using namespace CPlusPlus;
|
using namespace CPlusPlus;
|
||||||
|
|
||||||
|
namespace CppEditor {
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
|
const QStringList magicQObjectFunctions()
|
||||||
|
{
|
||||||
|
static QStringList list{"metaObject", "qt_metacast", "qt_metacall", "qt_static_metacall"};
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Internal
|
||||||
|
|
||||||
CppQuickFixOperation::CppQuickFixOperation(const CppQuickFixInterface &interface, int priority)
|
CppQuickFixOperation::CppQuickFixOperation(const CppQuickFixInterface &interface, int priority)
|
||||||
: QuickFixOperation(priority), CppQuickFixInterface(interface)
|
: QuickFixOperation(priority), CppQuickFixInterface(interface)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
CppQuickFixOperation::~CppQuickFixOperation() = default;
|
CppQuickFixOperation::~CppQuickFixOperation() = default;
|
||||||
|
|
||||||
|
} // namespace CppEditor
|
||||||
|
@@ -31,7 +31,13 @@
|
|||||||
#include <texteditor/quickfix.h>
|
#include <texteditor/quickfix.h>
|
||||||
|
|
||||||
namespace CppEditor {
|
namespace CppEditor {
|
||||||
namespace Internal { class CppQuickFixInterface; }
|
namespace Internal {
|
||||||
|
class CppQuickFixInterface;
|
||||||
|
|
||||||
|
// These are generated functions that should not be offered in quickfixes.
|
||||||
|
const QStringList magicQObjectFunctions();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
class CPPEDITOR_EXPORT CppQuickFixOperation
|
class CPPEDITOR_EXPORT CppQuickFixOperation
|
||||||
: public TextEditor::QuickFixOperation,
|
: public TextEditor::QuickFixOperation,
|
||||||
|
@@ -3496,6 +3496,10 @@ public:
|
|||||||
Function * const func = s->type()->asFunctionType();
|
Function * const func = s->type()->asFunctionType();
|
||||||
if (!func || func->isSignal() || func->isFriend())
|
if (!func || func->isSignal() || func->isFriend())
|
||||||
continue;
|
continue;
|
||||||
|
Overview oo = CppCodeStyleSettings::currentProjectCodeStyleOverview();
|
||||||
|
oo.showFunctionSignatures = true;
|
||||||
|
if (magicQObjectFunctions().contains(oo.prettyName(func->name())))
|
||||||
|
continue;
|
||||||
m_declarations << s;
|
m_declarations << s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user