diff options
author | David Schulz <david.schulz@theqtcompany.com> | 2016-03-16 13:04:05 +0100 |
---|---|---|
committer | David Schulz <david.schulz@theqtcompany.com> | 2016-04-28 12:14:41 +0000 |
commit | 898968b101abe4d197f0cfcdcdcebb58dfe0fe3c (patch) | |
tree | 87c83c2bba27bcea3d21db164925fc9197b940c2 /src/plugins/qmljseditor | |
parent | 16aeecea2c88d64d29f1d4f4e02939c790445e87 (diff) | |
download | qt-creator-898968b101abe4d197f0cfcdcdcebb58dfe0fe3c.tar.gz |
CodeAssist: Support only one quickfix assistant per editor class.
Currently we are just using the first that is found. Which could lead
to unexpected behavior. Adjust the API to make clear just one assistant
is supported per editor type.
Change-Id: I711e66b4c5c5f347118357a8bafa0ffc6d650f7e
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Diffstat (limited to 'src/plugins/qmljseditor')
-rw-r--r-- | src/plugins/qmljseditor/qmljseditordocument.cpp | 7 | ||||
-rw-r--r-- | src/plugins/qmljseditor/qmljseditordocument.h | 2 | ||||
-rw-r--r-- | src/plugins/qmljseditor/qmljseditorplugin.cpp | 3 | ||||
-rw-r--r-- | src/plugins/qmljseditor/qmljsquickfixassist.cpp | 3 | ||||
-rw-r--r-- | src/plugins/qmljseditor/qmljsquickfixassist.h | 2 |
5 files changed, 13 insertions, 4 deletions
diff --git a/src/plugins/qmljseditor/qmljseditordocument.cpp b/src/plugins/qmljseditor/qmljseditordocument.cpp index 0e73230ae0..d5bdc269ff 100644 --- a/src/plugins/qmljseditor/qmljseditordocument.cpp +++ b/src/plugins/qmljseditor/qmljseditordocument.cpp @@ -27,7 +27,9 @@ #include "qmljseditorconstants.h" #include "qmljseditordocument_p.h" +#include "qmljseditorplugin.h" #include "qmljshighlighter.h" +#include "qmljsquickfixassist.h" #include "qmljssemantichighlighter.h" #include "qmljssemanticinfoupdater.h" #include "qmloutlinemodel.h" @@ -580,6 +582,11 @@ Internal::QmlOutlineModel *QmlJSEditorDocument::outlineModel() const return d->m_outlineModel; } +TextEditor::QuickFixAssistProvider *QmlJSEditorDocument::quickFixAssistProvider() const +{ + return Internal::QmlJSEditorPlugin::instance()->quickFixAssistProvider(); +} + void QmlJSEditorDocument::setDiagnosticRanges(const QVector<QTextLayout::FormatRange> &ranges) { d->m_diagnosticRanges = ranges; diff --git a/src/plugins/qmljseditor/qmljseditordocument.h b/src/plugins/qmljseditor/qmljseditordocument.h index 05d9e09457..f883648381 100644 --- a/src/plugins/qmljseditor/qmljseditordocument.h +++ b/src/plugins/qmljseditor/qmljseditordocument.h @@ -52,6 +52,8 @@ public: void setDiagnosticRanges(const QVector<QTextLayout::FormatRange> &ranges); Internal::QmlOutlineModel *outlineModel() const; + TextEditor::QuickFixAssistProvider *quickFixAssistProvider() const override; + signals: void updateCodeWarnings(QmlJS::Document::Ptr doc); void semanticInfoUpdated(const QmlJSTools::SemanticInfo &semanticInfo); diff --git a/src/plugins/qmljseditor/qmljseditorplugin.cpp b/src/plugins/qmljseditor/qmljseditorplugin.cpp index adb409377b..794bd99416 100644 --- a/src/plugins/qmljseditor/qmljseditorplugin.cpp +++ b/src/plugins/qmljseditor/qmljseditorplugin.cpp @@ -182,8 +182,7 @@ bool QmlJSEditorPlugin::initialize(const QStringList & /*arguments*/, QString *e cmd = ActionManager::command(TextEditor::Constants::UN_COMMENT_SELECTION); contextMenu->addAction(cmd); - m_quickFixAssistProvider = new QmlJSQuickFixAssistProvider; - addAutoReleasedObject(m_quickFixAssistProvider); + m_quickFixAssistProvider = new QmlJSQuickFixAssistProvider(this); errorMessage->clear(); diff --git a/src/plugins/qmljseditor/qmljsquickfixassist.cpp b/src/plugins/qmljseditor/qmljsquickfixassist.cpp index 17da3905f2..344a58031b 100644 --- a/src/plugins/qmljseditor/qmljsquickfixassist.cpp +++ b/src/plugins/qmljseditor/qmljsquickfixassist.cpp @@ -66,7 +66,8 @@ QmlJSRefactoringFilePtr QmlJSQuickFixAssistInterface::currentFile() const // --------------------------- // QmlJSQuickFixAssistProvider // --------------------------- -QmlJSQuickFixAssistProvider::QmlJSQuickFixAssistProvider() +QmlJSQuickFixAssistProvider::QmlJSQuickFixAssistProvider(QObject *parent) + : TextEditor::QuickFixAssistProvider(parent) {} QmlJSQuickFixAssistProvider::~QmlJSQuickFixAssistProvider() diff --git a/src/plugins/qmljseditor/qmljsquickfixassist.h b/src/plugins/qmljseditor/qmljsquickfixassist.h index c606737c55..50f26ecb6e 100644 --- a/src/plugins/qmljseditor/qmljsquickfixassist.h +++ b/src/plugins/qmljseditor/qmljsquickfixassist.h @@ -55,7 +55,7 @@ private: class QmlJSQuickFixAssistProvider : public TextEditor::QuickFixAssistProvider { public: - QmlJSQuickFixAssistProvider(); + QmlJSQuickFixAssistProvider(QObject *parent = 0); ~QmlJSQuickFixAssistProvider(); IAssistProvider::RunType runType() const override; |