summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authorhjk <hjk121@nokiamail.com>2014-07-30 17:02:39 +0200
committerhjk <hjk121@nokiamail.com>2014-07-31 12:40:52 +0200
commit9fd2fe5a9a0b4824ac22c8c46b2dd1ed55ce8bfa (patch)
treeaf98647c2a317fffd381ff4ced176fa26a9c41d8 /src/plugins
parent80fb77285666fa12378aefabc4cc0290639d942c (diff)
downloadqt-creator-9fd2fe5a9a0b4824ac22c8c46b2dd1ed55ce8bfa.tar.gz
TextEditor: Make completion assist provider a data member
In case of the CppEditor a direct member is not possible due to setup restrictions inside the CppEditor machinery. I'd expect that to be fixable when the editor base system is in good shape. Change-Id: I184e219ca2dff6f67c9b58c182212eb12972cc84 Reviewed-by: Christian Stenger <christian.stenger@digia.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/android/javaeditor.cpp6
-rw-r--r--src/plugins/cmakeprojectmanager/cmakeeditor.cpp6
-rw-r--r--src/plugins/cmakeprojectmanager/cmakeeditor.h1
-rw-r--r--src/plugins/cppeditor/cppeditor.cpp8
-rw-r--r--src/plugins/cppeditor/cppeditor.h2
-rw-r--r--src/plugins/glsleditor/glsleditor.cpp5
-rw-r--r--src/plugins/glsleditor/glsleditoreditable.cpp10
-rw-r--r--src/plugins/glsleditor/glsleditoreditable.h1
-rw-r--r--src/plugins/qmakeprojectmanager/profileeditor.cpp6
-rw-r--r--src/plugins/qmakeprojectmanager/profileeditor.h1
-rw-r--r--src/plugins/qmljseditor/qmljseditoreditable.cpp6
-rw-r--r--src/plugins/qmljseditor/qmljseditoreditable.h2
-rw-r--r--src/plugins/texteditor/basetexteditor.cpp15
-rw-r--r--src/plugins/texteditor/basetexteditor.h8
14 files changed, 32 insertions, 45 deletions
diff --git a/src/plugins/android/javaeditor.cpp b/src/plugins/android/javaeditor.cpp
index daf55fd2ec..163941fcd9 100644
--- a/src/plugins/android/javaeditor.cpp
+++ b/src/plugins/android/javaeditor.cpp
@@ -56,6 +56,7 @@ JavaEditor::JavaEditor(JavaEditorWidget *editor)
TextEditor::Constants::C_TEXTEDITOR));
setDuplicateSupported(true);
setCommentStyle(Utils::CommentDefinition::CppStyle);
+ setCompletionAssistProvider(ExtensionSystem::PluginManager::getObject<JavaCompletionAssistProvider>());
}
Core::IEditor *JavaEditor::duplicate()
@@ -66,11 +67,6 @@ Core::IEditor *JavaEditor::duplicate()
return ret->editor();
}
-TextEditor::CompletionAssistProvider *JavaEditor::completionAssistProvider()
-{
- return ExtensionSystem::PluginManager::getObject<JavaCompletionAssistProvider>();
-}
-
//
// JavaEditorWidget
//
diff --git a/src/plugins/cmakeprojectmanager/cmakeeditor.cpp b/src/plugins/cmakeprojectmanager/cmakeeditor.cpp
index 127c8e3079..50c4eef74d 100644
--- a/src/plugins/cmakeprojectmanager/cmakeeditor.cpp
+++ b/src/plugins/cmakeprojectmanager/cmakeeditor.cpp
@@ -63,6 +63,7 @@ CMakeEditor::CMakeEditor(CMakeEditorWidget *editor)
TextEditor::Constants::C_TEXTEDITOR));
setDuplicateSupported(true);
setCommentStyle(Utils::CommentDefinition::HashStyle);
+ setCompletionAssistProvider(ExtensionSystem::PluginManager::getObject<CMakeFileCompletionAssistProvider>());
connect(document(), SIGNAL(changed()), this, SLOT(markAsChanged()));
}
@@ -74,11 +75,6 @@ Core::IEditor *CMakeEditor::duplicate()
return ret->editor();
}
-TextEditor::CompletionAssistProvider *CMakeEditor::completionAssistProvider()
-{
- return ExtensionSystem::PluginManager::getObject<CMakeFileCompletionAssistProvider>();
-}
-
void CMakeEditor::markAsChanged()
{
if (!document()->isModified())
diff --git a/src/plugins/cmakeprojectmanager/cmakeeditor.h b/src/plugins/cmakeprojectmanager/cmakeeditor.h
index 9205651f65..5c59481d47 100644
--- a/src/plugins/cmakeprojectmanager/cmakeeditor.h
+++ b/src/plugins/cmakeprojectmanager/cmakeeditor.h
@@ -53,7 +53,6 @@ public:
CMakeEditor(CMakeEditorWidget *);
Core::IEditor *duplicate();
- TextEditor::CompletionAssistProvider *completionAssistProvider();
QString contextHelpId() const;
diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp
index 0b7b638194..c692029fd9 100644
--- a/src/plugins/cppeditor/cppeditor.cpp
+++ b/src/plugins/cppeditor/cppeditor.cpp
@@ -114,6 +114,9 @@ CPPEditor::CPPEditor(CppEditorWidget *editor)
m_context.add(TextEditor::Constants::C_TEXTEDITOR);
setDuplicateSupported(true);
setCommentStyle(Utils::CommentDefinition::CppStyle);
+ setCompletionAssistProvider([this] () -> TextEditor::CompletionAssistProvider * {
+ return CppModelManagerInterface::instance()->cppEditorSupport(this)->completionAssistProvider();
+ });
}
Q_GLOBAL_STATIC(CppTools::SymbolFinder, symbolFinder)
@@ -797,11 +800,6 @@ bool CPPEditor::open(QString *errorString, const QString &fileName, const QStrin
return true;
}
-TextEditor::CompletionAssistProvider *CPPEditor::completionAssistProvider()
-{
- return CppModelManagerInterface::instance()->cppEditorSupport(this)->completionAssistProvider();
-}
-
void CppEditorWidget::applyFontSettings()
{
const TextEditor::FontSettings &fs = baseTextDocument()->fontSettings();
diff --git a/src/plugins/cppeditor/cppeditor.h b/src/plugins/cppeditor/cppeditor.h
index 20358f732f..28b9fb7ee5 100644
--- a/src/plugins/cppeditor/cppeditor.h
+++ b/src/plugins/cppeditor/cppeditor.h
@@ -66,8 +66,6 @@ public:
bool open(QString *errorString,
const QString &fileName,
const QString &realFileName) QTC_OVERRIDE;
-
- TextEditor::CompletionAssistProvider *completionAssistProvider() QTC_OVERRIDE;
};
class CppEditorWidget : public TextEditor::BaseTextEditorWidget
diff --git a/src/plugins/glsleditor/glsleditor.cpp b/src/plugins/glsleditor/glsleditor.cpp
index 7239153df7..3164e41f3e 100644
--- a/src/plugins/glsleditor/glsleditor.cpp
+++ b/src/plugins/glsleditor/glsleditor.cpp
@@ -214,11 +214,6 @@ bool GlslEditor::open(QString *errorString, const QString &fileName, const QStri
return b;
}
-TextEditor::CompletionAssistProvider *GlslEditor::completionAssistProvider()
-{
- return ExtensionSystem::PluginManager::getObject<GLSLCompletionAssistProvider>();
-}
-
QString GlslEditorWidget::wordUnderCursor() const
{
QTextCursor tc = textCursor();
diff --git a/src/plugins/glsleditor/glsleditoreditable.cpp b/src/plugins/glsleditor/glsleditoreditable.cpp
index 9bed72eee6..e44be24c83 100644
--- a/src/plugins/glsleditor/glsleditoreditable.cpp
+++ b/src/plugins/glsleditor/glsleditoreditable.cpp
@@ -28,17 +28,14 @@
****************************************************************************/
#include "glsleditoreditable.h"
-#include "glsleditor.h"
#include "glsleditorconstants.h"
+#include "glslcompletionassist.h"
#include <texteditor/texteditorconstants.h>
-#include <qmldesigner/qmldesignerconstants.h>
-#include <coreplugin/mimedatabase.h>
#include <coreplugin/icore.h>
-#include <coreplugin/designmode.h>
-#include <coreplugin/modemanager.h>
-#include <coreplugin/coreconstants.h>
+
+#include <extensionsystem/pluginmanager.h>
namespace GLSLEditor {
namespace Internal {
@@ -50,6 +47,7 @@ GlslEditor::GlslEditor(GlslEditorWidget *editor)
TextEditor::Constants::C_TEXTEDITOR));
setDuplicateSupported(true);
setCommentStyle(Utils::CommentDefinition::CppStyle);
+ setCompletionAssistProvider(ExtensionSystem::PluginManager::getObject<GLSLCompletionAssistProvider>());
}
} // namespace Internal
diff --git a/src/plugins/glsleditor/glsleditoreditable.h b/src/plugins/glsleditor/glsleditoreditable.h
index ddafaa8c48..9fdb0e87c3 100644
--- a/src/plugins/glsleditor/glsleditoreditable.h
+++ b/src/plugins/glsleditor/glsleditoreditable.h
@@ -46,7 +46,6 @@ public:
Core::IEditor *duplicate();
bool open(QString *errorString, const QString &fileName, const QString &realFileName);
- TextEditor::CompletionAssistProvider *completionAssistProvider();
};
} // namespace Internal
diff --git a/src/plugins/qmakeprojectmanager/profileeditor.cpp b/src/plugins/qmakeprojectmanager/profileeditor.cpp
index 6e246f95bd..d1563d48ac 100644
--- a/src/plugins/qmakeprojectmanager/profileeditor.cpp
+++ b/src/plugins/qmakeprojectmanager/profileeditor.cpp
@@ -59,6 +59,7 @@ ProFileEditor::ProFileEditor(ProFileEditorWidget *editor)
TextEditor::Constants::C_TEXTEDITOR));
setDuplicateSupported(true);
setCommentStyle(Utils::CommentDefinition::HashStyle);
+ setCompletionAssistProvider(ExtensionSystem::PluginManager::getObject<ProFileCompletionAssistProvider>());
}
Core::IEditor *ProFileEditor::duplicate()
@@ -69,11 +70,6 @@ Core::IEditor *ProFileEditor::duplicate()
return ret->editor();
}
-TextEditor::CompletionAssistProvider *ProFileEditor::completionAssistProvider()
-{
- return ExtensionSystem::PluginManager::getObject<ProFileCompletionAssistProvider>();
-}
-
//
// ProFileEditorWidget
//
diff --git a/src/plugins/qmakeprojectmanager/profileeditor.h b/src/plugins/qmakeprojectmanager/profileeditor.h
index c28c5d0aff..d586cc49b4 100644
--- a/src/plugins/qmakeprojectmanager/profileeditor.h
+++ b/src/plugins/qmakeprojectmanager/profileeditor.h
@@ -48,7 +48,6 @@ public:
ProFileEditor(ProFileEditorWidget *);
Core::IEditor *duplicate();
- TextEditor::CompletionAssistProvider *completionAssistProvider();
};
class ProFileEditorWidget : public TextEditor::BaseTextEditorWidget
diff --git a/src/plugins/qmljseditor/qmljseditoreditable.cpp b/src/plugins/qmljseditor/qmljseditoreditable.cpp
index bd38242107..f7a7baf23e 100644
--- a/src/plugins/qmljseditor/qmljseditoreditable.cpp
+++ b/src/plugins/qmljseditor/qmljseditoreditable.cpp
@@ -55,6 +55,7 @@ QmlJSEditor::QmlJSEditor(QmlJSTextEditorWidget *editor)
m_context.add(ProjectExplorer::Constants::LANG_QMLJS);
setDuplicateSupported(true);
setCommentStyle(Utils::CommentDefinition::CppStyle);
+ setCompletionAssistProvider(ExtensionSystem::PluginManager::getObject<Internal::QmlJSCompletionAssistProvider>());
}
bool QmlJSEditor::isDesignModePreferred() const
@@ -66,10 +67,5 @@ bool QmlJSEditor::isDesignModePreferred() const
return false;
}
-TextEditor::CompletionAssistProvider *QmlJSEditor::completionAssistProvider()
-{
- return ExtensionSystem::PluginManager::getObject<Internal::QmlJSCompletionAssistProvider>();
-}
-
} // namespace Internal
} // namespace QmlJSEditor
diff --git a/src/plugins/qmljseditor/qmljseditoreditable.h b/src/plugins/qmljseditor/qmljseditoreditable.h
index d6167188d3..32dc6e12b0 100644
--- a/src/plugins/qmljseditor/qmljseditoreditable.h
+++ b/src/plugins/qmljseditor/qmljseditoreditable.h
@@ -49,8 +49,6 @@ public:
Core::IEditor *duplicate();
bool open(QString *errorString, const QString &fileName, const QString &realFileName);
bool isDesignModePreferred() const;
-
- TextEditor::CompletionAssistProvider *completionAssistProvider();
};
} // namespace Internal
diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp
index 107da6636d..5c4e85988d 100644
--- a/src/plugins/texteditor/basetexteditor.cpp
+++ b/src/plugins/texteditor/basetexteditor.cpp
@@ -198,6 +198,7 @@ public:
QAction *m_fileEncodingLabelAction;
Utils::LineColumnLabel *m_fileEncodingLabel;
CommentDefinition m_commentDefinition;
+ std::function<CompletionAssistProvider *()> m_completionAssistProvider;
};
class BaseTextEditorWidgetPrivate
@@ -6447,6 +6448,8 @@ BaseTextEditor::BaseTextEditor(BaseTextEditorWidget *editor)
d->m_cursorPositionLabelAction = d->m_toolBar->addWidget(d->m_cursorPositionLabel);
d->m_fileEncodingLabelAction = d->m_toolBar->addWidget(d->m_fileEncodingLabel);
+ d->m_completionAssistProvider = [] () -> CompletionAssistProvider * { return 0; };
+
setFileEncodingLabelVisible(editor->displaySettings().m_displayFileEncoding);
connect(editor, SIGNAL(cursorPositionChanged()), this, SLOT(updateCursorPosition()));
connect(d->m_cursorPositionLabel, SIGNAL(clicked()), this, SLOT(openGotoLocator()));
@@ -6587,7 +6590,17 @@ void BaseTextEditor::setCommentStyle(CommentDefinition::Style style)
CompletionAssistProvider *BaseTextEditor::completionAssistProvider()
{
- return 0;
+ return d->m_completionAssistProvider();
+}
+
+void BaseTextEditor::setCompletionAssistProvider(CompletionAssistProvider *provider)
+{
+ d->m_completionAssistProvider = [provider] () -> CompletionAssistProvider * { return provider; };
+}
+
+void BaseTextEditor::setCompletionAssistProvider(const std::function<CompletionAssistProvider *()> &provider)
+{
+ d->m_completionAssistProvider = provider;
}
QObject *BaseTextEditor::fileEncodingLabel() const
diff --git a/src/plugins/texteditor/basetexteditor.h b/src/plugins/texteditor/basetexteditor.h
index a0fd346ca4..f55f745966 100644
--- a/src/plugins/texteditor/basetexteditor.h
+++ b/src/plugins/texteditor/basetexteditor.h
@@ -42,6 +42,7 @@
#include <utils/uncommentselection.h>
#include <QPlainTextEdit>
+#include <functional>
QT_BEGIN_NAMESPACE
class QToolBar;
@@ -185,7 +186,12 @@ public:
/*! Convenience style setter. */
void setCommentStyle(Utils::CommentDefinition::Style style);
- virtual CompletionAssistProvider *completionAssistProvider();
+ CompletionAssistProvider *completionAssistProvider();
+ void setCompletionAssistProvider(CompletionAssistProvider *provider); // Not owned.
+
+ // FIXME: Only used to delay initialization from CppEditor.
+ // There should be something simpler.
+ void setCompletionAssistProvider(const std::function<CompletionAssistProvider *()> &provider);
QObject *fileEncodingLabel() const; // FIXME: Remove