Commit 3a64f8a3 authored by Nikolai Kosjar's avatar Nikolai Kosjar

TextEditor: CodeAssist: Allow immediate proposals

Immediate proposals are displayed for asynchronous providers and fragile
proposals.

The idea is to show already available results immediately. The proposal
calculated in the process runner can then replace the immediate
proposal.

Change-Id: I7903e6677c9dfeb4957eb416062fff1fb01ff23f
Reviewed-by: default avatarJoerg Bornemann <joerg.bornemann@digia.com>
parent 0eb0f544
......@@ -639,6 +639,11 @@ CppCompletionAssistProcessor::CppCompletionAssistProcessor()
CppCompletionAssistProcessor::~CppCompletionAssistProcessor()
{}
IAssistProposal *CppCompletionAssistProcessor::immediateProposal(const IAssistInterface *)
{
return 0;
}
IAssistProposal * CppCompletionAssistProcessor::perform(const IAssistInterface *interface)
{
m_interface.reset(static_cast<const CppCompletionAssistInterface *>(interface));
......
......@@ -102,6 +102,7 @@ public:
CppCompletionAssistProcessor();
virtual ~CppCompletionAssistProcessor();
virtual TextEditor::IAssistProposal *immediateProposal(const TextEditor::IAssistInterface *);
virtual TextEditor::IAssistProposal *perform(const TextEditor::IAssistInterface *interface);
private:
......
......@@ -808,6 +808,8 @@ public:
: m_provider(static_cast<const FakeVimCompletionAssistProvider *>(provider))
{}
IAssistProposal *immediateProposal(const IAssistInterface *) { return 0; }
IAssistProposal *perform(const IAssistInterface *interface)
{
const QString &needle = m_provider->needle();
......
......@@ -214,6 +214,11 @@ GLSLCompletionAssistProcessor::GLSLCompletionAssistProcessor()
GLSLCompletionAssistProcessor::~GLSLCompletionAssistProcessor()
{}
IAssistProposal *GLSLCompletionAssistProcessor::immediateProposal(const IAssistInterface *)
{
return 0;
}
IAssistProposal *GLSLCompletionAssistProcessor::perform(const IAssistInterface *interface)
{
m_interface.reset(static_cast<const GLSLCompletionAssistInterface *>(interface));
......
......@@ -71,6 +71,7 @@ public:
GLSLCompletionAssistProcessor();
virtual ~GLSLCompletionAssistProcessor();
virtual TextEditor::IAssistProposal *immediateProposal(const TextEditor::IAssistInterface *);
virtual TextEditor::IAssistProposal *perform(const TextEditor::IAssistInterface *interface);
private:
......
......@@ -510,6 +510,11 @@ QmlJSCompletionAssistProcessor::QmlJSCompletionAssistProcessor()
QmlJSCompletionAssistProcessor::~QmlJSCompletionAssistProcessor()
{}
IAssistProposal *QmlJSCompletionAssistProcessor::immediateProposal(const IAssistInterface *)
{
return 0;
}
IAssistProposal *QmlJSCompletionAssistProcessor::createContentProposal() const
{
IGenericProposalModel *model = new QmlJSAssistProposalModel(m_completions);
......
......@@ -95,6 +95,7 @@ public:
QmlJSCompletionAssistProcessor();
virtual ~QmlJSCompletionAssistProcessor();
virtual TextEditor::IAssistProposal *immediateProposal(const TextEditor::IAssistInterface *);
virtual TextEditor::IAssistProposal *perform(const TextEditor::IAssistInterface *interface);
private:
......
......@@ -86,6 +86,8 @@ private:
class ClipboardAssistProcessor: public IAssistProcessor
{
public:
IAssistProposal *immediateProposal(const TextEditor::IAssistInterface *) { return 0; }
IAssistProposal *perform(const IAssistInterface *interface)
{
if (!interface)
......
......@@ -259,6 +259,9 @@ void CodeAssistantPrivate::requestProposal(AssistReason reason,
return;
if (provider->isAsynchronous()) {
if (IAssistProposal *newProposal = processor->immediateProposal(assistInterface))
displayProposal(newProposal, reason);
m_requestProvider = provider;
m_requestRunner = new ProcessorRunner;
connect(m_requestRunner, SIGNAL(finished()), this, SLOT(proposalComputed()));
......@@ -305,7 +308,7 @@ void CodeAssistantPrivate::displayProposal(IAssistProposal *newProposal, AssistR
QScopedPointer<IAssistProposal> proposalCandidate(newProposal);
if (isDisplayingProposal()) {
if (!m_proposal->isFragile() || proposalCandidate->isFragile())
if (!m_proposal->isFragile())
return;
destroyContext();
}
......
......@@ -46,6 +46,7 @@ public:
IAssistProcessor();
virtual ~IAssistProcessor();
virtual IAssistProposal *immediateProposal(const IAssistInterface *interface) = 0;
virtual IAssistProposal *perform(const IAssistInterface *interface) = 0;
};
......
......@@ -177,6 +177,11 @@ KeywordsCompletionAssistProcessor::KeywordsCompletionAssistProcessor(Keywords ke
KeywordsCompletionAssistProcessor::~KeywordsCompletionAssistProcessor()
{}
IAssistProposal *KeywordsCompletionAssistProcessor::immediateProposal(const IAssistInterface *)
{
return 0;
}
IAssistProposal *KeywordsCompletionAssistProcessor::perform(const IAssistInterface *interface)
{
m_interface.reset(interface);
......
......@@ -88,6 +88,7 @@ public:
KeywordsCompletionAssistProcessor(Keywords keywords);
virtual ~KeywordsCompletionAssistProcessor();
virtual TextEditor::IAssistProposal *immediateProposal(const TextEditor::IAssistInterface *);
virtual TextEditor::IAssistProposal *perform(const TextEditor::IAssistInterface *interface);
virtual QChar startOfCommentChar() const;
......
......@@ -47,6 +47,11 @@ QuickFixAssistProcessor::QuickFixAssistProcessor()
QuickFixAssistProcessor::~QuickFixAssistProcessor()
{}
IAssistProposal *QuickFixAssistProcessor::immediateProposal(const IAssistInterface *)
{
return 0;
}
IAssistProposal *QuickFixAssistProcessor::perform(const IAssistInterface *interface)
{
if (!interface)
......
......@@ -41,6 +41,8 @@ public:
virtual ~QuickFixAssistProcessor();
virtual const IAssistProvider *provider() const = 0;
virtual TextEditor::IAssistProposal *immediateProposal(const IAssistInterface *interface);
virtual IAssistProposal *perform(const IAssistInterface *interface);
};
......
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