CppEditor: GenerateGetterSetter now ignores symbols in Q_PROPERTY

Since the Q_PROPERTY's name equals the typical getter name the "Generate
Getter" quick fix was not offered.

Q_PROPERTY(int a ...) // <-- a is "recognized" as "int a();"
int m_a;

Task-number: QTCREATORBUG-14166
Change-Id: I35709a1b6492b68309d02427d60251df4fd76cfa
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
This commit is contained in:
Lorenz Haas
2015-03-21 19:24:31 +01:00
parent 4749d5ece4
commit 0913eb8660
2 changed files with 34 additions and 1 deletions

View File

@@ -2818,16 +2818,19 @@ public:
m_setterName = QString::fromLatin1("set%1%2")
.arg(m_baseName.left(1).toUpper()).arg(m_baseName.mid(1));
// Check if the class has already both a getter and setter.
// Check if the class has already a getter and/or a setter.
// This is only a simple check which should suffice not triggering the
// same quick fix again. Limitations:
// 1) It only checks in the current class, but not in base classes.
// 2) It compares only names instead of types/signatures.
// 3) Symbols in Qt property declarations are ignored.
bool hasGetter = false;
bool hasSetter = false;
if (Class *klass = m_classSpecifier->symbol) {
for (unsigned i = 0; i < klass->memberCount(); ++i) {
Symbol *symbol = klass->memberAt(i);
if (symbol->isQtPropertyDeclaration())
continue;
if (const Name *symbolName = symbol->name()) {
if (const Identifier *id = symbolName->identifier()) {
const QString memberName = QString::fromUtf8(id->chars(), id->size());