forked from qt-creator/qt-creator
CodeAssist: Support asynchronous processing without threads
This is required for the CodemodelBackendIPC integration in the ClangCodeModelPlugin. Since the heavy calculation happens in a separate process, we only need to send appropriate requests and receive results for a working completion. However, the CodeAssist API does not fit here since it only provides means of caculating the results in the main thread or a worker thread. We can't use the worker thread approach since that would lead to threading issues regarding QLocalSocket in CodemodelBackendIPC. IAssistProcessor::setAsyncProposalAvailable() will hand the results back to CodeAssist in order to display them. Change-Id: I496192560fb406ec40fa8bcb7904f7a03d2eef50 Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
This commit is contained in:
@@ -33,6 +33,8 @@
|
||||
|
||||
#include <texteditor/texteditor_global.h>
|
||||
|
||||
#include <functional>
|
||||
|
||||
namespace TextEditor {
|
||||
|
||||
class IAssistProvider;
|
||||
@@ -47,6 +49,15 @@ public:
|
||||
|
||||
virtual IAssistProposal *immediateProposal(const AssistInterface *) { return 0; }
|
||||
virtual IAssistProposal *perform(const AssistInterface *interface) = 0;
|
||||
|
||||
void setAsyncProposalAvailable(IAssistProposal *proposal);
|
||||
|
||||
// Internal, used by CodeAssist
|
||||
using AsyncCompletionsAvailableHandler = std::function<void (IAssistProposal *proposal)>;
|
||||
void setAsyncCompletionAvailableHandler(const AsyncCompletionsAvailableHandler &finalizer);
|
||||
|
||||
private:
|
||||
AsyncCompletionsAvailableHandler m_asyncCompletionsAvailableHandler;
|
||||
};
|
||||
|
||||
} // TextEditor
|
||||
|
||||
Reference in New Issue
Block a user