summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhjk <hjk@qt.io>2018-01-26 16:43:01 +0100
committerhjk <hjk@qt.io>2018-02-02 12:26:32 +0000
commit289f2b170acb721afc9bf81c3805f8ceae72f047 (patch)
tree514331c185fb72f632dcbc18754f17a214ac67e8
parentc4b3779b42f44254d5c1a6b1c246427f302f8d9e (diff)
downloadqt-creator-289f2b170acb721afc9bf81c3805f8ceae72f047.tar.gz
CppEditor: Do not add QuickFixFactories to object pool anymore
Not needed anymore. Also some cleanup, no 'using' in headers etc. Change-Id: I8c4547d80d0c0ffd989d1efbc74687c9f56096a4 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
-rw-r--r--src/plugins/cppeditor/cppeditorplugin.cpp4
-rw-r--r--src/plugins/cppeditor/cppquickfix.h4
-rw-r--r--src/plugins/cppeditor/cppquickfix_test.cpp1
-rw-r--r--src/plugins/cppeditor/cppquickfixassistant.cpp1
-rw-r--r--src/plugins/cppeditor/cppquickfixes.cpp111
-rw-r--r--src/plugins/cppeditor/cppquickfixes.h19
6 files changed, 68 insertions, 72 deletions
diff --git a/src/plugins/cppeditor/cppeditorplugin.cpp b/src/plugins/cppeditor/cppeditorplugin.cpp
index 27cbf4827e..beac37ee7e 100644
--- a/src/plugins/cppeditor/cppeditorplugin.cpp
+++ b/src/plugins/cppeditor/cppeditorplugin.cpp
@@ -69,6 +69,7 @@
using namespace Core;
using namespace TextEditor;
using namespace Utils;
+using namespace CppTools;
namespace CppEditor {
namespace Internal {
@@ -128,6 +129,7 @@ CppEditorPlugin::CppEditorPlugin() :
CppEditorPlugin::~CppEditorPlugin()
{
+ destroyCppQuickFixes();
m_instance = 0;
}
@@ -152,7 +154,7 @@ bool CppEditorPlugin::initialize(const QStringList & /*arguments*/, QString *err
&CppEditor::decorateEditor);
m_quickFixProvider = new CppQuickFixAssistProvider(this);
- registerQuickFixes(this);
+ createCppQuickFixes();
Context context(Constants::CPPEDITOR_ID);
diff --git a/src/plugins/cppeditor/cppquickfix.h b/src/plugins/cppeditor/cppquickfix.h
index 6244b5ca52..48ba6ece66 100644
--- a/src/plugins/cppeditor/cppquickfix.h
+++ b/src/plugins/cppeditor/cppquickfix.h
@@ -62,12 +62,14 @@ public:
CppQuickFixFactory();
~CppQuickFixFactory();
+ using QuickFixOperations = TextEditor::QuickFixOperations;
+
/*!
Implement this function to match and create the appropriate
CppQuickFixOperation objects.
*/
virtual void match(const Internal::CppQuickFixInterface &interface,
- TextEditor::QuickFixOperations &result) = 0;
+ QuickFixOperations &result) = 0;
static const QList<CppQuickFixFactory *> &cppQuickFixFactories();
};
diff --git a/src/plugins/cppeditor/cppquickfix_test.cpp b/src/plugins/cppeditor/cppquickfix_test.cpp
index bfc35a67c4..62af8f686b 100644
--- a/src/plugins/cppeditor/cppquickfix_test.cpp
+++ b/src/plugins/cppeditor/cppquickfix_test.cpp
@@ -48,6 +48,7 @@
using namespace Core;
using namespace CPlusPlus;
using namespace CppEditor::Internal::Tests;
+using namespace CppTools;
using namespace TextEditor;
using CppTools::Tests::TestIncludePaths;
diff --git a/src/plugins/cppeditor/cppquickfixassistant.cpp b/src/plugins/cppeditor/cppquickfixassistant.cpp
index 8fdcbe6601..f0a07adea5 100644
--- a/src/plugins/cppeditor/cppquickfixassistant.cpp
+++ b/src/plugins/cppeditor/cppquickfixassistant.cpp
@@ -30,6 +30,7 @@
#include "cppquickfixes.h"
#include <cpptools/cppmodelmanager.h>
+#include <cpptools/cpprefactoringchanges.h>
#include <texteditor/codeassist/genericproposal.h>
#include <texteditor/codeassist/iassistprocessor.h>
diff --git a/src/plugins/cppeditor/cppquickfixes.cpp b/src/plugins/cppeditor/cppquickfixes.cpp
index ee12f960b7..78c60ef2fe 100644
--- a/src/plugins/cppeditor/cppquickfixes.cpp
+++ b/src/plugins/cppeditor/cppquickfixes.cpp
@@ -39,6 +39,7 @@
#include <cpptools/cppclassesfilter.h>
#include <cpptools/cppcodestylesettings.h>
#include <cpptools/cpppointerdeclarationformatter.h>
+#include <cpptools/cpprefactoringchanges.h>
#include <cpptools/cpptoolsbridge.h>
#include <cpptools/cpptoolsconstants.h>
#include <cpptools/cpptoolsreuse.h>
@@ -99,59 +100,6 @@ const QList<CppQuickFixFactory *> &CppQuickFixFactory::cppQuickFixFactories()
namespace Internal {
-void registerQuickFixes(ExtensionSystem::IPlugin *plugIn)
-{
- plugIn->addAutoReleasedObject(new AddIncludeForUndefinedIdentifier);
-
- plugIn->addAutoReleasedObject(new FlipLogicalOperands);
- plugIn->addAutoReleasedObject(new InverseLogicalComparison);
- plugIn->addAutoReleasedObject(new RewriteLogicalAnd);
-
- plugIn->addAutoReleasedObject(new ConvertToCamelCase);
-
- plugIn->addAutoReleasedObject(new ConvertCStringToNSString);
- plugIn->addAutoReleasedObject(new ConvertNumericLiteral);
- plugIn->addAutoReleasedObject(new TranslateStringLiteral);
- plugIn->addAutoReleasedObject(new WrapStringLiteral);
-
- plugIn->addAutoReleasedObject(new MoveDeclarationOutOfIf);
- plugIn->addAutoReleasedObject(new MoveDeclarationOutOfWhile);
-
- plugIn->addAutoReleasedObject(new SplitIfStatement);
- plugIn->addAutoReleasedObject(new SplitSimpleDeclaration);
-
- plugIn->addAutoReleasedObject(new AddLocalDeclaration);
- plugIn->addAutoReleasedObject(new AddBracesToIf);
- plugIn->addAutoReleasedObject(new RearrangeParamDeclarationList);
- plugIn->addAutoReleasedObject(new ReformatPointerDeclaration);
-
- plugIn->addAutoReleasedObject(new CompleteSwitchCaseStatement);
- plugIn->addAutoReleasedObject(new InsertQtPropertyMembers);
- plugIn->addAutoReleasedObject(new ConvertQt4Connect);
-
- plugIn->addAutoReleasedObject(new ApplyDeclDefLinkChanges);
- plugIn->addAutoReleasedObject(new ConvertFromAndToPointer);
- plugIn->addAutoReleasedObject(new ExtractFunction);
- plugIn->addAutoReleasedObject(new ExtractLiteralAsParameter);
- plugIn->addAutoReleasedObject(new GenerateGetterSetter);
- plugIn->addAutoReleasedObject(new InsertDeclFromDef);
- plugIn->addAutoReleasedObject(new InsertDefFromDecl);
-
- plugIn->addAutoReleasedObject(new MoveFuncDefOutside);
- plugIn->addAutoReleasedObject(new MoveAllFuncDefOutside);
- plugIn->addAutoReleasedObject(new MoveFuncDefToDecl);
-
- plugIn->addAutoReleasedObject(new AssignToLocalVariable);
-
- plugIn->addAutoReleasedObject(new InsertVirtualMethods);
-
- plugIn->addAutoReleasedObject(new OptimizeForLoop);
-
- plugIn->addAutoReleasedObject(new EscapeStringLiteral);
-
- plugIn->addAutoReleasedObject(new ExtraRefactoringOperations);
-}
-
// In the following anonymous namespace all functions are collected, which could be of interest for
// different quick fixes.
namespace {
@@ -6077,7 +6025,64 @@ void ExtraRefactoringOperations::match(const CppQuickFixInterface &interface,
}
}
+void createCppQuickFixes()
+{
+ new AddIncludeForUndefinedIdentifier;
+ new FlipLogicalOperands;
+ new InverseLogicalComparison;
+ new RewriteLogicalAnd;
+
+ new ConvertToCamelCase;
+
+ new ConvertCStringToNSString;
+ new ConvertNumericLiteral;
+ new TranslateStringLiteral;
+ new WrapStringLiteral;
+
+ new MoveDeclarationOutOfIf;
+ new MoveDeclarationOutOfWhile;
+
+ new SplitIfStatement;
+ new SplitSimpleDeclaration;
+
+ new AddLocalDeclaration;
+ new AddBracesToIf;
+ new RearrangeParamDeclarationList;
+ new ReformatPointerDeclaration;
+
+ new CompleteSwitchCaseStatement;
+ new InsertQtPropertyMembers;
+ new ConvertQt4Connect;
+
+ new ApplyDeclDefLinkChanges;
+ new ConvertFromAndToPointer;
+ new ExtractFunction;
+ new ExtractLiteralAsParameter;
+ new GenerateGetterSetter;
+ new InsertDeclFromDef;
+ new InsertDefFromDecl;
+
+ new MoveFuncDefOutside;
+ new MoveAllFuncDefOutside;
+ new MoveFuncDefToDecl;
+
+ new AssignToLocalVariable;
+
+ new InsertVirtualMethods;
+
+ new OptimizeForLoop;
+
+ new EscapeStringLiteral;
+
+ new ExtraRefactoringOperations;
+}
+
+void destroyCppQuickFixes()
+{
+ for (int i = g_cppQuickFixFactories.size(); --i >= 0; )
+ delete g_cppQuickFixFactories.at(i);
+}
} // namespace Internal
} // namespace CppEditor
diff --git a/src/plugins/cppeditor/cppquickfixes.h b/src/plugins/cppeditor/cppquickfixes.h
index 5cbcd17e9a..21dadf0d0f 100644
--- a/src/plugins/cppeditor/cppquickfixes.h
+++ b/src/plugins/cppeditor/cppquickfixes.h
@@ -28,22 +28,6 @@
#include "cppeditor_global.h"
#include "cppquickfix.h"
-#include <cpptools/cpprefactoringchanges.h>
-#include <extensionsystem/iplugin.h>
-
-#include <QDialog>
-
-#include <functional>
-
-QT_BEGIN_NAMESPACE
-class QByteArray;
-template <class> class QList;
-QT_END_NAMESPACE
-
-using namespace CppTools;
-using namespace CPlusPlus;
-using namespace TextEditor;
-
///
/// Adding New Quick Fixes
///
@@ -55,7 +39,8 @@ using namespace TextEditor;
namespace CppEditor {
namespace Internal {
-void registerQuickFixes(ExtensionSystem::IPlugin *plugIn);
+void createCppQuickFixes();
+void destroyCppQuickFixes();
class ExtraRefactoringOperations : public CppQuickFixFactory
{