Commit 335e625b authored by hjk's avatar hjk

TextEditor: Flatten QuickFixAssistProcessor hierarchy

{Cpp,QmlJS}QuickFixProcessor were doing the same (storing a single
pointer to a IAssistProvider). This could be done in the base
class with the leaf classes removed.

Change-Id: I0e419f37c5547d5ddfcfd1a767d356040dd7e56f
Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@digia.com>
parent 81cb4719
......@@ -59,7 +59,7 @@ bool CppQuickFixAssistProvider::supportsEditor(Core::Id editorId) const
IAssistProcessor *CppQuickFixAssistProvider::createProcessor() const
{
return new CppQuickFixAssistProcessor(this);
return new QuickFixAssistProcessor(this);
}
QList<TextEditor::QuickFixFactory *> CppQuickFixAssistProvider::quickFixFactories() const
......@@ -70,18 +70,6 @@ QList<TextEditor::QuickFixFactory *> CppQuickFixAssistProvider::quickFixFactorie
return results;
}
// --------------------------
// CppQuickFixAssistProcessor
// --------------------------
CppQuickFixAssistProcessor::CppQuickFixAssistProcessor(const IAssistProvider *provider)
: m_provider(provider)
{}
const IAssistProvider *CppQuickFixAssistProcessor::provider() const
{
return m_provider;
}
// --------------------------
// CppQuickFixAssistInterface
// --------------------------
......
......@@ -73,17 +73,6 @@ private:
QList<CPlusPlus::AST *> m_path;
};
class CppQuickFixAssistProcessor : public TextEditor::QuickFixAssistProcessor
{
public:
CppQuickFixAssistProcessor(const TextEditor::IAssistProvider *provider);
const TextEditor::IAssistProvider *provider() const Q_DECL_OVERRIDE;
private:
const TextEditor::IAssistProvider *m_provider;
};
class CppQuickFixAssistProvider : public TextEditor::QuickFixAssistProvider
{
public:
......
......@@ -67,21 +67,6 @@ QmlJSRefactoringFilePtr QmlJSQuickFixAssistInterface::currentFile() const
return m_currentFile;
}
// ----------------------
// QmlJSQuickFixProcessor
// ----------------------
QmlJSQuickFixProcessor::QmlJSQuickFixProcessor(const TextEditor::IAssistProvider *provider)
: m_provider(provider)
{}
QmlJSQuickFixProcessor::~QmlJSQuickFixProcessor()
{}
const IAssistProvider *QmlJSQuickFixProcessor::provider() const
{
return m_provider;
}
// ---------------------------
// QmlJSQuickFixAssistProvider
// ---------------------------
......@@ -103,7 +88,7 @@ bool QmlJSQuickFixAssistProvider::supportsEditor(Core::Id editorId) const
IAssistProcessor *QmlJSQuickFixAssistProvider::createProcessor() const
{
return new QmlJSQuickFixProcessor(this);
return new QuickFixAssistProcessor(this);
}
QList<QuickFixFactory *> QmlJSQuickFixAssistProvider::quickFixFactories() const
......
......@@ -57,19 +57,6 @@ private:
};
class QmlJSQuickFixProcessor : public TextEditor::QuickFixAssistProcessor
{
public:
QmlJSQuickFixProcessor(const TextEditor::IAssistProvider *provider);
~QmlJSQuickFixProcessor();
const TextEditor::IAssistProvider *provider() const Q_DECL_OVERRIDE;
private:
const TextEditor::IAssistProvider *m_provider;
};
class QmlJSQuickFixAssistProvider : public TextEditor::QuickFixAssistProvider
{
public:
......
......@@ -37,11 +37,10 @@
// @TODO: Move...
#include <texteditor/quickfix.h>
#include <QDebug>
namespace TextEditor {
QuickFixAssistProcessor::QuickFixAssistProcessor()
QuickFixAssistProcessor::QuickFixAssistProcessor(const QuickFixAssistProvider *provider)
: m_provider(provider)
{}
QuickFixAssistProcessor::~QuickFixAssistProcessor()
......@@ -56,9 +55,7 @@ IAssistProposal *QuickFixAssistProcessor::perform(const AssistInterface *interfa
QuickFixOperations quickFixes;
const QuickFixAssistProvider *quickFixProvider =
static_cast<const QuickFixAssistProvider *>(provider());
foreach (QuickFixFactory *factory, quickFixProvider->quickFixFactories())
foreach (QuickFixFactory *factory, m_provider->quickFixFactories())
factory->matchingOperations(assistInterface, quickFixes);
if (!quickFixes.isEmpty()) {
......
......@@ -32,18 +32,20 @@
#include "iassistprocessor.h"
namespace TextEditor {
class QuickFixAssistProvider;
class TEXTEDITOR_EXPORT QuickFixAssistProcessor : public IAssistProcessor
{
public:
QuickFixAssistProcessor();
QuickFixAssistProcessor(const QuickFixAssistProvider *provider);
~QuickFixAssistProcessor();
virtual const IAssistProvider *provider() const = 0;
private:
IAssistProposal *perform(const AssistInterface *interface) Q_DECL_OVERRIDE;
const QuickFixAssistProvider *m_provider;
};
} // TextEditor
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment