forked from qt-creator/qt-creator
TextEditor: Move isAsynchronous() up to IAssistProvider
...from CompletionAssistProvider, so other providers can be executed asynchronously, too. Change-Id: I6ec06f6d76bc2937bc272450b4e8dffd81ee868e Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
This commit is contained in:
@@ -46,6 +46,11 @@ using namespace CPlusPlus;
|
||||
// -------------------------
|
||||
// CppQuickFixAssistProvider
|
||||
// -------------------------
|
||||
bool CppQuickFixAssistProvider::isAsynchronous() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CppQuickFixAssistProvider::supportsEditor(const Core::Id &editorId) const
|
||||
{
|
||||
return editorId == CppEditor::Constants::CPPEDITOR_ID;
|
||||
|
||||
@@ -86,6 +86,7 @@ private:
|
||||
class CppQuickFixAssistProvider : public TextEditor::QuickFixAssistProvider
|
||||
{
|
||||
public:
|
||||
virtual bool isAsynchronous() const;
|
||||
virtual bool supportsEditor(const Core::Id &editorId) const;
|
||||
virtual TextEditor::IAssistProcessor *createProcessor() const;
|
||||
|
||||
|
||||
@@ -96,6 +96,11 @@ QmlJSQuickFixAssistProvider::QmlJSQuickFixAssistProvider()
|
||||
QmlJSQuickFixAssistProvider::~QmlJSQuickFixAssistProvider()
|
||||
{}
|
||||
|
||||
bool QmlJSQuickFixAssistProvider::isAsynchronous() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool QmlJSQuickFixAssistProvider::supportsEditor(const Core::Id &editorId) const
|
||||
{
|
||||
return editorId == Constants::C_QMLJSEDITOR_ID;
|
||||
|
||||
@@ -77,6 +77,7 @@ public:
|
||||
QmlJSQuickFixAssistProvider();
|
||||
virtual ~QmlJSQuickFixAssistProvider();
|
||||
|
||||
virtual bool isAsynchronous() const;
|
||||
virtual bool supportsEditor(const Core::Id &editorId) const;
|
||||
virtual TextEditor::IAssistProcessor *createProcessor() const;
|
||||
|
||||
|
||||
@@ -112,6 +112,11 @@ public:
|
||||
} // namespace Internal
|
||||
} // namespace TextEditor
|
||||
|
||||
bool ClipboardAssistProvider::isAsynchronous() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ClipboardAssistProvider::supportsEditor(const Core::Id &/*editorId*/) const
|
||||
{
|
||||
return true;
|
||||
|
||||
@@ -38,6 +38,7 @@ namespace Internal {
|
||||
class ClipboardAssistProvider: public IAssistProvider
|
||||
{
|
||||
public:
|
||||
bool isAsynchronous() const;
|
||||
virtual bool supportsEditor(const Core::Id &editorId) const;
|
||||
virtual IAssistProcessor *createProcessor() const;
|
||||
};
|
||||
|
||||
@@ -123,7 +123,7 @@ private:
|
||||
CompletionAssistProvider *m_completionProvider;
|
||||
QList<QuickFixAssistProvider *> m_quickFixProviders;
|
||||
Internal::ProcessorRunner *m_requestRunner;
|
||||
CompletionAssistProvider *m_requestProvider;
|
||||
IAssistProvider *m_requestProvider;
|
||||
AssistKind m_assistKind;
|
||||
IAssistProposalWidget *m_proposalWidget;
|
||||
QScopedPointer<IAssistProposal> m_proposal;
|
||||
@@ -258,11 +258,8 @@ void CodeAssistantPrivate::requestProposal(AssistReason reason,
|
||||
if (!assistInterface)
|
||||
return;
|
||||
|
||||
if (kind == Completion) {
|
||||
CompletionAssistProvider *completionProvider =
|
||||
static_cast<CompletionAssistProvider *>(provider);
|
||||
if (completionProvider->isAsynchronous()) {
|
||||
m_requestProvider = completionProvider;
|
||||
if (provider->isAsynchronous()) {
|
||||
m_requestProvider = provider;
|
||||
m_requestRunner = new ProcessorRunner;
|
||||
connect(m_requestRunner, SIGNAL(finished()), this, SLOT(proposalComputed()));
|
||||
connect(m_requestRunner, SIGNAL(finished()), this, SLOT(finalizeRequest()));
|
||||
@@ -274,7 +271,6 @@ void CodeAssistantPrivate::requestProposal(AssistReason reason,
|
||||
m_requestRunner->start();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (IAssistProposal *newProposal = processor->perform(assistInterface))
|
||||
displayProposal(newProposal, reason);
|
||||
@@ -502,12 +498,16 @@ bool CodeAssistantPrivate::eventFilter(QObject *o, QEvent *e)
|
||||
} else if (type == QEvent::KeyPress) {
|
||||
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(e);
|
||||
const QString &keyText = keyEvent->text();
|
||||
|
||||
CompletionAssistProvider *completionProvider = 0;
|
||||
if ((keyText.isEmpty()
|
||||
&& keyEvent->key() != Qt::LeftArrow
|
||||
&& keyEvent->key() != Qt::RightArrow
|
||||
&& keyEvent->key() != Qt::Key_Shift)
|
||||
|| (!keyText.isEmpty() &&
|
||||
!m_requestProvider->isContinuationChar(keyText.at(0)))) {
|
||||
|| (!keyText.isEmpty()
|
||||
&& (((completionProvider = dynamic_cast<CompletionAssistProvider *>(m_requestProvider))
|
||||
? !completionProvider->isContinuationChar(keyText.at(0))
|
||||
: false)))) {
|
||||
destroyContext();
|
||||
} else if (!keyText.isEmpty() && !m_receivedContentWhileWaiting) {
|
||||
m_receivedContentWhileWaiting = true;
|
||||
|
||||
@@ -49,6 +49,12 @@ using namespace TextEditor;
|
||||
\sa IAssistProposal, IAssistProcessor
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn bool TextEditor::IAssistProvider::isAsynchronous() const;
|
||||
|
||||
Returns whether this provider runs asynchronously.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn bool TextEditor::IAssistProvider::supportsEditor(const Core::Id &editorId) const
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@ class TEXTEDITOR_EXPORT IAssistProvider : public QObject
|
||||
public:
|
||||
IAssistProvider() {}
|
||||
|
||||
virtual bool isAsynchronous() const = 0;
|
||||
virtual bool supportsEditor(const Core::Id &editorId) const = 0;
|
||||
virtual IAssistProcessor *createProcessor() const = 0;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user