forked from qt-creator/qt-creator
Clang: Treat brace initialization as constructor completion
Try to complete constructor after left brace with fallback to normal completion. Task-number: QTCREATORBUG-20957 Change-Id: I6c33790a3ee1e623a3d8abe9a44cfd821b6f3106 Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This commit is contained in:
@@ -188,7 +188,8 @@ IAssistProposal *ClangCompletionAssistProcessor::perform(const AssistInterface *
|
||||
static CodeCompletions filterFunctionSignatures(const CodeCompletions &completions)
|
||||
{
|
||||
return ::Utils::filtered(completions, [](const CodeCompletion &completion) {
|
||||
return completion.completionKind == CodeCompletion::FunctionOverloadCompletionKind;
|
||||
return completion.completionKind == CodeCompletion::FunctionOverloadCompletionKind
|
||||
|| completion.completionKind == CodeCompletion::ConstructorCompletionKind;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -197,19 +198,24 @@ void ClangCompletionAssistProcessor::handleAvailableCompletions(
|
||||
{
|
||||
QTC_CHECK(m_completions.isEmpty());
|
||||
|
||||
if (m_sentRequestType == NormalCompletion) {
|
||||
m_completions = toAssistProposalItems(completions, m_interface.data());
|
||||
|
||||
if (m_addSnippets && !m_completions.isEmpty())
|
||||
addSnippets();
|
||||
|
||||
setAsyncProposalAvailable(createProposal());
|
||||
} else {
|
||||
if (m_sentRequestType == FunctionHintCompletion){
|
||||
const CodeCompletions functionSignatures = filterFunctionSignatures(completions);
|
||||
if (!functionSignatures.isEmpty())
|
||||
if (!functionSignatures.isEmpty()) {
|
||||
setAsyncProposalAvailable(createFunctionHintProposal(functionSignatures));
|
||||
// else: Not a function call, but e.g. a function declaration like "void f("
|
||||
return;
|
||||
}
|
||||
// else: Proceed with a normal completion in case:
|
||||
// 1) it was not a function call, but e.g. a function declaration like "void f("
|
||||
// 2) '{' meant not a constructor call.
|
||||
}
|
||||
|
||||
//m_sentRequestType == NormalCompletion or function signatures were empty
|
||||
m_completions = toAssistProposalItems(completions, m_interface.data());
|
||||
|
||||
if (m_addSnippets && !m_completions.isEmpty())
|
||||
addSnippets();
|
||||
|
||||
setAsyncProposalAvailable(createProposal());
|
||||
}
|
||||
|
||||
const TextEditorWidget *ClangCompletionAssistProcessor::textEditorWidget() const
|
||||
|
||||
Reference in New Issue
Block a user