CppEditor: Merge two factories

They are closely related, and we might want to add more variants of this
functionality.

Change-Id: Ida83cce018fad5a84d5f6d24a0fa4ff2bca5a67b
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Christian Kandeler
2023-04-25 17:51:25 +02:00
parent 3821683647
commit 5e73bacb0e
3 changed files with 62 additions and 75 deletions

View File

@@ -284,23 +284,6 @@ public:
void match(const CppQuickFixInterface &interface, QuickFixOperations &result) override;
};
/*!
Rewrites
a = foo();
As
Type a = foo();
Where Type is the return type of foo()
Activates on: the assignee, if the type of the right-hand side of the assignment is known.
*/
class AddLocalDeclaration: public CppQuickFixFactory
{
public:
void match(const CppQuickFixInterface &interface, QuickFixOperations &result) override;
};
/*!
Add curly braces to a if statement that doesn't already contain a
compound statement. I.e.
@@ -374,16 +357,17 @@ public:
void match(const CppQuickFixInterface &interface, TextEditor::QuickFixOperations &result) override;
};
/*!
Adds a class member from an initialization in the constructor.
*/
class InsertMemberFromInitialization : public CppQuickFixFactory
class AddDeclarationForUndeclaredIdentifier : public CppQuickFixFactory
{
public:
void match(const CppQuickFixInterface &interface,
TextEditor::QuickFixOperations &result) override;
private:
// Returns whether to still do other checks.
bool checkForMemberInitializer(const CppQuickFixInterface &interface,
TextEditor::QuickFixOperations &result);
QString getType(
const CppQuickFixInterface &interface,
const CPlusPlus::MemInitializerAST *memInitializer,