CppEditor: Move some related quickfixes into dedicated files

The new file is still too large, but these functions and data structures
are so horribly coupled that it will take an extra refactoring round to
split them up.

Change-Id: I421a3db6dfc74ea78a35d0ccf1a88d782d863b9a
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Christian Kandeler
2024-05-14 17:45:34 +02:00
parent f11c896b7f
commit 8d0025fe09
8 changed files with 5133 additions and 5042 deletions

View File

@@ -95,6 +95,7 @@ add_qtc_plugin(CppEditor
insertionpointlocator.cpp insertionpointlocator.h
projectinfo.cpp projectinfo.h
projectpart.cpp projectpart.h
quickfixes/cppcodegenerationquickfixes.cpp quickfixes/cppcodegenerationquickfixes.h
quickfixes/cppinsertvirtualmethods.cpp quickfixes/cppinsertvirtualmethods.h
quickfixes/cppquickfix.cpp quickfixes/cppquickfix.h
quickfixes/cppquickfixassistant.cpp quickfixes/cppquickfixassistant.h

View File

@@ -219,6 +219,8 @@ QtcPlugin {
name: "Quickfixes"
prefix: "quickfixes/"
files: [
"cppcodegenerationquickfixes.cpp",
"cppcodegenerationquickfixes.h",
"cppinsertvirtualmethods.cpp",
"cppinsertvirtualmethods.h",
"cppquickfix.cpp",

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,8 @@
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once
namespace CppEditor::Internal {
void registerCodeGenerationQuickfixes();
} // namespace CppEditor::Internal

File diff suppressed because it is too large Load Diff

View File

@@ -5,6 +5,7 @@
#include "../cpptoolstestcase.h"
#include "cppquickfix.h"
#include "cppquickfixsettings.h"
#include <projectexplorer/headerpath.h>
@@ -22,6 +23,15 @@ class CppCodeStylePreferences;
namespace Internal {
namespace Tests {
class QuickFixSettings
{
const CppQuickFixSettings original = *CppQuickFixSettings::instance();
public:
CppQuickFixSettings *operator->() { return CppQuickFixSettings::instance(); }
~QuickFixSettings() { *CppQuickFixSettings::instance() = original; }
};
class BaseQuickFixTestCase : public CppEditor::Tests::TestCase
{
public:
@@ -47,6 +57,17 @@ private:
bool m_restoreHeaderPaths;
};
/// Tests the offered operations provided by a given CppQuickFixFactory
class QuickFixOfferedOperationsTest : public BaseQuickFixTestCase
{
public:
QuickFixOfferedOperationsTest(const QList<TestDocumentPtr> &testDocuments,
CppQuickFixFactory *factory,
const ProjectExplorer::HeaderPaths &headerPaths
= ProjectExplorer::HeaderPaths(),
const QStringList &expectedOperations = QStringList());
};
/// Tests a concrete QuickFixOperation of a given CppQuickFixFactory
class QuickFixOperationTest : public BaseQuickFixTestCase
{
@@ -76,34 +97,6 @@ private slots:
void testGeneric_data();
void testGeneric();
void testGenerateGetterSetterNamespaceHandlingCreate_data();
void testGenerateGetterSetterNamespaceHandlingCreate();
void testGenerateGetterSetterNamespaceHandlingAddUsing_data();
void testGenerateGetterSetterNamespaceHandlingAddUsing();
void testGenerateGetterSetterNamespaceHandlingFullyQualify_data();
void testGenerateGetterSetterNamespaceHandlingFullyQualify();
void testGenerateGetterSetterCustomNames_data();
void testGenerateGetterSetterCustomNames();
void testGenerateGetterSetterValueTypes_data();
void testGenerateGetterSetterValueTypes();
void testGenerateGetterSetterCustomTemplate();
void testGenerateGetterSetterNeedThis();
void testGenerateGetterSetterOfferedFixes_data();
void testGenerateGetterSetterOfferedFixes();
void testGenerateGetterSetterGeneralTests_data();
void testGenerateGetterSetterGeneralTests();
void testGenerateGetterSetterOnlyGetter();
void testGenerateGetterSetterOnlySetter();
void testGenerateGetterSetterAnonymousClass();
void testGenerateGetterSetterInlineInHeaderFile();
void testGenerateGetterSetterOnlySetterHeaderFileWithIncludeGuard();
void testGenerateGetterFunctionAsTemplateArg();
void testGenerateGettersSetters_data();
void testGenerateGettersSetters();
void testInsertQtPropertyMembers_data();
void testInsertQtPropertyMembers();
void testInsertMemberFromUse_data();
void testInsertMemberFromUse();
@@ -218,9 +211,6 @@ private slots:
void testRemoveUsingNamespaceSimple();
void testRemoveUsingNamespaceDifferentSymbols();
void testGenerateConstructor_data();
void testGenerateConstructor();
void testChangeCommentType_data();
void testChangeCommentType();

File diff suppressed because it is too large Load Diff

View File

@@ -453,39 +453,6 @@ public:
void doMatch(const CppQuickFixInterface &interface, TextEditor::QuickFixOperations &result) override;
};
/*!
Adds getter and setter functions for a member variable
*/
class GenerateGetterSetter : public CppQuickFixFactory
{
public:
void doMatch(const CppQuickFixInterface &interface, TextEditor::QuickFixOperations &result) override;
};
/*!
Adds getter and setter functions for several member variables
*/
class GenerateGettersSettersForClass : public CppQuickFixFactory
{
protected:
void setTest() { m_test = true; }
private:
void doMatch(const CppQuickFixInterface &interface,
TextEditor::QuickFixOperations &result) override;
bool m_test = false;
};
/*!
Adds missing members for a Q_PROPERTY
*/
class InsertQtPropertyMembers : public CppQuickFixFactory
{
public:
void doMatch(const CppQuickFixInterface &interface, TextEditor::QuickFixOperations &result) override;
};
/*!
Converts a Qt 4 QObject::connect() to Qt 5 style.
*/
@@ -586,21 +553,6 @@ private:
void doMatch(const CppQuickFixInterface &interface, TextEditor::QuickFixOperations &result) override;
};
/*!
Generate constructor
*/
class GenerateConstructor : public CppQuickFixFactory
{
protected:
void setTest() { m_test = true; }
private:
void doMatch(const CppQuickFixInterface &interface,
TextEditor::QuickFixOperations &result) override;
bool m_test = false;
};
//! Converts C-style to C++-style comments and vice versa
class ConvertCommentStyle : public CppQuickFixFactory
{