forked from qt-creator/qt-creator
CppEditor: Quickfix clean-ups
- Merge cppquickfixes.{h,cpp} and cppquickfix.{h,cpp}. - Remove unused functions, classes and typedefs. - Some renamings and adaptation of comments. Change-Id: I1fbcec7ee227f068527fb57552eb161a7e98bf9f Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -107,7 +107,6 @@ add_qtc_plugin(CppEditor
|
||||
quickfixes/cppinsertvirtualmethods.cpp quickfixes/cppinsertvirtualmethods.h
|
||||
quickfixes/cppquickfix.cpp quickfixes/cppquickfix.h
|
||||
quickfixes/cppquickfixassistant.cpp quickfixes/cppquickfixassistant.h
|
||||
quickfixes/cppquickfixes.cpp quickfixes/cppquickfixes.h
|
||||
quickfixes/cppquickfixhelpers.h quickfixes/cppquickfixhelpers.cpp
|
||||
quickfixes/cppquickfixprojectsettings.cpp quickfixes/cppquickfixprojectsettings.h
|
||||
quickfixes/cppquickfixprojectsettingswidget.cpp quickfixes/cppquickfixprojectsettingswidget.h
|
||||
|
@@ -245,8 +245,6 @@ QtcPlugin {
|
||||
"cppquickfix.h",
|
||||
"cppquickfixassistant.cpp",
|
||||
"cppquickfixassistant.h",
|
||||
"cppquickfixes.cpp",
|
||||
"cppquickfixes.h",
|
||||
"cppquickfixhelpers.cpp",
|
||||
"cppquickfixhelpers.h",
|
||||
"cppquickfixprojectsettings.cpp",
|
||||
|
@@ -19,7 +19,7 @@
|
||||
#include "cpptoolsreuse.h"
|
||||
#include "cpptoolssettings.h"
|
||||
#include "cpptypehierarchy.h"
|
||||
#include "quickfixes/cppquickfixes.h"
|
||||
#include "quickfixes/cppquickfix.h"
|
||||
#include "quickfixes/cppquickfixprojectsettingswidget.h"
|
||||
#include "quickfixes/cppquickfixsettingspage.h"
|
||||
#include "resourcepreviewhoverhandler.h"
|
||||
@@ -175,7 +175,7 @@ class CppEditorPlugin final : public ExtensionSystem::IPlugin
|
||||
public:
|
||||
~CppEditorPlugin() final
|
||||
{
|
||||
destroyCppQuickFixes();
|
||||
destroyCppQuickFixFactories();
|
||||
delete d;
|
||||
d = nullptr;
|
||||
}
|
||||
@@ -212,7 +212,7 @@ void CppEditorPlugin::initialize()
|
||||
|
||||
setupMenus();
|
||||
registerVariables();
|
||||
createCppQuickFixes();
|
||||
createCppQuickFixFactories();
|
||||
registerTests();
|
||||
|
||||
SnippetProvider::registerGroup(Constants::CPP_SNIPPETS_GROUP_ID, Tr::tr("C++", "SnippetProvider"),
|
||||
|
@@ -3,7 +3,36 @@
|
||||
|
||||
#include "cppquickfix.h"
|
||||
|
||||
#include "../baseeditordocumentprocessor.h"
|
||||
#include "../cppeditortr.h"
|
||||
#include "../cppeditorwidget.h"
|
||||
#include "../cppfunctiondecldeflink.h"
|
||||
#include "../cpprefactoringchanges.h"
|
||||
#include "assigntolocalvariable.h"
|
||||
#include "bringidentifierintoscope.h"
|
||||
#include "completeswitchstatement.h"
|
||||
#include "convertfromandtopointer.h"
|
||||
#include "convertnumericliteral.h"
|
||||
#include "convertqt4connect.h"
|
||||
#include "convertstringliteral.h"
|
||||
#include "converttocamelcase.h"
|
||||
#include "converttometamethodcall.h"
|
||||
#include "cppcodegenerationquickfixes.h"
|
||||
#include "cppinsertvirtualmethods.h"
|
||||
#include "cppquickfixassistant.h"
|
||||
#include "createdeclarationfromuse.h"
|
||||
#include "extractfunction.h"
|
||||
#include "extractliteralasparameter.h"
|
||||
#include "insertfunctiondefinition.h"
|
||||
#include "logicaloperationquickfixes.h"
|
||||
#include "moveclasstoownfile.h"
|
||||
#include "movefunctiondefinition.h"
|
||||
#include "rearrangeparamdeclarationlist.h"
|
||||
#include "reformatpointerdeclaration.h"
|
||||
#include "removeusingnamespace.h"
|
||||
#include "rewritecomment.h"
|
||||
#include "rewritecontrolstatements.h"
|
||||
#include "splitsimpledeclaration.h"
|
||||
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
#include <extensionsystem/pluginspec.h>
|
||||
@@ -12,6 +41,58 @@ using namespace CPlusPlus;
|
||||
using namespace TextEditor;
|
||||
|
||||
namespace CppEditor {
|
||||
namespace Internal {
|
||||
namespace {
|
||||
|
||||
class ApplyDeclDefLinkOperation : public CppQuickFixOperation
|
||||
{
|
||||
public:
|
||||
explicit ApplyDeclDefLinkOperation(const CppQuickFixInterface &interface,
|
||||
const std::shared_ptr<FunctionDeclDefLink> &link)
|
||||
: CppQuickFixOperation(interface, 100)
|
||||
, m_link(link)
|
||||
{}
|
||||
|
||||
void perform() override
|
||||
{
|
||||
if (editor()->declDefLink() == m_link)
|
||||
editor()->applyDeclDefLinkChanges(/*don't jump*/false);
|
||||
}
|
||||
|
||||
private:
|
||||
std::shared_ptr<FunctionDeclDefLink> m_link;
|
||||
};
|
||||
|
||||
class ExtraRefactoringOperations : public CppQuickFixFactory
|
||||
{
|
||||
public:
|
||||
void doMatch(const CppQuickFixInterface &interface, QuickFixOperations &result) override
|
||||
{
|
||||
const auto processor = CppModelManager::cppEditorDocumentProcessor(interface.filePath());
|
||||
if (processor) {
|
||||
const auto clangFixItOperations = processor->extraRefactoringOperations(interface);
|
||||
result.append(clangFixItOperations);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//! Applies function signature changes
|
||||
class ApplyDeclDefLinkChanges: public CppQuickFixFactory
|
||||
{
|
||||
public:
|
||||
void doMatch(const CppQuickFixInterface &interface, TextEditor::QuickFixOperations &result) override
|
||||
{
|
||||
std::shared_ptr<FunctionDeclDefLink> link = interface.editor()->declDefLink();
|
||||
if (!link || !link->isMarkerVisible())
|
||||
return;
|
||||
|
||||
auto op = new ApplyDeclDefLinkOperation(interface, link);
|
||||
op->setDescription(Tr::tr("Apply Function Signature Changes"));
|
||||
result << op;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
static ExtensionSystem::IPlugin *getCppEditor()
|
||||
{
|
||||
@@ -23,25 +104,82 @@ static ExtensionSystem::IPlugin *getCppEditor()
|
||||
QTC_ASSERT(false, return nullptr);
|
||||
}
|
||||
|
||||
CppQuickFixOperation::~CppQuickFixOperation() = default;
|
||||
|
||||
void createCppQuickFixFactories()
|
||||
{
|
||||
new ApplyDeclDefLinkChanges;
|
||||
new ExtraRefactoringOperations;
|
||||
|
||||
registerAssignToLocalVariableQuickfix();
|
||||
registerBringIdentifierIntoScopeQuickfixes();
|
||||
registerCodeGenerationQuickfixes();
|
||||
registerCompleteSwitchStatementQuickfix();
|
||||
registerConvertFromAndToPointerQuickfix();
|
||||
registerConvertNumericLiteralQuickfix();
|
||||
registerConvertQt4ConnectQuickfix();
|
||||
registerConvertStringLiteralQuickfixes();
|
||||
registerConvertToCamelCaseQuickfix();
|
||||
registerConvertToMetaMethodCallQuickfix();
|
||||
registerCreateDeclarationFromUseQuickfixes();
|
||||
registerExtractFunctionQuickfix();
|
||||
registerExtractLiteralAsParameterQuickfix();
|
||||
registerInsertFunctionDefinitionQuickfixes();
|
||||
registerInsertVirtualMethodsQuickfix();
|
||||
registerLogicalOperationQuickfixes();
|
||||
registerMoveClassToOwnFileQuickfix();
|
||||
registerMoveFunctionDefinitionQuickfixes();
|
||||
registerRearrangeParamDeclarationListQuickfix();
|
||||
registerReformatPointerDeclarationQuickfix();
|
||||
registerRemoveUsingNamespaceQuickfix();
|
||||
registerRewriteCommentQuickfixes();
|
||||
registerRewriteControlStatementQuickfixes();
|
||||
registerSplitSimpleDeclarationQuickfix();
|
||||
}
|
||||
|
||||
static QList<CppQuickFixFactory *> g_cppQuickFixFactories;
|
||||
|
||||
void destroyCppQuickFixFactories()
|
||||
{
|
||||
for (int i = g_cppQuickFixFactories.size(); --i >= 0; )
|
||||
delete g_cppQuickFixFactories.at(i);
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
CppQuickFixFactory::CppQuickFixFactory()
|
||||
{
|
||||
Internal::g_cppQuickFixFactories.append(this);
|
||||
}
|
||||
|
||||
CppQuickFixFactory::~CppQuickFixFactory()
|
||||
{
|
||||
Internal::g_cppQuickFixFactories.removeOne(this);
|
||||
}
|
||||
|
||||
ExtensionSystem::IPlugin *CppQuickFixFactory::cppEditor()
|
||||
{
|
||||
static ExtensionSystem::IPlugin *plugin = getCppEditor();
|
||||
static ExtensionSystem::IPlugin * const plugin = Internal::getCppEditor();
|
||||
return plugin;
|
||||
}
|
||||
|
||||
namespace Internal {
|
||||
|
||||
const QStringList magicQObjectFunctions()
|
||||
void CppQuickFixFactory::match(const Internal::CppQuickFixInterface &interface,
|
||||
QuickFixOperations &result)
|
||||
{
|
||||
static QStringList list{"metaObject", "qt_metacast", "qt_metacall", "qt_static_metacall"};
|
||||
return list;
|
||||
if (m_clangdReplacement) {
|
||||
if (const auto clangdVersion = CppModelManager::usesClangd(
|
||||
interface.currentFile()->editor()->textDocument());
|
||||
clangdVersion && clangdVersion >= m_clangdReplacement) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
doMatch(interface, result);
|
||||
}
|
||||
|
||||
CppQuickFixOperation::CppQuickFixOperation(const CppQuickFixInterface &interface, int priority)
|
||||
: QuickFixOperation(priority), CppQuickFixInterface(interface)
|
||||
{}
|
||||
const QList<CppQuickFixFactory *> &CppQuickFixFactory::cppQuickFixFactories()
|
||||
{
|
||||
return Internal::g_cppQuickFixFactories;
|
||||
}
|
||||
|
||||
CppQuickFixOperation::~CppQuickFixOperation() = default;
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace CppEditor
|
||||
|
@@ -22,10 +22,15 @@ class CppQuickFixOperation
|
||||
public Internal::CppQuickFixInterface
|
||||
{
|
||||
public:
|
||||
explicit CppQuickFixOperation(const CppQuickFixInterface &interface, int priority = -1);
|
||||
explicit CppQuickFixOperation(const CppQuickFixInterface &interface, int priority = -1)
|
||||
: QuickFixOperation(priority), CppQuickFixInterface(interface)
|
||||
{}
|
||||
~CppQuickFixOperation() override;
|
||||
};
|
||||
|
||||
void createCppQuickFixFactories();
|
||||
void destroyCppQuickFixFactories();
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
/*!
|
||||
@@ -67,8 +72,11 @@ public:
|
||||
|
||||
private:
|
||||
/*!
|
||||
Implement this function to doMatch and create the appropriate
|
||||
Implement this function to match and create the appropriate
|
||||
CppQuickFixOperation objects.
|
||||
Make sure that the function is "cheap". Otherwise, since the match()
|
||||
functions are also called to generate context menu entries,
|
||||
the user might experience a delay opening the context menu.
|
||||
*/
|
||||
virtual void doMatch(const Internal::CppQuickFixInterface &interface,
|
||||
QuickFixOperations &result) = 0;
|
||||
|
@@ -9,7 +9,6 @@
|
||||
#include "../cppsourceprocessertesthelper.h"
|
||||
#include "../cpptoolssettings.h"
|
||||
#include "cppquickfixassistant.h"
|
||||
#include "cppquickfixes.h"
|
||||
|
||||
#include <projectexplorer/kitmanager.h>
|
||||
#include <projectexplorer/projectexplorer.h>
|
||||
@@ -32,8 +31,6 @@ using namespace Utils;
|
||||
using CppEditor::Tests::TemporaryDir;
|
||||
using CppEditor::Tests::Internal::TestIncludePaths;
|
||||
|
||||
typedef QByteArray _;
|
||||
|
||||
namespace CppEditor {
|
||||
namespace Internal {
|
||||
namespace Tests {
|
||||
@@ -250,48 +247,5 @@ void QuickFixOperationTest::run(const QList<TestDocumentPtr> &testDocuments,
|
||||
|
||||
} // namespace Tests
|
||||
} // namespace Internal
|
||||
|
||||
typedef QSharedPointer<CppQuickFixFactory> CppQuickFixFactoryPtr;
|
||||
|
||||
} // namespace CppEditor
|
||||
|
||||
namespace CppEditor::Internal::Tests {
|
||||
|
||||
class CppCodeStyleSettingsChanger {
|
||||
public:
|
||||
CppCodeStyleSettingsChanger(const CppCodeStyleSettings &settings);
|
||||
~CppCodeStyleSettingsChanger(); // Restore original
|
||||
|
||||
static CppCodeStyleSettings currentSettings();
|
||||
|
||||
private:
|
||||
void setSettings(const CppCodeStyleSettings &settings);
|
||||
|
||||
CppCodeStyleSettings m_originalSettings;
|
||||
};
|
||||
|
||||
CppCodeStyleSettingsChanger::CppCodeStyleSettingsChanger(const CppCodeStyleSettings &settings)
|
||||
{
|
||||
m_originalSettings = currentSettings();
|
||||
setSettings(settings);
|
||||
}
|
||||
|
||||
CppCodeStyleSettingsChanger::~CppCodeStyleSettingsChanger()
|
||||
{
|
||||
setSettings(m_originalSettings);
|
||||
}
|
||||
|
||||
void CppCodeStyleSettingsChanger::setSettings(const CppCodeStyleSettings &settings)
|
||||
{
|
||||
QVariant variant;
|
||||
variant.setValue(settings);
|
||||
|
||||
CppToolsSettings::cppCodeStyle()->currentDelegate()->setValue(variant);
|
||||
}
|
||||
|
||||
CppCodeStyleSettings CppCodeStyleSettingsChanger::currentSettings()
|
||||
{
|
||||
return CppToolsSettings::cppCodeStyle()->currentDelegate()->value().value<CppCodeStyleSettings>();
|
||||
}
|
||||
|
||||
} // namespace CppEditor::Internal::Tests
|
||||
|
@@ -1,226 +0,0 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "cppquickfixes.h"
|
||||
|
||||
#include "../baseeditordocumentprocessor.h"
|
||||
#include "../cppcodestylesettings.h"
|
||||
#include "../cppeditortr.h"
|
||||
#include "../cppeditorwidget.h"
|
||||
#include "../cppfunctiondecldeflink.h"
|
||||
#include "../cpppointerdeclarationformatter.h"
|
||||
#include "../cpprefactoringchanges.h"
|
||||
#include "../cpptoolsreuse.h"
|
||||
#include "assigntolocalvariable.h"
|
||||
#include "bringidentifierintoscope.h"
|
||||
#include "completeswitchstatement.h"
|
||||
#include "convertfromandtopointer.h"
|
||||
#include "convertnumericliteral.h"
|
||||
#include "convertqt4connect.h"
|
||||
#include "convertstringliteral.h"
|
||||
#include "converttocamelcase.h"
|
||||
#include "converttometamethodcall.h"
|
||||
#include "cppcodegenerationquickfixes.h"
|
||||
#include "cppinsertvirtualmethods.h"
|
||||
#include "cppquickfixassistant.h"
|
||||
#include "cppquickfixhelpers.h"
|
||||
#include "createdeclarationfromuse.h"
|
||||
#include "extractfunction.h"
|
||||
#include "extractliteralasparameter.h"
|
||||
#include "insertfunctiondefinition.h"
|
||||
#include "logicaloperationquickfixes.h"
|
||||
#include "moveclasstoownfile.h"
|
||||
#include "movefunctiondefinition.h"
|
||||
#include "rearrangeparamdeclarationlist.h"
|
||||
#include "reformatpointerdeclaration.h"
|
||||
#include "removeusingnamespace.h"
|
||||
#include "rewritecomment.h"
|
||||
#include "rewritecontrolstatements.h"
|
||||
#include "splitsimpledeclaration.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/messagemanager.h>
|
||||
|
||||
#include <cplusplus/ASTPath.h>
|
||||
#include <cplusplus/CPlusPlusForwardDeclarations.h>
|
||||
#include <cplusplus/CppRewriter.h>
|
||||
#include <cplusplus/declarationcomments.h>
|
||||
#include <cplusplus/NamePrettyPrinter.h>
|
||||
#include <cplusplus/Overview.h>
|
||||
#include <cplusplus/TypeOfExpression.h>
|
||||
#include <cplusplus/TypePrettyPrinter.h>
|
||||
|
||||
#include <projectexplorer/editorconfiguration.h>
|
||||
#include <projectexplorer/projectnodes.h>
|
||||
#include <projectexplorer/projecttree.h>
|
||||
#include <projectexplorer/projectmanager.h>
|
||||
|
||||
#include <texteditor/tabsettings.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/basetreeview.h>
|
||||
#include <utils/codegeneration.h>
|
||||
#include <utils/layoutbuilder.h>
|
||||
#include <utils/fancylineedit.h>
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/pathchooser.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/treemodel.h>
|
||||
#include <utils/treeviewcombobox.h>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QCheckBox>
|
||||
#include <QComboBox>
|
||||
#include <QDialog>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
#include <QFormLayout>
|
||||
#include <QGridLayout>
|
||||
#include <QHash>
|
||||
#include <QHeaderView>
|
||||
#include <QInputDialog>
|
||||
#include <QMimeData>
|
||||
#include <QPair>
|
||||
#include <QProxyStyle>
|
||||
#include <QPushButton>
|
||||
#include <QRegularExpression>
|
||||
#include <QSharedPointer>
|
||||
#include <QStack>
|
||||
#include <QStyledItemDelegate>
|
||||
#include <QTableView>
|
||||
#include <QTextCodec>
|
||||
#include <QTextCursor>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include <cctype>
|
||||
|
||||
using namespace CPlusPlus;
|
||||
using namespace ProjectExplorer;
|
||||
using namespace TextEditor;
|
||||
using namespace Utils;
|
||||
|
||||
namespace CppEditor {
|
||||
|
||||
static QList<CppQuickFixFactory *> g_cppQuickFixFactories;
|
||||
|
||||
CppQuickFixFactory::CppQuickFixFactory()
|
||||
{
|
||||
g_cppQuickFixFactories.append(this);
|
||||
}
|
||||
|
||||
CppQuickFixFactory::~CppQuickFixFactory()
|
||||
{
|
||||
g_cppQuickFixFactories.removeOne(this);
|
||||
}
|
||||
|
||||
void CppQuickFixFactory::match(const Internal::CppQuickFixInterface &interface,
|
||||
QuickFixOperations &result)
|
||||
{
|
||||
if (m_clangdReplacement) {
|
||||
if (const auto clangdVersion = CppModelManager::usesClangd(
|
||||
interface.currentFile()->editor()->textDocument());
|
||||
clangdVersion && clangdVersion >= m_clangdReplacement) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
doMatch(interface, result);
|
||||
}
|
||||
|
||||
const QList<CppQuickFixFactory *> &CppQuickFixFactory::cppQuickFixFactories()
|
||||
{
|
||||
return g_cppQuickFixFactories;
|
||||
}
|
||||
|
||||
namespace Internal {
|
||||
|
||||
namespace {
|
||||
|
||||
class ApplyDeclDefLinkOperation : public CppQuickFixOperation
|
||||
{
|
||||
public:
|
||||
explicit ApplyDeclDefLinkOperation(const CppQuickFixInterface &interface,
|
||||
const std::shared_ptr<FunctionDeclDefLink> &link)
|
||||
: CppQuickFixOperation(interface, 100)
|
||||
, m_link(link)
|
||||
{}
|
||||
|
||||
void perform() override
|
||||
{
|
||||
if (editor()->declDefLink() == m_link)
|
||||
editor()->applyDeclDefLinkChanges(/*don't jump*/false);
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void performChanges(const CppRefactoringFilePtr &, const CppRefactoringChanges &)
|
||||
{ /* never called since perform is overridden */ }
|
||||
|
||||
private:
|
||||
std::shared_ptr<FunctionDeclDefLink> m_link;
|
||||
};
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
void ApplyDeclDefLinkChanges::doMatch(const CppQuickFixInterface &interface,
|
||||
QuickFixOperations &result)
|
||||
{
|
||||
std::shared_ptr<FunctionDeclDefLink> link = interface.editor()->declDefLink();
|
||||
if (!link || !link->isMarkerVisible())
|
||||
return;
|
||||
|
||||
auto op = new ApplyDeclDefLinkOperation(interface, link);
|
||||
op->setDescription(Tr::tr("Apply Function Signature Changes"));
|
||||
result << op;
|
||||
}
|
||||
|
||||
void ExtraRefactoringOperations::doMatch(const CppQuickFixInterface &interface,
|
||||
QuickFixOperations &result)
|
||||
{
|
||||
const auto processor = CppModelManager::cppEditorDocumentProcessor(interface.filePath());
|
||||
if (processor) {
|
||||
const auto clangFixItOperations = processor->extraRefactoringOperations(interface);
|
||||
result.append(clangFixItOperations);
|
||||
}
|
||||
}
|
||||
|
||||
void createCppQuickFixes()
|
||||
{
|
||||
new ApplyDeclDefLinkChanges;
|
||||
|
||||
registerInsertVirtualMethodsQuickfix();
|
||||
registerMoveClassToOwnFileQuickfix();
|
||||
registerRemoveUsingNamespaceQuickfix();
|
||||
registerCodeGenerationQuickfixes();
|
||||
registerConvertQt4ConnectQuickfix();
|
||||
registerMoveFunctionDefinitionQuickfixes();
|
||||
registerInsertFunctionDefinitionQuickfixes();
|
||||
registerBringIdentifierIntoScopeQuickfixes();
|
||||
registerConvertStringLiteralQuickfixes();
|
||||
registerCreateDeclarationFromUseQuickfixes();
|
||||
registerLogicalOperationQuickfixes();
|
||||
registerRewriteControlStatementQuickfixes();
|
||||
registerRewriteCommentQuickfixes();
|
||||
registerExtractFunctionQuickfix();
|
||||
registerExtractLiteralAsParameterQuickfix();
|
||||
registerConvertFromAndToPointerQuickfix();
|
||||
registerAssignToLocalVariableQuickfix();
|
||||
registerCompleteSwitchStatementQuickfix();
|
||||
registerConvertToMetaMethodCallQuickfix();
|
||||
registerSplitSimpleDeclarationQuickfix();
|
||||
registerConvertNumericLiteralQuickfix();
|
||||
registerConvertToCamelCaseQuickfix();
|
||||
registerRearrangeParamDeclarationListQuickfix();
|
||||
registerReformatPointerDeclarationQuickfix();
|
||||
|
||||
new ExtraRefactoringOperations;
|
||||
}
|
||||
|
||||
void destroyCppQuickFixes()
|
||||
{
|
||||
for (int i = g_cppQuickFixFactories.size(); --i >= 0; )
|
||||
delete g_cppQuickFixFactories.at(i);
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace CppEditor
|
@@ -1,41 +0,0 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cppquickfix.h"
|
||||
|
||||
#include <variant>
|
||||
|
||||
///
|
||||
/// Adding New Quick Fixes
|
||||
///
|
||||
/// When adding new Quick Fixes, make sure that the doMatch() function is "cheap".
|
||||
/// Otherwise, since the match() functions are also called to generate context menu
|
||||
/// entries, the user might experience a delay opening the context menu.
|
||||
///
|
||||
|
||||
namespace CppEditor {
|
||||
namespace Internal {
|
||||
using TypeOrExpr = std::variant<const CPlusPlus::ExpressionAST *, CPlusPlus::FullySpecifiedType>;
|
||||
|
||||
void createCppQuickFixes();
|
||||
void destroyCppQuickFixes();
|
||||
|
||||
class ExtraRefactoringOperations : public CppQuickFixFactory
|
||||
{
|
||||
public:
|
||||
void doMatch(const CppQuickFixInterface &interface, QuickFixOperations &result) override;
|
||||
};
|
||||
|
||||
/*!
|
||||
Applies function signature changes
|
||||
*/
|
||||
class ApplyDeclDefLinkChanges: public CppQuickFixFactory
|
||||
{
|
||||
public:
|
||||
void doMatch(const CppQuickFixInterface &interface, TextEditor::QuickFixOperations &result) override;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace CppEditor
|
@@ -190,4 +190,10 @@ CPlusPlus::FullySpecifiedType typeOfExpr(
|
||||
return rewriteType(result.first().type(), &env, control);
|
||||
}
|
||||
|
||||
const QStringList magicQObjectFunctions()
|
||||
{
|
||||
static QStringList list{"metaObject", "qt_metacast", "qt_metacall", "qt_static_metacall"};
|
||||
return list;
|
||||
}
|
||||
|
||||
} // namespace CppEditor::Internal
|
||||
|
@@ -4,7 +4,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "../cpprefactoringchanges.h"
|
||||
#include "cppquickfixes.h"
|
||||
|
||||
#include <QStringList>
|
||||
|
||||
|
@@ -9,7 +9,7 @@
|
||||
#include "../cpprefactoringchanges.h"
|
||||
#include "../insertionpointlocator.h"
|
||||
#include "../symbolfinder.h"
|
||||
#include "cppquickfixes.h"
|
||||
#include "cppquickfix.h"
|
||||
#include "cppquickfixhelpers.h"
|
||||
#include "cppquickfixprojectsettings.h"
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
#include <QtTest>
|
||||
#endif
|
||||
|
||||
#include <variant>
|
||||
|
||||
using namespace CPlusPlus;
|
||||
using namespace ProjectExplorer;
|
||||
using namespace TextEditor;
|
||||
@@ -33,6 +35,8 @@ using namespace Utils;
|
||||
namespace CppEditor::Internal {
|
||||
namespace {
|
||||
|
||||
using TypeOrExpr = std::variant<const CPlusPlus::ExpressionAST *, CPlusPlus::FullySpecifiedType>;
|
||||
|
||||
// FIXME: Needs to consider the scope at the insertion site.
|
||||
static QString declFromExpr(
|
||||
const TypeOrExpr &typeOrExpr,
|
||||
|
Reference in New Issue
Block a user