summaryrefslogtreecommitdiff
path: root/src/plugins/clangcodemodel/clangassistproposalitem.cpp
diff options
context:
space:
mode:
authorIvan Donchevskii <ivan.donchevskii@qt.io>2017-06-01 16:36:56 +0200
committerIvan Donchevskii <ivan.donchevskii@qt.io>2017-06-14 14:42:11 +0000
commitae10749ffe6f00af062aed543f8a6923879ea8af (patch)
tree520f85454cc18483680936bf376ad136b062c52f /src/plugins/clangcodemodel/clangassistproposalitem.cpp
parentf9f10a1e32dbdcad02d9c5064018b34c771fe3dd (diff)
downloadqt-creator-ae10749ffe6f00af062aed543f8a6923879ea8af.tar.gz
Clang: Fix slots and function pointers completion
Check completed functions for preceding & and don't add parantheses in that case Task-number: QTCREATORBUG-17578 Change-Id: I21b1e2c9ffb9d288f3267146e9afd575e6fef30b Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
Diffstat (limited to 'src/plugins/clangcodemodel/clangassistproposalitem.cpp')
-rw-r--r--src/plugins/clangcodemodel/clangassistproposalitem.cpp61
1 files changed, 33 insertions, 28 deletions
diff --git a/src/plugins/clangcodemodel/clangassistproposalitem.cpp b/src/plugins/clangcodemodel/clangassistproposalitem.cpp
index 67754a06c4..012ac9af5e 100644
--- a/src/plugins/clangcodemodel/clangassistproposalitem.cpp
+++ b/src/plugins/clangcodemodel/clangassistproposalitem.cpp
@@ -111,43 +111,48 @@ void ClangAssistProposalItem::apply(TextEditor::TextDocumentManipulatorInterface
// in which case it would be annoying if we put the cursor after the already automatically
// inserted closing parenthesis.
const bool skipClosingParenthesis = m_typedCharacter != QLatin1Char('(');
+ QTextCursor cursor = manipulator.textCursorAt(basePosition);
+ cursor.movePosition(QTextCursor::PreviousWord);
+ while (manipulator.characterAt(cursor.position()) == ':')
+ cursor.movePosition(QTextCursor::PreviousWord, QTextCursor::MoveAnchor, 2);
+ if (manipulator.characterAt(cursor.position()) != '&') {
+ if (completionSettings.m_spaceAfterFunctionName)
+ extraCharacters += QLatin1Char(' ');
+ extraCharacters += QLatin1Char('(');
+ if (m_typedCharacter == QLatin1Char('('))
+ m_typedCharacter = QChar();
- if (completionSettings.m_spaceAfterFunctionName)
- extraCharacters += QLatin1Char(' ');
- extraCharacters += QLatin1Char('(');
- if (m_typedCharacter == QLatin1Char('('))
- m_typedCharacter = QChar();
-
- // If the function doesn't return anything, automatically place the semicolon,
- // unless we're doing a scope completion (then it might be function definition).
- const QChar characterAtCursor = manipulator.characterAt(manipulator.currentPosition());
- bool endWithSemicolon = m_typedCharacter == QLatin1Char(';')/*
- || (function->returnType()->isVoidType() && m_completionOperator != T_COLON_COLON)*/; //###
- const QChar semicolon = m_typedCharacter.isNull() ? QLatin1Char(';') : m_typedCharacter;
-
- if (endWithSemicolon && characterAtCursor == semicolon) {
- endWithSemicolon = false;
- m_typedCharacter = QChar();
- }
+ // If the function doesn't return anything, automatically place the semicolon,
+ // unless we're doing a scope completion (then it might be function definition).
+ const QChar characterAtCursor = manipulator.characterAt(manipulator.currentPosition());
+ bool endWithSemicolon = m_typedCharacter == QLatin1Char(';')/*
+ || (function->returnType()->isVoidType() && m_completionOperator != T_COLON_COLON)*/; //###
+ const QChar semicolon = m_typedCharacter.isNull() ? QLatin1Char(';') : m_typedCharacter;
- // If the function takes no arguments, automatically place the closing parenthesis
- if (!isOverloaded() && !ccr.hasParameters() && skipClosingParenthesis) {
- extraCharacters += QLatin1Char(')');
- if (endWithSemicolon) {
- extraCharacters += semicolon;
+ if (endWithSemicolon && characterAtCursor == semicolon) {
+ endWithSemicolon = false;
m_typedCharacter = QChar();
}
- } else if (autoParenthesesEnabled) {
- const QChar lookAhead = manipulator.characterAt(manipulator.currentPosition() + 1);
- if (MatchingText::shouldInsertMatchingText(lookAhead)) {
+
+ // If the function takes no arguments, automatically place the closing parenthesis
+ if (!isOverloaded() && !ccr.hasParameters() && skipClosingParenthesis) {
extraCharacters += QLatin1Char(')');
- --cursorOffset;
- setAutoCompleteSkipPos = true;
if (endWithSemicolon) {
extraCharacters += semicolon;
- --cursorOffset;
m_typedCharacter = QChar();
}
+ } else if (autoParenthesesEnabled) {
+ const QChar lookAhead = manipulator.characterAt(manipulator.currentPosition() + 1);
+ if (MatchingText::shouldInsertMatchingText(lookAhead)) {
+ extraCharacters += QLatin1Char(')');
+ --cursorOffset;
+ setAutoCompleteSkipPos = true;
+ if (endWithSemicolon) {
+ extraCharacters += semicolon;
+ --cursorOffset;
+ m_typedCharacter = QChar();
+ }
+ }
}
}
}