forked from qt-creator/qt-creator
CodeAssist: Store processor state in specialized objects
Change-Id: I19de64b948599c833496ab8caabf3eaafc845658 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -128,8 +128,8 @@ IAssistProposal *ClangCompletionAssistProcessor::perform(const AssistInterface *
|
||||
m_interface.reset(static_cast<const ClangCompletionAssistInterface *>(interface));
|
||||
|
||||
if (interface->reason() != ExplicitlyInvoked && !accepts()) {
|
||||
setPerformWasApplicable(false);
|
||||
return 0;
|
||||
m_requestSent = false;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return startCompletionHelper(); // == 0 if results are calculated asynchronously
|
||||
@@ -246,16 +246,14 @@ IAssistProposal *ClangCompletionAssistProcessor::startCompletionHelper()
|
||||
case ClangCompletionContextAnalyzer::PassThroughToLibClang: {
|
||||
m_addSnippets = m_completionOperator == T_EOF_SYMBOL;
|
||||
m_sentRequestType = NormalCompletion;
|
||||
const bool requestSent = sendCompletionRequest(analyzer.positionForClang(),
|
||||
modifiedFileContent);
|
||||
setPerformWasApplicable(requestSent);
|
||||
m_requestSent = sendCompletionRequest(analyzer.positionForClang(),
|
||||
modifiedFileContent);
|
||||
break;
|
||||
}
|
||||
case ClangCompletionContextAnalyzer::PassThroughToLibClangAfterLeftParen: {
|
||||
m_sentRequestType = FunctionHintCompletion;
|
||||
const bool requestSent = sendCompletionRequest(analyzer.positionForClang(), QByteArray(),
|
||||
analyzer.functionNameStart());
|
||||
setPerformWasApplicable(requestSent);
|
||||
m_requestSent = sendCompletionRequest(analyzer.positionForClang(), QByteArray(),
|
||||
analyzer.functionNameStart());
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@@ -590,16 +588,18 @@ bool ClangCompletionAssistProcessor::sendCompletionRequest(int position,
|
||||
}
|
||||
|
||||
TextEditor::IAssistProposal *ClangCompletionAssistProcessor::createProposal(
|
||||
CompletionCorrection neededCorrection) const
|
||||
CompletionCorrection neededCorrection)
|
||||
{
|
||||
m_requestSent = false;
|
||||
TextEditor::GenericProposalModelPtr model(new ClangAssistProposalModel(neededCorrection));
|
||||
model->loadContent(m_completions);
|
||||
return new ClangAssistProposal(m_positionForProposal, model);
|
||||
}
|
||||
|
||||
IAssistProposal *ClangCompletionAssistProcessor::createFunctionHintProposal(
|
||||
const ClangBackEnd::CodeCompletions &completions) const
|
||||
const ClangBackEnd::CodeCompletions &completions)
|
||||
{
|
||||
m_requestSent = false;
|
||||
TextEditor::FunctionHintProposalModelPtr model(new ClangFunctionHintModel(completions));
|
||||
return new FunctionHintProposal(m_positionForProposal, model);
|
||||
}
|
||||
|
||||
@@ -52,6 +52,7 @@ public:
|
||||
|
||||
void handleAvailableCompletions(const CodeCompletions &completions,
|
||||
CompletionCorrection neededCorrection);
|
||||
bool running() final { return m_requestSent; }
|
||||
|
||||
const TextEditor::TextEditorWidget *textEditorWidget() const;
|
||||
|
||||
@@ -62,9 +63,9 @@ private:
|
||||
bool accepts() const;
|
||||
|
||||
TextEditor::IAssistProposal *createProposal(
|
||||
CompletionCorrection neededCorrection = CompletionCorrection::NoCorrection) const;
|
||||
CompletionCorrection neededCorrection = CompletionCorrection::NoCorrection);
|
||||
TextEditor::IAssistProposal *createFunctionHintProposal(
|
||||
const CodeCompletions &completions) const;
|
||||
const CodeCompletions &completions);
|
||||
|
||||
bool completeInclude(const QTextCursor &cursor);
|
||||
bool completeInclude(int position);
|
||||
@@ -93,6 +94,7 @@ private:
|
||||
QScopedPointer<const ClangCompletionAssistInterface> m_interface;
|
||||
unsigned m_completionOperator;
|
||||
enum CompletionRequestType { NormalCompletion, FunctionHintCompletion } m_sentRequestType;
|
||||
bool m_requestSent = false;
|
||||
bool m_addSnippets = false; // For type == Type::NormalCompletion
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user