diff --git a/src/plugins/cppeditor/cppeditorwidget.cpp b/src/plugins/cppeditor/cppeditorwidget.cpp index 07ed9ac7027..3ba8d40548e 100644 --- a/src/plugins/cppeditor/cppeditorwidget.cpp +++ b/src/plugins/cppeditor/cppeditorwidget.cpp @@ -70,6 +70,7 @@ #include #include #include +#include #include #include #include diff --git a/src/plugins/cppeditor/cppquickfix.cpp b/src/plugins/cppeditor/cppquickfix.cpp index ecd6e83fbbe..48d8170193c 100644 --- a/src/plugins/cppeditor/cppquickfix.cpp +++ b/src/plugins/cppeditor/cppquickfix.cpp @@ -52,10 +52,3 @@ void CppQuickFixFactory::matchingOperations(const QuickFixInterface &interface, return; match(*cppInterface, result); } - -QList CppQuickFixFactory::cppQuickFixFactories() -{ - return Utils::filtered(QuickFixFactory::allQuickFixFactories(), [](QuickFixFactory *f) { - return qobject_cast(f) != nullptr; - }); -} diff --git a/src/plugins/cppeditor/cppquickfixassistant.cpp b/src/plugins/cppeditor/cppquickfixassistant.cpp index a35b421ce29..7517e4c136b 100644 --- a/src/plugins/cppeditor/cppquickfixassistant.cpp +++ b/src/plugins/cppeditor/cppquickfixassistant.cpp @@ -30,6 +30,9 @@ #include "cppquickfixes.h" #include + +#include +#include #include #include @@ -44,6 +47,25 @@ using namespace CPlusPlus; namespace CppEditor { namespace Internal { +// ------------------------- +// CppQuickFixAssistProcessor +// ------------------------- +class CppQuickFixAssistProcessor : public IAssistProcessor +{ + IAssistProposal *perform(const AssistInterface *interface) override + { + QSharedPointer assistInterface(interface); + + QuickFixOperations quickFixes; + + for (QuickFixFactory *factory : QuickFixFactory::allQuickFixFactories()) + if (qobject_cast(factory) != nullptr) + factory->matchingOperations(assistInterface, quickFixes); + + return GenericProposal::createProposal(interface, quickFixes); + } +}; + // ------------------------- // CppQuickFixAssistProvider // ------------------------- @@ -54,7 +76,7 @@ IAssistProvider::RunType CppQuickFixAssistProvider::runType() const IAssistProcessor *CppQuickFixAssistProvider::createProcessor() const { - return new QuickFixAssistProcessor(CppQuickFixFactory::cppQuickFixFactories()); + return new CppQuickFixAssistProcessor; } // -------------------------- diff --git a/src/plugins/cppeditor/cppquickfixassistant.h b/src/plugins/cppeditor/cppquickfixassistant.h index d7c9a09bcf3..127515f0fda 100644 --- a/src/plugins/cppeditor/cppquickfixassistant.h +++ b/src/plugins/cppeditor/cppquickfixassistant.h @@ -29,7 +29,6 @@ #include #include -#include #include diff --git a/src/plugins/qmljseditor/qmljsquickfix.cpp b/src/plugins/qmljseditor/qmljsquickfix.cpp index 72575ea330c..926cf4a4768 100644 --- a/src/plugins/qmljseditor/qmljsquickfix.cpp +++ b/src/plugins/qmljseditor/qmljsquickfix.cpp @@ -78,11 +78,4 @@ void QmlJSQuickFixFactory::matchingOperations(const QuickFixInterface &interface match(interface.staticCast(), result); } -QList QmlJSQuickFixFactory::qmlJSQuickFixFactories() -{ - return Utils::filtered(QuickFixFactory::allQuickFixFactories(), [](QuickFixFactory *f) { - return qobject_cast(f) != nullptr; - }); -} - } // namespace QmlJSEditor diff --git a/src/plugins/qmljseditor/qmljsquickfix.h b/src/plugins/qmljseditor/qmljsquickfix.h index fb64ab41a88..fda4a25a48f 100644 --- a/src/plugins/qmljseditor/qmljsquickfix.h +++ b/src/plugins/qmljseditor/qmljsquickfix.h @@ -90,8 +90,6 @@ protected: QmlJSQuickFixOperation objects. */ virtual void match(const QmlJSQuickFixInterface &interface, TextEditor::QuickFixOperations &result) = 0; - - static QList qmlJSQuickFixFactories(); }; } // namespace QmlJSEditor diff --git a/src/plugins/qmljseditor/qmljsquickfixassist.cpp b/src/plugins/qmljseditor/qmljsquickfixassist.cpp index a0c9af21e6a..52a23a43fa8 100644 --- a/src/plugins/qmljseditor/qmljsquickfixassist.cpp +++ b/src/plugins/qmljseditor/qmljsquickfixassist.cpp @@ -30,6 +30,9 @@ //temp #include "qmljsquickfix.h" +#include +#include + #include using namespace QmlJSTools; @@ -63,6 +66,25 @@ QmlJSRefactoringFilePtr QmlJSQuickFixAssistInterface::currentFile() const return m_currentFile; } +// --------------------------- +// QmlJSQuickFixAssistProcessor +// --------------------------- +class QmlJSQuickFixAssistProcessor : public IAssistProcessor +{ + IAssistProposal *perform(const AssistInterface *interface) override + { + QSharedPointer assistInterface(interface); + + QuickFixOperations quickFixes; + + for (QuickFixFactory *factory : QuickFixFactory::allQuickFixFactories()) + if (qobject_cast(factory) != nullptr) + factory->matchingOperations(assistInterface, quickFixes); + + return GenericProposal::createProposal(interface, quickFixes); + } +}; + // --------------------------- // QmlJSQuickFixAssistProvider // --------------------------- @@ -80,7 +102,7 @@ IAssistProvider::RunType QmlJSQuickFixAssistProvider::runType() const IAssistProcessor *QmlJSQuickFixAssistProvider::createProcessor() const { - return new QuickFixAssistProcessor(QmlJSQuickFixFactory::allQuickFixFactories()); + return new QmlJSQuickFixAssistProcessor; } } // namespace QmlJSEditor diff --git a/src/plugins/qmljseditor/qmljsquickfixassist.h b/src/plugins/qmljseditor/qmljsquickfixassist.h index 646e8b90a21..1fd39d4e007 100644 --- a/src/plugins/qmljseditor/qmljsquickfixassist.h +++ b/src/plugins/qmljseditor/qmljsquickfixassist.h @@ -31,8 +31,6 @@ #include #include -#include - namespace QmlJSEditor { namespace Internal { diff --git a/src/plugins/texteditor/codeassist/genericproposal.cpp b/src/plugins/texteditor/codeassist/genericproposal.cpp index 33fb0c547f3..c2b06e4f954 100644 --- a/src/plugins/texteditor/codeassist/genericproposal.cpp +++ b/src/plugins/texteditor/codeassist/genericproposal.cpp @@ -23,6 +23,8 @@ ** ****************************************************************************/ +#include "assistinterface.h" +#include "assistproposalitem.h" #include "genericproposal.h" #include "genericproposalmodel.h" #include "genericproposalwidget.h" @@ -44,6 +46,25 @@ GenericProposal::GenericProposal(int cursorPos, const QList items; + foreach (const QuickFixOperation::Ptr &op, quickFixes) { + QVariant v; + v.setValue(op); + AssistProposalItem *item = new AssistProposalItem; + item->setText(op->description()); + item->setData(v); + item->setOrder(op->priority()); + items.append(item); + } + + return new GenericProposal(interface->position(), items); +} + bool GenericProposal::hasItemsToPropose(const QString &prefix, AssistReason reason) const { if (!prefix.isEmpty()) { diff --git a/src/plugins/texteditor/codeassist/genericproposal.h b/src/plugins/texteditor/codeassist/genericproposal.h index 1155ab52ad4..3acfe46bc45 100644 --- a/src/plugins/texteditor/codeassist/genericproposal.h +++ b/src/plugins/texteditor/codeassist/genericproposal.h @@ -27,6 +27,7 @@ #include "iassistproposal.h" +#include namespace TextEditor { @@ -38,8 +39,12 @@ class TEXTEDITOR_EXPORT GenericProposal : public IAssistProposal public: GenericProposal(int cursorPos, GenericProposalModel *model); GenericProposal(int cursorPos, const QList &items); + ~GenericProposal(); + static GenericProposal *createProposal(const AssistInterface *interface, + const QuickFixOperations &quickFixes); + bool hasItemsToPropose(const QString &prefix, AssistReason reason) const override; IAssistProposalModel *model() const override; IAssistProposalWidget *createWidget() const override; diff --git a/src/plugins/texteditor/codeassist/quickfixassistprocessor.cpp b/src/plugins/texteditor/codeassist/quickfixassistprocessor.cpp deleted file mode 100644 index cb3a4e80423..00000000000 --- a/src/plugins/texteditor/codeassist/quickfixassistprocessor.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#include "quickfixassistprocessor.h" -#include "assistinterface.h" -#include "genericproposalmodel.h" -#include "assistproposalitem.h" -#include "genericproposal.h" - -// @TODO: Move... -#include - -namespace TextEditor { - -QuickFixAssistProcessor::QuickFixAssistProcessor(const QList &factories) - : m_factories(factories) -{} - -QuickFixAssistProcessor::~QuickFixAssistProcessor() -{} - -IAssistProposal *QuickFixAssistProcessor::perform(const AssistInterface *interface) -{ - if (!interface) - return 0; - - QSharedPointer assistInterface(interface); - - QuickFixOperations quickFixes; - - for (QuickFixFactory *factory : m_factories) - factory->matchingOperations(assistInterface, quickFixes); - - if (!quickFixes.isEmpty()) { - QList items; - foreach (const QuickFixOperation::Ptr &op, quickFixes) { - QVariant v; - v.setValue(op); - AssistProposalItem *item = new AssistProposalItem; - item->setText(op->description()); - item->setData(v); - item->setOrder(op->priority()); - items.append(item); - } - - return new GenericProposal(interface->position(), items); - } - - return 0; -} - -} // namespace TextEdit diff --git a/src/plugins/texteditor/codeassist/quickfixassistprocessor.h b/src/plugins/texteditor/codeassist/quickfixassistprocessor.h deleted file mode 100644 index 144fbd92484..00000000000 --- a/src/plugins/texteditor/codeassist/quickfixassistprocessor.h +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#pragma once - -#include "iassistprocessor.h" - -#include - -namespace TextEditor { - -class QuickFixAssistProvider; -class QuickFixFactory; - -class TEXTEDITOR_EXPORT QuickFixAssistProcessor : public IAssistProcessor -{ -public: - QuickFixAssistProcessor(const QList &factories); - ~QuickFixAssistProcessor(); - -private: - IAssistProposal *perform(const AssistInterface *interface) override; - - const QList m_factories; -}; - -} // TextEditor diff --git a/src/plugins/texteditor/texteditor.pro b/src/plugins/texteditor/texteditor.pro index b41ddf65831..becb9f51eaf 100644 --- a/src/plugins/texteditor/texteditor.pro +++ b/src/plugins/texteditor/texteditor.pro @@ -80,7 +80,6 @@ SOURCES += texteditorplugin.cpp \ codeassist/runner.cpp \ codeassist/completionassistprovider.cpp \ codeassist/genericproposalmodel.cpp \ - codeassist/quickfixassistprocessor.cpp \ codeassist/genericproposal.cpp \ codeassist/genericproposalwidget.cpp \ codeassist/iassistproposalmodel.cpp \ @@ -190,7 +189,6 @@ HEADERS += texteditorplugin.h \ codeassist/assistproposaliteminterface.h \ codeassist/completionassistprovider.h \ codeassist/genericproposalmodel.h \ - codeassist/quickfixassistprocessor.h \ codeassist/genericproposal.h \ codeassist/genericproposalwidget.h \ codeassist/iassistproposalmodel.h \ diff --git a/src/plugins/texteditor/texteditor.qbs b/src/plugins/texteditor/texteditor.qbs index 383fb492268..09054d80ddb 100644 --- a/src/plugins/texteditor/texteditor.qbs +++ b/src/plugins/texteditor/texteditor.qbs @@ -184,8 +184,6 @@ Project { "ifunctionhintproposalmodel.h", "keywordscompletionassist.cpp", "keywordscompletionassist.h", - "quickfixassistprocessor.cpp", - "quickfixassistprocessor.h", "runner.cpp", "runner.h", "textdocumentmanipulator.cpp",