forked from qt-creator/qt-creator
Clang: Do not show global completions after comma
Handle the case when we try to show the function hint but do not find any completion. Do not fall back to the normal code completion in such case. Fixes: QTCREATORBUG-21624 Change-Id: I147d71b8970c18d49947f68786347a9db97736bb Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This commit is contained in:
@@ -214,6 +214,9 @@ void ClangCompletionAssistProcessor::handleAvailableCompletions(const CodeComple
|
|||||||
setAsyncProposalAvailable(createFunctionHintProposal(completions));
|
setAsyncProposalAvailable(createFunctionHintProposal(completions));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!m_fallbackToNormalCompletion)
|
||||||
|
return;
|
||||||
// else: Proceed with a normal completion in case:
|
// else: Proceed with a normal completion in case:
|
||||||
// 1) it was not a function call, but e.g. a function declaration like "void f("
|
// 1) it was not a function call, but e.g. a function declaration like "void f("
|
||||||
// 2) '{' meant not a constructor call.
|
// 2) '{' meant not a constructor call.
|
||||||
@@ -286,6 +289,14 @@ static QByteArray modifyInput(QTextDocument *doc, int endOfExpression) {
|
|||||||
return modifiedInput;
|
return modifiedInput;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static QChar lastPrecedingNonWhitespaceChar(const ClangCompletionAssistInterface *interface)
|
||||||
|
{
|
||||||
|
int pos = interface->position();
|
||||||
|
while (pos >= 0 && interface->characterAt(pos).isSpace())
|
||||||
|
--pos;
|
||||||
|
return pos >= 0 ? interface->characterAt(pos) : QChar::Null;
|
||||||
|
}
|
||||||
|
|
||||||
IAssistProposal *ClangCompletionAssistProcessor::startCompletionHelper()
|
IAssistProposal *ClangCompletionAssistProcessor::startCompletionHelper()
|
||||||
{
|
{
|
||||||
ClangCompletionContextAnalyzer analyzer(m_interface.data(), m_interface->languageFeatures());
|
ClangCompletionContextAnalyzer analyzer(m_interface.data(), m_interface->languageFeatures());
|
||||||
@@ -323,6 +334,8 @@ IAssistProposal *ClangCompletionAssistProcessor::startCompletionHelper()
|
|||||||
}
|
}
|
||||||
case ClangCompletionContextAnalyzer::PassThroughToLibClangAfterLeftParen: {
|
case ClangCompletionContextAnalyzer::PassThroughToLibClangAfterLeftParen: {
|
||||||
m_sentRequestType = FunctionHintCompletion;
|
m_sentRequestType = FunctionHintCompletion;
|
||||||
|
if (lastPrecedingNonWhitespaceChar(m_interface.data()) == ',')
|
||||||
|
m_fallbackToNormalCompletion = false;
|
||||||
m_requestSent = sendCompletionRequest(analyzer.positionForClang(), QByteArray(),
|
m_requestSent = sendCompletionRequest(analyzer.positionForClang(), QByteArray(),
|
||||||
analyzer.functionNameStart());
|
analyzer.functionNameStart());
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -97,6 +97,7 @@ private:
|
|||||||
CompletionRequestType m_sentRequestType = NormalCompletion;
|
CompletionRequestType m_sentRequestType = NormalCompletion;
|
||||||
bool m_requestSent = false;
|
bool m_requestSent = false;
|
||||||
bool m_addSnippets = false; // For type == Type::NormalCompletion
|
bool m_addSnippets = false; // For type == Type::NormalCompletion
|
||||||
|
bool m_fallbackToNormalCompletion = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
Reference in New Issue
Block a user