forked from qt-creator/qt-creator
Clang: Fix completion after qualification (::)
...and maybe other cases.
Since
Clang: fix findStartOfName handling
commit 82d0650b11
the proposal's base position was calculated wrong. As a result, an early
return triggert in CodeAssistantPrivate::displayProposal (call to
newProposal->hasItemsToPropose(prefix, reason)) and no completions were
displayed.
Fix by ensuring that the added code from the mentioned commit is only
called when needed, namely only for function expressions.
Task-number: QTCREATORBUG-19083
Change-Id: I8f23c9b7186f9d81159939c8b3ef475a09bbe760
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -243,11 +243,14 @@ static bool isValidIdentifierChar(const QChar &character)
|
||||
|
||||
int ActivationSequenceContextProcessor::findStartOfName(
|
||||
const TextEditor::AssistInterface *assistInterface,
|
||||
int startPosition)
|
||||
int startPosition,
|
||||
NameCategory category)
|
||||
{
|
||||
int position = startPosition;
|
||||
QChar character;
|
||||
if (position > 2 && assistInterface->characterAt(position - 1) == '>'
|
||||
|
||||
if (category == NameCategory::Function
|
||||
&& position > 2 && assistInterface->characterAt(position - 1) == '>'
|
||||
&& assistInterface->characterAt(position - 2) != '-') {
|
||||
uint unbalancedLessGreater = 1;
|
||||
--position;
|
||||
@@ -267,11 +270,12 @@ int ActivationSequenceContextProcessor::findStartOfName(
|
||||
} while (isValidIdentifierChar(character));
|
||||
|
||||
int prevPosition = skipPrecedingWhitespace(assistInterface, position);
|
||||
if (assistInterface->characterAt(prevPosition) == ':'
|
||||
if (category == NameCategory::Function
|
||||
&& assistInterface->characterAt(prevPosition) == ':'
|
||||
&& assistInterface->characterAt(prevPosition - 1) == ':') {
|
||||
// Handle :: case - go recursive
|
||||
prevPosition = skipPrecedingWhitespace(assistInterface, prevPosition - 2);
|
||||
return findStartOfName(assistInterface, prevPosition + 1);
|
||||
return findStartOfName(assistInterface, prevPosition + 1, category);
|
||||
}
|
||||
|
||||
return position + 1;
|
||||
|
||||
Reference in New Issue
Block a user