forked from qt-creator/qt-creator
Do not add parentheses when completing dereferenced function.
When completing function name, scan text backwards to find if we are trying to dereference the function. Change-Id: I32cabecb651ff35d949600d9fdeb61c8e68ae98f Reviewed-by: Erik Verbruggen <erik.verbruggen@nokia.com>
This commit is contained in:
committed by
Erik Verbruggen
parent
f371f3d3d7
commit
c1f3b7170d
@@ -198,6 +198,26 @@ bool CppAssistProposalItem::prematurelyApplies(const QChar &typedChar) const
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool isDereferenced(TextEditor::BaseTextEditor *editor, int basePosition)
|
||||
{
|
||||
QTextCursor cursor = editor->editorWidget()->textCursor();
|
||||
cursor.setPosition(basePosition);
|
||||
|
||||
BackwardsScanner scanner(cursor);
|
||||
for (int pos = scanner.startToken()-1; pos >= 0; pos--) {
|
||||
switch (scanner[pos].kind()) {
|
||||
case T_COLON_COLON:
|
||||
case T_IDENTIFIER:
|
||||
//Ignore scope specifiers
|
||||
break;
|
||||
|
||||
case T_AMPER: return true;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void CppAssistProposalItem::applyContextualContent(TextEditor::BaseTextEditor *editor,
|
||||
int basePosition) const
|
||||
{
|
||||
@@ -249,7 +269,7 @@ void CppAssistProposalItem::applyContextualContent(TextEditor::BaseTextEditor *e
|
||||
extraChars += QLatin1Char('<');
|
||||
}
|
||||
#endif
|
||||
} else if (! function->isAmbiguous()) {
|
||||
} else if (!isDereferenced(editor, basePosition) && ! function->isAmbiguous()) {
|
||||
// When the user typed the opening parenthesis, he'll likely also type the closing one,
|
||||
// in which case it would be annoying if we put the cursor after the already automatically
|
||||
// inserted closing parenthesis.
|
||||
|
||||
Reference in New Issue
Block a user